diff --git a/ASCOfficeDocxFile2/X2tConverter_win_test.sln b/ASCOfficeDocxFile2/X2tConverter_win_test.sln index 7b6d26f3f7..2f0d69150d 100644 --- a/ASCOfficeDocxFile2/X2tConverter_win_test.sln +++ b/ASCOfficeDocxFile2/X2tConverter_win_test.sln @@ -44,8 +44,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\DesktopEditor\ {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "agg2d", "..\DesktopEditor\agg-2.4\agg_vs2005.vcproj", "{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml2", "..\Common\DocxFormat\Source\XML\libxml2\win_build\libxml2.vcproj", "{21663823-DE45-479B-91D0-B4FEF4916EF0}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RtfFormatLib", "..\ASCOfficeRtfFile\RtfFormatLib\Win32\RtfFormatLib.vcproj", "{AF2D00A7-A351-4700-AE88-C1D9ADE29345}" @@ -105,10 +103,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormatWriterLib", "..\AS EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "..\ASCOfficeOdfFileW\source\win32\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECMACryptReader", "..\OfficeCryptReader\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\OfficeCryptReader\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\Common\3dParty\cryptopp\cryptlib.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "agg2d", "..\DesktopEditor\agg-2.4\agg_vs2005.vcproj", "{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -420,27 +420,6 @@ Global {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.ReleaseOpenSource|Win32.ActiveCfg = Release|x64 {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.ReleaseOpenSource|x64.ActiveCfg = Release|x64 {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.ReleaseOpenSource|x64.Build.0 = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.ActiveCfg = Debug|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.Build.0 = Debug|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.ActiveCfg = Debug|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.Build.0 = Debug|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|Win32.Build.0 = Debug|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|x64.ActiveCfg = Debug|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|x64.Build.0 = Debug|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|Win32.ActiveCfg = Release|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|Win32.Build.0 = Release|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|x64.ActiveCfg = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|x64.Build.0 = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.ActiveCfg = Release|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.Build.0 = Release|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|x64.ActiveCfg = Release|Win32 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|Win32.ActiveCfg = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|x64.ActiveCfg = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|x64.Build.0 = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|Win32.ActiveCfg = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|x64.ActiveCfg = Release|x64 - {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|x64.Build.0 = Release|x64 {21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.ActiveCfg = Debug|Win32 {21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.Build.0 = Debug|Win32 {21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|x64.ActiveCfg = Debug|x64 @@ -596,7 +575,8 @@ Global {F8274B05-168E-4D6E-B843-AA7510725363}.ReleaseOpenSource|x64.Build.0 = Release|x64 {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.Debug|Win32.ActiveCfg = Debug|Win32 {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.Debug|Win32.Build.0 = Debug|Win32 - {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.Debug|x64.ActiveCfg = Debug|Win32 + {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.Debug|x64.ActiveCfg = Debug|x64 + {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.Debug|x64.Build.0 = Debug|x64 {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32 {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.DLL-Import Debug|Win32.Build.0 = Debug|Win32 {355A22F4-1394-4B82-B2F1-FF0ECFB9E3EF}.DLL-Import Debug|x64.ActiveCfg = Debug|Win32 @@ -790,7 +770,8 @@ Global {BEE01B53-244A-44E6-8947-ED9342D9247E}.ReleaseOpenSource|x64.Build.0 = Release|x64 {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.Debug|Win32.ActiveCfg = Debug|Win32 {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.Debug|Win32.Build.0 = Debug|Win32 - {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.Debug|x64.ActiveCfg = Debug|Win32 + {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.Debug|x64.ActiveCfg = Debug|x64 + {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.Debug|x64.Build.0 = Debug|x64 {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32 {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.DLL-Import Debug|Win32.Build.0 = Debug|Win32 {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}.DLL-Import Debug|x64.ActiveCfg = Debug|Win32 @@ -828,6 +809,28 @@ Global {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.ReleaseOpenSource|Win32.ActiveCfg = Release|x64 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.ReleaseOpenSource|x64.ActiveCfg = Release|x64 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.ReleaseOpenSource|x64.Build.0 = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.ActiveCfg = Debug|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.Build.0 = Debug|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.ActiveCfg = Debug|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.Build.0 = Debug|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|Win32.Build.0 = Debug|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|x64.ActiveCfg = Debug|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Debug|x64.Build.0 = Debug|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|Win32.ActiveCfg = Release|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|Win32.Build.0 = Release|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|x64.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.DLL-Import Release|x64.Build.0 = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.ActiveCfg = Release|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.Build.0 = Release|Win32 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|x64.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|x64.Build.0 = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|Win32.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|x64.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseASC|x64.Build.0 = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|Win32.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|x64.ActiveCfg = Release|x64 + {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.ReleaseOpenSource|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ASCOfficePPTXFile/Editor/Drawing/Enums.h b/ASCOfficePPTXFile/Editor/Drawing/Enums.h index aa7cb1271d..522e44f9bb 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Enums.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Enums.h @@ -591,7 +591,7 @@ namespace NSOfficeDrawing etWheel, etWipe, etZoom - } + }; /////////////////////////////////////////////////////////////// // а нужно ли...? /////////////////////////////////////////////////////////////// diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp index 8a375e56ce..3ba1484339 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp @@ -35,6 +35,9 @@ #include "Ole1FormatReader.h" #include "ConvertationManager.h" +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Enums.h" + +#include HRESULT ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name) { @@ -357,7 +360,13 @@ bool RtfNormalReader::ExecuteCommand( RtfDocument& oDocument, RtfReader& oReader if(true == oDocument.GetItem( oCurSection ) ) { oCurSection->m_oProperty = oReader.m_oCurSectionProp; - oCurSection->m_bFinalize = true; + if (oParagraphReaderDestination.nCurItap > 0) + { + } + else + { + oCurSection->m_bFinalize = true; + } } oParagraphReaderDestination.Finalize( oReader/* , oCurSection*/); @@ -654,7 +663,7 @@ bool ShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CStr else if( _T("shptxt") == sCommand ) { if( PROP_DEF == m_oShape.m_nShapeType ) - m_oShape.m_nShapeType = 202;//Text box + m_oShape.m_nShapeType = NSOfficeDrawing::sptTextBox; ParagraphReader oParagraphReader(_T("shptxt"), oReader); StartSubReader( oParagraphReader, oDocument, oReader ); @@ -2322,202 +2331,156 @@ void ParagraphPropDestination::Finalize( RtfReader& oReader/*, RtfSectionPtr pSe { } - if( _T("shapeType") == m_sPropName ) - m_oShape.m_nShapeType = nValue; + if( _T("shapeType") == m_sPropName ) m_oShape.m_nShapeType = nValue; //Position absolute - else if( _T("posh") == m_sPropName ) - m_oShape.m_nPositionH = nValue; - else if( _T("posrelh") == m_sPropName ) - m_oShape.m_nPositionHRelative = nValue; - else if( _T("posv") == m_sPropName ) - m_oShape.m_nPositionV = nValue; - else if( _T("posrelv") == m_sPropName ) - m_oShape.m_nPositionVRelative = nValue; - else if( _T("fLayoutInCell") == m_sPropName ) - m_oShape.m_bLayoutInCell = nValue; - else if( _T("fAllowOverlap") == m_sPropName ) - m_oShape.m_bAllowOverlap = nValue; + else if( _T("posh") == m_sPropName ) m_oShape.m_nPositionH = nValue; + else if( _T("posrelh") == m_sPropName ) m_oShape.m_nPositionHRelative = nValue; + else if( _T("posv") == m_sPropName ) m_oShape.m_nPositionV = nValue; + else if( _T("posrelv") == m_sPropName ) m_oShape.m_nPositionVRelative = nValue; + else if( _T("fLayoutInCell") == m_sPropName ) m_oShape.m_bLayoutInCell = nValue; + else if( _T("fAllowOverlap") == m_sPropName ) m_oShape.m_bAllowOverlap = nValue; //Position relative - else if( _T("pctHorizPos") == m_sPropName ) - m_oShape.m_nPositionHPct = nValue; - else if( _T("pctVertPos") == m_sPropName ) - m_oShape.m_nPositionVPct = nValue; - else if( _T("pctHoriz") == m_sPropName ) - m_oShape.m_nPctWidth = nValue; - else if( _T("pctVert") == m_sPropName ) - m_oShape.m_nPctHeight = nValue; - else if( _T("sizerelh") == m_sPropName ) - m_oShape.m_nPctWidthRelative = nValue; - else if( _T("sizerelv") == m_sPropName ) - m_oShape.m_nPctHeightRelative = nValue; - else if( _T("colStart") == m_sPropName ) - m_oShape.m_nColStart = nValue; - //Rehydration - else if( _T("metroBlob") == m_sPropName ) - m_oShape.m_sMetroBlob = sValue; - //Object Type - else if( _T("fIsBullet") == m_sPropName ) - m_oShape.m_bIsBullet = nValue; - else if( _T("rotation") == m_sPropName ) - m_oShape.m_nRotation = nValue; - else if( _T("fFlipV") == m_sPropName ) - m_oShape.m_bFlipV = nValue; - else if( _T("fFlipH") == m_sPropName ) - m_oShape.m_bFlipH = nValue; - else if( _T("shapeType") == m_sPropName ) - m_oShape.m_nShapeType = nValue; + else if( _T("pctHorizPos") == m_sPropName ) m_oShape.m_nPositionHPct = nValue; + else if( _T("pctVertPos") == m_sPropName ) m_oShape.m_nPositionVPct = nValue; + else if( _T("pctHoriz") == m_sPropName ) m_oShape.m_nPctWidth = nValue; + else if( _T("pctVert") == m_sPropName ) m_oShape.m_nPctHeight = nValue; + else if( _T("sizerelh") == m_sPropName ) m_oShape.m_nPctWidthRelative = nValue; + else if( _T("sizerelv") == m_sPropName ) m_oShape.m_nPctHeightRelative = nValue; + else if( _T("colStart") == m_sPropName ) m_oShape.m_nColStart = nValue; +//Rehydration + else if( _T("metroBlob") == m_sPropName ) m_oShape.m_sMetroBlob = sValue; +//Object Type + else if( _T("fIsBullet") == m_sPropName ) m_oShape.m_bIsBullet = nValue; + else if( _T("rotation") == m_sPropName ) m_oShape.m_nRotation = nValue; + else if( _T("fFlipV") == m_sPropName ) m_oShape.m_bFlipV = nValue; + else if( _T("fFlipH") == m_sPropName ) m_oShape.m_bFlipH = nValue; + else if( _T("shapeType") == m_sPropName ) m_oShape.m_nShapeType = nValue; +//custom + else if( _T("shapePath") == m_sPropName ) m_oShape.m_nShapePath = nValue; else if( _T("pWrapPolygonVertices") == m_sPropName ) { - CString sWrapPair; - int nPosition = 0; - int nCount=0; - while(true) + std::wstring sValue_(sValue.GetBuffer()); + std::vector< std::wstring > splitted; + + boost::algorithm::split(splitted, sValue_, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on); + + for (int i = 2 ; i < splitted.size(); i++) { - sWrapPair = sValue.Tokenize(_T(";"),nPosition); - if( _T("") == sWrapPair ) - break; - nCount++; - if( nCount > 2 ) - { - int nSubPos = 0; - CString sWrapPoint = sWrapPair.Tokenize( _T(","), nSubPos); - sWrapPoint.Remove('('); - int nWrapPoint = Strings::ToInteger(sWrapPoint); - m_oShape.m_aWrapPoints.push_back( nWrapPoint ); - sWrapPoint = sWrapPair.Tokenize( _T(","), nSubPos); - sWrapPoint.Remove(')'); - try - { - nWrapPoint = Strings::ToInteger(sWrapPoint); - //(-90,-() - file_1_(1).rtf - } - catch(...) - { - nWrapPoint = 0; - } + boost::algorithm::replace_all(splitted[i], L")", L""); + boost::algorithm::replace_all(splitted[i], L"(", L""); + int pos = splitted[i].find(L","); - m_oShape.m_aWrapPoints.push_back( nWrapPoint ); - } + int x = _wtoi(splitted[i].substr(0, pos).c_str()); + int y = _wtoi(splitted[i].substr(pos + 1, splitted[i].length() - 1).c_str()); + + m_oShape.m_aWrapPoints.push_back( std::pair(x, y) ); } - } - else if( _T("dxWrapDistLeft") == m_sPropName ) - m_oShape.m_nWrapDistLeft = RtfUtility::Emu2Twips( nValue ); - else if( _T("dyWrapDistTop") == m_sPropName ) - m_oShape.m_nWrapDistTop = RtfUtility::Emu2Twips( nValue ); - else if( _T("dxWrapDistRight") == m_sPropName ) - m_oShape.m_nWrapDistRight = RtfUtility::Emu2Twips( nValue ); - else if( _T("dyWrapDistBottom") == m_sPropName ) - m_oShape.m_nWrapDistBottom = RtfUtility::Emu2Twips( nValue ); - else if( _T("fBehindDocument") == m_sPropName ) - m_oShape.m_nZOrderRelative = nValue; - else if( _T("fHidden") == m_sPropName ) - m_oShape.m_bHidden = nValue; + else if( _T("pVerticies") == m_sPropName ) + { + std::wstring sValue_(sValue.GetBuffer()); + std::vector< std::wstring > splitted; + + boost::algorithm::split(splitted, sValue_, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on); + + for (int i = 2 ; i < splitted.size(); i++) + { + boost::algorithm::replace_all(splitted[i], L")", L""); + boost::algorithm::replace_all(splitted[i], L"(", L""); + int pos = splitted[i].find(L","); + + int x = _wtoi(splitted[i].substr(0, pos).c_str()); + int y = _wtoi(splitted[i].substr(pos + 1, splitted[i].length() - 1).c_str()); + + m_oShape.m_aPVerticles.push_back( std::pair(x, y) ); + } + } + else if( _T("pSegmentInfo") == m_sPropName ) + { + std::wstring sValue_(sValue.GetBuffer()); + std::vector< std::wstring > splitted; + + boost::algorithm::split(splitted, sValue_, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on); + + for (int i = 2 ; i < splitted.size(); i++) + { + int val = _wtoi(splitted[i].c_str()); + + m_oShape.m_aPSegmentInfo.push_back( val ); + } + } + else if( _T("geoBottom") == m_sPropName ) m_oShape.m_nGeoBottom = nValue; + else if( _T("geoLeft") == m_sPropName ) m_oShape.m_nGeoLeft = nValue; + else if( _T("geoRight") == m_sPropName ) m_oShape.m_nGeoRight = nValue; + else if( _T("geoTop") == m_sPropName ) m_oShape.m_nGeoTop = nValue; +// + else if( _T("dxWrapDistLeft") == m_sPropName ) m_oShape.m_nWrapDistLeft = RtfUtility::Emu2Twips( nValue ); + else if( _T("dyWrapDistTop") == m_sPropName ) m_oShape.m_nWrapDistTop = RtfUtility::Emu2Twips( nValue ); + else if( _T("dxWrapDistRight") == m_sPropName ) m_oShape.m_nWrapDistRight = RtfUtility::Emu2Twips( nValue ); + else if( _T("dyWrapDistBottom") == m_sPropName ) m_oShape.m_nWrapDistBottom = RtfUtility::Emu2Twips( nValue ); + else if( _T("fBehindDocument") == m_sPropName ) m_oShape.m_nZOrderRelative = nValue; + else if( _T("fHidden") == m_sPropName ) m_oShape.m_bHidden = nValue; //Text box - else if( _T("dxTextLeft") == m_sPropName ) - m_oShape.m_nTexpLeft = nValue; - else if( _T("dyTextTop") == m_sPropName ) - m_oShape.m_nTexpTop = nValue; - else if( _T("dxTextRight") == m_sPropName ) - m_oShape.m_nTexpRight = nValue; - else if( _T("dyTextBottom") == m_sPropName ) - m_oShape.m_nTexpBottom = nValue; - else if( _T("anchorText") == m_sPropName ) - m_oShape.m_nAnchorText = nValue; + else if( _T("dxTextLeft") == m_sPropName ) m_oShape.m_nTexpLeft = nValue; + else if( _T("dyTextTop") == m_sPropName ) m_oShape.m_nTexpTop = nValue; + else if( _T("dxTextRight") == m_sPropName ) m_oShape.m_nTexpRight = nValue; + else if( _T("dyTextBottom") == m_sPropName ) m_oShape.m_nTexpBottom = nValue; + else if( _T("anchorText") == m_sPropName ) m_oShape.m_nAnchorText = nValue; //Geometry - else if( _T("adjustValue") == m_sPropName ) - m_oShape.m_nAdjustValue = nValue; - else if( _T("adjust2Value") == m_sPropName ) - m_oShape.m_nAdjustValue2 = nValue; - else if( _T("adjust3Value") == m_sPropName ) - m_oShape.m_nAdjustValue3 = nValue; - else if( _T("adjust4Value") == m_sPropName ) - m_oShape.m_nAdjustValue4 = nValue; - else if( _T("adjust5Value") == m_sPropName ) - m_oShape.m_nAdjustValue5 = nValue; - else if( _T("adjust6Value") == m_sPropName ) - m_oShape.m_nAdjustValue6 = nValue; - else if( _T("adjust7Value") == m_sPropName ) - m_oShape.m_nAdjustValue7 = nValue; - else if( _T("adjust8Value") == m_sPropName ) - m_oShape.m_nAdjustValue8 = nValue; - else if( _T("adjust9Value") == m_sPropName ) - m_oShape.m_nAdjustValue9 = nValue; - else if( _T("adjust10Value") == m_sPropName ) - m_oShape.m_nAdjustValue10 = nValue; + else if( _T("adjustValue") == m_sPropName ) m_oShape.m_nAdjustValue = nValue; + else if( _T("adjust2Value") == m_sPropName ) m_oShape.m_nAdjustValue2 = nValue; + else if( _T("adjust3Value") == m_sPropName ) m_oShape.m_nAdjustValue3 = nValue; + else if( _T("adjust4Value") == m_sPropName ) m_oShape.m_nAdjustValue4 = nValue; + else if( _T("adjust5Value") == m_sPropName ) m_oShape.m_nAdjustValue5 = nValue; + else if( _T("adjust6Value") == m_sPropName ) m_oShape.m_nAdjustValue6 = nValue; + else if( _T("adjust7Value") == m_sPropName ) m_oShape.m_nAdjustValue7 = nValue; + else if( _T("adjust8Value") == m_sPropName ) m_oShape.m_nAdjustValue8 = nValue; + else if( _T("adjust9Value") == m_sPropName ) m_oShape.m_nAdjustValue9 = nValue; + else if( _T("adjust10Value") == m_sPropName ) m_oShape.m_nAdjustValue10 = nValue; //WordArt Effects - else if( _T("cropFromTop") == m_sPropName ) - m_oShape.m_nCropFromTop = nValue; - else if( _T("cropFromBottom") == m_sPropName ) - m_oShape.m_nCropFromBottom = nValue; - else if( _T("cropFromLeft") == m_sPropName ) - m_oShape.m_nCropFromRight = nValue; - else if( _T("cropFromRight") == m_sPropName ) - m_oShape.m_nCropFromTop = nValue; + else if( _T("cropFromTop") == m_sPropName ) m_oShape.m_nCropFromTop = nValue; + else if( _T("cropFromBottom") == m_sPropName ) m_oShape.m_nCropFromBottom = nValue; + else if( _T("cropFromLeft") == m_sPropName ) m_oShape.m_nCropFromRight = nValue; + else if( _T("cropFromRight") == m_sPropName ) m_oShape.m_nCropFromTop = nValue; //Grouped Shapes - else if( _T("groupBottom") == m_sPropName ) - m_oShape.m_nGroupBottom = nValue; - else if( _T("groupLeft") == m_sPropName ) - m_oShape.m_nGroupLeft = nValue; - else if( _T("groupRight") == m_sPropName ) - m_oShape.m_nGroupRight = nValue; - else if( _T("groupTop") == m_sPropName ) - m_oShape.m_nGroupTop = nValue; - else if( _T("relBottom") == m_sPropName ) - m_oShape.m_nRelBottom = nValue; - else if( _T("relLeft") == m_sPropName ) - m_oShape.m_nRelLeft = nValue; - else if( _T("relRight") == m_sPropName ) - m_oShape.m_nRelRight = nValue; - else if( _T("relTop") == m_sPropName ) - m_oShape.m_nRelTop = nValue; - else if( _T("relRotation") == m_sPropName ) - m_oShape.m_nRelRotation = nValue; - else if( _T("dhgt") == m_sPropName ) - m_oShape.m_nRelZOrder = nValue; -//Fill - else if( _T("fFilled") == m_sPropName ) - m_oShape.m_bFilled = (0 == nValue ? false : true ); - else if( _T("fillType") == m_sPropName ) - m_oShape.m_nFillType = nValue; - else if( _T("fillColor") == m_sPropName ) - m_oShape.m_nFillColor = nValue; - else if( _T("fillBackColor") == m_sPropName ) - m_oShape.m_nFillColor2 = nValue; - else if( _T("fillOpacity") == m_sPropName ) - m_oShape.m_nFillOpacity = nValue * 100 / 65536; - else if( _T("fillAngle") == m_sPropName ) - m_oShape.m_nFillAngle = nValue / 65536; - else if( _T("fillFocus") == m_sPropName ) - m_oShape.m_nFillFocus = nValue; + else if( _T("groupBottom") == m_sPropName ) m_oShape.m_nGroupBottom = nValue; + else if( _T("groupLeft") == m_sPropName ) m_oShape.m_nGroupLeft = nValue; + else if( _T("groupRight") == m_sPropName ) m_oShape.m_nGroupRight = nValue; + else if( _T("groupTop") == m_sPropName ) m_oShape.m_nGroupTop = nValue; - else if( _T("fGtext") == m_sPropName ) - m_oShape.m_bGtext = nValue; - else if( _T("gtextSize") == m_sPropName ) - m_oShape.m_nGtextSize = nValue; + else if( _T("relBottom") == m_sPropName ) m_oShape.m_nRelBottom = nValue; + else if( _T("relLeft") == m_sPropName ) m_oShape.m_nRelLeft = nValue; + else if( _T("relRight") == m_sPropName ) m_oShape.m_nRelRight = nValue; + else if( _T("relTop") == m_sPropName ) m_oShape.m_nRelTop = nValue; + else if( _T("relRotation") == m_sPropName ) m_oShape.m_nRelRotation = nValue; + + else if( _T("dhgt") == m_sPropName ) m_oShape.m_nRelZOrder = nValue; +//Fill + else if( _T("fFilled") == m_sPropName ) m_oShape.m_bFilled = (0 == nValue ? false : true ); + else if( _T("fillType") == m_sPropName ) m_oShape.m_nFillType = nValue; + else if( _T("fillColor") == m_sPropName ) m_oShape.m_nFillColor = nValue; + else if( _T("fillBackColor") == m_sPropName ) m_oShape.m_nFillColor2 = nValue; + else if( _T("fillOpacity") == m_sPropName ) m_oShape.m_nFillOpacity = nValue * 100 / 65536; + else if( _T("fillAngle") == m_sPropName ) m_oShape.m_nFillAngle = nValue / 65536; + else if( _T("fillFocus") == m_sPropName ) m_oShape.m_nFillFocus = nValue; + + else if( _T("fGtext") == m_sPropName ) m_oShape.m_bGtext = nValue; + else if( _T("gtextSize") == m_sPropName ) m_oShape.m_nGtextSize = nValue; //Line - else if( _T("fLine") == m_sPropName ) - m_oShape.m_bLine = ( 0 == nValue ? false : true ); - else if( _T("lineStartArrowhead") == m_sPropName ) - m_oShape.m_nLineStartArrow = nValue; - else if( _T("lineColor") == m_sPropName ) - m_oShape.m_nLineColor = nValue; - else if( _T("lineStartArrowWidth") == m_sPropName ) - m_oShape.m_nLineStartArrowWidth = nValue; - else if( _T("lineStartArrowLength") == m_sPropName ) - m_oShape.m_nLineStartArrowLength = nValue; - else if( _T("lineEndArrowhead") == m_sPropName ) - m_oShape.m_nLineEndArrow = nValue; - else if( _T("lineEndArrowWidth") == m_sPropName ) - m_oShape.m_nLineEndArrowWidth = nValue; - else if( _T("lineEndArrowLength") == m_sPropName ) - m_oShape.m_nLineEndArrowLength = nValue; - else if( _T("lineWidth") == m_sPropName ) - m_oShape.m_nLineWidth = nValue; - else if( _T("lineDashing") == m_sPropName ) - m_oShape.m_nLineDashing = nValue; + else if( _T("fLine") == m_sPropName ) m_oShape.m_bLine = ( 0 == nValue ? false : true ); + else if( _T("lineStartArrowhead") == m_sPropName ) m_oShape.m_nLineStartArrow = nValue; + else if( _T("lineColor") == m_sPropName ) m_oShape.m_nLineColor = nValue; + else if( _T("lineStartArrowWidth") == m_sPropName ) m_oShape.m_nLineStartArrowWidth = nValue; + else if( _T("lineStartArrowLength") == m_sPropName ) m_oShape.m_nLineStartArrowLength = nValue; + else if( _T("lineEndArrowhead") == m_sPropName ) m_oShape.m_nLineEndArrow = nValue; + else if( _T("lineEndArrowWidth") == m_sPropName ) m_oShape.m_nLineEndArrowWidth = nValue; + else if( _T("lineEndArrowLength") == m_sPropName ) m_oShape.m_nLineEndArrowLength = nValue; + else if( _T("lineWidth") == m_sPropName ) m_oShape.m_nLineWidth = nValue; + else if( _T("lineDashing") == m_sPropName ) m_oShape.m_nLineDashing = nValue; + else if (_T("cxstyle") == m_sPropName ) m_oShape.m_nConnectorStyle = nValue; + else if (_T("cxk") == m_sPropName ) m_oShape.m_nConnectionType = nValue; else { std::wstring name = m_sPropName.GetBuffer(); diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h index 1e256e24b2..a6c7810675 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h @@ -1126,7 +1126,7 @@ public: return true; else if( _T("pict") == sCommand ) { - m_oShape.m_eShapeType = RtfShape::st_inline; + m_oShape.m_eAnchorTypeShape = RtfShape::st_inline; m_oShape.m_nShapeType = 75; m_oShape.m_nWrapType = 3; // none m_oShape.m_nPositionHRelative = 3;//TCHAR @@ -1165,7 +1165,7 @@ public: } else if( _T("pict") == sCommand ) { - m_oShape.m_eShapeType = RtfShape::st_inline; + m_oShape.m_eAnchorTypeShape = RtfShape::st_inline; m_oShape.m_nShapeType = 75; m_oShape.m_nWrapType = 3; // none m_oShape.m_nPositionHRelative = 3;//TCHAR @@ -1523,13 +1523,12 @@ private: RtfParagraphPtr m_oCurParagraph; //реальные параграфы и таблицы - std::vector< ITextItemPtr > aCellRenderables; - std::vector< int > aItaps; //вложенность параграфов - std::vector< RtfTableCellPtr > aCells; - std::vector< int > aCellItaps; //вложенность cell - std::vector< RtfTableRowPtr > aRows; - std::vector< int > aRowItaps; //вложенность row - int nCurItap; + std::vector< ITextItemPtr > aCellRenderables; + std::vector< int > aItaps; //вложенность параграфов + std::vector< RtfTableCellPtr > aCells; + std::vector< int > aCellItaps; //вложенность cell + std::vector< RtfTableRowPtr > aRows; + std::vector< int > aRowItaps; //вложенность row RtfRowProperty oCurRowProperty; RtfReader* m_oReader; @@ -1537,16 +1536,17 @@ private: public: TextItemContainerPtr m_oTextItems; //для разбивки на TextItem int nTargetItap; //уровень который считается не таблицей ( для того чтобы читать параграфы в таблицах ) + int nCurItap; RtfTab m_oCurTab; ParagraphPropDestination( ) { - nTargetItap = PROP_DEF; - m_bPar = false; - m_oTextItems = TextItemContainerPtr( new TextItemContainer() ); - nCurItap = 0;//main document - m_eInternalState = is_normal; - m_oCurParagraph = RtfParagraphPtr(new RtfParagraph()); + nTargetItap = PROP_DEF; + m_bPar = false; + m_oTextItems = TextItemContainerPtr( new TextItemContainer() ); + nCurItap = 0;//main document + m_eInternalState = is_normal; + m_oCurParagraph = RtfParagraphPtr(new RtfParagraph()); } bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,RtfAbstractReader& oAbstrReader,CString sCommand, bool hasParameter, int parameter); void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, CString sText) diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXNumberingReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXNumberingReader.h index c3f120443a..d0c9d441d4 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXNumberingReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXNumberingReader.h @@ -60,7 +60,7 @@ public: RtfShapePtr oNewShape( new RtfShape() ); if( true == oShapeReader.Parse( oParam, oNewShape ) ) { - oNewShape->m_eShapeType = RtfShape::st_inline; + oNewShape->m_eAnchorTypeShape = RtfShape::st_inline; oNewShape->m_nPositionHRelative = 3; oNewShape->m_nPositionVRelative = 3; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp index eb388d389e..44f891d18c 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp @@ -199,7 +199,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP RtfCharPtr oNewChar( new RtfChar() ); oNewChar->m_bRtfEncode = false; CString sFieldText; - sFieldText.AppendFormat(_T("HYPERLINK \"%ls\""), sTarget.GetBuffer() ); + sFieldText += _T("HYPERLINK \"") + sTarget + _T("\""); oNewChar->setText( sFieldText ); RtfParagraphPtr oNewInsertParagraph( new RtfParagraph() ); oNewInsertParagraph->AddItem( oNewChar ); @@ -470,20 +470,13 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap if (ooxObject->m_oShape.IsInit()) { RtfShapePtr oNewShape( new RtfShape() ); - oNewShape->m_eShapeType = RtfShape::st_inline; + oNewShape->m_eAnchorTypeShape = RtfShape::st_inline; OOXShapeReader oShapeReader(ooxObject->m_oShape.GetPointer()); if( true == oShapeReader.Parse( oParam, oNewShape ) ) aPictShape = oNewShape; } - //if (ooxObject->m_oGroupShape.IsInit()) - //{ - // RtfShapeGroupPtr oNewShape( new RtfShapeGroup() ); - // oNewShape->m_eShapeType = RtfShape::st_inline; - // OOXShapeGroupReader oShapeReader; - // if( true == oShapeReader.Parse( oParam, oNewShape ) ) - // aPictShape = oNewShape; - //} + if (ooxObject->m_oOleObject.IsInit()) { RtfOlePtr oNewOle( new RtfOle() ); @@ -608,23 +601,35 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap { OOX::Logic::CPicture *ooxPicture = dynamic_cast(ooxItem); if( ooxPicture) - {//todooo - groups & custom - RtfShapePtr oNewShape( new RtfShape() ); - OOXShapeReader *pShapeReader = NULL; - - if (ooxPicture->m_oShape.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShape.GetPointer()); - else if (ooxPicture->m_oShapeRect.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRect.GetPointer()); - else if (ooxPicture->m_oShapeRoundRect.IsInit())pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRoundRect.GetPointer()); - else if (ooxPicture->m_oShapeOval.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeOval.GetPointer()); - else if (ooxPicture->m_oShapeLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeLine.GetPointer()); - else if (ooxPicture->m_oShapePolyLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapePolyLine.GetPointer()); - else if (ooxPicture->m_oShapeCurve.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeCurve.GetPointer()); - - if (pShapeReader) + { + if (ooxPicture->m_oShapeGroup.IsInit()) { - if( true == pShapeReader->Parse( oParam, oNewShape ) ) - oOutputParagraph.AddItem( oNewShape ); - delete pShapeReader; + RtfShapeGroupPtr oNewShape( new RtfShapeGroup() ); + OOXShapeGroupReader oShapeGroupReader(ooxPicture->m_oShapeGroup.GetPointer()); + if( true == oShapeGroupReader.Parse( oParam, oNewShape ) ) + oOutputParagraph.AddItem( oNewShape ); + } + else + { + RtfShapePtr oNewShape( new RtfShape() ); + OOXShapeReader *pShapeReader = NULL; + + if (ooxPicture->m_oShape.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShape.GetPointer()); + else if (ooxPicture->m_oShapeType.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeType.GetPointer()); + else if (ooxPicture->m_oShapeArc.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeArc.GetPointer()); + else if (ooxPicture->m_oShapeRect.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRect.GetPointer()); + else if (ooxPicture->m_oShapeRoundRect.IsInit())pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRoundRect.GetPointer()); + else if (ooxPicture->m_oShapeOval.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeOval.GetPointer()); + else if (ooxPicture->m_oShapeLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeLine.GetPointer()); + else if (ooxPicture->m_oShapePolyLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapePolyLine.GetPointer()); + else if (ooxPicture->m_oShapeCurve.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeCurve.GetPointer()); + + if (pShapeReader) + { + if( true == pShapeReader->Parse( oParam, oNewShape ) ) + oOutputParagraph.AddItem( oNewShape ); + delete pShapeReader; + } } } }break; @@ -765,7 +770,11 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap int nFontSize = 10; if( PROP_DEF != oNewProperty.m_nFontSize ) nFontSize = oNewProperty.m_nFontSize / 2; - sFieldText.AppendFormat(_T("SYMBOL %d \\\\f \"%ls\" \\\\s %d"), nChar, sFont.GetBuffer(), nFontSize ); + + sFieldText.AppendFormat(_T("SYMBOL %d \\\\f \""), nChar); + sFieldText += sFont; + sFieldText.AppendFormat(_T("\" \\\\s %d"), nFontSize ); + oNewChar->setText( sFieldText ); RtfParagraphPtr oNewInsertParagraph( new RtfParagraph() ); oNewInsertParagraph->AddItem( oNewChar ); diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureAnchorReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureAnchorReader.h index 8c6d9310a2..6c8bde59c2 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureAnchorReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureAnchorReader.h @@ -48,7 +48,7 @@ public: if (m_ooxAnchor == NULL) return false; oOutput.m_oPicture = RtfPicturePtr( new RtfPicture() ); - oOutput.m_eShapeType = RtfShape::st_anchor; + oOutput.m_eAnchorTypeShape = RtfShape::st_anchor; oOutput.m_nShapeType = 75; oOutput.m_bAllowOverlap = m_ooxAnchor->m_oAllowOverlap.IsInit() ? m_ooxAnchor->m_oAllowOverlap->ToBool() : false; @@ -241,22 +241,20 @@ public: } if (m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon.IsInit())///??? todooo twips ? pt? { - int nValue; + int nValueX, nValueY; if (m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_oStart.IsInit()) { - nValue = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_oStart->m_oX.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + nValueX = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_oStart->m_oX.ToTwips(); + nValueY = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_oStart->m_oY.ToTwips(); - nValue =m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_oStart->m_oY.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + oOutput.m_aWrapPoints.push_back( std::pair(nValueX, nValueY)); } for( int i = 0; i < m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_arrLineTo.size(); i++ ) { - nValue = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_arrLineTo[i]->m_oX.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + nValueX = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_arrLineTo[i]->m_oX.ToTwips(); + nValueY = m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_arrLineTo[i]->m_oY.ToTwips(); - nValue =m_ooxAnchor->m_oWrapThrough->m_oWrapPolygon->m_arrLineTo[i]->m_oY.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + oOutput.m_aWrapPoints.push_back( std::pair(nValueX, nValueY)); } } } @@ -275,24 +273,22 @@ public: } if (m_ooxAnchor->m_oWrapTight->m_oWrapPolygon.IsInit()) { - int nValue; + int nValueX, nValueY; if (m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_oStart.IsInit()) { - nValue = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_oStart->m_oX.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + nValueX = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_oStart->m_oX.ToTwips(); + nValueY = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_oStart->m_oY.ToTwips(); - nValue =m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_oStart->m_oY.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + oOutput.m_aWrapPoints.push_back( std::pair(nValueX, nValueY) ); } for( int i = 0; i < m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_arrLineTo.size(); i++ ) { - nValue = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_arrLineTo[i]->m_oX.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + nValueX = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_arrLineTo[i]->m_oX.ToTwips(); + nValueY = m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_arrLineTo[i]->m_oY.ToTwips(); - nValue =m_ooxAnchor->m_oWrapTight->m_oWrapPolygon->m_arrLineTo[i]->m_oY.ToTwips(); - oOutput.m_aWrapPoints.push_back( nValue ); + oOutput.m_aWrapPoints.push_back( std::pair(nValueX, nValueY) ); } } } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureInlineReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureInlineReader.h index bb32056636..e6685324ee 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureInlineReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureInlineReader.h @@ -46,7 +46,7 @@ public: if (m_ooxInline == NULL) return false; oOutput.m_oPicture = RtfPicturePtr( new RtfPicture() ); - oOutput.m_eShapeType = RtfShape::st_inline; + oOutput.m_eAnchorTypeShape = RtfShape::st_inline; oOutput.m_nShapeType = 75; oOutput.m_nLeft = 0; oOutput.m_nTop = 0; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.h index 0670eb642d..055bc30220 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.h @@ -40,18 +40,20 @@ class OOXReader { public: - RtfConvertationManager *m_convertationManager; - CString m_sPath; + RtfConvertationManager* m_convertationManager; + CString m_sPath; - int m_nCurItap; //для определение вложенности таблицы + int m_nCurItap; //для определение вложенности таблицы - int m_nCurFittextId; - std::map m_aBookmarks; + int m_nCurFittextId; + std::map m_aBookmarks; - std::map m_mapPictureBullet; - std::map m_mapFootnotes; - std::map m_mapEndnotes; + std::map m_mapPictureBullet; + std::map m_mapFootnotes; + std::map m_mapEndnotes; + std::map m_mapShapeTypes; +//------------------------------------------------------------------------ OOXIdGenerator m_oOOXIdGenerator; //Theme Fonts diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp index 8b692487e0..0600760958 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp @@ -32,6 +32,205 @@ #include "OOXShapeReader.h" #include "OOXTextItemReader.h" +bool ParseStyle(RtfShape* pShape, SimpleTypes::Vml::CCssProperty* prop) +{ + if (pShape == NULL) return false; + if (prop == NULL) return false; + + switch(prop->get_Type()) + { + case SimpleTypes::Vml::cssptUnknown : + break; + case SimpleTypes::Vml::cssptFlip : + switch(pShape->m_bFlipH = prop->get_Value().eFlip) + { + case SimpleTypes::Vml::cssflipX: pShape->m_bFlipH = true; break; + case SimpleTypes::Vml::cssflipY: pShape->m_bFlipV = true; break; + case SimpleTypes::Vml::cssflipXY: pShape->m_bFlipH = true; pShape->m_bFlipV = true; break; + case SimpleTypes::Vml::cssflipYX : pShape->m_bFlipH = true; pShape->m_bFlipV = true; break; + } + break; + case SimpleTypes::Vml::cssptWidth : + { + if (prop->get_Value().oValue.eType == SimpleTypes::Vml::cssunitstypeUnits) + pShape->m_nRelRight = (int)(20 * prop->get_Value().oValue.dValue); + else + pShape->m_nRelRight = (int)(prop->get_Value().oValue.dValue); + + pShape->m_nRight = pShape->m_nRelRight; + + if( PROP_DEF != pShape->m_nLeft ) + pShape->m_nRight += pShape->m_nLeft; + if( PROP_DEF != pShape->m_nRelLeft) + pShape->m_nRelRight += pShape->m_nRelLeft; + }break; + case SimpleTypes::Vml::cssptHeight : + { + if (prop->get_Value().oValue.eType == SimpleTypes::Vml::cssunitstypeUnits) + pShape->m_nRelBottom = (int)(20 * prop->get_Value().oValue.dValue); //pt + else + pShape->m_nRelBottom = (int)(prop->get_Value().oValue.dValue); //absolute + + pShape->m_nBottom = pShape->m_nRelBottom; + + if( PROP_DEF != pShape->m_nTop ) + pShape->m_nBottom += pShape->m_nTop; + if( PROP_DEF != pShape->m_nRelTop) + pShape->m_nRelBottom += pShape->m_nRelTop; + }break; + case SimpleTypes::Vml::cssptLeft : + { + pShape->m_nRelLeft = prop->get_Value().oValue.dValue; //absolute + + if( PROP_DEF != pShape->m_nRelRight) + pShape->m_nRelRight += pShape->m_nRelLeft; + }break; + case SimpleTypes::Vml::cssptTop : + { + pShape->m_nRelTop = prop->get_Value().oValue.dValue; //absolute + if( PROP_DEF != pShape->m_nRelBottom) + pShape->m_nRelBottom += pShape->m_nRelTop; + }break; + case SimpleTypes::Vml::cssptMarginBottom: + { + pShape->m_nBottom = (int)(20 * prop->get_Value().oValue.dValue ); + }break; + case SimpleTypes::Vml::cssptMarginLeft : + { + pShape->m_nLeft = (int)(20 * prop->get_Value().oValue.dValue ); + }break;//pt tp twips + case SimpleTypes::Vml::cssptMarginRight : + { + pShape->m_nRight = (int)(20 * prop->get_Value().oValue.dValue ); + }break; + case SimpleTypes::Vml::cssptMarginTop: + { + pShape->m_nTop = (int)(20 * prop->get_Value().oValue.dValue ); + }break; + case SimpleTypes::Vml::cssptMsoPositionHorizontal: + { + pShape->m_nPositionH = prop->get_Value().eMsoPosHor; + }break; + case SimpleTypes::Vml::cssptMsoPositionHorizontalRelative : + { + pShape->m_nPositionHRelative = prop->get_Value().eMsoPosHorRel; + switch(prop->get_Value().eMsoPosHorRel) + { + case SimpleTypes::Vml::cssmsoposhorrelMargin: pShape->m_eXAnchor = RtfShape::ax_margin; break; + case SimpleTypes::Vml::cssmsoposhorrelPage: pShape->m_eXAnchor = RtfShape::ax_page; break; + case SimpleTypes::Vml::cssmsoposhorrelText: + case SimpleTypes::Vml::cssmsoposhorrelChar: break;//inline + } + }break; + case SimpleTypes::Vml::cssptMsoPositionVertical: + { + pShape->m_nPositionV = prop->get_Value().eMsoPosVer; + }break; + case SimpleTypes::Vml::cssptMsoPositionVerticalRelative : + { + pShape->m_nPositionVRelative = prop->get_Value().eMsoPosVerRel; + switch(prop->get_Value().eMsoPosVerRel) + { + case SimpleTypes::Vml::cssmsoposverrelMargin: pShape->m_eYAnchor = RtfShape::ay_margin; break; + case SimpleTypes::Vml::cssmsoposverrelPage: pShape->m_eYAnchor = RtfShape::ay_page; break; + case SimpleTypes::Vml::cssmsoposverrelText: + case SimpleTypes::Vml::cssmsoposverrelLine: break;//inline + } + }break; + case SimpleTypes::Vml::cssptMsoWrapDistanceBottom: + { + pShape->m_nWrapDistBottom = (int)(20 * prop->get_Value().dValue ); + }break; + case SimpleTypes::Vml::cssptMsoWrapDistanceLeft : + { + pShape->m_nWrapDistLeft = (int)(20 * prop->get_Value().dValue ); + }break; + case SimpleTypes::Vml::cssptMsoWrapDistanceRight: + { + pShape->m_nWrapDistRight = (int)(20 * prop->get_Value().dValue ); + }break; + case SimpleTypes::Vml::cssptMsoWrapDistanceTop : + { + pShape->m_nWrapDistTop = (int)(20 * prop->get_Value().dValue ); + }break; + case SimpleTypes::Vml::cssptMsoWrapEdited: + break; + case SimpleTypes::Vml::cssptMsoWrapStyle: + + if (prop->get_Value().eMsoWrapStyle == SimpleTypes::Vml::cssmsowrapstyleNone) + pShape->m_nWrapType = 3; + else + pShape->m_nWrapType = 2; + break; + case SimpleTypes::Vml::cssptPosition: + break; + case SimpleTypes::Vml::cssptRotation: + { + pShape->m_nRotation = 65536 * prop->get_Value().dValue; + if( PROP_DEF != pShape->m_nRelRight || PROP_DEF != pShape->m_nRelLeft || PROP_DEF != pShape->m_nRelTop || PROP_DEF != pShape->m_nRelBottom ) + pShape->m_nRelRotation = pShape->m_nRotation; + }break; + case SimpleTypes::Vml::cssptVisibility : + break; + case SimpleTypes::Vml::cssptZIndex : + { + pShape->m_eAnchorTypeShape = RtfShape::st_anchor; + + int nValue = prop->get_Value().oZIndex.nOrder; + pShape->m_nZOrder = nValue; + if( nValue > 0 ) + pShape->m_nZOrderRelative = 0; + else if( nValue < 0 ) + pShape->m_nZOrderRelative = 1; + }break; + case SimpleTypes::Vml::cssptFontFamily: + { + pShape->m_sGtextFont = CString(prop->get_Value().wsValue); + }break; + case SimpleTypes::Vml::cssptFontSize: + { + pShape->m_nGtextSize = prop->get_Value().oValue.dValue; + }break; + case SimpleTypes::Vml::cssptVTextAnchor: + { + pShape->m_nAnchorText = prop->get_Value().eVTextAnchor;//совпдает + pShape->m_bFitShapeToText = 0; + }break; + case SimpleTypes::Vml::csspctMsoWidthPercent: + { + pShape->m_nPctWidth = prop->get_Value().oValue.dValue; + }break; + case SimpleTypes::Vml::csspctMsoHeightPercent: + { + pShape->m_nPctHeight = prop->get_Value().oValue.dValue; + }break; + case SimpleTypes::Vml::cssptDirection : break; + case SimpleTypes::Vml::cssptLayoutFlow : break; + case SimpleTypes::Vml::cssptMsoDirectionAlt : break; + case SimpleTypes::Vml::cssptMsoFitShapeToText : break; + case SimpleTypes::Vml::cssptMsoFitTextToShape : break; + case SimpleTypes::Vml::cssptMsoLayoutFlowAlt : break; + case SimpleTypes::Vml::cssptMsoNextTextbox : break; + case SimpleTypes::Vml::cssptMsoRotate : break; + case SimpleTypes::Vml::cssptMsoTextScale : break; + case SimpleTypes::Vml::cssptFont : break; + case SimpleTypes::Vml::cssptFontStyle : break; + case SimpleTypes::Vml::cssptFontVariant : break; + case SimpleTypes::Vml::cssptFontWeight : break; + case SimpleTypes::Vml::cssptMsoTextShadow : break; + case SimpleTypes::Vml::cssptTextDecoration : break; + case SimpleTypes::Vml::cssptVRotateLetters : break; + case SimpleTypes::Vml::cssptVSameLetterHeights : break; + case SimpleTypes::Vml::cssptVTextAlign : break; + case SimpleTypes::Vml::cssptVTextKern : break; + case SimpleTypes::Vml::cssptVTextReverse : break; + case SimpleTypes::Vml::cssptVTextSpacingMode : break; + case SimpleTypes::Vml::cssptVTextSpacing : break; + } + return true; +} + + OOXShapeReader::OOXShapeReader(OOX::WritingElementWithChilds * elem) { m_arrElement = elem; @@ -152,7 +351,7 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type())) { oOutput->m_oPicture = RtfPicturePtr( new RtfPicture() ); - oOutput->m_eShapeType = RtfShape::st_none; + oOutput->m_eAnchorTypeShape = RtfShape::st_none; oOutput->m_nShapeType = 75; OOX::Image* pImage = (OOX::Image*)oFile.operator->(); @@ -266,14 +465,14 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) OOX::Vml::CTextPath *text_path= dynamic_cast(m_arrElement->m_arrItems[i]); if (text_path) { - oOutput->m_bGtext = 1; + oOutput->m_bGtext = 1; if (text_path->m_sString.IsInit()) { oOutput->m_sGtextUNICODE = text_path->m_sString.get(); } if (text_path->m_oStyle.IsInit()) { - ParseStyles( *oOutput, text_path->m_oStyle->m_arrProperties ); + ParseStyles( oOutput, text_path->m_oStyle->m_arrProperties ); } } @@ -283,7 +482,7 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) //проверяем на inline if((PROP_DEF == oOutput->m_nLeft/* || 0 == oOutput->m_nLeft */) && ( PROP_DEF == oOutput->m_nTop/* || 0 == oOutput->m_nTop */) && PROP_DEF == oOutput->m_nPositionH && PROP_DEF == oOutput->m_nPositionV ) - oOutput->m_eShapeType = RtfShape::st_inline; + oOutput->m_eAnchorTypeShape = RtfShape::st_inline; //если ничего не задали делаем inline if( (PROP_DEF == oOutput->m_nLeft || 0 == oOutput->m_nLeft ) && ( PROP_DEF == oOutput->m_nTop || 0 == oOutput->m_nTop ) && PROP_DEF == oOutput->m_nPositionH && PROP_DEF == oOutput->m_nPositionV ) { @@ -296,23 +495,37 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) } bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput) { - if (m_vmlElement == NULL && m_arrElement) return false; - - if (m_vmlElement == NULL ) return Parse2(oParam , oOutput); + if (m_vmlElement == NULL && m_arrElement) return false; + if (m_vmlElement == NULL ) return Parse2(oParam , oOutput); if( m_vmlElement->m_sId.IsInit()) { oOutput->m_nID = oParam.oReader->m_oOOXIdGenerator.GetId( m_vmlElement->m_sId.get()); } - + //oOutput->m_nLeft = 0; //стили только с widht height (например в Numbering) //oOutput->m_nTop = 0; - oOutput->m_eShapeType = RtfShape::st_none; //inline or anchor - - if ( m_vmlElement->m_oStyle.IsInit()) + +// геометрия -------------------------------------------------------------------------------------------------------- + + SimpleTypes::Vml::CVmlPath * custom_path = NULL; + + if (OOX::Vml::CShapeType* shape_type = dynamic_cast(m_vmlElement)) { - if( false == ParseStyles( *oOutput, m_vmlElement->m_oStyle->m_arrProperties ) ) - return false; + oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive; + + if (shape_type->m_sId.IsInit()) + { + if (oParam.oReader->m_mapShapeTypes.find(shape_type->m_sId.get()) == + oParam.oReader->m_mapShapeTypes.end()) + { + oParam.oReader->m_mapShapeTypes.insert(oParam.oReader->m_mapShapeTypes.begin(), + std::pair(shape_type->m_sId.get(), shape_type)); + + return false;//add type but bot add object + } + } + custom_path = shape_type->m_oPath.GetPointer(); } if (OOX::Vml::CShape* shape = dynamic_cast(m_vmlElement)) { @@ -321,18 +534,61 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput) if (shape->m_sType.IsInit()) { + CString type = shape->m_sType.get().Mid(1);//without # + std::map::iterator it = oParam.oReader->m_mapShapeTypes.find(type); + + if ( it != oParam.oReader->m_mapShapeTypes.end()) + { + OOXShapeReader sub_reader(it->second); + sub_reader.Parse(oParam, oOutput); + } int pos = shape->m_sType->Find(_T("#_x0000_t")); if (pos >= 0) { - oOutput->m_nShapeType = _wtoi(shape->m_sType->Mid(pos + 9, shape->m_sType->GetLength() - pos - 9).GetString()); + oOutput->m_nShapeType = _wtoi(shape->m_sType->Mid(pos + 9, shape->m_sType->GetLength() - pos - 9).GetString()); } } + else + { + oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive; + custom_path = shape->m_oPath.GetPointer(); + } } - if (OOX::Vml::CRect* rect = dynamic_cast(m_vmlElement)) + else if (OOX::Vml::CRect* rect = dynamic_cast(m_vmlElement)) { - oOutput->m_nShapeType = 1; + oOutput->m_nShapeType = NSOfficeDrawing::sptRectangle; } - + else if (OOX::Vml::COval* oval = dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptEllipse; + } + else if (OOX::Vml::CLine* line = dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptLine; + } + else if (OOX::Vml::CArc* arc = dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptArc; + } + else if (OOX::Vml::CCurve* curve= dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive; + } + else if (OOX::Vml::CRoundRect* curve= dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptRoundRectangle; + } + else if (OOX::Vml::CPolyLine* polyline = dynamic_cast(m_vmlElement)) + { + oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive; + //polyline->m_oPoints + } + + if (oOutput->m_nShapeType == NSOfficeDrawing::sptNotPrimitive && custom_path) + { + // + } +//------------------------------------------------------------------------------------------------------------- if (m_vmlElement->m_oFilled.IsInit()) oOutput->m_bFilled = m_vmlElement->m_oFilled->GetValue() == SimpleTypes::booleanFalse ? 0 : 1; @@ -348,227 +604,157 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput) if( m_vmlElement->m_oStrokeWeight.IsInit()) oOutput->m_nLineWidth = m_vmlElement->m_oStrokeWeight->ToEmu(); - switch(m_vmlElement->m_oConnectorType.GetValue()) + if (m_vmlElement->m_oConnectorType.IsInit()) { - case SimpleTypes::connectortypeCurved : oOutput->m_nConnectionType = 2; break; - case SimpleTypes::connectortypeElbow : oOutput->m_nConnectionType = 1; break; - case SimpleTypes::connectortypeNone : oOutput->m_nConnectionType = 3; break; - case SimpleTypes::connectortypeStraight : oOutput->m_nConnectionType = 0; break; + switch(m_vmlElement->m_oConnectorType->GetValue()) + { + case SimpleTypes::connectortypeCurved : oOutput->m_nConnectionType = 2; break; + case SimpleTypes::connectortypeElbow : oOutput->m_nConnectionType = 1; break; + case SimpleTypes::connectortypeNone : oOutput->m_nConnectionType = 3; break; + case SimpleTypes::connectortypeStraight : oOutput->m_nConnectionType = 0; break; + } } oOutput->m_bLayoutInCell = m_vmlElement->m_oAllowInCell.GetValue(); oOutput->m_bAllowOverlap = m_vmlElement->m_oAllowOverlap.GetValue(); + oOutput->m_nWrapType = 3; //default (non wrap) + oOutput->m_eAnchorTypeShape = RtfShape::st_none; //inline or anchor + + if ( m_vmlElement->m_oStyle.IsInit()) + { + if( false == ParseStyles( oOutput, m_vmlElement->m_oStyle->m_arrProperties ) ) + return false; + } + if( m_vmlElement->m_oWrapCoords.IsInit()) { + if (oOutput->m_nWrapType == 3) oOutput->m_nWrapType =2; + int nPosition = 0; CString sPoint = _T("start"); for (long i =0 ;i < m_vmlElement->m_oWrapCoords->GetSize(); i++) { - oOutput->m_aWrapPoints.push_back( m_vmlElement->m_oWrapCoords->GetX(i));// todooo y??? + oOutput->m_aWrapPoints.push_back( std::pair( m_vmlElement->m_oWrapCoords->GetX(i), + m_vmlElement->m_oWrapCoords->GetY(i))); } } - if( m_vmlElement->m_oCoordOrigin.IsInit() ) { - oOutput->m_nGroupLeft = m_vmlElement->m_oCoordOrigin->GetX(); - oOutput->m_nGroupTop = m_vmlElement->m_oCoordOrigin->GetY(); + oOutput->m_nGroupLeft = m_vmlElement->m_oCoordOrigin->GetX(); + oOutput->m_nGroupTop = m_vmlElement->m_oCoordOrigin->GetY(); } if( m_vmlElement->m_oCoordSize.IsInit()) + {// shapeType content only size + if (oOutput->m_nGroupLeft != PROP_DEF) + oOutput->m_nGroupRight = oOutput->m_nGroupLeft + m_vmlElement->m_oCoordSize->GetX(); + if (oOutput->m_nGroupTop != PROP_DEF) + oOutput->m_nGroupBottom = oOutput->m_nGroupTop + m_vmlElement->m_oCoordSize->GetY(); + } + + if (m_vmlElement->m_oConnectorType.IsInit()) { - oOutput->m_nGroupRight = oOutput->m_nGroupLeft + m_vmlElement->m_oCoordSize->GetX(); - oOutput->m_nGroupBottom = oOutput->m_nGroupTop + m_vmlElement->m_oCoordSize->GetY(); + switch(m_vmlElement->m_oConnectorType->GetValue()) + { + case SimpleTypes::connectortypeCurved : oOutput->m_nConnectorStyle = 2; break; + case SimpleTypes::connectortypeElbow : oOutput->m_nConnectorStyle = 1; break; + case SimpleTypes::connectortypeNone : oOutput->m_nConnectorStyle = 3; break; + case SimpleTypes::connectortypeStraight: oOutput->m_nConnectorStyle = 0; break; + } + } + +//--------------------- + + if (OOX::CHdrFtr *pHdrFtr = dynamic_cast(oParam.oReader->m_currentContainer)) + { + oOutput->m_nHeader = 1;//shape in header/footer } return Parse2(oParam, oOutput); - - - return true; } -bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty* prop) +bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOutput) { - if (prop == NULL) return false; + if (m_vmlGroup == NULL) return false; - switch(prop->get_Type()) + if( m_vmlGroup->m_sId.IsInit()) { - case SimpleTypes::Vml::cssptUnknown : - break; - case SimpleTypes::Vml::cssptFlip : - switch(oShape.m_bFlipH = prop->get_Value().eFlip) - { - case SimpleTypes::Vml::cssflipX: oShape.m_bFlipH = true; break; - case SimpleTypes::Vml::cssflipY: oShape.m_bFlipV = true; break; - case SimpleTypes::Vml::cssflipXY: oShape.m_bFlipH = true; oShape.m_bFlipV = true; break; - case SimpleTypes::Vml::cssflipYX : oShape.m_bFlipH = true; oShape.m_bFlipV = true; break; - } - break; - case SimpleTypes::Vml::cssptWidth : - { - //OOX::SimpleTypes::CPoint oPoint; - //oPoint.FromPoints(prop->get_Value().dValue); - - oShape.m_nRight = oShape.m_nRelRight = (int)(20 * prop->get_Value().oValue.dValue); - - if( PROP_DEF != oShape.m_nLeft ) - oShape.m_nRight += oShape.m_nLeft; - if( PROP_DEF != oShape.m_nRelLeft) - oShape.m_nRelRight += oShape.m_nRelLeft; - }break; - case SimpleTypes::Vml::cssptHeight : - { - oShape.m_nBottom = oShape.m_nRelBottom = (int)(20 * prop->get_Value().oValue.dValue); - - if( PROP_DEF != oShape.m_nTop ) - oShape.m_nBottom += oShape.m_nTop; - if( PROP_DEF != oShape.m_nRelTop) - oShape.m_nRelBottom += oShape.m_nRelTop; - }break; - case SimpleTypes::Vml::cssptLeft : - { - oShape.m_nRelLeft = prop->get_Value().oValue.dValue; - if( PROP_DEF != oShape.m_nRelRight) - oShape.m_nRelRight += oShape.m_nRelLeft; - }break; - case SimpleTypes::Vml::cssptTop : - { - oShape.m_nRelTop = prop->get_Value().oValue.dValue; - if( PROP_DEF != oShape.m_nRelBottom) - oShape.m_nRelBottom += oShape.m_nRelTop; - }break; - case SimpleTypes::Vml::cssptMarginBottom: - { - oShape.m_nBottom = (int)(20 * prop->get_Value().oValue.dValue ); - }break; - case SimpleTypes::Vml::cssptMarginLeft : - { - oShape.m_nLeft = (int)(20 * prop->get_Value().oValue.dValue ); - }break;//pt tp twips - case SimpleTypes::Vml::cssptMarginRight : - { - oShape.m_nRight = (int)(20 * prop->get_Value().oValue.dValue ); - }break; - case SimpleTypes::Vml::cssptMarginTop: - { - oShape.m_nTop = (int)(20 * prop->get_Value().oValue.dValue ); - }break; - case SimpleTypes::Vml::cssptMsoPositionHorizontal: - { - oShape.m_nPositionH = prop->get_Value().eMsoPosHor; - }break; - case SimpleTypes::Vml::cssptMsoPositionHorizontalRelative : - { - oShape.m_nPositionHRelative = prop->get_Value().eMsoPosHorRel; - switch(prop->get_Value().eMsoPosHorRel) - { - case SimpleTypes::Vml::cssmsoposhorrelMargin: oShape.m_eXAnchor = RtfShape::ax_margin; break; - case SimpleTypes::Vml::cssmsoposhorrelPage: oShape.m_eXAnchor = RtfShape::ax_page; break; - case SimpleTypes::Vml::cssmsoposhorrelText: - case SimpleTypes::Vml::cssmsoposhorrelChar: break;//inline - } - }break; - case SimpleTypes::Vml::cssptMsoPositionVertical: - { - oShape.m_nPositionV = prop->get_Value().eMsoPosVer; - }break; - case SimpleTypes::Vml::cssptMsoPositionVerticalRelative : - { - oShape.m_nPositionVRelative = prop->get_Value().eMsoPosVerRel; - switch(prop->get_Value().eMsoPosVerRel) - { - case SimpleTypes::Vml::cssmsoposverrelMargin: oShape.m_eYAnchor = RtfShape::ay_margin; break; - case SimpleTypes::Vml::cssmsoposverrelPage: oShape.m_eYAnchor = RtfShape::ay_page; break; - case SimpleTypes::Vml::cssmsoposverrelText: - case SimpleTypes::Vml::cssmsoposverrelLine: break;//inline - } - }break; - case SimpleTypes::Vml::cssptMsoWrapDistanceBottom: - { - oShape.m_nWrapDistBottom = (int)(20 * prop->get_Value().dValue ); - }break; - case SimpleTypes::Vml::cssptMsoWrapDistanceLeft : - { - oShape.m_nWrapDistLeft = (int)(20 * prop->get_Value().dValue ); - }break; - case SimpleTypes::Vml::cssptMsoWrapDistanceRight: - { - oShape.m_nWrapDistRight = (int)(20 * prop->get_Value().dValue ); - }break; - case SimpleTypes::Vml::cssptMsoWrapDistanceTop : - { - oShape.m_nWrapDistTop = (int)(20 * prop->get_Value().dValue ); - }break; - case SimpleTypes::Vml::cssptMsoWrapEdited: - break; - case SimpleTypes::Vml::cssptMsoWrapStyle: - break; - case SimpleTypes::Vml::cssptPosition: - break; - case SimpleTypes::Vml::cssptRotation: - { - oShape.m_nRotation = 65536 * prop->get_Value().dValue; - if( PROP_DEF != oShape.m_nRelRight || PROP_DEF != oShape.m_nRelLeft || PROP_DEF != oShape.m_nRelTop || PROP_DEF != oShape.m_nRelBottom ) - oShape.m_nRelRotation = oShape.m_nRotation; - }break; - case SimpleTypes::Vml::cssptVisibility : - break; - case SimpleTypes::Vml::cssptZIndex : - { - oShape.m_eShapeType = RtfShape::st_anchor; - - int nValue = prop->get_Value().oZIndex.nOrder; - oShape.m_nZOrder = nValue; - if( nValue > 0 ) - oShape.m_nZOrderRelative = 0; - else if( nValue < 0 ) - oShape.m_nZOrderRelative = 1; - }break; - case SimpleTypes::Vml::cssptFontFamily: - { - oShape.m_sGtextFont = CString(prop->get_Value().wsValue); - }break; - case SimpleTypes::Vml::cssptFontSize: - { - oShape.m_nGtextSize = prop->get_Value().oValue.dValue; - }break; - case SimpleTypes::Vml::cssptVTextAnchor: - { - oShape.m_nAnchorText = prop->get_Value().eVTextAnchor;//совпдает - oShape.m_bFitShapeToText = 0; - }break; - case SimpleTypes::Vml::csspctMsoWidthPercent: - { - oShape.m_nPctWidth = prop->get_Value().oValue.dValue; - }break; - case SimpleTypes::Vml::csspctMsoHeightPercent: - { - oShape.m_nPctHeight = prop->get_Value().oValue.dValue; - }break; - case SimpleTypes::Vml::cssptDirection : break; - case SimpleTypes::Vml::cssptLayoutFlow : break; - case SimpleTypes::Vml::cssptMsoDirectionAlt : break; - case SimpleTypes::Vml::cssptMsoFitShapeToText : break; - case SimpleTypes::Vml::cssptMsoFitTextToShape : break; - case SimpleTypes::Vml::cssptMsoLayoutFlowAlt : break; - case SimpleTypes::Vml::cssptMsoNextTextbox : break; - case SimpleTypes::Vml::cssptMsoRotate : break; - case SimpleTypes::Vml::cssptMsoTextScale : break; - case SimpleTypes::Vml::cssptFont : break; - case SimpleTypes::Vml::cssptFontStyle : break; - case SimpleTypes::Vml::cssptFontVariant : break; - case SimpleTypes::Vml::cssptFontWeight : break; - case SimpleTypes::Vml::cssptMsoTextShadow : break; - case SimpleTypes::Vml::cssptTextDecoration : break; - case SimpleTypes::Vml::cssptVRotateLetters : break; - case SimpleTypes::Vml::cssptVSameLetterHeights : break; - case SimpleTypes::Vml::cssptVTextAlign : break; - case SimpleTypes::Vml::cssptVTextKern : break; - case SimpleTypes::Vml::cssptVTextReverse : break; - case SimpleTypes::Vml::cssptVTextSpacingMode : break; - case SimpleTypes::Vml::cssptVTextSpacing : break; + oOutput->m_nID = oParam.oReader->m_oOOXIdGenerator.GetId( m_vmlGroup->m_sId.get()); + } + oOutput->m_eAnchorTypeShape = RtfShape::st_none; //inline or anchor + + oOutput->m_bLayoutInCell = m_vmlGroup->m_oAllowInCell.GetValue(); + oOutput->m_bAllowOverlap = m_vmlGroup->m_oAllowOverlap.GetValue(); + + oOutput->m_nWrapType = 3; //def + + if ( m_vmlGroup->m_oStyle.IsInit()) + { + if( false == ParseStyles( oOutput, m_vmlGroup->m_oStyle->m_arrProperties ) ) + return false; } + if( m_vmlGroup->m_oWrapCoords.IsInit()) + { + if (oOutput->m_nWrapType == 3) oOutput->m_nWrapType =2; + int nPosition = 0; + CString sPoint = _T("start"); + for (long i =0 ;i < m_vmlGroup->m_oWrapCoords->GetSize(); i++) + { + oOutput->m_aWrapPoints.push_back( std::pair( m_vmlGroup->m_oWrapCoords->GetX(i), + m_vmlGroup->m_oWrapCoords->GetY(i))); + } + } + + if( m_vmlGroup->m_oCoordOrigin.IsInit() ) + { + oOutput->m_nGroupLeft = m_vmlGroup->m_oCoordOrigin->GetX(); + oOutput->m_nGroupTop = m_vmlGroup->m_oCoordOrigin->GetY(); + } + + if( m_vmlGroup->m_oCoordSize.IsInit()) + { + oOutput->m_nGroupRight = oOutput->m_nGroupLeft + m_vmlGroup->m_oCoordSize->GetX(); + oOutput->m_nGroupBottom = oOutput->m_nGroupTop + m_vmlGroup->m_oCoordSize->GetY(); + } + + for( int i = 0; i < m_vmlGroup->m_arrItems.size() ; i++ ) + { + if (m_vmlGroup->m_arrItems[i] == NULL) continue; + + if (m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_group) + { + RtfShapeGroupPtr oNewShape( new RtfShapeGroup() ); + + OOXShapeGroupReader oShapeReader(dynamic_cast(m_vmlGroup->m_arrItems[i])); + + oNewShape->m_bInGroup = true; + if( true == oShapeReader.Parse( oParam, oNewShape ) ) + oOutput->AddItem( oNewShape ); + } + else if ( m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_arc || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_line || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_oval || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_shape || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_rect || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_roundrect || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_polyline || + m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_shapetype) + { + RtfShapePtr oNewShape( new RtfShape() );//set type .. .todooo + + OOXShapeReader oShapeReader(dynamic_cast(m_vmlGroup->m_arrItems[i])); + + oNewShape->m_bInGroup = true; + if( true == oShapeReader.Parse( oParam, oNewShape ) ) + oOutput->AddItem( oNewShape ); + } + else + { + //??? todooo + //shapetype как минимум нужен !!! + } + } return true; } - diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.h index 06c891914b..d395b28878 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.h @@ -38,6 +38,8 @@ #include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h" +bool ParseStyle(RtfShape* pShape, SimpleTypes::Vml::CCssProperty* prop); + class OOXShapeReader { public: @@ -100,16 +102,14 @@ private: OOX::Vml::CVmlCommonElements *m_vmlElement; OOX::WritingElementWithChilds *m_arrElement; - bool ParseStyles(RtfShape& oShape, std::vector & props) + bool ParseStyles(RtfShapePtr pShape, std::vector & props) { for (long i=0; i< props.size(); i++) { - ParseStyle( oShape, props[i]); + ParseStyle( pShape.get(), props[i]); } return true; } - bool ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty* prop); - }; @@ -123,50 +123,14 @@ public: m_vmlGroup = vmlGroup; } - bool Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOutput) + bool ParseStyles(RtfShapeGroupPtr pGroupShape, std::vector & props) { - if (m_vmlGroup == NULL) return false; - - //RtfShapePtr oBaseShape = boost::static_pointer_cast( oOutput ); - // - //OOXShapeReader oShapeReader(m_vmlGroup); - //oShapeReader.Parse( oParam, oBaseShape ); - //todooo притащить сюда атрибуты группы - - for( int i = 0; i < m_vmlGroup->m_arrItems.size() ; i++ ) + for (long i=0; i< props.size(); i++) { - if (m_vmlGroup->m_arrItems[i] == NULL) continue; - - if (m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_group) - { - RtfShapeGroupPtr oNewShape( new RtfShapeGroup() ); - - OOXShapeGroupReader oShapeReader(dynamic_cast(m_vmlGroup->m_arrItems[i])); - - if( true == oShapeReader.Parse( oParam, oNewShape ) ) - oOutput->AddItem( oNewShape ); - } - else if ( m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_arc || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_line || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_oval || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_shape || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_rect || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_roundrect || - m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_polyline) - { - RtfShapePtr oNewShape( new RtfShape() );//set type .. .todooo - - OOXShapeReader oShapeReader(dynamic_cast(m_vmlGroup->m_arrItems[i])); - - if( true == oShapeReader.Parse( oParam, oNewShape ) ) - oOutput->AddItem( oNewShape ); - } - else - { - //??? todooo - //shapetype как минимум нужен !!! - } + ParseStyle( dynamic_cast(pGroupShape.get()), props[i]); } return true; } + + bool Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOutput); }; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp index 003fb74909..5d3bf7c29a 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp @@ -55,7 +55,7 @@ CString RtfBookmarkStart::RenderToOOX(RenderParameter oRenderParameter) { CString sResult; //ATLASSERT( false == m_sName.IsEmpty() ); - sResult.Append(_T(" ( oRenderParameter.poWriter ); RtfDocument * poDocument = static_cast (oRenderParameter.poDocument); @@ -75,8 +75,8 @@ CString RtfBookmarkStart::RenderToOOX(RenderParameter oRenderParameter) sResult.AppendFormat(_T(" w:colFirst =\"%d\""), nID); if( PROP_DEF != nLastColumn ) sResult.AppendFormat(_T(" w:colLast =\"%d\""), nID); - sResult.AppendFormat(_T(" w:name =\"%ls\""), Utils::PrepareToXML( m_sName ).GetBuffer() ); - sResult.Append(_T("/>")); + sResult += _T(" w:name =\"") + Utils::PrepareToXML( m_sName ) + _T("\""); + sResult += _T("/>"); return sResult; } CString RtfBookmarkEnd::RenderToRtf(RenderParameter oRenderParameter) diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h b/ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h index 3e2493b3ea..b7cebbc1cd 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h @@ -207,21 +207,21 @@ public: CString RenderToRtf(RenderParameter oRenderParameter) } sResult += _T("{\\*\\fldinst "); RenderParameter oNewParam = oRenderParameter; - oNewParam.nType = RENDER_TO_RTF_PARAM_CHAR; - oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR; + oNewParam.nType = RENDER_TO_RTF_PARAM_CHAR; + oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR; sResult += m_oInsert->RenderToRtf( oNewParam ); if( true == m_bReferenceToEndnote ) sResult += _T("\\fldalt"); - if( false == m_sData.IsEmpty() ) - sResult.AppendFormat( _T("{\\*\\datafield %ls}"), m_sData.GetBuffer()); + if( !m_sData.IsEmpty() ) + sResult += _T("{\\*\\datafield ") + m_sData + _T("}"); sResult += _T("}"); CString str = m_oResult->RenderToRtf( oRenderParameter ) ; - sResult.AppendFormat(_T("{\\fldrslt %ls}"), str.GetBuffer()); + sResult += _T("{\\fldrslt ") + str + _T("}"); sResult += _T("}"); return sResult; } @@ -262,7 +262,7 @@ public: CString RenderToOOX(RenderParameter oRenderParameter) OOXRelsWriter* poRelsWriter = static_cast( oRenderParameter.poRels ); CString sId = poRelsWriter->AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"), Utils::PrepareToXML( sHyperlink ), false ); //добавляем гиперссылку в документ - sResult.AppendFormat( _T(""), sId.GetBuffer() ); + sResult += _T(""); oNewParam.nType = RENDER_TO_OOX_PARAM_RUN; sResult += m_oResult->RenderToOOX(oNewParam); diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfMath.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfMath.cpp index b16f3d1711..a14982e6f5 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfMath.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfMath.cpp @@ -90,9 +90,9 @@ CString RtfMath::RenderToRtf(RenderParameter oRenderParameter) CString sResult; if( RENDER_TO_RTF_PARAM_NESTED != oRenderParameter.nType ) - sResult.Append(_T("{\\mmath")); + sResult += _T("{\\mmath"); - sResult.AppendFormat(_T("{\\%ls"), m_sRtfName.GetBuffer()); + sResult += _T("{\\") + m_sRtfName; RenderParameter oNewParameter = oRenderParameter; CString sVal; @@ -120,10 +120,10 @@ CString RtfMath::RenderToRtf(RenderParameter oRenderParameter) for( int i = 0; i < (int)m_aArray.size(); i++ ) sResult.Append(m_aArray[i]->RenderToRtf( oNewParameter )); } - sResult.Append(_T("}")); + sResult += _T("}"); if( RENDER_TO_RTF_PARAM_NESTED != oRenderParameter.nType ) - sResult.AppendFormat(_T("}"), m_sRtfName.GetBuffer()); + sResult += _T("}");// m_sRtfName return sResult; } CString RtfMath::RenderToOOX(RenderParameter oRenderParameter) diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfOldList.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfOldList.cpp index 4b7b6e406a..8b877ee1f1 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfOldList.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfOldList.cpp @@ -54,10 +54,11 @@ CString RtfOldList::RenderToOOX(RenderParameter oRenderParameter) CString sText = m_oLevelText->RenderToOOX( oNewParameter ); sResult.AppendFormat( _T(""), m_nLs ); - sResult.Append(_T("")); - sResult.Append(_T("")); - sResult.Append(_T("")); - if( false == sText.IsEmpty() ) + sResult += _T(""); + sResult += _T(""); + sResult += _T(""); + + if(!sText.IsEmpty() ) sResult.AppendFormat(_T(""), Utils::PrepareToXML( sText ).GetBuffer() ); else { diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp index f729f29fa2..fcd88db508 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp @@ -957,33 +957,35 @@ CString RtfListLevelProperty::RenderToOOX2(RenderParameter oRenderParameter, int { sResult.AppendFormat( _T("")); + sResult += _T(">"); if( PROP_DEF != m_nJustification ) { switch( m_nJustification ) { - case 0:sResult.Append(_T("")); break; - case 1:sResult.Append(_T("")); break; - case 2:sResult.Append(_T("")); break; + case 0: sResult += _T(""); break; + case 1: sResult += _T(""); break; + case 2: sResult += _T(""); break; } } if( 1 == m_nNoRestart) - sResult.Append(_T("")); + sResult += _T(""); if( 1 == m_nLegal) - sResult.Append(_T("")); + sResult += _T(""); - sResult.AppendFormat( _T(""), GetLevelTextOOX().GetBuffer() ); - sResult.AppendFormat(_T(""), GetFormat(m_nNumberType).GetBuffer() ); + sResult += _T(""); + sResult += _T(""); + RENDER_OOX_INT( m_nPictureIndex, sResult, _T("w:lvlPicBulletId") ) RENDER_OOX_INT( m_nStart, sResult, _T("w:start") ) + if( PROP_DEF != m_nFollow ) { switch( m_nFollow ) { - case 0: sResult.Append( _T("") );break; - case 1: sResult.Append( _T("") );break; - case 2: sResult.Append( _T("") );break; + case 0: sResult += _T(""); break; + case 1: sResult += _T(""); break; + case 2: sResult += _T(""); break; } } @@ -998,22 +1000,24 @@ CString RtfListLevelProperty::RenderToOOX2(RenderParameter oRenderParameter, int } RENDER_OOX_INT_ATTRIBUTE( m_nIndent, sIndent, _T("w:left") ) RENDER_OOX_INT_ATTRIBUTE( m_nIndentStart, sIndent, _T("w:start") ) - if( false == sIndent.IsEmpty() ) - spPr.AppendFormat(_T(""), sIndent.GetBuffer()); + + if( !sIndent.IsEmpty() ) + spPr += _T(""); - spPr.Append( m_oTabs.RenderToOOX( oRenderParameter ) ); + spPr += m_oTabs.RenderToOOX( oRenderParameter ); - if( false == spPr.IsEmpty() ) - sResult.AppendFormat(_T("%ls"), spPr.GetBuffer()); + if( !spPr.IsEmpty() ) + sResult += _T("") + spPr + _T(""); - CString srPr; RenderParameter oNewParam = oRenderParameter; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; - srPr.Append( m_oCharProp.RenderToOOX(oNewParam) ); - if( false == srPr.IsEmpty() ) - sResult.AppendFormat(_T("%ls"), srPr.GetBuffer()); + + CString srPr = m_oCharProp.RenderToOOX(oNewParam); - sResult.Append(_T("")); + if( !srPr.IsEmpty() ) + sResult += _T("") + srPr + _T(""); + + sResult += _T(""); } return sResult; } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp index 57d8b6d4fb..870a72e9c8 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp @@ -59,7 +59,7 @@ void RtfReader::PushState() psaveNew -> m_oCellProperty = m_oState->m_oCellProperty; psaveNew -> m_oCurOldList = m_oState->m_oCurOldList; //psaveNew -> m_oSectionProp = m_oState->m_oSectionProp; - psaveNew -> psave = m_oState; + psaveNew -> m_pSaveState = m_oState; m_oState = psaveNew; if( PROP_DEF == m_oState->m_oCharProp.m_nFont ) @@ -67,9 +67,8 @@ void RtfReader::PushState() } void RtfReader::PopState() { - if( 0 != m_oState->psave ) - m_oState = m_oState->psave; - //delete psaveOld; + if( 0 != m_oState->m_pSaveState ) + m_oState = m_oState->m_pSaveState; } CString RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharString, RtfDocument& oDocument, RtfReader& oReader) diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.h index 162c1fbbc1..87c142f07e 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.h @@ -53,8 +53,8 @@ public: RtfRowProperty m_oRowProperty; RtfCellProperty m_oCellProperty; RtfOldList m_oCurOldList; - // RtfSectionProperty m_oSectionProp; - ReaderStatePtr psave; + // RtfSectionProperty m_oSectionProp; + ReaderStatePtr m_pSaveState; std::string m_sCurText; ReaderState() @@ -65,7 +65,6 @@ public: m_oRowProperty.SetDefaultRtf(); m_oCellProperty.SetDefaultRtf(); m_oCurOldList.SetDefault(); - //m_oSectionProp.SetDefaultOOX(); } }; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp index f1e702231d..c20d1b4443 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp @@ -39,15 +39,15 @@ CString RtfDocumentProperty::RenderToRtf(RenderParameter oRenderParameter) { case cp_ansi: { - sResult.Append( _T("\\ansi") ); + sResult += _T("\\ansi"); if( PROP_DEF != m_nAnsiCodePage ) sResult.AppendFormat( _T("\\ansicpg%d"), m_nAnsiCodePage ); break; } - case cp_mac: sResult.Append( _T("\\mac") );break; - case cp_pc: sResult.Append( _T("\\pc") );break; - case cp_pca: sResult.Append( _T("\\pca") );break; + case cp_mac: sResult += _T("\\mac" ); break; + case cp_pc: sResult += _T("\\pc" ); break; + case cp_pca: sResult += _T("\\pca" ); break; } RENDER_RTF_BOOL( m_bHypCaps, sResult, _T("hyphcaps") ) RENDER_RTF_BOOL( m_bAutoHyp, sResult, _T("hyphauto") ) @@ -85,46 +85,47 @@ CString RtfDocumentProperty::RenderToRtf(RenderParameter oRenderParameter) //footnote, endnote property if( PROP_DEF != m_nFootnoteNumberingFormat ) - sResult.Append( _T("\\") + GetRtfFormat(m_nFootnoteNumberingFormat, true) ); + sResult += _T("\\") + GetRtfFormat(m_nFootnoteNumberingFormat, true); RENDER_RTF_INT( m_nFootnoteStart, sResult, _T("ftnstart") ) if( PROP_DEF != m_eFootnoteRestart ) { switch( m_eFootnoteRestart ) { - case fr_EachPage: sResult.Append( _T("ftnrstpg") ); break; - case fr_EachSection: sResult.Append( _T("ftnrestart") ); break; - case fr_Continuous: sResult.Append( _T("ftnrstcont") ); break; + case fr_EachPage: sResult += _T("ftnrstpg") ; break; + case fr_EachSection: sResult += _T("ftnrestart"); break; + case fr_Continuous: sResult += _T("ftnrstcont"); break; } } if( PROP_DEF != m_eFootnotePlacement ) { switch( m_eFootnoteRestart ) { - case fp_EndSection: sResult.Append( _T("endnotes") ); break; - case fp_EndDocument: sResult.Append( _T("enddoc") ); break; - case fp_BeneathText: sResult.Append( _T("ftntj") ); break; - case fp_BottomPage: sResult.Append( _T("ftnbj") ); break; + case fp_EndSection: sResult += _T("endnotes"); break; + case fp_EndDocument: sResult += _T("enddoc"); break; + case fp_BeneathText: sResult += _T("ftntj"); break; + case fp_BottomPage: sResult += _T("ftnbj"); break; } } if( PROP_DEF != m_nEndnoteNumberingFormat ) - sResult.Append( _T("\\") + GetRtfFormat(m_nEndnoteNumberingFormat, false) ); + sResult += _T("\\") + GetRtfFormat(m_nEndnoteNumberingFormat, false); + RENDER_RTF_INT( m_nEndnoteStart, sResult, _T("aftnstart") ) if( PROP_DEF != m_eEndnoteRestart ) { switch( m_eEndnoteRestart ) { - case er_EachSection: sResult.Append( _T("aftnrestart") ); break; - case er_Continuous: sResult.Append( _T("aftnrstcont") ); break; + case er_EachSection: sResult += _T("aftnrestart"); break; + case er_Continuous: sResult += _T("aftnrstcont"); break; } } if( PROP_DEF != m_eEndnotePlacement ) { switch( m_eEndnotePlacement ) { - case ep_EndSection: sResult.Append( _T("aendnotes") ); break; - case ep_EndDocument: sResult.Append( _T("aenddoc") ); break; - case ep_BeneathText: sResult.Append( _T("aftntj") ); break; - case ep_BottomPage: sResult.Append( _T("aftnbj") ); break; + case ep_EndSection: sResult += _T("aendnotes"); break; + case ep_EndDocument: sResult += _T("aenddoc"); break; + case ep_BeneathText: sResult += _T("aftntj"); break; + case ep_BottomPage: sResult += _T("aftnbj"); break; } } @@ -132,7 +133,7 @@ CString RtfDocumentProperty::RenderToRtf(RenderParameter oRenderParameter) RENDER_RTF_INT( m_bSplitPageBrake, sResult, _T("spltpgpar") ) if( 0 != m_bHtmlAutoSpace ) - sResult.Append( _T("\\htmautsp") ); + sResult += _T("\\htmautsp"); return sResult; } @@ -142,9 +143,9 @@ CString RtfDocumentProperty::RenderToOOX(RenderParameter oRenderParameter) if( PROP_DEF != m_bHypCaps ) { if( 0 == m_bHypCaps ) - sResult.Append( _T("") ); + sResult += _T(""); else - sResult.Append( _T("") ); + sResult += _T(""); } RENDER_OOX_BOOL( m_bAutoHyp, sResult, _T("w:autoHyphenation") ) RENDER_OOX_INT( m_nMaxHypen, sResult, _T("w:consecutiveHyphenLimit") ) @@ -157,16 +158,16 @@ CString RtfDocumentProperty::RenderToOOX(RenderParameter oRenderParameter) if( PROP_DEF != m_bDorderSurroundHeader ) { if( 0 == m_bDorderSurroundHeader ) - sResult.Append( _T("") ); + sResult += _T(""); else - sResult.Append( _T("") ); + sResult += _T(""); } if( PROP_DEF != m_bDorderSurroundFotter ) { if( 0 == m_bDorderSurroundFotter ) - sResult.Append( _T("") ); + sResult += _T(""); else - sResult.Append( _T("") ); + sResult += _T(""); } RENDER_OOX_BOOL( m_bAlignBordersAndEdges, sResult, _T("w:alignBordersAndEdges") ) @@ -180,68 +181,86 @@ CString RtfDocumentProperty::RenderToOOX(RenderParameter oRenderParameter) //footnote, endnote property CString sFootnoteProp; - for( int i = 0; i < (int)m_aSpecialFootnotes.size(); i++ ) + for( int i = 0; i < m_aSpecialFootnotes.size(); i++ ) + { sFootnoteProp.AppendFormat( _T(""), m_aSpecialFootnotes[i] ); + } + if( PROP_DEF != m_nFootnoteNumberingFormat ) - sFootnoteProp.AppendFormat( _T(""), RtfListLevelProperty::GetFormat( m_nFootnoteNumberingFormat ).GetBuffer() ); + { + sFootnoteProp += _T(""); + } RENDER_OOX_INT( m_nFootnoteStart, sFootnoteProp, _T("w:numStart") ); + if( PROP_DEF != m_eFootnoteRestart ) { switch( m_eFootnoteRestart ) { - case fr_EachPage: sFootnoteProp.Append( _T("") ); break; - case fr_EachSection: sFootnoteProp.Append( _T("") ); break; - case fr_Continuous: sFootnoteProp.Append( _T("") ); break; + case fr_EachPage: sFootnoteProp += _T(""); break; + case fr_EachSection: sFootnoteProp += _T(""); break; + case fr_Continuous: sFootnoteProp += _T(""); break; } } if( PROP_DEF != m_eFootnotePlacement ) { switch( m_eFootnotePlacement ) { - case fp_EndSection: sFootnoteProp.Append( _T("") ); break; - case fp_EndDocument: sFootnoteProp.Append( _T("") ); break; - case fp_BeneathText: sFootnoteProp.Append( _T("") ); break; - case fp_BottomPage: sFootnoteProp.Append( _T("") ); break; + case fp_EndSection: sFootnoteProp += _T(""); break; + case fp_EndDocument: sFootnoteProp += _T(""); break; + case fp_BeneathText: sFootnoteProp += _T(""); break; + case fp_BottomPage: sFootnoteProp += _T(""); break; } } - if( false == sFootnoteProp.IsEmpty() ) - sResult.AppendFormat( _T("%ls"), sFootnoteProp.GetBuffer() ); + if( !sFootnoteProp.IsEmpty() && !m_aSpecialFootnotes.empty()) + sResult += _T("") + sFootnoteProp + _T(""); CString sEndnoteProp; //todooo проверить id - for( int i = 0; i < (int)m_aSpecialEndnotes.size(); i++ ) - sEndnoteProp.AppendFormat( _T(""), m_aSpecialEndnotes[i] ); + for( int i = 0; i < m_aSpecialEndnotes.size(); i++ ) + { + sEndnoteProp.AppendFormat( _T(""), m_aSpecialEndnotes[i] ); + } if( PROP_DEF != m_nFootnoteNumberingFormat ) - sFootnoteProp.AppendFormat( _T(""), RtfListLevelProperty::GetFormat( m_nFootnoteNumberingFormat ).GetBuffer() ); + { + sFootnoteProp += _T(""); + } RENDER_OOX_INT( m_nEndnoteStart, sEndnoteProp, _T("w:numStart") ); + if( PROP_DEF != m_eEndnoteRestart ) { switch( m_eEndnoteRestart ) { - case fr_EachSection: sEndnoteProp.Append( _T("") ); break; - case fr_Continuous: sEndnoteProp.Append( _T("") ); break; + case fr_EachSection: sEndnoteProp += _T("" ); break; + case fr_Continuous: sEndnoteProp += _T("" ); break; } } if( PROP_DEF != m_eEndnotePlacement ) { switch( m_eEndnotePlacement ) { - case fp_EndSection: sEndnoteProp.Append( _T("") ); break; - case fp_EndDocument: sEndnoteProp.Append( _T("") ); break; - case fp_BeneathText: sEndnoteProp.Append( _T("") ); break; - case fp_BottomPage: sEndnoteProp.Append( _T("") ); break; + case fp_EndSection: sEndnoteProp += _T("" ); break; + case fp_EndDocument: sEndnoteProp += _T("" ); break; + case fp_BeneathText: sEndnoteProp += _T("" ); break; + case fp_BottomPage: sEndnoteProp += _T("" ); break; } } - if( false == sEndnoteProp.IsEmpty() ) - sResult.AppendFormat( _T("%ls"), sEndnoteProp.GetBuffer() ); + if( !sEndnoteProp.IsEmpty() && !m_aSpecialEndnotes.empty()) + sResult += _T("") + sEndnoteProp + _T(""); CString sCompat; if( 1 != m_bHtmlAutoSpace ) - sCompat.Append( _T("") ); + sCompat += _T(""); if( 0 == m_bUseTabAlignment ) - sCompat.Append( _T("") ); - if( false == sCompat.IsEmpty() ) - sResult.AppendFormat( _T("%ls"), sCompat.GetBuffer() ); + sCompat += _T(""); + + if( !sCompat.IsEmpty() ) + { + sResult += _T("") + sCompat + _T(""); + } return sResult; } @@ -263,7 +282,7 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) RENDER_RTF_BOOL( m_bLandscapeFormat, sResult, _T("landscape") ) } - sResult.Append( _T("\\sectd") ); + sResult += _T("\\sectd"); RENDER_RTF_BOOL( m_bBidi, sResult, _T("endnhere") ) RENDER_RTF_INT( m_nPaperSourceFirst, sResult, _T("binfsxn") ) RENDER_RTF_INT( m_nPaperSourceOther, sResult, _T("binsxn") ) @@ -273,11 +292,11 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) //Section Break switch( m_eSectionBreak ) { - case sb_sbknone: sResult.Append( _T("\\sbknone") );break; - case sb_sbkcol: sResult.Append( _T("\\sbkcol") );break; - case sb_sbkpage: sResult.Append( _T("\\sbkpage") );break; - case sb_sbkeven: sResult.Append( _T("\\sbkeven") );break; - case sb_sbkodd: sResult.Append( _T("\\sbkodd") );break; + case sb_sbknone: sResult += _T("\\sbknone" ); break; + case sb_sbkcol: sResult += _T("\\sbkcol" ); break; + case sb_sbkpage: sResult += _T("\\sbkpage" ); break; + case sb_sbkeven: sResult += _T("\\sbkeven" ); break; + case sb_sbkodd: sResult += _T("\\sbkodd" ); break; } //Columns RENDER_RTF_INT( m_nColumnNumber, sResult, _T("cols") ) @@ -297,69 +316,69 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) //Footnotes and Endnotes switch( m_eFootnotesJust ) { - case fj_sftntj: sResult.Append( _T("\\sftntj") );break; - case fj_sftnbj: sResult.Append( _T("\\sftnbj") );break; + case fj_sftntj: sResult += _T("\\sftntj" ); break; + case fj_sftnbj: sResult += _T("\\sftnbj" ); break; } RENDER_RTF_INT( m_nFootnotesStart, sResult, _T("sftnstart") ) switch( m_eFootnotesRestart ) { - case fr_sftnrstpg: sResult.Append( _T("\\sftnrstpg") );break; - case fr_sftnrestart: sResult.Append( _T("\\sftnrestart") );break; - case fr_sftnrstcont: sResult.Append( _T("\\sftnrstcont") );break; + case fr_sftnrstpg: sResult += _T("\\sftnrstpg" ); break; + case fr_sftnrestart: sResult += _T("\\sftnrestart" ); break; + case fr_sftnrstcont: sResult += _T("\\sftnrstcont" ); break; } switch( m_eFootnotesFormat ) { - case ff_sftnnar: sResult.Append( _T("\\sftnnar") );break; - case ff_sftnnalc: sResult.Append( _T("\\sftnnalc") );break; - case ff_sftnnauc: sResult.Append( _T("\\sftnnauc") );break; - case ff_sftnnrlc: sResult.Append( _T("\\sftnnrlc") );break; - case ff_sftnnruc: sResult.Append( _T("\\sftnnruc") );break; - case ff_sftnnchi: sResult.Append( _T("\\sftnnchi") );break; - case ff_sftnnchosung: sResult.Append( _T("\\sftnnchosung") );break; - case ff_sftnncnum: sResult.Append( _T("\\sftnncnum") );break; - case ff_sftnndbnum: sResult.Append( _T("\\sftnndbnum") );break; - case ff_sftnndbnumd: sResult.Append( _T("\\sftnndbnumd") );break; - case ff_sftnndbnumt: sResult.Append( _T("\\sftnndbnumt") );break; - case ff_sftnndbnumk: sResult.Append( _T("\\sftnndbnumk") );break; - case ff_sftnndbar: sResult.Append( _T("\\sftnndbar") );break; - case ff_sftnnganada: sResult.Append( _T("\\sftnnganada") );break; - case ff_sftnngbnum: sResult.Append( _T("\\sftnngbnum") );break; - case ff_sftnngbnumd: sResult.Append( _T("\\sftnngbnumd") );break; - case ff_sftnngbnuml: sResult.Append( _T("\\sftnngbnuml") );break; - case ff_sftnngbnumk: sResult.Append( _T("\\sftnngbnumk") );break; - case ff_sftnnzodiac: sResult.Append( _T("\\sftnnzodiac") );break; - case ff_sftnnzodiacd: sResult.Append( _T("\\sftnnzodiacd") );break; - case ff_sftnnzodiacl: sResult.Append( _T("\\sftnnzodiacl") );break; + case ff_sftnnar: sResult += _T("\\sftnnar" ); break; + case ff_sftnnalc: sResult += _T("\\sftnnalc" ); break; + case ff_sftnnauc: sResult += _T("\\sftnnauc" ); break; + case ff_sftnnrlc: sResult += _T("\\sftnnrlc" ); break; + case ff_sftnnruc: sResult += _T("\\sftnnruc" ); break; + case ff_sftnnchi: sResult += _T("\\sftnnchi" ); break; + case ff_sftnnchosung: sResult += _T("\\sftnnchosung" ); break; + case ff_sftnncnum: sResult += _T("\\sftnncnum" ); break; + case ff_sftnndbnum: sResult += _T("\\sftnndbnum" ); break; + case ff_sftnndbnumd: sResult += _T("\\sftnndbnumd" ); break; + case ff_sftnndbnumt: sResult += _T("\\sftnndbnumt" ); break; + case ff_sftnndbnumk: sResult += _T("\\sftnndbnumk" ); break; + case ff_sftnndbar: sResult += _T("\\sftnndbar" ); break; + case ff_sftnnganada: sResult += _T("\\sftnnganada" ); break; + case ff_sftnngbnum: sResult += _T("\\sftnngbnum" ); break; + case ff_sftnngbnumd: sResult += _T("\\sftnngbnumd" ); break; + case ff_sftnngbnuml: sResult += _T("\\sftnngbnuml" ); break; + case ff_sftnngbnumk: sResult += _T("\\sftnngbnumk" ); break; + case ff_sftnnzodiac: sResult += _T("\\sftnnzodiac" ); break; + case ff_sftnnzodiacd: sResult += _T("\\sftnnzodiacd" ); break; + case ff_sftnnzodiacl: sResult += _T("\\sftnnzodiacl" ); break; } RENDER_RTF_INT( m_nEndnotesStart, sResult, _T("saftnstart") ) switch( m_eEndnotesRestart ) { - case er_saftnrestart: sResult.Append( _T("\\saftnrestart") );break; - case er_saftnrstcont: sResult.Append( _T("\\saftnrstcont") );break; + case er_saftnrestart: sResult += _T("\\saftnrestart" ); break; + case er_saftnrstcont: sResult += _T("\\saftnrstcont" ); break; } switch( m_eEndnotesFormat ) { - case ef_saftnnar: sResult.Append( _T("\\saftnnar") );break; - case ef_saftnnalc: sResult.Append( _T("\\saftnnalc") );break; - case ef_saftnnauc: sResult.Append( _T("\\saftnnauc") );break; - case ef_saftnnrlc: sResult.Append( _T("\\saftnnrlc") );break; - case ef_saftnnruc: sResult.Append( _T("\\saftnnruc") );break; - case ef_saftnnchi: sResult.Append( _T("\\saftnnchi") );break; - case ef_saftnnchosung: sResult.Append( _T("\\saftnnchosung") );break; - case ef_saftnncnum: sResult.Append( _T("\\saftnncnum") );break; - case ef_saftnndbnum: sResult.Append( _T("\\saftnndbnum") );break; - case ef_saftnndbnumd: sResult.Append( _T("\\saftnndbnumd") );break; - case ef_saftnndbnumt: sResult.Append( _T("\\saftnndbnumt") );break; - case ef_saftnndbnumk: sResult.Append( _T("\\saftnndbnumk") );break; - case ef_saftnndbar: sResult.Append( _T("\\saftnndbar") );break; - case ef_saftnnganada: sResult.Append( _T("\\saftnnganada") );break; - case ef_saftnngbnum: sResult.Append( _T("\\saftnngbnum") );break; - case ef_saftnngbnumd: sResult.Append( _T("\\saftnngbnumd") );break; - case ef_saftnngbnuml: sResult.Append( _T("\\saftnngbnuml") );break; - case ef_saftnngbnumk: sResult.Append( _T("\\saftnngbnumk") );break; - case ef_saftnnzodiac: sResult.Append( _T("\\saftnnzodiac") );break; - case ef_saftnnzodiacd: sResult.Append( _T("\\saftnnzodiacd") );break; - case ef_saftnnzodiacl: sResult.Append( _T("\\saftnnzodiacl") );break; + case ef_saftnnar: sResult += _T("\\saftnnar" ); break; + case ef_saftnnalc: sResult += _T("\\saftnnalc" ); break; + case ef_saftnnauc: sResult += _T("\\saftnnauc" ); break; + case ef_saftnnrlc: sResult += _T("\\saftnnrlc" ); break; + case ef_saftnnruc: sResult += _T("\\saftnnruc" ); break; + case ef_saftnnchi: sResult += _T("\\saftnnchi" ); break; + case ef_saftnnchosung: sResult += _T("\\saftnnchosung" ); break; + case ef_saftnncnum: sResult += _T("\\saftnncnum" ); break; + case ef_saftnndbnum: sResult += _T("\\saftnndbnum" ); break; + case ef_saftnndbnumd: sResult += _T("\\saftnndbnumd" ); break; + case ef_saftnndbnumt: sResult += _T("\\saftnndbnumt" ); break; + case ef_saftnndbnumk: sResult += _T("\\saftnndbnumk" ); break; + case ef_saftnndbar: sResult += _T("\\saftnndbar" ); break; + case ef_saftnnganada: sResult += _T("\\saftnnganada" ); break; + case ef_saftnngbnum: sResult += _T("\\saftnngbnum" ); break; + case ef_saftnngbnumd: sResult += _T("\\saftnngbnumd" ); break; + case ef_saftnngbnuml: sResult += _T("\\saftnngbnuml" ); break; + case ef_saftnngbnumk: sResult += _T("\\saftnngbnumk" ); break; + case ef_saftnnzodiac: sResult += _T("\\saftnnzodiac" ); break; + case ef_saftnnzodiacd: sResult += _T("\\saftnnzodiacd" ); break; + case ef_saftnnzodiacl: sResult += _T("\\saftnnzodiacl" ); break; } //Line Numbering @@ -368,9 +387,9 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) RENDER_RTF_INT( m_nLineStart, sResult, _T("linestarts") ) switch( m_eLineNumberRestart ) { - case lnr_linerestart: sResult.Append( _T("\\linerestart") );break; - case lnr_lineppage: sResult.Append( _T("\\lineppage") );break; - case lnr_linecont: sResult.Append( _T("\\linecont") );break; + case lnr_linerestart: sResult += _T("\\linerestart" );break; + case lnr_lineppage: sResult += _T("\\lineppage" ); break; + case lnr_linecont: sResult += _T("\\linecont" ); break; } if( RENDER_TO_OOX_PARAM_FIRST_SECTION != oRenderParameter.nType )//Пишем как свойства секции @@ -399,17 +418,17 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) RENDER_RTF_INT( m_nPageNumberY, sResult, _T("pgny") ) switch( m_ePageNumberFormat ) { - case pnf_pgndec: sResult.Append( _T("\\pgndec") );break; - case pnf_pgnucrm: sResult.Append( _T("\\pgnucrm") );break; - case pnf_pgnlcrm: sResult.Append( _T("\\pgnlcrm") );break; + case pnf_pgndec: sResult += _T("\\pgndec" ); break; + case pnf_pgnucrm: sResult += _T("\\pgnucrm" ); break; + case pnf_pgnlcrm: sResult += _T("\\pgnlcrm" ); break; } //Vertical Alignment switch( m_eVerticalAlignment ) { - case va_vertalt: sResult.Append( _T("\\vertalt") );break; - case va_vertalb: sResult.Append( _T("\\vertalb") );break; - case va_vertalc: sResult.Append( _T("\\vertalc") );break; - case va_vertalj: sResult.Append( _T("\\vertalj") );break; + case va_vertalt: sResult += _T("\\vertalt" ); break; + case va_vertalb: sResult += _T("\\vertalb" ); break; + case va_vertalc: sResult += _T("\\vertalc" ); break; + case va_vertalj: sResult += _T("\\vertalj" ); break; } //Text Flow @@ -418,24 +437,24 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) //Page Borders if( true == m_oBorderLeft.IsValid() ) { - sResult.Append( _T("\\pgbrdrl") ); - sResult.Append( m_oBorderLeft.RenderToRtf( oRenderParameter ) ); + sResult += _T("\\pgbrdrl"); + sResult += m_oBorderLeft.RenderToRtf( oRenderParameter ); } if( true == m_oBorderTop.IsValid() ) { - sResult.Append( _T("\\pgbrdrt") ); - sResult.Append( m_oBorderTop.RenderToRtf( oRenderParameter ) ); + sResult += _T("\\pgbrdrt"); + sResult += m_oBorderTop.RenderToRtf( oRenderParameter ); } if( true == m_oBorderRight.IsValid() ) { - sResult.Append( _T("\\pgbrdrr") ); - sResult.Append( m_oBorderRight.RenderToRtf( oRenderParameter ) ); + sResult += _T("\\pgbrdrr"); + sResult += m_oBorderRight.RenderToRtf( oRenderParameter ); } if( true == m_oBorderBottom.IsValid() ) { - sResult.Append( _T("\\pgbrdrb") ); - sResult.Append( m_oBorderBottom.RenderToRtf( oRenderParameter ) ); + sResult += _T("\\pgbrdrb"); + sResult += m_oBorderBottom.RenderToRtf( oRenderParameter ); } RENDER_RTF_INT( m_nBorderArt, sResult, _T("brdrart") ) RENDER_RTF_INT( m_nBorderMeasure, sResult, _T("pgbrdropt") ) @@ -444,54 +463,54 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter) //footer - header if( 0 != m_oHeaderRight ) { - sResult.Append( _T("{\\headerr") ); - sResult.Append( m_oHeaderRight->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\headerr"); + sResult += m_oHeaderRight->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } if( 0 != m_oHeaderLeft ) { - sResult.Append( _T("{\\headerl") ); - sResult.Append( m_oHeaderLeft->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\headerl"); + sResult += m_oHeaderLeft->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } if( 0 != m_oHeaderFirst ) { - sResult.Append( _T("{\\headerf") ); - sResult.Append( m_oHeaderFirst->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\headerf"); + sResult += m_oHeaderFirst->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } if( 0 != m_oFooterRight ) { - sResult.Append( _T("{\\footerr") ); - sResult.Append( m_oFooterRight->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\footerr"); + sResult += m_oFooterRight->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } if( 0 != m_oFooterLeft ) { - sResult.Append( _T("{\\footerl") ); - sResult.Append( m_oFooterLeft->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\footerl"); + sResult += m_oFooterLeft->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } if( 0 != m_oFooterFirst ) { - sResult.Append( _T("{\\footerf") ); - sResult.Append( m_oFooterFirst->RenderToRtf( oRenderParameter )); - sResult.Append( _T("\\par") ); - sResult.Append( _T("}") ); + sResult += _T("{\\footerf"); + sResult += m_oFooterFirst->RenderToRtf( oRenderParameter ); + sResult += _T("\\par"); + sResult += _T("}"); } return sResult; } CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter) { CString sResult; - sResult.Append(_T("")); + sResult += _T(""); if( 1 == m_bBidi ) - sResult.Append(_T("")); + sResult += _T(""); CString sPaperSource; if( PROP_DEF != m_nPaperSourceFirst ) sPaperSource.AppendFormat( _T(" w:first=\"%d\""), m_nPaperSourceFirst ); @@ -500,16 +519,19 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter) if( false == sPaperSource.IsEmpty() ) sResult.AppendFormat(_T(""), sPaperSource.GetBuffer() ); if( 1 == m_bRtlGutter ) - sResult.Append(_T("")); + sResult += _T(""); //Section Break switch( m_eSectionBreak ) { - case sb_sbknone: sResult.Append(_T("") );break; - case sb_sbkcol: sResult.Append(_T("") );break; - case sb_sbkpage: sResult.Append(_T("") );break; - case sb_sbkeven: sResult.Append(_T("") );break; - case sb_sbkodd: sResult.Append(_T("") );break; + case sb_sbkcol: sResult += _T(""); break; + case sb_sbkpage: sResult += _T(""); break; + case sb_sbkeven: sResult += _T(""); break; + case sb_sbkodd: sResult += _T(""); break; + case sb_sbknone: + default: + sResult += _T(""); + break; } //Columns if( PROP_DEF != m_nColumnNumber ) @@ -529,113 +551,114 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter) if( PROP_DEF != m_nColumnSpace ) sCollumnFormating.AppendFormat( _T(" w:space=\"%d\""), m_nColumnSpace ); if( true == bEqualWidth ) - sCollumnFormating.Append( _T(" w:equalWidth=\"true\"/>") ); + sCollumnFormating += _T(" w:equalWidth=\"true\"/>" ); else { - sCollumnFormating.Append( _T(" w:equalWidth=\"false\">") ); + sCollumnFormating += _T(" w:equalWidth=\"false\">"); for( int i = 0; i < (int)m_oCollumnProperty.m_aCollumnProperty.size(); i++ ) { - sCollumnFormating.Append( _T("") ); + sCollumnFormating += _T( "/>" ); } - sCollumnFormating.Append( _T("") ); + sCollumnFormating += _T( "" ); } if( false == sCollumnFormating.IsEmpty() ) - sResult.Append( sCollumnFormating ); + sResult += sCollumnFormating; } //Footnotes and Endnotes CString sFootnotesProp; switch( m_eFootnotesJust ) { - case fj_sftntj:sFootnotesProp.Append( _T("") );break; - case fj_sftnbj:sFootnotesProp.Append( _T("") );break; + case fj_sftntj: sFootnotesProp += _T("" ); break; + case fj_sftnbj: sFootnotesProp += _T("" ); break; } RENDER_OOX_INT( m_nFootnotesStart, sFootnotesProp, _T("w:numStart") ) switch( m_eFootnotesRestart ) { - case fr_sftnrstpg:sFootnotesProp.Append( _T("") );break; - case fr_sftnrestart:sFootnotesProp.Append( _T("") );break; - case fr_sftnrstcont:sFootnotesProp.Append( _T("") );break; + case fr_sftnrstpg: sFootnotesProp += _T("" ); break; + case fr_sftnrestart: sFootnotesProp += _T("" ); break; + case fr_sftnrstcont: sFootnotesProp += _T("" ); break; } - switch( m_eFootnotesRestart ) + switch( m_eFootnotesFormat ) { - case ff_sftnnar:sFootnotesProp.Append( _T("") );break; - case ff_sftnnalc:sFootnotesProp.Append( _T("") );break; - case ff_sftnnauc:sFootnotesProp.Append( _T("") );break; - case ff_sftnnrlc:sFootnotesProp.Append( _T("") );break; - case ff_sftnnruc:sFootnotesProp.Append( _T("") );break; - case ff_sftnnchi:sFootnotesProp.Append( _T("") );break; - case ff_sftnnchosung:sFootnotesProp.Append( _T("") );break; - case ff_sftnncnum:sFootnotesProp.Append( _T("") );break; - case ff_sftnndbnum:sFootnotesProp.Append( _T("") );break; - case ff_sftnndbnumd:sFootnotesProp.Append( _T("") );break; - case ff_sftnndbnumt:sFootnotesProp.Append( _T("") );break; - case ff_sftnndbnumk:sFootnotesProp.Append( _T("") );break; - case ff_sftnndbar:sFootnotesProp.Append( _T("") );break; - case ff_sftnnganada:sFootnotesProp.Append( _T("") );break; - case ff_sftnngbnum:sFootnotesProp.Append( _T("") );break; - case ff_sftnngbnumd:sFootnotesProp.Append( _T("") );break; - case ff_sftnngbnuml:sFootnotesProp.Append( _T("") );break; - case ff_sftnngbnumk:sFootnotesProp.Append( _T("") );break; - case ff_sftnnzodiac:sFootnotesProp.Append( _T("") );break; - case ff_sftnnzodiacd:sFootnotesProp.Append( _T("") );break; - case ff_sftnnzodiacl:sFootnotesProp.Append( _T("") );break; + case ff_sftnnar: sFootnotesProp += _T("" ); break; + case ff_sftnnalc: sFootnotesProp += _T("" ); break; + case ff_sftnnauc: sFootnotesProp += _T("" ); break; + case ff_sftnnrlc: sFootnotesProp += _T("" ); break; + case ff_sftnnruc: sFootnotesProp += _T("" ); break; + case ff_sftnnchi: sFootnotesProp += _T("" ); break; + case ff_sftnnchosung: sFootnotesProp += _T("" ); break; + case ff_sftnncnum: sFootnotesProp += _T("" ); break; + case ff_sftnndbnum: sFootnotesProp += _T("" ); break; + case ff_sftnndbnumd: sFootnotesProp += _T("" ); break; + case ff_sftnndbnumt: sFootnotesProp += _T("" ); break; + case ff_sftnndbnumk: sFootnotesProp += _T("" ); break; + case ff_sftnndbar: sFootnotesProp += _T("" ); break; + case ff_sftnnganada: sFootnotesProp += _T("" ); break; + case ff_sftnngbnum: sFootnotesProp += _T("" ); break; + case ff_sftnngbnumd: sFootnotesProp += _T("" ); break; + case ff_sftnngbnuml: sFootnotesProp += _T("" ); break; + case ff_sftnngbnumk: sFootnotesProp += _T("" ); break; + case ff_sftnnzodiac: sFootnotesProp += _T("" ); break; + case ff_sftnnzodiacd: sFootnotesProp += _T("" ); break; + case ff_sftnnzodiacl: sFootnotesProp += _T("" ); break; } - if( false == sFootnotesProp.IsEmpty() ) - sResult.AppendFormat( _T("%ls"), sFootnotesProp.GetBuffer() ); + if(!sFootnotesProp.IsEmpty() ) + sResult += _T("") + sFootnotesProp + _T(""); CString sEndnotesProp; RENDER_OOX_INT( m_nEndnotesStart, sEndnotesProp, _T("w:numStart") ) + switch( m_eEndnotesRestart ) { - case er_saftnrestart:sEndnotesProp.Append( _T("") );break; - case er_saftnrstcont:sEndnotesProp.Append( _T("") );break; + case er_saftnrestart: sEndnotesProp += _T("" ); break; + case er_saftnrstcont: sEndnotesProp += _T("" ); break; } - switch( m_eEndnotesRestart ) + switch( m_eEndnotesFormat ) { - case ef_saftnnar:sEndnotesProp.Append( _T("") );break; - case ef_saftnnalc:sEndnotesProp.Append( _T("") );break; - case ef_saftnnauc:sEndnotesProp.Append( _T("") );break; - case ef_saftnnrlc:sEndnotesProp.Append( _T("") );break; - case ef_saftnnruc:sEndnotesProp.Append( _T("") );break; - case ef_saftnnchi:sEndnotesProp.Append( _T("") );break; - case ef_saftnnchosung:sEndnotesProp.Append( _T("") );break; - case ef_saftnncnum:sEndnotesProp.Append( _T("") );break; - case ef_saftnndbnum:sEndnotesProp.Append( _T("") );break; - case ef_saftnndbnumd:sEndnotesProp.Append( _T("") );break; - case ef_saftnndbnumt:sEndnotesProp.Append( _T("") );break; - case ef_saftnndbnumk:sEndnotesProp.Append( _T("") );break; - case ef_saftnndbar:sEndnotesProp.Append( _T("") );break; - case ef_saftnnganada:sEndnotesProp.Append( _T("") );break; - case ef_saftnngbnum:sEndnotesProp.Append( _T("") );break; - case ef_saftnngbnumd:sEndnotesProp.Append( _T("") );break; - case ef_saftnngbnuml:sEndnotesProp.Append( _T("") );break; - case ef_saftnngbnumk:sEndnotesProp.Append( _T("") );break; - case ef_saftnnzodiac:sEndnotesProp.Append( _T("") );break; - case ef_saftnnzodiacd:sEndnotesProp.Append( _T("") );break; - case ef_saftnnzodiacl:sEndnotesProp.Append( _T("") );break; + case ef_saftnnar: sEndnotesProp += _T("" ); break; + case ef_saftnnalc: sEndnotesProp += _T("" ); break; + case ef_saftnnauc: sEndnotesProp += _T("" ); break; + case ef_saftnnrlc: sEndnotesProp += _T("" ); break; + case ef_saftnnruc: sEndnotesProp += _T("" ); break; + case ef_saftnnchi: sEndnotesProp += _T("" ); break; + case ef_saftnnchosung: sEndnotesProp += _T("" ); break; + case ef_saftnncnum: sEndnotesProp += _T("" ); break; + case ef_saftnndbnum: sEndnotesProp += _T("" ); break; + case ef_saftnndbnumd: sEndnotesProp += _T("" ); break; + case ef_saftnndbnumt: sEndnotesProp += _T("" ); break; + case ef_saftnndbnumk: sEndnotesProp += _T("" ); break; + case ef_saftnndbar: sEndnotesProp += _T("" ); break; + case ef_saftnnganada: sEndnotesProp += _T("" ); break; + case ef_saftnngbnum: sEndnotesProp += _T("" ); break; + case ef_saftnngbnumd: sEndnotesProp += _T("" ); break; + case ef_saftnngbnuml: sEndnotesProp += _T("" ); break; + case ef_saftnngbnumk: sEndnotesProp += _T("" ); break; + case ef_saftnnzodiac: sEndnotesProp += _T("" ); break; + case ef_saftnnzodiacd: sEndnotesProp += _T("" ); break; + case ef_saftnnzodiacl: sEndnotesProp += _T("" ); break; } - if( false == sEndnotesProp.IsEmpty() ) - sResult.AppendFormat( _T("%ls"), sEndnotesProp.GetBuffer() ); + if(!sEndnotesProp.IsEmpty() ) + sResult += _T("") + sEndnotesProp + _T(""); //Line Numbering CString sLineNumbering; if( PROP_DEF != m_nLineModulus ) sLineNumbering.AppendFormat( _T(" w:countBy=\"%d\""), m_nLineModulus ); - if( PROP_DEF != m_nLineX ) + if( PROP_DEF != m_nLineX && 0 != m_nLineX) sLineNumbering.AppendFormat( _T(" w:distance=\"%d\""), m_nLineX ); if( PROP_DEF != m_nLineStart ) sLineNumbering.AppendFormat( _T(" w:start=\"%d\""), m_nLineStart ); switch( m_eLineNumberRestart ) { - case lnr_linerestart:sLineNumbering.Append( _T(" w:restart=\"newSection\"") );break; - case lnr_lineppage:sLineNumbering.Append( _T(" w:restart=\"newPage\"") );break; - case lnr_linecont:sLineNumbering.Append( _T(" w:restart=\"continuous\"") );break; + case lnr_linerestart: sLineNumbering += _T(" w:restart=\"newSection\""); break; + case lnr_lineppage: sLineNumbering += _T(" w:restart=\"newPage\""); break; + case lnr_linecont: sLineNumbering += _T(" w:restart=\"continuous\""); break; } if( false == sLineNumbering.IsEmpty() ) sResult.AppendFormat( _T(""), sLineNumbering.GetBuffer() ); @@ -680,20 +703,20 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter) //Vertical Alignment switch( m_eVerticalAlignment ) { - case va_vertalt:sResult.Append(_T(""));break; - case va_vertalb:sResult.Append(_T(""));break; - case va_vertalc:sResult.Append(_T(""));break; - case va_vertalj:sResult.Append(_T(""));break; + case va_vertalt: sResult += _T(""); break; + case va_vertalb: sResult += _T(""); break; + case va_vertalc: sResult += _T(""); break; + case va_vertalj: sResult += _T(""); break; } //Text Flow switch( m_nTextFollow ) { - case 0: sResult.Append( _T("") );break; - case 1: sResult.Append( _T("") );break; - case 2: sResult.Append( _T("") );break; - case 3: sResult.Append( _T("") );break; - case 4: sResult.Append( _T("") );break; - case 5: sResult.Append( _T("") );break; + case 0: sResult += _T("" ); break; + case 1: sResult += _T("" ); break; + case 2: sResult += _T("" ); break; + case 3: sResult += _T("" ); break; + case 4: sResult += _T("" ); break; + case 5: sResult += _T("" ); break; } //Page Borders CString sBorders; @@ -702,46 +725,46 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter) if( true == m_oBorderLeft.IsValid() ) { oNewParam.sValue = _T("w:left"); - sBorders.Append( m_oBorderLeft.RenderToOOX( oNewParam ) ); + sBorders += m_oBorderLeft.RenderToOOX( oNewParam ); } if( true == m_oBorderTop.IsValid() ) { oNewParam.sValue = _T("w:top"); - sBorders.Append( m_oBorderTop.RenderToOOX( oNewParam ) ); + sBorders += m_oBorderTop.RenderToOOX( oNewParam ) ; } if( true == m_oBorderRight.IsValid() ) { oNewParam.sValue = _T("w:right"); - sBorders.Append( m_oBorderRight.RenderToOOX( oNewParam ) ); + sBorders += m_oBorderRight.RenderToOOX( oNewParam ); } if( true == m_oBorderBottom.IsValid() ) { oNewParam.sValue = _T("w:bottom"); - sBorders.Append( m_oBorderBottom.RenderToOOX( oNewParam ) ); + sBorders += m_oBorderBottom.RenderToOOX( oNewParam ); } if( false == sBorders.IsEmpty() ) { - sResult.Append( _T("") ); - sResult.Append( sBorders ); - sResult.Append( _T("") ); + sResult += _T(">"); + sResult += sBorders; + sResult += _T(""); } if( 0 != m_oHeaderLeft ) { @@ -801,10 +824,9 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame poOOXWriter->m_oCustomRelsWriter.push_back( oNewRelsWr ); oNewParameter.poRels = oNewRelsWr.get(); - sContent.Append( oTarget->RenderToOOX(oNewParameter) ); + sContent += oTarget->RenderToOOX(oNewParameter); sContent.AppendFormat( _T(""), sRootName.GetBuffer() ); - std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sContent.GetBuffer()); CString sFilePath = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + sFilename; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp index 6fa095f728..2074d4bca7 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp @@ -35,7 +35,7 @@ void RtfShape::SetDefault() { - m_eShapeType = st_none; + m_eAnchorTypeShape = st_none; //Common DEFAULT_PROPERTY( m_nLeft ) @@ -81,7 +81,6 @@ void RtfShape::SetDefault() DEFAULT_PROPERTY( m_nWrapDistRight ) DEFAULT_PROPERTY( m_nWrapDistBottom ) - //m_bBehindDocument = -1; DEFAULT_PROPERTY( m_bHidden ) //Text box @@ -110,7 +109,12 @@ void RtfShape::SetDefault() DEFAULT_PROPERTY( m_nAdjustValue8 ) DEFAULT_PROPERTY( m_nAdjustValue9 ) DEFAULT_PROPERTY( m_nAdjustValue10 ) - +//Custom + DEFAULT_PROPERTY( m_nGeoLeft) + DEFAULT_PROPERTY( m_nGeoTop) + DEFAULT_PROPERTY( m_nGeoRight) + DEFAULT_PROPERTY( m_nGeoBottom) + DEFAULT_PROPERTY( m_nShapePath) //Picture Effects DEFAULT_PROPERTY( m_nCropFromTop ) DEFAULT_PROPERTY( m_nCropFromBottom ) @@ -122,6 +126,7 @@ void RtfShape::SetDefault() DEFAULT_PROPERTY( m_nGroupLeft ) DEFAULT_PROPERTY( m_nGroupRight ) DEFAULT_PROPERTY( m_nGroupTop ) + DEFAULT_PROPERTY( m_nRelBottom ) DEFAULT_PROPERTY( m_nRelLeft ) DEFAULT_PROPERTY( m_nRelRight ) @@ -162,107 +167,63 @@ void RtfShape::SetDefault() m_aTextItems = TextItemContainerPtr(); m_oPicture = RtfPicturePtr(); - m_bIsOle = false; + + m_bIsOle = false; + m_bInGroup = false; } CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) { + if( PROP_DEF == m_nShapeType) return L""; + CString sResult; - if( PROP_DEF != m_nShapeType && 0 != m_nShapeType ) + //запоминаем координаты и если нужно поворачиваем + int nLeft = m_nLeft; + int nTop = m_nTop; + int nRight = m_nRight; + int nBottom = m_nBottom; + int nRotate = m_nRotation; + + int nRelLeft = m_nRelLeft; + int nRelTop = m_nRelTop; + int nRelRight = m_nRelRight; + int nRelBottom = m_nRelBottom; + int nRelRotate = m_nRelRotation; + + if( PROP_DEF != m_nRotation && PROP_DEF != m_nLeft && PROP_DEF != m_nTop && + PROP_DEF != m_nRight && PROP_DEF != m_nBottom ) + ToRtfRotation( m_nRotation, m_nLeft, m_nTop, m_nRight, m_nBottom ); + + if( PROP_DEF != m_nRelRotation && PROP_DEF != m_nRelLeft && PROP_DEF != m_nRelTop && + PROP_DEF != m_nRelRight && PROP_DEF != m_nRelBottom ) + ToRtfRotation( m_nRelRotation, m_nRelLeft, m_nRelTop, m_nRelRight, m_nRelBottom ); + + if( st_inline == m_eAnchorTypeShape ) { - //запоминаем координаты и если нужно поворачиваем - int nLeft = m_nLeft; - int nTop = m_nTop; - int nRight = m_nRight; - int nBottom = m_nBottom; - int nRotate = m_nRotation; - - int nRelLeft = m_nRelLeft; - int nRelTop = m_nRelTop; - int nRelRight = m_nRelRight; - int nRelBottom = m_nRelBottom; - int nRelRotate = m_nRelRotation; - - if( PROP_DEF != m_nRotation && PROP_DEF != m_nLeft && PROP_DEF != m_nTop && - PROP_DEF != m_nRight && PROP_DEF != m_nBottom ) - ToRtfRotation( m_nRotation, m_nLeft, m_nTop, m_nRight, m_nBottom ); - - if( PROP_DEF != m_nRelRotation && PROP_DEF != m_nRelLeft && PROP_DEF != m_nRelTop && - PROP_DEF != m_nRelRight && PROP_DEF != m_nRelBottom ) - ToRtfRotation( m_nRelRotation, m_nRelLeft, m_nRelTop, m_nRelRight, m_nRelBottom ); - - if( st_inline == m_eShapeType ) + if( NULL != m_oPicture && m_nShapeType == 75) { - if( NULL != m_oPicture && m_nShapeType == 75) + if (m_oPicture->m_nWidth == PROP_DEF) { - if (m_oPicture->m_nWidth == PROP_DEF) - { - m_oPicture->m_nWidth = m_nRight; - m_oPicture->m_nHeight = m_nBottom; - } - if (m_oPicture->m_nWidthGoal == PROP_DEF) - { - m_oPicture->m_nWidthGoal = m_oPicture->m_nWidth; - m_oPicture->m_nHeightGoal = m_oPicture->m_nHeight; - } - if( RtfPicture::dt_wmf == m_oPicture->eDataType ) - { - sResult += m_oPicture->RenderToRtf( oRenderParameter ); - } - else - { - sResult += _T("{\\*\\shppict"); - sResult += m_oPicture->RenderToRtf( oRenderParameter ); - sResult += _T("}"); - sResult += _T("{\\nonshppict"); - sResult += m_oPicture->GenerateWMF( oRenderParameter ); - - sResult += _T("}"); - } + m_oPicture->m_nWidth = m_nRight; + m_oPicture->m_nHeight = m_nBottom; + } + if (m_oPicture->m_nWidthGoal == PROP_DEF) + { + m_oPicture->m_nWidthGoal = m_oPicture->m_nWidth; + m_oPicture->m_nHeightGoal = m_oPicture->m_nHeight; + } + if( RtfPicture::dt_wmf == m_oPicture->eDataType ) + { + sResult += m_oPicture->RenderToRtf( oRenderParameter ); } else { - sResult += _T("{\\shp"); - sResult += _T("{\\*\\shpinst"); - RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") ); - RENDER_RTF_INT( m_nTop , sResult, _T("shptop") ); - RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") ); - RENDER_RTF_INT( m_nRight , sResult, _T("shpright") ); - RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); - RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") ); - RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") ); - RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") ); - RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") ); - - sResult += _T("\\shpbxignore"); - sResult += _T("\\shpbyignore"); - - sResult.AppendFormat( _T("{\\sp{\\sn fUseShapeAnchor}{\\sv %d}}"), false); - sResult.AppendFormat( _T("{\\sp{\\sn fPseudoInline}{\\sv %d}}"), true); - - sResult += RenderToRtfShapeProperty( oRenderParameter ); - - //picture - if( 0 != m_oPicture && m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 9) - { - sResult += _T("{\\sp{\\sn fillBlip}{\\sv "); - sResult += m_oPicture->RenderToRtf( oRenderParameter ); - sResult += _T("}}"); - } - //textbox - if( 0 != m_aTextItems ) - { - sResult += _T("{\\shptxt "); - sResult += m_aTextItems->RenderToRtf( oRenderParameter ); - sResult += _T("}"); - } + sResult += _T("{\\*\\shppict"); + sResult += m_oPicture->RenderToRtf( oRenderParameter ); sResult += _T("}"); - //if( 0 != m_oPicture ) - //{ - // sResult += _T("{\\shprslt\\par\\plain")); - // sResult += m_oPicture->GenerateWMF( oRenderParameter ) ); - // sResult += _T("\\par}")); - //} + sResult += _T("{\\nonshppict"); + sResult += m_oPicture->GenerateWMF( oRenderParameter ); + sResult += _T("}"); } } @@ -270,12 +231,65 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) { sResult += _T("{\\shp"); sResult += _T("{\\*\\shpinst"); + RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); + + if (!m_bInGroup) + { + RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") ); + RENDER_RTF_INT( m_nTop , sResult, _T("shptop") ); + RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") ); + RENDER_RTF_INT( m_nRight , sResult, _T("shpright") ); + RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") ); + RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") ); + RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") ); + RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") ); + + sResult += _T("\\shpbxignore"); + sResult += _T("\\shpbyignore"); + + sResult.AppendFormat( _T("{\\sp{\\sn fUseShapeAnchor}{\\sv %d}}"), false); + sResult.AppendFormat( _T("{\\sp{\\sn fPseudoInline}{\\sv %d}}"), true); + } + + sResult += RenderToRtfShapeProperty( oRenderParameter ); + + //picture + if( 0 != m_oPicture && m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 9) + { + sResult += _T("{\\sp{\\sn fillBlip}{\\sv "); + sResult += m_oPicture->RenderToRtf( oRenderParameter ); + sResult += _T("}}"); + } + //textbox + if( 0 != m_aTextItems ) + { + sResult += _T("{\\shptxt "); + sResult += m_aTextItems->RenderToRtf( oRenderParameter ); + sResult += _T("}"); + } + sResult += _T("}"); + //if( 0 != m_oPicture ) + //{ + // sResult += _T("{\\shprslt\\par\\plain")); + // sResult += m_oPicture->GenerateWMF( oRenderParameter ) ); + // sResult += _T("\\par}")); + //} + sResult += _T("}"); + } + } + else + { + sResult += _T("{\\shp"); + sResult += _T("{\\*\\shpinst"); + + RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); + if (!m_bInGroup) + { RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") ); RENDER_RTF_INT( m_nTop , sResult, _T("shptop") ); RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") ); RENDER_RTF_INT( m_nRight , sResult, _T("shpright") ); - RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); RENDER_RTF_INT( m_nZOrder , sResult, _T("shpz") ); RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") ); RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") ); @@ -297,55 +311,56 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) } sResult += _T("\\shpbyignore"); RENDER_RTF_INT( m_nZOrderRelative, sResult, _T("shpfblwtxt")); + } - sResult += RenderToRtfShapeProperty( oRenderParameter ); + sResult += RenderToRtfShapeProperty( oRenderParameter ); - //picture - if( 0 != m_oPicture) + //picture + if( 0 != m_oPicture) + { + if (m_nShapeType == 75) { - if (m_nShapeType == 75) - { - sResult += _T("{\\sp{\\sn pib}{\\sv "); - sResult += m_oPicture->RenderToRtf( oRenderParameter ); - sResult += _T("}}"); - } - else if (m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 9) - { - sResult += _T("{\\sp{\\sn fillType}{\\sv 2}}"); - sResult += _T("{\\sp{\\sn fillBlip}{\\sv "); - sResult += m_oPicture->RenderToRtf( oRenderParameter ); - sResult += _T("}}"); - } + sResult += _T("{\\sp{\\sn pib}{\\sv "); + sResult += m_oPicture->RenderToRtf( oRenderParameter ); + sResult += _T("}}"); } - //textbox - if( m_aTextItems ) + else if (m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 9) { - sResult += _T("{\\shptxt "); - sResult += m_aTextItems->RenderToRtf( oRenderParameter ); - sResult += _T("}"); - } - sResult += _T("}"); - if( m_oPicture && m_nShapeType == 75 ) - { - sResult += _T("{\\shprslt\\par\\plain"); - sResult += m_oPicture->GenerateWMF( oRenderParameter ); - sResult += _T("\\par}"); + sResult += _T("{\\sp{\\sn fillType}{\\sv 2}}"); + sResult += _T("{\\sp{\\sn fillBlip}{\\sv "); + sResult += m_oPicture->RenderToRtf( oRenderParameter ); + sResult += _T("}}"); } + } + //textbox + if( m_aTextItems ) + { + sResult += _T("{\\shptxt "); + sResult += m_aTextItems->RenderToRtf( oRenderParameter ); sResult += _T("}"); } - //восстанавливаем координаты и если нужно поворачиваем - m_nLeft = nLeft; - m_nTop = nTop; - m_nRight = nRight; - m_nBottom = nBottom; - m_nRotation = nRotate; - - m_nRelLeft = nRelLeft; - m_nRelTop = nRelTop; - m_nRelRight = nRelRight; - m_nRelBottom = nRelBottom; - m_nRelRotation = nRelRotate; + sResult += _T("}"); + if( m_oPicture && m_nShapeType == 75 ) + { + sResult += _T("{\\shprslt\\par\\plain"); + sResult += m_oPicture->GenerateWMF( oRenderParameter ); + sResult += _T("\\par}"); + } + sResult += _T("}"); } + //восстанавливаем координаты и если нужно поворачиваем + m_nLeft = nLeft; + m_nTop = nTop; + m_nRight = nRight; + m_nBottom = nBottom; + m_nRotation = nRotate; + + m_nRelLeft = nRelLeft; + m_nRelTop = nRelTop; + m_nRelRight = nRelRight; + m_nRelBottom = nRelBottom; + m_nRelRotation = nRelRotate; + return sResult; } CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter) @@ -459,6 +474,32 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter) sResult.AppendFormat( _T("{\\sp{\\sn adjust9Value}{\\sv %d}}"), m_nAdjustValue9 ); if( PROP_DEF != m_nAdjustValue ) sResult.AppendFormat( _T("{\\sp{\\sn adjust10Value}{\\sv %d}}"), m_nAdjustValue10 ); +//custom + if( PROP_DEF != m_nGeoLeft) + sResult.AppendFormat( _T("{\\sp{\\sn geoLeft}{\\sv %d}}"), m_nGeoLeft ); + if( PROP_DEF != m_nGeoTop) + sResult.AppendFormat( _T("{\\sp{\\sn geoTop}{\\sv %d}}"), m_nGeoTop); + if( PROP_DEF != m_nGeoRight) + sResult.AppendFormat( _T("{\\sp{\\sn geoRight}{\\sv %d}}"), m_nGeoRight ); + if( PROP_DEF != m_nGeoBottom) + sResult.AppendFormat( _T("{\\sp{\\sn geoBottom}{\\sv %d}}"), m_nGeoBottom ); + if( PROP_DEF != m_nShapePath) + sResult.AppendFormat( _T("{\\sp{\\sn shapePath}{\\sv %d}}"), m_nShapePath ); + if( !m_aPVerticles.empty()) + { + sResult.AppendFormat( _T("{\\sp{\\sn pVerticies}{\\sv 8;%d"), m_aPVerticles.size() ); + for( int i = 0; i < m_aPVerticles.size(); i ++ ) + sResult.AppendFormat( _T(";(%d,%d)"), m_aPVerticles[i].first, m_aPVerticles[i].second ); + sResult += _T("}}"); + } + if( !m_aPSegmentInfo.empty()) + { + sResult += _T("{\\sp{\\sn pSegmentInfo}{\\sv "); + sResult.AppendFormat( _T("{\\sp{\\sn pSegmentInfo}{\\sv 2;%d"), m_aPSegmentInfo.size() ); + for( int i = 0; i < m_aPSegmentInfo.size(); i ++ ) + sResult.AppendFormat( _T(";%d"), m_aPSegmentInfo[i] ); + sResult += _T("}}"); + } //Connectors if( PROP_DEF != m_nConnectionType ) sResult.AppendFormat( _T("{\\sp{\\sn cxk}{\\sv %d}}"), m_nConnectionType ); @@ -475,7 +516,7 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter) sResult.AppendFormat( _T("{\\sp{\\sn cropFromRight}{\\sv %d}}"), m_nCropFromRight ); //Grouped Shapes if( PROP_DEF != m_nGroupBottom ) - sResult.AppendFormat( _T("{\\sp{\\sn groupBottom}{\\sv %d}}"), m_nCropFromRight ); + sResult.AppendFormat( _T("{\\sp{\\sn groupBottom}{\\sv %d}}"), m_nGroupBottom ); if( PROP_DEF != m_nGroupLeft ) sResult.AppendFormat( _T("{\\sp{\\sn groupLeft}{\\sv %d}}"), m_nGroupLeft ); if( PROP_DEF != m_nGroupRight ) @@ -532,12 +573,11 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter) sResult.AppendFormat( _T("{\\sp{\\sn lineDashing}{\\sv %d}}"), m_nLineDashing ); //pWrapPolygonVertices Points of the text wrap polygon. - int nWrapPointCount = (int)m_aWrapPoints.size(); - if( nWrapPointCount > 0 ) + if( !m_aWrapPoints.empty()) { - sResult.AppendFormat( _T("{\\sp{\\sn pWrapPolygonVertices}{\\sv 8;%d"), nWrapPointCount / 2 ); - for( int i = 0; i < nWrapPointCount - 1; i += 2 ) - sResult.AppendFormat( _T(";(%d,%d)"), m_aWrapPoints[i], m_aWrapPoints[ i + 1 ] ); + sResult.AppendFormat( _T("{\\sp{\\sn pWrapPolygonVertices}{\\sv 8;%d"), m_aWrapPoints.size() ); + for( int i = 0; i < m_aWrapPoints.size(); i ++ ) + sResult.AppendFormat( _T(";(%d,%d)"), m_aWrapPoints[i].first, m_aWrapPoints[i].second ); sResult += _T("}}"); } //WordArt @@ -564,71 +604,84 @@ CString RtfShape::RenderToOOX(RenderParameter oRenderParameter) { CString sResult; RtfDocument* poDocument = static_cast(oRenderParameter.poDocument); + if( PROP_DEF != m_nShapeType && 0 != m_nShapeType ) { - { - TextItemContainerPtr aTempTextItems; - if( 75 == m_nShapeType && 0 != m_aTextItems ) - {//Значит это Ole обьект с anchor, для него все также только TextBox надо делать по-другому - aTempTextItems = m_aTextItems; - m_aTextItems = TextItemContainerPtr(); - m_bIsOle = true; - } + TextItemContainerPtr aTempTextItems; + + if( 75 == m_nShapeType && 0 != m_aTextItems ) + {//Значит это Ole обьект с anchor, для него все также только TextBox надо делать по-другому + aTempTextItems = m_aTextItems; + m_aTextItems = TextItemContainerPtr(); + m_bIsOle = true; + } - sResult = RenderToOOXBegin(oRenderParameter); - if( _T("") != sResult ) - sResult += RenderToOOXEnd(oRenderParameter); + sResult = RenderToOOXBegin(oRenderParameter); + + if( !sResult.IsEmpty() ) + sResult += RenderToOOXEnd(oRenderParameter); - CString sOle; - if( 0 != aTempTextItems ) - {//пишем только Ole обьект - //ищем первый ole обьект - RtfOlePtr poFirstOle; - int nTempTextItemsCount = aTempTextItems->GetCount(); - for( int i = 0; i < nTempTextItemsCount; i++ ) + CString sOle; + if( 0 != aTempTextItems ) + {//пишем только Ole обьект + //ищем первый ole обьект + RtfOlePtr poFirstOle; + int nTempTextItemsCount = aTempTextItems->GetCount(); + for( int i = 0; i < nTempTextItemsCount; i++ ) + { + ITextItemPtr piCurTextItem; + aTempTextItems->GetItem( piCurTextItem, i ); + if( NULL != piCurTextItem && TYPE_RTF_PARAGRAPH == piCurTextItem->GetType() ) { - ITextItemPtr piCurTextItem; - aTempTextItems->GetItem( piCurTextItem, i ); - if( NULL != piCurTextItem && TYPE_RTF_PARAGRAPH == piCurTextItem->GetType() ) + RtfParagraphPtr poCurParagraph = boost::static_pointer_cast< RtfParagraph, ITextItem >( piCurTextItem ); + if( NULL != poCurParagraph ) { - RtfParagraphPtr poCurParagraph = boost::static_pointer_cast< RtfParagraph, ITextItem >( piCurTextItem ); - if( NULL != poCurParagraph ) + bool bBreak = false; + for( int j = 0; j < poCurParagraph->GetCount(); j++ ) { - bool bBreak = false; - for( int j = 0; j < poCurParagraph->GetCount(); j++ ) + IDocumentElementPtr piCurIDocumentElement; + poCurParagraph->GetItem( piCurIDocumentElement, j ); + if( NULL != piCurIDocumentElement && TYPE_RTF_OLE == piCurIDocumentElement->GetType() ) { - IDocumentElementPtr piCurIDocumentElement; - poCurParagraph->GetItem( piCurIDocumentElement, j ); - if( NULL != piCurIDocumentElement && TYPE_RTF_OLE == piCurIDocumentElement->GetType() ) - { - //рендерим только Ole часть - RenderParameter oNewParam = oRenderParameter; - oNewParam.nType = RENDER_TO_OOX_PARAM_OLE_ONLY; - oNewParam.nValue = m_nID; + //рендерим только Ole часть + RenderParameter oNewParam = oRenderParameter; + oNewParam.nType = RENDER_TO_OOX_PARAM_OLE_ONLY; + oNewParam.nValue = m_nID; - RtfOlePtr poCurOle = boost::static_pointer_cast< RtfOle, IDocumentElement >( piCurIDocumentElement ); - if( NULL != poCurOle ) - { - sOle += poCurOle->RenderToOOX( oNewParam ); - bBreak = true; - break; - } + RtfOlePtr poCurOle = boost::static_pointer_cast< RtfOle, IDocumentElement >( piCurIDocumentElement ); + if( NULL != poCurOle ) + { + sOle += poCurOle->RenderToOOX( oNewParam ); + bBreak = true; + break; } } - if( true == bBreak ) - break; } + if( true == bBreak ) + break; } } - //возвращаем text box на место - m_aTextItems = aTempTextItems; } - if( false == sOle.IsEmpty() ) - sResult.Replace( _T(""), sOle + _T("") ); + //возвращаем text box на место + m_aTextItems = aTempTextItems; } + if( false == sOle.IsEmpty() ) + sResult.Replace( _T(""), sOle + _T("") ); } return sResult; } +CString RtfShape::GetShapeNodeName(int type) +{ + switch(type) + { + case NSOfficeDrawing::sptRectangle: return _T("v:rect"); + case NSOfficeDrawing::sptEllipse: return _T("v:oval"); + case NSOfficeDrawing::sptRoundRectangle: return _T("v:roundrect"); + case NSOfficeDrawing::sptLine: return _T("v:line"); + case NSOfficeDrawing::sptArc: return _T("v:arc"); + default: return _T("v:shape"); + } +} CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) { if( false == IsValid() ) @@ -644,10 +697,10 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) else sResult += _T("");//работает по умолчанию - if( _T("") == oRenderParameter.sValue ) - sResult += _T(" 0) + sResult.AppendFormat( _T(" o:spt=\"%d\""), m_nShapeType ); + } if( 0 == m_bFilled) sResult += _T(" filled=\"f\""); else sResult += _T(" filled=\"t\""); @@ -675,8 +733,7 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) RtfColor color(m_nLineColor); sResult.AppendFormat( _T(" strokecolor=\"#") + color.ToHexColor(true) + _T("\"")); } - - //Connectors +//path switch( m_nConnectionType ) { case 0: sResult += _T(" o:connecttype=\"custom\""); break; @@ -684,6 +741,7 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) case 2: sResult += _T(" o:connecttype=\"rect\""); break; case 3: sResult += _T(" o:connecttype=\"segments\""); break; } +//Connectors switch( m_nConnectorStyle ) { case 0: sResult += _T(" o:connectortype=\"straight\""); break; @@ -699,14 +757,21 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) if( 3 != m_nPositionHRelative || 3 != m_nPositionVRelative ) { sStyle .Append ( _T("position:absolute;") ); - sStyle.AppendFormat ( _T("margin-left:%fpt;") , RtfUtility::Twip2pt(m_nLeft) ); - sStyle.AppendFormat ( _T("margin-top:%fpt;") , RtfUtility::Twip2pt(m_nTop)); - sStyle.AppendFormat ( _T("margin-bottom:%fpt;") , RtfUtility::Twip2pt(m_nBottom) ); - sStyle.AppendFormat ( _T("margin-right:%fpt;") , RtfUtility::Twip2pt(m_nRight)); + if (oRenderParameter.nType != RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2) + { + sStyle.AppendFormat ( _T("margin-left:%.2fpt;") , RtfUtility::Twip2pt(m_nLeft) ); + sStyle.AppendFormat ( _T("margin-top:%.2fpt;") , RtfUtility::Twip2pt(m_nTop) ); + sStyle.AppendFormat ( _T("margin-bottom:%.2fpt;") , RtfUtility::Twip2pt(m_nBottom) ); + sStyle.AppendFormat ( _T("margin-right:%.2fpt;") , RtfUtility::Twip2pt(m_nRight) ); + } } int nWidth = m_nRight - m_nLeft; int nHeight = m_nBottom - m_nTop; - sStyle.AppendFormat(_T("width:%fpt;height:%fpt;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); + + if (oRenderParameter.nType == RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2) + sStyle.AppendFormat(_T("width:%.2f;height:%.2f;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); + else + sStyle.AppendFormat(_T("width:%.2fpt;height:%.2fpt;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); } else if( PROP_DEF != m_nRelLeft && PROP_DEF != m_nRelRight && PROP_DEF != m_nRelTop && PROP_DEF != m_nRelBottom ) { @@ -716,25 +781,28 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) sStyle.Append ( _T("position:absolute;") ); sStyle.AppendFormat ( _T("left:%d;") , m_nRelLeft ); sStyle.AppendFormat ( _T("top:%d;") , m_nRelTop); - sStyle.AppendFormat ( _T("bottom:%d;") , m_nRelBottom ); - sStyle.AppendFormat ( _T("right:%d;") , m_nRelRight); + //sStyle.AppendFormat ( _T("bottom:%d;") , m_nRelBottom ); + //sStyle.AppendFormat ( _T("right:%d;") , m_nRelRight); sStyle.AppendFormat ( _T("width:%d;height:%d;") , nWidth, nHeight); } else if( 0 != m_oPicture && PROP_DEF != m_oPicture->m_nWidthGoal && PROP_DEF != m_oPicture->m_nHeightGoal && PROP_DEF != (int)m_oPicture->m_dScaleX && PROP_DEF != (int)m_oPicture->m_dScaleY ) { - int nWidth = (int)(m_oPicture->m_nWidthGoal * m_oPicture->m_dScaleX / 100); + float nWidth = (int)(m_oPicture->m_nWidthGoal * m_oPicture->m_dScaleX / 100.); if( PROP_DEF != m_oPicture->m_nCropL ) nWidth -= m_oPicture->m_nCropL; if( PROP_DEF != m_oPicture->m_nCropR ) nWidth -= m_oPicture->m_nCropR; - int nHeight = (int)(m_oPicture->m_nHeightGoal * m_oPicture->m_dScaleY / 100); + float nHeight = (int)(m_oPicture->m_nHeightGoal * m_oPicture->m_dScaleY / 100.); if( PROP_DEF != m_oPicture->m_nCropT ) nHeight -= m_oPicture->m_nCropT; if( PROP_DEF != m_oPicture->m_nCropB ) nHeight -= m_oPicture->m_nCropB; - sStyle.AppendFormat(_T("width:%.2fpt;height:%.2fpt;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); + if (oRenderParameter.nType == RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2) + sStyle.AppendFormat(_T("width:%.2f;height:%.2f;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); + else + sStyle.AppendFormat(_T("width:%.2fpt;height:%.2fpt;"), RtfUtility::Twip2pt(nWidth), RtfUtility::Twip2pt(nHeight)); } switch( m_nPositionH ) @@ -848,27 +916,26 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) nZIndex = m_nRelZOrder; else if( PROP_DEF != m_nZOrder ) nZIndex = m_nZOrder; - else + else if (oRenderParameter.nType != RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2) nZIndex = 100; //на свое усмотрение ставлю 100 - if( PROP_DEF != m_nZOrderRelative ) + + if( PROP_DEF != m_nZOrderRelative && PROP_DEF != nZIndex) { - //берем большое значение чтобы сделать строго выше или ниже текста - if( 0 == m_nZOrderRelative ) - sStyle.AppendFormat( _T("z-index:%d;"), 10000 + nZIndex );//Text is below shape - else - sStyle.AppendFormat( _T("z-index:%d;"), -10000 + nZIndex );//Shape is below text + //берем большое значение чтобы сделать строго выше или ниже текста + if( 0 == m_nZOrderRelative ) nZIndex += 10000; + else nZIndex -= 10000; } - else + if (PROP_DEF != nZIndex) sStyle.AppendFormat( _T("z-index:%d;"), nZIndex ); if( PROP_DEF != m_nWrapDistLeft ) - sStyle.AppendFormat( _T("mso-wrap-distance-left:%fpt;"), RtfUtility::Twip2pt( m_nWrapDistLeft )); + sStyle.AppendFormat( _T("mso-wrap-distance-left:%.2fpt;"), RtfUtility::Twip2pt( m_nWrapDistLeft )); if( PROP_DEF != m_nWrapDistTop ) - sStyle.AppendFormat( _T("mso-wrap-distance-top:%fpt;"), RtfUtility::Twip2pt( m_nWrapDistTop )); + sStyle.AppendFormat( _T("mso-wrap-distance-top:%.2fpt;"), RtfUtility::Twip2pt( m_nWrapDistTop )); if( PROP_DEF != m_nWrapDistRight ) - sStyle.AppendFormat( _T("mso-wrap-distance-right:%fpt;"), RtfUtility::Twip2pt( m_nWrapDistRight )); + sStyle.AppendFormat( _T("mso-wrap-distance-right:%.2fpt;"), RtfUtility::Twip2pt( m_nWrapDistRight )); if( PROP_DEF != m_nWrapDistBottom ) - sStyle.AppendFormat( _T("mso-wrap-distance-bottom:%fpt;"), RtfUtility::Twip2pt( m_nWrapDistBottom )); + sStyle.AppendFormat( _T("mso-wrap-distance-bottom:%.2fpt;"), RtfUtility::Twip2pt( m_nWrapDistBottom )); switch( m_nAnchorText) { @@ -891,19 +958,29 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) sResult += _T(" style=\"") + sStyle + _T("\""); } //---------------------------------------------------------------------------------------------------------------------------- - if( PROP_DEF != m_bLayoutInCell ) + if( true == m_bIsOle ) sResult += _T(" o:ole=\"\""); + + if( PROP_DEF != m_nGroupLeft && PROP_DEF != m_nGroupTop ) + sResult.AppendFormat( _T(" coordorigin=\"%d,%d\""), m_nGroupLeft, m_nGroupTop); + if( PROP_DEF != m_nGroupLeft && PROP_DEF != m_nGroupTop && PROP_DEF != m_nGroupRight && PROP_DEF != m_nGroupBottom) + sResult.AppendFormat( _T(" coordsize=\"%d,%d\""), m_nGroupRight - m_nGroupLeft, m_nGroupBottom - m_nGroupTop ); + + if (oRenderParameter.nType != RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2) { - if( 0 == m_bLayoutInCell ) - sResult += _T(" o:allowincell=\"false\""); - else - sResult += _T(" o:allowincell=\"true\""); - } - if( PROP_DEF != m_bAllowOverlap ) - { - if( 0 == m_bAllowOverlap ) - sResult += _T(" o:allowoverlap=\"false\""); - else - sResult += _T(" o:allowoverlap=\"true\""); + if( PROP_DEF != m_bLayoutInCell ) + { + if( 0 == m_bLayoutInCell ) + sResult += _T(" o:allowincell=\"false\""); + else + sResult += _T(" o:allowincell=\"true\""); + } + if( PROP_DEF != m_bAllowOverlap ) + { + if( 0 == m_bAllowOverlap ) + sResult += _T(" o:allowoverlap=\"false\""); + else + sResult += _T(" o:allowoverlap=\"true\""); + } } //Position @@ -951,29 +1028,24 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) sResult.AppendFormat( _T(" adj=\"%ls\""),sAdjust.GetBuffer() ); } //Geometry - if( m_aWrapPoints.size() > 0 ) + if( !m_aWrapPoints.empty()) { sResult += _T(" wrapcoords=\""); - sResult.AppendFormat( _T("%d"), m_aWrapPoints[0]); + sResult.AppendFormat( _T("%d,%d"), m_aWrapPoints[0].first, m_aWrapPoints[0].second); - for( int i = 1; i < (int)m_aWrapPoints.size(); i++ ) + for( int i = 0; i < (int)m_aWrapPoints.size(); i++ ) { - sResult.AppendFormat( _T(" %d"), m_aWrapPoints[i]); + sResult.AppendFormat( _T(",%d,%d"), m_aWrapPoints[i].first, m_aWrapPoints[i].second); } sResult += _T("\""); } - if( PROP_DEF != m_nGroupLeft && PROP_DEF != m_nGroupTop ) - sResult.AppendFormat( _T(" coordorigin=\"%d,%d\""), m_nGroupLeft, m_nGroupTop); - if( PROP_DEF != m_nGroupLeft && PROP_DEF != m_nGroupTop && PROP_DEF != m_nGroupRight && PROP_DEF != m_nGroupBottom) - sResult.AppendFormat( _T(" coordsize=\"%d,%d\""), m_nGroupRight - m_nGroupLeft, m_nGroupBottom - m_nGroupTop ); - - if( true == m_bIsOle ) sResult += _T(" o:ole=\"\""); - + if(PROP_DEF != m_nLineWidth) sResult.AppendFormat( _T(" strokeweight=\"%fpt\""), RtfUtility::Emu2Pt(m_nLineWidth) ); - sResult += _T(">"); + sResult += _T(">"); +//-------------------------------------------------------------------------------------------------------------- nodes if( PROP_DEF != m_nWrapType && 3 != m_nWrapType) { sResult += _T(""), - RtfUtility::Emu2Pt(m_nTexpLeft), RtfUtility::Emu2Pt(m_nTexpTop), RtfUtility::Emu2Pt(m_nTexpRight), RtfUtility::Emu2Pt(m_nTexpBottom) ); + sResult.AppendFormat( _T(" inset=\"%dpt, %dpt, %dpt, %dpt\">"), + (int)RtfUtility::Emu2Pt(m_nTexpLeft), (int)RtfUtility::Emu2Pt(m_nTexpTop), (int)RtfUtility::Emu2Pt(m_nTexpRight), (int)RtfUtility::Emu2Pt(m_nTexpBottom) ); } else sResult += _T(">"); @@ -1204,10 +1276,12 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter) { CString sResult; - if( _T("") == oRenderParameter.sValue ) - sResult += _T(""); - else - sResult.AppendFormat( _T(""), oRenderParameter.sValue.GetBuffer() ); + + if (oRenderParameter.sValue.IsEmpty()) + oRenderParameter.sValue = GetShapeNodeName(m_nShapeType); + + sResult += _T(""); + if( RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2 == oRenderParameter.nType ) ; else if( RENDER_TO_OOX_PARAM_SHAPE_WSHAPE == oRenderParameter.nType ) @@ -1218,20 +1292,139 @@ CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter) } CString RtfShapeGroup::RenderToRtf(RenderParameter oRenderParameter) { - return RtfShape::RenderToRtf( oRenderParameter ); + CString sResult; + //запоминаем координаты и если нужно поворачиваем + int nLeft = m_nLeft; + int nTop = m_nTop; + int nRight = m_nRight; + int nBottom = m_nBottom; + int nRotate = m_nRotation; + + int nRelLeft = m_nRelLeft; + int nRelTop = m_nRelTop; + int nRelRight = m_nRelRight; + int nRelBottom = m_nRelBottom; + int nRelRotate = m_nRelRotation; + + if( PROP_DEF != m_nRotation && PROP_DEF != m_nLeft && PROP_DEF != m_nTop && + PROP_DEF != m_nRight && PROP_DEF != m_nBottom ) + ToRtfRotation( m_nRotation, m_nLeft, m_nTop, m_nRight, m_nBottom ); + + if( PROP_DEF != m_nRelRotation && PROP_DEF != m_nRelLeft && PROP_DEF != m_nRelTop && + PROP_DEF != m_nRelRight && PROP_DEF != m_nRelBottom ) + ToRtfRotation( m_nRelRotation, m_nRelLeft, m_nRelTop, m_nRelRight, m_nRelBottom ); + + if( st_inline == m_eAnchorTypeShape ) + { + sResult += _T("{\\shpgrp"); + sResult += _T("{\\*\\shpinst"); + + RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); + + if (!m_bInGroup) + { + RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") ); + RENDER_RTF_INT( m_nTop , sResult, _T("shptop") ); + RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") ); + RENDER_RTF_INT( m_nRight , sResult, _T("shpright") ); + RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") ); + RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") ); + RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") ); + RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") ); + + sResult += _T("\\shpbxignore"); + sResult += _T("\\shpbyignore"); + + sResult.AppendFormat( _T("{\\sp{\\sn fUseShapeAnchor}{\\sv %d}}"), false); + sResult.AppendFormat( _T("{\\sp{\\sn fPseudoInline}{\\sv %d}}"), true); + } + + + sResult += RenderToRtfShapeProperty( oRenderParameter ); + + for (int i = 0 ; i < m_aArray.size(); i++) + { + sResult += m_aArray[i]->RenderToRtf( oRenderParameter ); + } + sResult += _T("}"); + sResult += _T("}"); + } + else + { + sResult += _T("{\\shpgrp"); + sResult += _T("{\\*\\shpinst"); + + RENDER_RTF_INT( m_nID , sResult, _T("shplid") ); + + if (!m_bInGroup) + { + RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") ); + RENDER_RTF_INT( m_nTop , sResult, _T("shptop") ); + RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") ); + RENDER_RTF_INT( m_nRight , sResult, _T("shpright") ); + RENDER_RTF_INT( m_nZOrder , sResult, _T("shpz") ); + RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") ); + RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") ); + RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") ); + RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") ); + + switch(m_eXAnchor) + { + case ax_page: sResult += _T("\\shpbxpage"); break; + case ax_margin: sResult += _T("\\shpbxmargin"); break; + case ax_column: sResult += _T("\\shpbxcolumn"); break; + } + sResult += _T("\\shpbxignore"); + switch(m_eYAnchor) + { + case ay_page: sResult += _T("\\shpbypage"); break; + case ay_margin: sResult += _T("\\shpbymargin"); break; + case ay_Para: sResult += _T("\\shpbypara"); break; + } + sResult += _T("\\shpbyignore"); + RENDER_RTF_INT( m_nZOrderRelative, sResult, _T("shpfblwtxt")); + } + sResult += _T("{\\sp{\\sn lidRegroup}{\\sv 0}}"); + + sResult += RenderToRtfShapeProperty( oRenderParameter ); + + for (int i = 0 ; i < m_aArray.size(); i++) + { + sResult += m_aArray[i]->RenderToRtf( oRenderParameter ); + } + + sResult += _T("}"); + sResult += _T("}"); + } + //восстанавливаем координаты и если нужно поворачиваем + m_nLeft = nLeft; + m_nTop = nTop; + m_nRight = nRight; + m_nBottom = nBottom; + m_nRotation = nRotate; + + m_nRelLeft = nRelLeft; + m_nRelTop = nRelTop; + m_nRelRight = nRelRight; + m_nRelBottom = nRelBottom; + m_nRelRotation = nRelRotate; + + return sResult; } CString RtfShapeGroup::RenderToOOX(RenderParameter oRenderParameter) { CString sResult; RenderParameter oNewParamGroup = oRenderParameter; oNewParamGroup.sValue = _T("v:group"); - RenderParameter oNewParamShape = oRenderParameter; - oNewParamShape.sValue = _T("v:shape"); sResult = RenderToOOXBegin( oNewParamGroup ); for( int i = 0; i < (int)m_aArray.size(); i++ ) { + RenderParameter oNewParamShape = oRenderParameter; + oNewParamShape.sValue = L""; + oNewParamShape.nType = RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2; //in group + sResult += m_aArray[i]->RenderToOOX( oNewParamShape ); } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.h b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.h index 5df823a9bd..c2d2beb3de 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.h @@ -31,220 +31,233 @@ */ #pragma once #include "RtfPicture.h" +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Enums.h" class RtfShape: public IRenderableProperty { public: - typedef enum{ st_none, st_inline, st_anchor }ShapeType; - typedef enum{ - ax_none, - //ax_ignore, //shpbxignore Ignore \shpbxpage, \shpbxmargin, and \shpbxcolumn, in favor of the posrelh property. The ignored properties will be written for backward compatibility with older readers that do not understand \posrelh. - ax_page, //shpbxpage The shape is positioned relative to the page in the x (horizontal) direction. - ax_margin, //shpbxmargin The shape is positioned relative to the margin in the x (horizontal) direction. - ax_column //shpbxcolumn The shape is positioned relative to the column in the x (horizontal) direction. - }AnchorX; - typedef enum{ - ay_none, - //ay_ignore, //shpbyignore Ignore \shpbypage, \shpbymargin, and \shpbxpara, in favor of the posrelh property. The ignored properties will be written for backward compatibility with older readers that do not understand the posrelh property. - ay_page, //shpbypage The shape is positioned relative to the page in the y (vertical) direction. - ay_margin, //shpbymargin The shape is positioned relative to the margin in the y (vertical) direction. - ay_Para //shpbypara The shape is positioned relative to the paragraph in the y (vertical) direction. - }AnchorY; + bool m_bIsOle; + bool m_bInGroup; //local anchor - ShapeType m_eShapeType; +//----------------------------- + typedef enum{ st_none, st_inline, st_anchor }AnchorTypeShape; + typedef enum + { + ax_none, + //ax_ignore, //shpbxignore Ignore \shpbxpage, \shpbxmargin, and \shpbxcolumn, in favor of the posrelh property. The ignored properties will be written for backward compatibility with older readers that do not understand \posrelh. + ax_page, //shpbxpage The shape is positioned relative to the page in the x (horizontal) direction. + ax_margin, //shpbxmargin The shape is positioned relative to the margin in the x (horizontal) direction. + ax_column //shpbxcolumn The shape is positioned relative to the column in the x (horizontal) direction. + }AnchorX; + typedef enum + { + ay_none, + //ay_ignore, //shpbyignore Ignore \shpbypage, \shpbymargin, and \shpbxpara, in favor of the posrelh property. The ignored properties will be written for backward compatibility with older readers that do not understand the posrelh property. + ay_page, //shpbypage The shape is positioned relative to the page in the y (vertical) direction. + ay_margin, //shpbymargin The shape is positioned relative to the margin in the y (vertical) direction. + ay_Para //shpbypara The shape is positioned relative to the paragraph in the y (vertical) direction. + }AnchorY; - CString m_sName; - CString m_sDescription; + AnchorTypeShape m_eAnchorTypeShape; - int m_nLeft; //shpleftN Specifies position of shape from the left of the anchor. The value N is in twips. - int m_nTop; //shptopN Specifies position of shape from the top of the anchor. The value N is in twips. - int m_nBottom; //shpbottomN Specifies position of shape from the bottom of the anchor. The value N is in twips. - int m_nRight; //shprightN Specifies position of shape from the right of the anchor. The value N is in twips. - int m_nID; //shplidN A number that is unique to each shape. This keyword is primarily used for linked text boxes. The value N is a long integer. - int m_nZOrder; //shpzN Describes the z-order of the shape. It starts at 0 for the shape that is furthest from the top, and proceeds to the top most shape (N). The shapes that appear inside the header document will have a separate z-order, compared to the z-order of the shapes in the main document. For instance, both the back-most shape in the header and the back-most main-document shape will have a z-order of 0. - int m_nHeader; //shpfhdrN Set to 0 if the shape is in the main document. Set to 1 if the shape is in the header document. - int m_nWrapType; //shpwrN Describes the type of wrap for the shape: - int m_nWrapSideType; //shpwrkN Wrap on side (for types 2 and 4 for \shpwrN ): - int m_nZOrderRelative; //shpfblwtxtN Describes relative z-ordering: - int m_bLockAnchor; //shplockanchor Lock anchor for a shape. - - AnchorX m_eXAnchor; - AnchorY m_eYAnchor; + CString m_sName; + CString m_sDescription; + + int m_nLeft; //shpleftN Specifies position of shape from the left of the anchor. The value N is in twips. + int m_nTop; //shptopN Specifies position of shape from the top of the anchor. The value N is in twips. + int m_nBottom; //shpbottomN Specifies position of shape from the bottom of the anchor. The value N is in twips. + int m_nRight; //shprightN Specifies position of shape from the right of the anchor. The value N is in twips. + int m_nID; //shplidN A number that is unique to each shape. This keyword is primarily used for linked text boxes. The value N is a long integer. + int m_nZOrder; //shpzN Describes the z-order of the shape. It starts at 0 for the shape that is furthest from the top, and proceeds to the top most shape (N). The shapes that appear inside the header document will have a separate z-order, compared to the z-order of the shapes in the main document. For instance, both the back-most shape in the header and the back-most main-document shape will have a z-order of 0. + int m_nHeader; //shpfhdrN Set to 0 if the shape is in the main document. Set to 1 if the shape is in the header document. + int m_nWrapType; //shpwrN Describes the type of wrap for the shape: + int m_nWrapSideType; //shpwrkN Wrap on side (for types 2 and 4 for \shpwrN ): + int m_nZOrderRelative; //shpfblwtxtN Describes relative z-ordering: + int m_bLockAnchor; //shplockanchor Lock anchor for a shape. + + AnchorX m_eXAnchor; + AnchorY m_eYAnchor; //----------------ShapeProperty-------------------- //Position absolute - int m_nPositionH; //posh Horizontal alignment - int m_nPositionHRelative; //posrelh Position horizontally relative to: - int m_nPositionV; //posv Vertical alignment: - int m_nPositionVRelative; //posrelv Position horizontally relative to: - int m_bLayoutInCell; //fLayoutInCell Allows shape to anchor and position inside table cells. - int m_bAllowOverlap; //fAllowOverlap Allows shape to overlap other shapes unless it is a shape with None wrapping (\shpwr3), in which case it can always overlap an object with other types of wrapping and vice-versa. + int m_nPositionH; //posh Horizontal alignment + int m_nPositionHRelative; //posrelh Position horizontally relative to: + int m_nPositionV; //posv Vertical alignment: + int m_nPositionVRelative; //posrelv Position horizontally relative to: + int m_bLayoutInCell; //fLayoutInCell Allows shape to anchor and position inside table cells. + int m_bAllowOverlap; //fAllowOverlap Allows shape to overlap other shapes unless it is a shape with None wrapping (\shpwr3), in which case it can always overlap an object with other types of wrapping and vice-versa. //Position relative - int m_nPositionHPct; //pctHorizPos Percentage horizontal position for a shape - int m_nPositionVPct; //pctVert Percentage vertical position for a shape - int m_nPctWidth; //pctHoriz Percentage width for a shape - int m_nPctHeight; //pctVert Percentage height for a shape - int m_nPctWidthRelative; //sizerelh Relative size horizontal relation - int m_nPctHeightRelative; //sizerelv Relative size vertical relation - int m_nColStart; //colStart Starting column - int m_nColSpan; //colSpan Number of columns to span + int m_nPositionHPct; //pctHorizPos Percentage horizontal position for a shape + int m_nPositionVPct; //pctVert Percentage vertical position for a shape + int m_nPctWidth; //pctHoriz Percentage width for a shape + int m_nPctHeight; //pctVert Percentage height for a shape + int m_nPctWidthRelative; //sizerelh Relative size horizontal relation + int m_nPctHeightRelative; //sizerelv Relative size vertical relation + int m_nColStart; //colStart Starting column + int m_nColSpan; //colSpan Number of columns to span //Rehydration - CString m_sMetroBlob; // metroBlob Specifies application-specific data used to convert a shape to other formats. It is an encoded TBYTE stream. - CString m_sMetroBlobRels; - CString m_sMetroBlobData; - + CString m_sMetroBlob; // metroBlob Specifies application-specific data used to convert a shape to other formats. It is an encoded TBYTE stream. + CString m_sMetroBlobRels; + CString m_sMetroBlobData; //Object Type - bool m_bIsOle; - int m_bIsBullet; //fIsBullet Indicates whether a picture was inserted as a picture bullet. - int m_nRotation; //rotation Rotation of the shape. Angle 0 - int m_bFlipV; //fFlipV Vertical flip, applied after the rotation. Boolean FALSE - int m_bFlipH; //fFlipH Horizontal flip, applied after the rotation. Boolean FALSE - int m_nShapeType; //shapeType See below for values. 0 indicates user-drawn freeforms and polygons. Not applicable Not applicable - int m_nWrapDistLeft; //dxWrapDistLeft Left wrapping distance from text. - int m_nWrapDistTop; // - int m_nWrapDistRight; // - int m_nWrapDistBottom; // -// int m_bBehindDocument; //Place the shape behind text. Boolean FALSE - int m_bHidden; //Do not display or print (only set through Visual Basic for Applications). Boolean FALSE + int m_bIsBullet; //fIsBullet Indicates whether a picture was inserted as a picture bullet. + int m_nRotation; //rotation Rotation of the shape. Angle 0 + int m_bFlipV; //fFlipV Vertical flip, applied after the rotation. Boolean FALSE + int m_bFlipH; //fFlipH Horizontal flip, applied after the rotation. Boolean FALSE + int m_nShapeType; //shapeType See below for values. 0 indicates user-drawn freeforms and polygons. Not applicable Not applicable + + int m_nWrapDistLeft; //dxWrapDistLeft Left wrapping distance from text. + int m_nWrapDistTop; + int m_nWrapDistRight; + int m_nWrapDistBottom; + int m_bHidden; //Do not display or print (only set through Visual Basic for Applications). Boolean FALSE //Text box - int m_nAnchorText; - int m_nTexpLeft; //dxTextLeft Left internal margin of the text box. EMU 91,440 - int m_nTexpTop; // - int m_nTexpRight; // - int m_nTexpBottom; // - int m_bFitShapeToText; - int m_bFitTextToShape; - int m_nCcol; //columns - int m_nTxdir; //bidi - int m_nWrapText; + int m_nAnchorText; + int m_nTexpLeft; //dxTextLeft Left internal margin of the text box. EMU 91,440 + int m_nTexpTop; + int m_nTexpRight; + int m_nTexpBottom; + int m_bFitShapeToText; + int m_bFitTextToShape; + int m_nCcol; //columns + int m_nTxdir; //bidi + int m_nWrapText; //Geometry - int m_nAdjustValue; //adjustValue First adjust value from an adjust handle. The interpretation varies with the shape type. Adjust values alter the geometry of the shape in smart ways. Integer 0 - int m_nAdjustValue2; - int m_nAdjustValue3; - int m_nAdjustValue4; - int m_nAdjustValue5; - int m_nAdjustValue6; - int m_nAdjustValue7; - int m_nAdjustValue8; - int m_nAdjustValue9; - int m_nAdjustValue10; + int m_nAdjustValue; //adjustValue First adjust value from an adjust handle. The interpretation varies with the shape type. Adjust values alter the geometry of the shape in smart ways. Integer 0 + int m_nAdjustValue2; + int m_nAdjustValue3; + int m_nAdjustValue4; + int m_nAdjustValue5; + int m_nAdjustValue6; + int m_nAdjustValue7; + int m_nAdjustValue8; + int m_nAdjustValue9; + int m_nAdjustValue10; +//Custom + int m_nGeoLeft; + int m_nGeoTop; + int m_nGeoRight; + int m_nGeoBottom; + int m_nShapePath; + std::vector< std::pair > m_aPVerticles; + std::vector< int> m_aPSegmentInfo; //Connectors - int m_nConnectionType; //cxk Connection site type - int m_nConnectorStyle; //cxstyle Connector style + int m_nConnectionType; //cxk Connection site type + int m_nConnectorStyle; //cxstyle Connector style //Picture Effects - int m_nCropFromTop; //cropFromTop Top cropping percentage. Измеряется в fraction 1 /65536 - int m_nCropFromBottom; //cropFromBottom Bottom cropping percentage. - int m_nCropFromLeft; //cropFromLeft Left cropping percentage. - int m_nCropFromRight; //cropFromRight Right cropping percentage. + int m_nCropFromTop; //cropFromTop Top cropping percentage. Измеряется в fraction 1 /65536 + int m_nCropFromBottom; //cropFromBottom Bottom cropping percentage. + int m_nCropFromLeft; //cropFromLeft Left cropping percentage. + int m_nCropFromRight; //cropFromRight Right cropping percentage. //Grouped Shapes - int m_nGroupBottom; //groupBottom Defines the height of the group rectangle, but does not necessarily indicate position on the page. The difference between groupBottom and groupTop should match the dimensions specified by \shptopN and \shpbottomN. - int m_nGroupLeft; //groupLeft Defines the width of the group rectangle, but does not necessarily indicate position on the page. The difference between groupLeft and groupRight should match the dimensions specified by \shpleftN and \shprightN. - int m_nGroupRight; //groupRight See meaning for groupLeft. - int m_nGroupTop; //groupTop See meaning for groupBottom. - int m_nRelBottom; //relBottom Defines the bottom of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. - int m_nRelLeft; //relLeft Defines the left of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. - int m_nRelRight; //relRight Defines the right of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. - int m_nRelTop; //relTop Defines the top of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. - int m_nRelRotation; //relRotation Represents the information stored in the site of a shape, which defines the size and location of the shape in the parent group or drawing. The coordinates are relative to the position of the parent group or drawing. The units are relative to the m_rcg of the parent. - int m_nRelZOrder; //dhgt Word 2007 Z-order position of shape(s) on a page. Shapes with small dhgts are further back than shapes with large dhgts. + int m_nGroupBottom; //groupBottom Defines the height of the group rectangle, but does not necessarily indicate position on the page. The difference between groupBottom and groupTop should match the dimensions specified by \shptopN and \shpbottomN. + int m_nGroupLeft; //groupLeft Defines the width of the group rectangle, but does not necessarily indicate position on the page. The difference between groupLeft and groupRight should match the dimensions specified by \shpleftN and \shprightN. + int m_nGroupRight; //groupRight See meaning for groupLeft. + int m_nGroupTop; //groupTop See meaning for groupBottom. + int m_nRelBottom; //relBottom Defines the bottom of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. + int m_nRelLeft; //relLeft Defines the left of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. + int m_nRelRight; //relRight Defines the right of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. + int m_nRelTop; //relTop Defines the top of a shape within its parent shape (used for shapes in a group). The measurement is relative to the position of the parent group or drawing. + int m_nRelRotation; //relRotation Represents the information stored in the site of a shape, which defines the size and location of the shape in the parent group or drawing. The coordinates are relative to the position of the parent group or drawing. The units are relative to the m_rcg of the parent. + int m_nRelZOrder; //dhgt Word 2007 Z-order position of shape(s) on a page. Shapes with small dhgts are further back than shapes with large dhgts. //Fill - int m_bFilled; //fFilled The shape is filled. - int m_nFillColor; //fillColor - int m_nFillColor2; //fillBackColor - int m_nFillType; - int m_nFillOpacity; - int m_nFillFocus; - int m_nFillAngle; - //int m_bFillShape; //есть копия заливки картинкой + int m_bFilled; //fFilled The shape is filled. + int m_nFillColor; //fillColor + int m_nFillColor2; //fillBackColor + int m_nFillType; + int m_nFillOpacity; + int m_nFillFocus; + int m_nFillAngle; + //int m_bFillShape; //есть копия заливки картинкой //Line - int m_bLine; //fLine Has a line - int m_nLineColor; - int m_nLineStartArrow; //lineStartArrowhead Start arrow type: - int m_nLineEndArrow; //lineEndArrowhead End arrow type (for acceptable values see meaning for lineStartArrowhead). - int m_nLineStartArrowWidth; //lineStartArrowWidth Start arrow width: - int m_nLineStartArrowLength; //lineStartArrowLength Start arrow length: - int m_nLineEndArrowWidth; //lineEndArrowWidth End arrow width (for acceptable values see meaning for lineStartArrowWidth). - int m_nLineEndArrowLength; //lineEndArrowLength End arrow length (for acceptable values see meaning for lineStartArrowLength). - int m_nLineWidth; //lineWidth Width of the line. - int m_nLineDashing; + int m_bLine; //fLine Has a line + int m_nLineColor; + int m_nLineStartArrow; //lineStartArrowhead Start arrow type: + int m_nLineEndArrow; //lineEndArrowhead End arrow type (for acceptable values see meaning for lineStartArrowhead). + int m_nLineStartArrowWidth; //lineStartArrowWidth Start arrow width: + int m_nLineStartArrowLength; //lineStartArrowLength Start arrow length: + int m_nLineEndArrowWidth; //lineEndArrowWidth End arrow width (for acceptable values see meaning for lineStartArrowWidth). + int m_nLineEndArrowLength; //lineEndArrowLength End arrow length (for acceptable values see meaning for lineStartArrowLength). + int m_nLineWidth; //lineWidth Width of the line. + int m_nLineDashing; //WordArt - CString m_sGtextUNICODE; - CString m_sGtextFont; - int m_nGtextSize; - int m_bGtext; + CString m_sGtextUNICODE; + CString m_sGtextFont; + int m_nGtextSize; + int m_bGtext; //pWrapPolygonVertices Points of the text wrap polygon. - std::vector< int > m_aWrapPoints; + std::vector< std::pair > m_aWrapPoints; //textbox - TextItemContainerPtr m_aTextItems; - RtfPicturePtr m_oPicture; + TextItemContainerPtr m_aTextItems; + RtfPicturePtr m_oPicture; //------------------------------------------------------------------------------------------------------ - RtfShape() - { - SetDefault(); - } + RtfShape() + { + SetDefault(); + } - bool IsValid() - { - return PROP_DEF != m_nShapeType; - } - void SetDefaultRtf() - { - SetDefault(); - } - void SetDefaultOOX() - { - SetDefault(); - } - void SetDefault(); - CString RenderToRtf (RenderParameter oRenderParameter); - CString RenderToOOX (RenderParameter oRenderParameter); + bool IsValid() + { + return PROP_DEF != m_nShapeType; + } + void SetDefaultRtf() + { + SetDefault(); + } + void SetDefaultOOX() + { + SetDefault(); + } + void SetDefault(); + CString RenderToRtf (RenderParameter oRenderParameter); + CString RenderToOOX (RenderParameter oRenderParameter); - CString RenderToOOXBegin(RenderParameter oRenderParameter); - CString RenderToOOXEnd (RenderParameter oRenderParameter); - - void ToRtfRotation( int nAngel , int &nLeft, int &nTop, int& nRight, int& nBottom ) + CString RenderToOOXBegin(RenderParameter oRenderParameter); + CString RenderToOOXEnd (RenderParameter oRenderParameter); + + void ToRtfRotation( int nAngel , int &nLeft, int &nTop, int& nRight, int& nBottom ) + { + //поворачиваем на 45 градусов + nAngel -= 45; + //делаем угол от 0 до 360 + nAngel = nAngel % 360; + if( nAngel < 0 ) + nAngel += 360; + int nQuater = nAngel / 90; // определяем четверть + if( 0 == nQuater || 2 == nQuater ) { - //поворачиваем на 45 градусов - nAngel -= 45; - //делаем угол от 0 до 360 - nAngel = nAngel % 360; - if( nAngel < 0 ) - nAngel += 360; - int nQuater = nAngel / 90; // определяем четверть - if( 0 == nQuater || 2 == nQuater ) - { - //поворачиваем относительно центра на 90 градусов обратно - int nCenterX = ( nLeft + nRight ) / 2; - int nCenterY = ( nTop + nBottom ) / 2; - int nWidth = nRight - nLeft; - int nHeight = nBottom - nTop; + //поворачиваем относительно центра на 90 градусов обратно + int nCenterX = ( nLeft + nRight ) / 2; + int nCenterY = ( nTop + nBottom ) / 2; + int nWidth = nRight - nLeft; + int nHeight = nBottom - nTop; - nLeft = nCenterX - nHeight / 2; - nRight = nCenterX + nHeight / 2; - nTop = nCenterY - nWidth / 2; - nBottom = nCenterY + nWidth / 2; - } + nLeft = nCenterX - nHeight / 2; + nRight = nCenterX + nHeight / 2; + nTop = nCenterY - nWidth / 2; + nBottom = nCenterY + nWidth / 2; } -private: - CString RenderToRtfShapeProperty(RenderParameter oRenderParameter); - + } + CString RenderToRtfShapeProperty(RenderParameter oRenderParameter); + CString GetShapeNodeName(int type); }; typedef boost::shared_ptr RtfShapePtr; + class RtfShapeGroup : public RtfShape, public ItemContainer { public: - CString RenderToRtf(RenderParameter oRenderParameter); - CString RenderToOOX(RenderParameter oRenderParameter); - bool IsValid() - { - return true; - } + CString RenderToRtf(RenderParameter oRenderParameter); + CString RenderToOOX(RenderParameter oRenderParameter); + bool IsValid() + { + return true; + } }; typedef boost::shared_ptr RtfShapeGroupPtr; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXContentTypesWriter.h b/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXContentTypesWriter.h index 29ae78d3fd..7aa3c57911 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXContentTypesWriter.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXContentTypesWriter.h @@ -80,19 +80,31 @@ private: CString CreateXml() { CString sResult; - sResult.Append( _T("") ); + sResult += _T(""); sResult.AppendChar('\n'); - sResult.Append( _T("") ); + sResult += _T(""); - sResult.Append( _T("") ); - sResult.Append( _T("") ); + sResult += _T(""); + sResult += _T(""); for( int i = 0; i < (int)m_aExtensions.size(); i++ ) - sResult.AppendFormat( _T(""), m_aExtensions[i].GetBuffer(), m_aExtTypes[i].GetBuffer()); + { + sResult += _T(""); + } for( int i = 0; i < (int)m_aTargets.size(); i++ ) - sResult.AppendFormat( _T(""), m_aTargets[i].GetBuffer(), m_aTypes[i].GetBuffer()); - sResult.Append( _T("") ); + { + sResult += _T(""); + } + sResult += _T(""); return sResult; } }; diff --git a/ASCOfficeXlsFile2/ASCOfficeXlsFileTest/ASCOfficeXlsFileTest.vcproj b/ASCOfficeXlsFile2/ASCOfficeXlsFileTest/ASCOfficeXlsFileTest.vcproj index 2274596c78..b37c63b7c9 100644 --- a/ASCOfficeXlsFile2/ASCOfficeXlsFileTest/ASCOfficeXlsFileTest.vcproj +++ b/ASCOfficeXlsFile2/ASCOfficeXlsFileTest/ASCOfficeXlsFileTest.vcproj @@ -353,7 +353,27 @@ /> + + + + + + + + + diff --git a/Common/3dParty/cryptopp/cryptlib.vcproj b/Common/3dParty/cryptopp/cryptlib.vcproj index 6750bb23eb..fe530f1cb3 100644 --- a/Common/3dParty/cryptopp/cryptlib.vcproj +++ b/Common/3dParty/cryptopp/cryptlib.vcproj @@ -1,7 +1,7 @@ + + + + + + @@ -91,6 +105,15 @@ + + + + @@ -151,6 +177,15 @@ + + + + @@ -211,6 +249,15 @@ + + + + @@ -271,12 +321,21 @@ + + + + @@ -328,12 +390,21 @@ + + + + @@ -384,6 +458,15 @@ + + + + @@ -440,6 +526,15 @@ + + + + @@ -3202,80 +3300,6 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h b/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h index b481dbcebf..1b7dff6e4e 100644 --- a/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h +++ b/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h @@ -3270,9 +3270,10 @@ namespace SimpleTypes }; enum ECssUnitsType { - cssunitstypeAuto = 0, - cssunitstypeUnits = 1, - cssunitstypePerc = 2, + cssunitstypeAuto = 0, + cssunitstypeUnits = 1, + cssunitstypePerc = 2, + cssunitstypeAbsolute = 3 }; struct TCssUnitsValue { @@ -3823,10 +3824,15 @@ namespace SimpleTypes } else { - m_oValue.oValue.eType = cssunitstypeUnits; - - CString strValue = sValue.Mid( 0, nPos ); - m_oValue.oValue.dValue = strValue.IsEmpty() ? 0 : _wtof(strValue ); + m_oValue.oValue.eType = cssunitstypeAbsolute; + try + { + m_oValue.oValue.dValue = sValue.IsEmpty() ? 0 : _wtof(sValue ); + } + catch(...) + { + m_oValue.oValue.dValue = 0; + } } } diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp index 98611dedd0..f7232b52da 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp @@ -551,8 +551,10 @@ namespace OOX if ( 0 != m_oSpt.GetValue() ) sResult += _T("o:spt=\"") + m_oSpt.ToString() + _T("\" "); - if ( SimpleTypes::connectortypeStraight != m_oConnectorType.GetValue() ) - sResult += _T("o:connectortype=\"") + m_oConnectorType.ToString() + _T("\" "); + if (m_oConnectorType.IsInit()) + { + sResult += _T("o:connectortype=\"") + m_oConnectorType->ToString() + _T("\" "); + } ComplexTypes_WriteAttribute ( _T("o:bwmode=\""), m_oBwMode ); ComplexTypes_WriteAttribute ( _T("o:bwpure=\""), m_oBwPure ); diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h index ad9b207482..32c1c42d6a 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h @@ -121,7 +121,7 @@ namespace OOX nullable> m_oInsetPen; // 2.2 AG_OfficeShapeAttributes SimpleTypes::CDecimalNumber<> m_oSpt; - SimpleTypes::CConnectorType m_oConnectorType; + nullable> m_oConnectorType; nullable> m_oBwMode; nullable> m_oBwPure; nullable> m_oBwNormal; diff --git a/DesktopEditor/agg-2.4/agg_vs2005.vcproj b/DesktopEditor/agg-2.4/agg_vs2005.vcproj index e05c1cd703..66371420ba 100644 --- a/DesktopEditor/agg-2.4/agg_vs2005.vcproj +++ b/DesktopEditor/agg-2.4/agg_vs2005.vcproj @@ -105,7 +105,7 @@ UseOfMFC="0" UseOfATL="0" ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="1" + CharacterSet="0" DeleteExtensionsOnClean="" > + @@ -137,6 +140,130 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/X2tConverter/test/win32Test/X2tTest.vcproj b/X2tConverter/test/win32Test/X2tTest.vcproj index b3b0bde6ac..c1a19d5801 100644 --- a/X2tConverter/test/win32Test/X2tTest.vcproj +++ b/X2tConverter/test/win32Test/X2tTest.vcproj @@ -11,6 +11,9 @@ + @@ -165,6 +168,158 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -183,6 +338,15 @@ UsePrecompiledHeader="0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + +