Commit f1f07e8f authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

правка багов rtf->docx

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62590 954022d7-b5bf-4e40-9824-e11837661b57
parent 947e8663
......@@ -588,14 +588,12 @@ class RtfFontTableReader: public RtfAbstractReader
private:
typedef enum { is_normal, is_panose, is_altname } InternalState;
int m_nKeepGlobalCodepage;
RtfFont m_oFont;
InternalState m_eInternalState;
public:
RtfFontTableReader()
{
m_bUseGlobalCodepage = true;
m_nKeepGlobalCodepage = -1;
m_eInternalState = is_normal;
m_oFont.SetDefaultOOX();
......@@ -603,9 +601,6 @@ public:
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CString sCommand, bool hasParameter, int parameter)
{
if (m_nKeepGlobalCodepage < 0)//для корректного отображения названий шрифта нужно использовать данные самого шрифта
m_nKeepGlobalCodepage = oDocument.m_oProperty.m_nAnsiCodePage;
if( _T("fonttbl") == sCommand )
;
else if( _T("flomajor") == sCommand )
......@@ -663,7 +658,7 @@ public:
{
if( true == hasParameter )
{
oDocument.m_oProperty.m_nAnsiCodePage = m_oFont.m_nCodePage = parameter;
m_oFont.m_nCodePage = parameter;
}
}
else if( _T("fprq") == sCommand )
......@@ -677,8 +672,29 @@ public:
//ATLASSERT( false );
}
return true;
}
void ExecuteTextInternal2( RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars)
{
if(oReader.m_oState->m_sCurText.length() < 1 )return;
//для корректного отображения названий шрифта нужно использовать данные самого шрифта
int nKeepGlobalCodepage = oDocument.m_oProperty.m_nAnsiCodePage;
if (m_oFont.m_nCodePage > 0)
{
oDocument.m_oProperty.m_nAnsiCodePage = m_oFont.m_nCodePage;
}
if (m_oFont.m_nCharset > 2 && oDocument.m_oProperty.m_nAnsiCodePage == 0)
{
oDocument.m_oProperty.m_nAnsiCodePage = RtfUtility::CharsetToCodepage(m_oFont.m_nCharset);
}
RtfAbstractReader::ExecuteTextInternal2(oDocument, oReader, sKey, nSkipChars);
oDocument.m_oProperty.m_nAnsiCodePage = nKeepGlobalCodepage;
}
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, CString sText)
{
if( is_panose == m_eInternalState )
......@@ -691,6 +707,7 @@ public:
{
sText.Remove(';');
m_oFont.m_sName += sText;
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
oDocument.m_oFontTable.DirectAddItem( m_oFont );
m_oFont.SetDefaultRtf();
}
......@@ -699,7 +716,6 @@ public:
m_oFont.m_sName += sText;
}
}
oDocument.m_oProperty.m_nAnsiCodePage = m_nKeepGlobalCodepage;
}
void PopState(RtfDocument& oDocument, RtfReader& oReader)
{
......
......@@ -2603,11 +2603,11 @@ CString RtfInformation::RenderToOOX(RenderParameter oRenderParameter)
{
OOX::CCore *pCore = static_cast<OOX::CCore*>( oRenderParameter.poWriter );
if( m_sTitle.GetLength() > 0 ) pCore->m_sTitle = m_sTitle;
if( m_sSubject.GetLength() > 0 ) pCore->m_sSubject = m_sSubject;
if( m_sTitle.GetLength() > 0 ) pCore->m_sTitle = Utils::PrepareToXML(m_sTitle);
if( m_sSubject.GetLength() > 0 ) pCore->m_sSubject = Utils::PrepareToXML(m_sSubject);
if( m_sAuthor.GetLength() > 0 ) pCore->m_sCreator = m_sAuthor;
if( m_sKeywords.GetLength() > 0 ) pCore->m_sKeywords = m_sKeywords;
if( m_sComment.GetLength() > 0 ) pCore->m_sDescription = m_sComment;
if( m_sComment.GetLength() > 0 ) pCore->m_sDescription = Utils::PrepareToXML(m_sComment);
//CString sCreateTime = m_oCreateTime.RenderToOOX( oRenderParameter );
//if( false == sCreateTime.IsEmpty() ) pCore->m_sCreated = sCreateTime;
......
......@@ -230,7 +230,7 @@ public:
return sResult;
}
void ExecuteTextInternal2( RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars)
virtual void ExecuteTextInternal2( RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars)
{
if(oReader.m_oState->m_sCurText.length() > 0)
{
......
......@@ -53,7 +53,7 @@ public:
{
return FileSystem::Directory::CreateDirectoryWithUniqueName(FileSystem::Directory::GetTempPath());
}
static CString PrepareToXML( CString sInput)
static CString PrepareToXML( const CString & sInput)
{
CString sResult = sInput;
//&amp; («&»), &lt; («<»), &gt; («>»), &apos; («'»), и &quot; («"»)
......
......@@ -16,6 +16,17 @@ namespace Txt2Docx
Txt::File m_inputFile;
OOX::CDocument m_outputFile;
static CString PrepareToXML( const std::wstring & sInput)
{
CString sResult = std_string2string(sInput);
//&amp; (&), &lt; (<), &gt; (>), &apos; ('), &quot; (")
sResult.Replace(_T("&"), _T("&amp;"));
sResult.Replace(_T("<"), _T("&lt;"));
sResult.Replace(_T(">"), _T("&gt;"));
sResult.Replace(_T("\""), _T("&quot;"));
sResult.Replace(_T("'"), _T("&apos;"));
return sResult;
}
};
Converter::Converter(int encoding) : converter_( new Converter_Impl(encoding) )
......@@ -122,7 +133,7 @@ namespace Txt2Docx
if(line->length() > 0)
{
CString s = std_string2string(*line);
CString s = PrepareToXML(*line);
temp->AddText(s);//, rPr);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment