From 7e6252a0bfb6f8242071e809f7d482cf18eb31bf Mon Sep 17 00:00:00 2001 From: Daria Date: Fri, 29 Aug 2025 16:23:50 +0300 Subject: [PATCH 1/4] Fix bug 56387 --- RtfFile/Format/ConvertationManager.cpp | 5 ++++- RtfFile/Format/ConvertationManager.h | 3 ++- RtfFile/Format/RtfProperty.cpp | 29 +++++++++++++++++++++----- RtfFile/Format/RtfProperty.h | 5 +++++ RtfFile/Format/RtfSection.cpp | 2 ++ RtfFile/Format/RtfSection.h | 2 ++ X2tConverter/src/cextracttools.h | 16 ++++++++++++++ X2tConverter/src/lib/rtf.h | 11 +++++++++- X2tConverter/test/qmake/main.cpp | 14 ++++++++++--- 9 files changed, 76 insertions(+), 11 deletions(-) diff --git a/RtfFile/Format/ConvertationManager.cpp b/RtfFile/Format/ConvertationManager.cpp index a6d7686054..2810287ac1 100644 --- a/RtfFile/Format/ConvertationManager.cpp +++ b/RtfFile/Format/ConvertationManager.cpp @@ -95,7 +95,10 @@ _UINT32 RtfConvertationManager::ConvertRtfToOOX( std::wstring sSrcFileName, std: m_poOOXWriter = &oWriter; if (false == oReader.Load( )) return AVS_FILEUTILS_ERROR_CONVERT; - + if (!m_sDefaultFontName.empty()) + oDocument.m_oProperty.m_sDefFontName = m_sDefaultFontName; + if (m_nDefaultFontSize != NULL) + oDocument.m_oProperty.m_nDefFontSize = m_nDefaultFontSize; oWriter.Save(); NSDirectory::DeleteDirectory(oReader.m_sTempFolder); diff --git a/RtfFile/Format/ConvertationManager.h b/RtfFile/Format/ConvertationManager.h index 33bd8a72d0..643cdf3cc8 100644 --- a/RtfFile/Format/ConvertationManager.h +++ b/RtfFile/Format/ConvertationManager.h @@ -46,7 +46,8 @@ class RtfConvertationManager public: std::wstring m_sTempFolder; int m_nUserLCID; - + std::wstring m_sDefaultFontName; + int m_nDefaultFontSize; RtfConvertationManager(); _UINT32 ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath); diff --git a/RtfFile/Format/RtfProperty.cpp b/RtfFile/Format/RtfProperty.cpp index aca412d165..a47fb65acc 100644 --- a/RtfFile/Format/RtfProperty.cpp +++ b/RtfFile/Format/RtfProperty.cpp @@ -156,9 +156,15 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter) poRtfDocument->m_oFontTable.GetFont( poRtfDocument->m_oProperty.m_nDefFont, oDefFont ); sFontName = oDefFont.m_sName; } + if (!poRtfDocument->m_oProperty.m_sDefFontName.empty() && sFontName.empty()) + { + sFontName = poRtfDocument->m_oProperty.m_sDefFontName; + } if( sFontName.empty()) - sFontName = L"Arial"; - } + { + sFontName = DefaultStyle::FontName; + } + } if( RENDER_TO_OOX_PARAM_MINOR_FONT == oRenderParameter.nType ) { std::wstring sTag; @@ -1347,8 +1353,10 @@ void RtfCharProperty::SetDefaultRtf() m_poShading.SetDefaultRtf(); m_poBorder.SetDefaultRtf(); - if (false == m_bListLevel) - m_nFontSize = 24; + //if (false == m_bListLevel) + //{ + //m_nFontSize = DefaultStyle::FontSize; + //} } void RtfCharProperty::SetDefaultOOX() { @@ -1586,7 +1594,18 @@ std::wstring RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter) bool bInsert = false; bool bDelete = false; - + + if (m_nFontSize == PROP_DEF) + { + if (poRtfDocument->m_oProperty.m_nDefFontSize != PROP_DEF) + { + m_nFontSize = poRtfDocument->m_oProperty.m_nDefFontSize; + } + else + { + m_nFontSize = DefaultStyle::FontSize; + } + } if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType) {//w:rPr в m:ctrlPr if (m_nRevised != PROP_DEF) diff --git a/RtfFile/Format/RtfProperty.h b/RtfFile/Format/RtfProperty.h index e8aa7f2fba..293657f929 100644 --- a/RtfFile/Format/RtfProperty.h +++ b/RtfFile/Format/RtfProperty.h @@ -1299,6 +1299,11 @@ public: std::wstring RenderToOOX(RenderParameter oRenderParameter); }; +namespace DefaultStyle +{ +const std::wstring FontName = L"Times New Roman"; +const int FontSize = 24; +} //typedef boost::shared_ptr RtfTableStylePropertyPtr; typedef boost::shared_ptr RtfCharStylePtr; typedef boost::shared_ptr RtfParagraphStylePtr; diff --git a/RtfFile/Format/RtfSection.cpp b/RtfFile/Format/RtfSection.cpp index 50b69589a8..0c20fc6a44 100644 --- a/RtfFile/Format/RtfSection.cpp +++ b/RtfFile/Format/RtfSection.cpp @@ -55,6 +55,8 @@ void RtfDocumentProperty::SetDefaultOOX() } void RtfDocumentProperty::SetDefault() { + m_sDefFontName = L""; + m_nDefFontSize = PROP_DEF; m_eCodePage = cp_ansi; m_nTabWidth = 720; //todo -1 m_nDefFont = PROP_DEF; diff --git a/RtfFile/Format/RtfSection.h b/RtfFile/Format/RtfSection.h index f10b3aff99..6f8d487b96 100644 --- a/RtfFile/Format/RtfSection.h +++ b/RtfFile/Format/RtfSection.h @@ -44,6 +44,8 @@ public: cp_pc, // pc IBM PC code page 437 cp_pca, // pca IBM PC code page 850, used by IBM Personal System/2 (not implemented in version 1 of Microsoft Word for OS/2) } m_eCodePage; + std::wstring m_sDefFontName; + int m_nDefFontSize; int m_nAnsiCodePage; int m_nDefFont; diff --git a/X2tConverter/src/cextracttools.h b/X2tConverter/src/cextracttools.h index 4892e54f71..30ca89f251 100644 --- a/X2tConverter/src/cextracttools.h +++ b/X2tConverter/src/cextracttools.h @@ -493,6 +493,8 @@ namespace NExtractTools class InputParams { public: + std::wstring* m_sDefaultFontName; + int* m_nDefaultFontSize; std::wstring* m_sKey; std::wstring* m_sFileFrom; std::wstring* m_sFileTo; @@ -528,6 +530,8 @@ namespace NExtractTools public: InputParams() { + m_sDefaultFontName = NULL; + m_nDefaultFontSize = NULL; m_sKey = NULL; m_sFileFrom = NULL; m_sFileTo = NULL; @@ -561,6 +565,8 @@ namespace NExtractTools } ~InputParams() { + RELEASEOBJECT(m_sDefaultFontName); + RELEASEOBJECT(m_nDefaultFontSize); RELEASEOBJECT(m_sKey); RELEASEOBJECT(m_sFileFrom); RELEASEOBJECT(m_sFileTo); @@ -686,6 +692,16 @@ namespace NExtractTools RELEASEOBJECT(m_nFormatTo); m_nFormatTo = new int(XmlUtils::GetInteger(sValue)); } + else if (_T("DefaultFontName") == sName) + { + RELEASEOBJECT(m_sDefaultFontName); + m_sDefaultFontName = new std::wstring(sValue); + } + else if (_T("DefaultFontSize") == sName) + { + RELEASEOBJECT(m_nDefaultFontSize); + m_nDefaultFontSize = new int(XmlUtils::GetInteger(sValue)); + } else if (_T("m_nCsvTxtEncoding") == sName) { RELEASEOBJECT(m_nCsvTxtEncoding); diff --git a/X2tConverter/src/lib/rtf.h b/X2tConverter/src/lib/rtf.h index f9fffb71ef..1fc143f419 100644 --- a/X2tConverter/src/lib/rtf.h +++ b/X2tConverter/src/lib/rtf.h @@ -45,7 +45,16 @@ namespace NExtractTools rtfConvert.m_sTempFolder = convertParams.m_sTempDir; rtfConvert.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; - + if (params.m_sDefaultFontName != NULL) + rtfConvert.m_sDefaultFontName = *params.m_sDefaultFontName; + if (params.m_nDefaultFontSize != NULL) + { + rtfConvert.m_nDefaultFontSize = *params.m_nDefaultFontSize; + } + else + { + rtfConvert.m_nDefaultFontSize = NULL; + } return 0 == rtfConvert.ConvertRtfToOOX(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } _UINT32 docx_dir2rtf(const std::wstring& sFrom, const std::wstring& sTo, InputParams& params, ConvertParams& convertParams) diff --git a/X2tConverter/test/qmake/main.cpp b/X2tConverter/test/qmake/main.cpp index c1ff84e987..2e1c4e24de 100644 --- a/X2tConverter/test/qmake/main.cpp +++ b/X2tConverter/test/qmake/main.cpp @@ -38,14 +38,16 @@ int main(int argc, char** argv) std::wstring curr_dir = NSFile::GetProcessDirectory(); std::wstring wsep = FILE_SEPARATOR_STR; - std::wstring filename_in = curr_dir + wsep + L"123.docx"; - std::wstring filename_out = curr_dir + wsep + L"123.pdf"; + // std::wstring filename_in = curr_dir + wsep + L"Diva readme.rtf"; + std::wstring filename_in = curr_dir + wsep + L"CONTRACT.rtf"; + std::wstring filename_out = curr_dir + wsep + L"123.docx"; std::wstring fonts_dir = curr_dir + wsep + L"fonts"; std::wstring xml = curr_dir + wsep + L"params.xml"; std::wstring tmp_dir = NSDirectory::CreateDirectoryWithUniqueName(curr_dir); CheckFonts(fonts_dir); + std::wstring fontname = L"Times New Roman"; // GENERATE XML NSStringUtils::CStringBuilder oBuilder; @@ -88,7 +90,13 @@ int main(int argc, char** argv) oBuilder.WriteString(fonts_dir + L"/AllFonts.js"); oBuilder.WriteString(L""); - // temp directory + oBuilder.WriteString(L""); + oBuilder.WriteEncodeXmlString(fontname); + oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + oBuilder.WriteEncodeXmlString(L"24"); + oBuilder.WriteString(L""); + // temp directory oBuilder.WriteString(L""); oBuilder.WriteEncodeXmlString(tmp_dir); oBuilder.WriteString(L""); From 31b8fdbd8d34d236e39904387e2c51f984bc68a2 Mon Sep 17 00:00:00 2001 From: Daria Date: Thu, 4 Sep 2025 11:19:25 +0300 Subject: [PATCH 2/4] For bug 50842 --- RtfFile/Format/DestinationCommand.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RtfFile/Format/DestinationCommand.cpp b/RtfFile/Format/DestinationCommand.cpp index 93a5db6ada..18a61da876 100644 --- a/RtfFile/Format/DestinationCommand.cpp +++ b/RtfFile/Format/DestinationCommand.cpp @@ -2957,12 +2957,12 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt int x = 0, y = 0; try { - x = XmlUtils::GetInteger(splitted[i].substr(0, pos)); + x = XmlUtils::GetInteger(splitted[i].substr(0, pos)) - m_oShape.m_nRelLeft; } catch(...){} try { - y = XmlUtils::GetInteger(splitted[i].substr(pos + 1, splitted[i].length() - 1)); + y = XmlUtils::GetInteger(splitted[i].substr(pos + 1, splitted[i].length() - 1)) - m_oShape.m_nRelTop; } catch(...){} @@ -2986,10 +2986,10 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt m_oShape.m_aPSegmentInfo.push_back( val ); } } - else if ( L"geoBottom" == m_sPropName ) m_oShape.m_nGeoBottom = nValue; - else if ( L"geoLeft" == m_sPropName ) m_oShape.m_nGeoLeft = nValue; - else if ( L"geoRight" == m_sPropName ) m_oShape.m_nGeoRight = nValue; - else if ( L"geoTop" == m_sPropName ) m_oShape.m_nGeoTop = nValue; + else if ( L"geoBottom" == m_sPropName ) m_oShape.m_nGeoBottom = nValue - m_oShape.m_nRelTop; + else if ( L"geoLeft" == m_sPropName ) m_oShape.m_nGeoLeft = nValue - m_oShape.m_nRelLeft; + else if ( L"geoRight" == m_sPropName ) m_oShape.m_nGeoRight = nValue - m_oShape.m_nRelLeft; + else if ( L"geoTop" == m_sPropName ) m_oShape.m_nGeoTop = nValue - m_oShape.m_nRelTop; // else if ( L"dxWrapDistLeft" == m_sPropName ) m_oShape.m_nWrapDistLeft = RtfUtility::Emu2Twips( nValue ); else if ( L"dyWrapDistTop" == m_sPropName ) m_oShape.m_nWrapDistTop = RtfUtility::Emu2Twips( nValue ); From b14b1a3f3edac69e322a40b3fb5158641fea1df2 Mon Sep 17 00:00:00 2001 From: Daria Date: Mon, 8 Sep 2025 11:03:40 +0300 Subject: [PATCH 3/4] Fix bug 61632 --- RtfFile/Format/RtfShape.cpp | 19 ++++++++++++++++++- .../Reader/OOXParagraphElementReaders.cpp | 10 +++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/RtfFile/Format/RtfShape.cpp b/RtfFile/Format/RtfShape.cpp index fd47c3119d..eb8629d8cb 100644 --- a/RtfFile/Format/RtfShape.cpp +++ b/RtfFile/Format/RtfShape.cpp @@ -1454,7 +1454,24 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) sShapeNodes += L" inset=\"" + std::to_wstring((int)RtfUtility::Emu2Pt(m_nTexpLeft)) + L"pt," + std::to_wstring((int)RtfUtility::Emu2Pt(m_nTexpTop)) + L"pt," + std::to_wstring((int)RtfUtility::Emu2Pt(m_nTexpRight)) + L"pt," - + std::to_wstring((int)RtfUtility::Emu2Pt(m_nTexpBottom)) + L"pt\">"; + + std::to_wstring((int)RtfUtility::Emu2Pt(m_nTexpBottom)) + L"pt\""; + if (m_nTxflTextFlow != PROP_DEF) + { + switch (m_nTxflTextFlow) + { + case 0: + break; + case 1: + sShapeNodes += L" style=\"mso-layout-flow-alt:vertical-ideographic\""; + break; + case 2: + sShapeNodes += L" style=\"mso-layout-flow-alt:vertical\""; + break; + default: + break; + } + } + sShapeNodes += L">"; } else sShapeNodes += L">"; diff --git a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp index c2d29de5b9..6ea7ea4e23 100644 --- a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp +++ b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp @@ -971,15 +971,15 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap { bool res = false; OOX::Logic::CAlternateContent *ooxAlt = dynamic_cast(ooxItem); - + for (size_t i = 0; res == false && i < ooxAlt->m_arrChoiceItems.size(); i++) + { + res = Parse(oParam, oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrChoiceItems[i]); + } for (size_t i = 0; res == false && i < ooxAlt->m_arrFallbackItems.size(); i++) { res = Parse(oParam, oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrFallbackItems[i]); } - for (size_t i = 0; res == false && i < ooxAlt->m_arrChoiceItems.size(); i++) - { - res = Parse(oParam, oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrChoiceItems[i]); - } + }break; case OOX::et_w_sym: From a9fa5b8072693087d229d625f205fc4869851f7c Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 11 Sep 2025 13:43:53 +0300 Subject: [PATCH 4/4] Refactoring default styles --- RtfFile/Format/ConvertationManager.cpp | 23 ++++++++------- RtfFile/Format/ConvertationManager.h | 26 ++++++++-------- RtfFile/Format/RtfProperty.cpp | 41 ++++++++++---------------- RtfFile/Format/RtfProperty.h | 5 ---- RtfFile/Format/RtfSection.cpp | 5 ++-- RtfFile/Format/RtfSection.h | 6 ++-- X2tConverter/src/cextracttools.h | 28 +++++++++--------- X2tConverter/src/lib/rtf.h | 16 ++++------ X2tConverter/test/qmake/main.cpp | 24 ++++++++------- 9 files changed, 79 insertions(+), 95 deletions(-) diff --git a/RtfFile/Format/ConvertationManager.cpp b/RtfFile/Format/ConvertationManager.cpp index 2810287ac1..1990875192 100644 --- a/RtfFile/Format/ConvertationManager.cpp +++ b/RtfFile/Format/ConvertationManager.cpp @@ -61,6 +61,8 @@ RtfConvertationManager::RtfConvertationManager( ) m_poRtfWriter = NULL; m_poRtfReader = NULL; + + m_nDefaultFontSize = 0; } _UINT32 RtfConvertationManager::ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath ) { @@ -91,20 +93,21 @@ _UINT32 RtfConvertationManager::ConvertRtfToOOX( std::wstring sSrcFileName, std: oWriter.m_sTempFolder = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetTempPath()); } - m_poRtfReader = &oReader; - m_poOOXWriter = &oWriter; + m_poRtfReader = &oReader; + m_poOOXWriter = &oWriter; - if (false == oReader.Load( )) return AVS_FILEUTILS_ERROR_CONVERT; - if (!m_sDefaultFontName.empty()) - oDocument.m_oProperty.m_sDefFontName = m_sDefaultFontName; - if (m_nDefaultFontSize != NULL) - oDocument.m_oProperty.m_nDefFontSize = m_nDefaultFontSize; + if (false == oReader.Load()) + return AVS_FILEUTILS_ERROR_CONVERT; + if (!m_sDefaultFontName.empty()) + oDocument.m_oProperty.m_sDefFontName = m_sDefaultFontName; + if (m_nDefaultFontSize > 0) + oDocument.m_oProperty.m_nDefFontSize = m_nDefaultFontSize; oWriter.Save(); - NSDirectory::DeleteDirectory(oReader.m_sTempFolder); - NSDirectory::DeleteDirectory(oWriter.m_sTempFolder); + NSDirectory::DeleteDirectory(oReader.m_sTempFolder); + NSDirectory::DeleteDirectory(oWriter.m_sTempFolder); - return S_OK; + return S_OK; } _UINT32 RtfConvertationManager::ConvertOOXToRtf( std::wstring sDstFileName, std::wstring sSrcPath ) { diff --git a/RtfFile/Format/ConvertationManager.h b/RtfFile/Format/ConvertationManager.h index 643cdf3cc8..8ad0a30459 100644 --- a/RtfFile/Format/ConvertationManager.h +++ b/RtfFile/Format/ConvertationManager.h @@ -44,27 +44,25 @@ namespace OOX { namespace Vml { class CShapeType; } } class RtfConvertationManager { public: - std::wstring m_sTempFolder; + std::wstring m_sTempFolder; int m_nUserLCID; - std::wstring m_sDefaultFontName; - int m_nDefaultFontSize; + std::wstring m_sDefaultFontName; + int m_nDefaultFontSize; RtfConvertationManager(); - _UINT32 ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath); + _UINT32 ConvertRtfToOOX(std::wstring sSrcFileName, std::wstring sDstPath); - _UINT32 ConvertOOXToRtf( std::wstring sDstFileName, std::wstring sSrcPath); + _UINT32 ConvertOOXToRtf(std::wstring sDstFileName, std::wstring sSrcPath); - void OnCompleteItemRtf(); - void OnCompleteItemOOX(); + void OnCompleteItemRtf(); + void OnCompleteItemOOX(); private: - OOXWriter* m_poOOXWriter; - OOXReader* m_poOOXReader; - - RtfWriter* m_poRtfWriter; - RtfReader* m_poRtfReader; - - bool m_bParseFirstItem; + OOXWriter* m_poOOXWriter; + OOXReader* m_poOOXReader; + RtfWriter* m_poRtfWriter; + RtfReader* m_poRtfReader; + bool m_bParseFirstItem; }; diff --git a/RtfFile/Format/RtfProperty.cpp b/RtfFile/Format/RtfProperty.cpp index a47fb65acc..85eb810cea 100644 --- a/RtfFile/Format/RtfProperty.cpp +++ b/RtfFile/Format/RtfProperty.cpp @@ -143,12 +143,12 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter) { if ( IsValid() == false) return L""; - std::wstring sResult; - - RtfDocument* poRtfDocument = static_cast(oRenderParameter.poDocument); - std::wstring sFontName = m_sName; + std::wstring sResult; - if( sFontName.empty() ) + RtfDocument* poRtfDocument = static_cast(oRenderParameter.poDocument); + std::wstring sFontName = m_sName; + + if( sFontName.empty() ) { if( PROP_DEF != poRtfDocument->m_oProperty.m_nDefFont ) { @@ -156,18 +156,14 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter) poRtfDocument->m_oFontTable.GetFont( poRtfDocument->m_oProperty.m_nDefFont, oDefFont ); sFontName = oDefFont.m_sName; } - if (!poRtfDocument->m_oProperty.m_sDefFontName.empty() && sFontName.empty()) - { - sFontName = poRtfDocument->m_oProperty.m_sDefFontName; - } - if( sFontName.empty()) - { - sFontName = DefaultStyle::FontName; - } - } + if (sFontName.empty()) + { + sFontName = poRtfDocument->m_oProperty.m_sDefFontName; + } + } if( RENDER_TO_OOX_PARAM_MINOR_FONT == oRenderParameter.nType ) { - std::wstring sTag; + std::wstring sTag; switch(m_eFontTheme) { case ft_flominor: @@ -1595,17 +1591,10 @@ std::wstring RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter) bool bInsert = false; bool bDelete = false; - if (m_nFontSize == PROP_DEF) - { - if (poRtfDocument->m_oProperty.m_nDefFontSize != PROP_DEF) - { - m_nFontSize = poRtfDocument->m_oProperty.m_nDefFontSize; - } - else - { - m_nFontSize = DefaultStyle::FontSize; - } - } + if (m_nFontSize == PROP_DEF) + { + m_nFontSize = poRtfDocument->m_oProperty.m_nDefFontSize; + } if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType) {//w:rPr в m:ctrlPr if (m_nRevised != PROP_DEF) diff --git a/RtfFile/Format/RtfProperty.h b/RtfFile/Format/RtfProperty.h index 293657f929..e8aa7f2fba 100644 --- a/RtfFile/Format/RtfProperty.h +++ b/RtfFile/Format/RtfProperty.h @@ -1299,11 +1299,6 @@ public: std::wstring RenderToOOX(RenderParameter oRenderParameter); }; -namespace DefaultStyle -{ -const std::wstring FontName = L"Times New Roman"; -const int FontSize = 24; -} //typedef boost::shared_ptr RtfTableStylePropertyPtr; typedef boost::shared_ptr RtfCharStylePtr; typedef boost::shared_ptr RtfParagraphStylePtr; diff --git a/RtfFile/Format/RtfSection.cpp b/RtfFile/Format/RtfSection.cpp index 0c20fc6a44..641b95b155 100644 --- a/RtfFile/Format/RtfSection.cpp +++ b/RtfFile/Format/RtfSection.cpp @@ -55,8 +55,9 @@ void RtfDocumentProperty::SetDefaultOOX() } void RtfDocumentProperty::SetDefault() { - m_sDefFontName = L""; - m_nDefFontSize = PROP_DEF; + m_sDefFontName = L"Times New Roman"; + m_nDefFontSize = 24; + m_eCodePage = cp_ansi; m_nTabWidth = 720; //todo -1 m_nDefFont = PROP_DEF; diff --git a/RtfFile/Format/RtfSection.h b/RtfFile/Format/RtfSection.h index 6f8d487b96..5045e708f5 100644 --- a/RtfFile/Format/RtfSection.h +++ b/RtfFile/Format/RtfSection.h @@ -44,10 +44,10 @@ public: cp_pc, // pc IBM PC code page 437 cp_pca, // pca IBM PC code page 850, used by IBM Personal System/2 (not implemented in version 1 of Microsoft Word for OS/2) } m_eCodePage; - std::wstring m_sDefFontName; - int m_nDefFontSize; + std::wstring m_sDefFontName; + int m_nDefFontSize; - int m_nAnsiCodePage; + int m_nAnsiCodePage; int m_nDefFont; int m_nDefMathFont; int m_nDefLang; diff --git a/X2tConverter/src/cextracttools.h b/X2tConverter/src/cextracttools.h index 30ca89f251..25c139a73c 100644 --- a/X2tConverter/src/cextracttools.h +++ b/X2tConverter/src/cextracttools.h @@ -530,8 +530,8 @@ namespace NExtractTools public: InputParams() { - m_sDefaultFontName = NULL; - m_nDefaultFontSize = NULL; + m_sDefaultFontName = NULL; + m_nDefaultFontSize = NULL; m_sKey = NULL; m_sFileFrom = NULL; m_sFileTo = NULL; @@ -565,8 +565,8 @@ namespace NExtractTools } ~InputParams() { - RELEASEOBJECT(m_sDefaultFontName); - RELEASEOBJECT(m_nDefaultFontSize); + RELEASEOBJECT(m_sDefaultFontName); + RELEASEOBJECT(m_nDefaultFontSize); RELEASEOBJECT(m_sKey); RELEASEOBJECT(m_sFileFrom); RELEASEOBJECT(m_sFileTo); @@ -692,16 +692,16 @@ namespace NExtractTools RELEASEOBJECT(m_nFormatTo); m_nFormatTo = new int(XmlUtils::GetInteger(sValue)); } - else if (_T("DefaultFontName") == sName) - { - RELEASEOBJECT(m_sDefaultFontName); - m_sDefaultFontName = new std::wstring(sValue); - } - else if (_T("DefaultFontSize") == sName) - { - RELEASEOBJECT(m_nDefaultFontSize); - m_nDefaultFontSize = new int(XmlUtils::GetInteger(sValue)); - } + else if (_T("m_sDefaultFontName") == sName) + { + RELEASEOBJECT(m_sDefaultFontName); + m_sDefaultFontName = new std::wstring(sValue); + } + else if (_T("m_nDefaultFontSize") == sName) + { + RELEASEOBJECT(m_nDefaultFontSize); + m_nDefaultFontSize = new int(XmlUtils::GetInteger(sValue)); + } else if (_T("m_nCsvTxtEncoding") == sName) { RELEASEOBJECT(m_nCsvTxtEncoding); diff --git a/X2tConverter/src/lib/rtf.h b/X2tConverter/src/lib/rtf.h index 1fc143f419..c3423280f8 100644 --- a/X2tConverter/src/lib/rtf.h +++ b/X2tConverter/src/lib/rtf.h @@ -45,16 +45,12 @@ namespace NExtractTools rtfConvert.m_sTempFolder = convertParams.m_sTempDir; rtfConvert.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; - if (params.m_sDefaultFontName != NULL) - rtfConvert.m_sDefaultFontName = *params.m_sDefaultFontName; - if (params.m_nDefaultFontSize != NULL) - { - rtfConvert.m_nDefaultFontSize = *params.m_nDefaultFontSize; - } - else - { - rtfConvert.m_nDefaultFontSize = NULL; - } + + if (params.m_sDefaultFontName != NULL) + rtfConvert.m_sDefaultFontName = *params.m_sDefaultFontName; + if (params.m_nDefaultFontSize != NULL) + rtfConvert.m_nDefaultFontSize = *params.m_nDefaultFontSize; + return 0 == rtfConvert.ConvertRtfToOOX(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } _UINT32 docx_dir2rtf(const std::wstring& sFrom, const std::wstring& sTo, InputParams& params, ConvertParams& convertParams) diff --git a/X2tConverter/test/qmake/main.cpp b/X2tConverter/test/qmake/main.cpp index 2e1c4e24de..67e1075c4a 100644 --- a/X2tConverter/test/qmake/main.cpp +++ b/X2tConverter/test/qmake/main.cpp @@ -38,16 +38,14 @@ int main(int argc, char** argv) std::wstring curr_dir = NSFile::GetProcessDirectory(); std::wstring wsep = FILE_SEPARATOR_STR; - // std::wstring filename_in = curr_dir + wsep + L"Diva readme.rtf"; - std::wstring filename_in = curr_dir + wsep + L"CONTRACT.rtf"; - std::wstring filename_out = curr_dir + wsep + L"123.docx"; + std::wstring filename_in = curr_dir + wsep + L"CONTRACT.rtf"; + std::wstring filename_out = curr_dir + wsep + L"123.docx"; std::wstring fonts_dir = curr_dir + wsep + L"fonts"; std::wstring xml = curr_dir + wsep + L"params.xml"; std::wstring tmp_dir = NSDirectory::CreateDirectoryWithUniqueName(curr_dir); CheckFonts(fonts_dir); - std::wstring fontname = L"Times New Roman"; // GENERATE XML NSStringUtils::CStringBuilder oBuilder; @@ -90,13 +88,17 @@ int main(int argc, char** argv) oBuilder.WriteString(fonts_dir + L"/AllFonts.js"); oBuilder.WriteString(L""); - oBuilder.WriteString(L""); - oBuilder.WriteEncodeXmlString(fontname); - oBuilder.WriteString(L""); - oBuilder.WriteString(L""); - oBuilder.WriteEncodeXmlString(L"24"); - oBuilder.WriteString(L""); - // temp directory + if (false) + { + oBuilder.WriteString(L""); + oBuilder.WriteEncodeXmlString(L"Arial"); + oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + oBuilder.WriteEncodeXmlString(L"12"); + oBuilder.WriteString(L""); + } + + // temp directory oBuilder.WriteString(L""); oBuilder.WriteEncodeXmlString(tmp_dir); oBuilder.WriteString(L"");