From 206809549a90a70c30761f02b246b2c0e0c8a658 Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Tue, 23 Jun 2015 11:45:43 +0000 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20WordArt=20=D0=B8=D0=B7=20doc=20=D0=B2=20docx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63207 954022d7-b5bf-4e40-9824-e11837661b57 --- ASCOfficeDocFile/Common/XmlTools.h | 12 + .../DocDocxConverter/DocumentMapping.cpp | 19 +- .../DocDocxConverter/NumberingMapping.cpp | 2 +- .../DocDocxConverter/OfficeDrawing/Shape.h | 8 +- .../OfficeDrawing/ShapeType.h | 3 + .../OfficeDrawing/ShapeTypeFactory.cpp | 46 ++- .../OfficeDrawing/Shapetypes/TextboxType.h | 28 +- .../OfficeDrawing/Shapetypes/WordArtText.h | 95 +++++ .../DocDocxConverter/OpenXmlPackage.cpp | 11 - .../DocDocxConverter/VMLPictureMapping.cpp | 32 +- .../DocDocxConverter/VMLPictureMapping.h | 1 + .../DocDocxConverter/VMLShapeMapping.cpp | 137 ++++--- .../DocDocxConverter/VMLShapeMapping.h | 2 +- .../DocDocxConverter/VMLShapeTypeMapping.cpp | 12 +- .../DocFormatLib/Win32/DocFormatLib.vcproj | 384 +++++++++--------- .../DocFormatLib/Win32/DocFormatLib.vcxproj | 1 + 16 files changed, 481 insertions(+), 312 deletions(-) create mode 100644 ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/WordArtText.h diff --git a/ASCOfficeDocFile/Common/XmlTools.h b/ASCOfficeDocFile/Common/XmlTools.h index 95fcb9c02c..f6fcdf4cc7 100644 --- a/ASCOfficeDocFile/Common/XmlTools.h +++ b/ASCOfficeDocFile/Common/XmlTools.h @@ -14,7 +14,19 @@ using namespace std; #include "../../Common/DocxFormat/Source/Base/ASCString.h" #endif +inline static std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace) +{ + size_t pos = 0; + while ((pos = subject.find(search, pos)) != std::string::npos) + { + subject.replace(pos, search.length(), replace); + pos += replace.length(); + } + + return subject; +} +//---------------------------------------------------------------- namespace XMLTools { /*======================================================================================================== diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index 181b7da5b0..e9bccf1c74 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -614,7 +614,7 @@ namespace DocFileFormat if (pShape) { m_pXmlWriter->WriteNodeBegin (_T("w:pict")); - VMLShapeMapping oVmlWriter (m_pXmlWriter, pSpa, NULL, m_context, _caller); + VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller); pShape->Convert(&oVmlWriter); m_pXmlWriter->WriteNodeEnd (_T("w:pict")); } @@ -626,15 +626,18 @@ namespace DocFileFormat if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)) { - VMLPictureMapping* pVMLPicture = new VMLPictureMapping(m_context, m_pXmlWriter, false, _caller); - if (pVMLPicture) + m_pXmlWriter->WriteNodeBegin (_T("w:pict")); + if (oPicture.blipStoreEntry) { - m_pXmlWriter->WriteNodeBegin (_T("w:pict")); - oPicture.Convert (pVMLPicture); - m_pXmlWriter->WriteNodeEnd (_T("w:pict")); - - RELEASEOBJECT(pVMLPicture); + VMLPictureMapping oVMLPicture(m_context, m_pXmlWriter, false, _caller); + oPicture.Convert (&oVMLPicture); } + else + { + VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, &oPicture, _caller); + oPicture.shapeContainer->Convert(&oVmlWriter); + } + m_pXmlWriter->WriteNodeEnd (_T("w:pict")); } } else if ((TextMark::AutoNumberedFootnoteReference == c) && fSpec) diff --git a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp index 9e553545f4..775b28948a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp @@ -462,7 +462,7 @@ namespace DocFileFormat } else { - VMLShapeMapping oShape (m_pXmlWriter, NULL, &pict, m_context,this,true); + VMLShapeMapping oShape (m_context, m_pXmlWriter, NULL, &pict, this,true); pict.shapeContainer->Convert(&oShape); } diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shape.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shape.h index cf08d2b7a8..74898542ea 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shape.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shape.h @@ -73,7 +73,13 @@ namespace DocFileFormat fHaveAnchor = FormatUtils::BitmaskToBool( flag, 0x200 ); fBackground = FormatUtils::BitmaskToBool( flag, 0x400 ); fHaveSpt = FormatUtils::BitmaskToBool( flag, 0x800 ); - shapeType = ShapeTypeFactory::NewShapeType((MSOSPT)Instance); + + if (Instance > 0) + shapeType = ShapeTypeFactory::NewShapeType((MSOSPT)Instance); + else if (!fHaveSpt) + { + shapeType = ShapeTypeFactory::NewShapeType(msosptNotPrimitive); + } } virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeType.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeType.h index 2d946b9199..0fd04d136a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeType.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeType.h @@ -315,6 +315,9 @@ namespace DocFileFormat /// By default nothing is locked. ProtectionBooleanProperties Lock; + /// + std::wstring Textpath; + protected: unsigned int TypeCode; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp index 259b65470b..824efa3d5b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp @@ -37,6 +37,7 @@ #include "Shapetypes/BracketsType.h" #include "Shapetypes/CalloutsType.h" #include "Shapetypes/Connector.h" +#include "Shapetypes/WordArtText.h" namespace DocFileFormat { @@ -81,7 +82,6 @@ namespace DocFileFormat case msosptDonut : { pShape = new DonutType(); } break; case msosptPictureFrame : { pShape = new PictureFrameType(); } break; case msosptTextBox : { pShape = new TextboxType(); } break; - case msosptTextStop : { pShape = new TextStop(); } break; case msosptBevel : { pShape = new BevelType(); } break; case msosptPentagon : { pShape = new PentagonType(); } break; case msosptFoldedCorner : { pShape = new FoldedCornerlType(); } break; @@ -182,6 +182,50 @@ namespace DocFileFormat case msosptCurvedConnector3 : { pShape = new CurvedConnector3(); } break; case msosptCurvedConnector4 : { pShape = new CurvedConnector4(); } break; case msosptCurvedConnector5 : { pShape = new CurvedConnector5(); } break; +//wordArt + + case msosptTextStop : { pShape = new WordArtTextStop(); } break; + case msosptTextArchUpCurve : { pShape = new WordArtTextArchUpCurve(); } break; + case msosptTextPlainText : + //без детализаций - todooo прописать формулы + case msosptTextTriangle : + case msosptTextTriangleInverted : + case msosptTextChevron : + case msosptTextChevronInverted : + case msosptTextRingInside : + case msosptTextRingOutside : + case msosptTextArchDownCurve : + case msosptTextCircleCurve : + case msosptTextButtonCurve : + case msosptTextArchUpPour : + case msosptTextArchDownPour : + case msosptTextCirclePour : + case msosptTextButtonPour : + case msosptTextCurveUp : + case msosptTextCurveDown : + case msosptTextCascadeUp : + case msosptTextCascadeDown : + case msosptTextWave1 : + case msosptTextWave2 : + case msosptTextWave3 : + case msosptTextWave4 : + case msosptTextInflate : + case msosptTextDeflate : + case msosptTextInflateBottom : + case msosptTextDeflateBottom : + case msosptTextInflateTop : + case msosptTextDeflateTop : + case msosptTextDeflateInflate : + case msosptTextDeflateInflateDeflate : + case msosptTextFadeRight : + case msosptTextFadeLeft : + case msosptTextFadeUp : + case msosptTextFadeDown : + case msosptTextSlantUp : + case msosptTextSlantDown : + case msosptTextCanUp : + case msosptTextCanDown : + { pShape = new WordArtTextType(TypeCode); } break; default : { pShape = NULL; } break; } diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/TextboxType.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/TextboxType.h index 3ff506ac51..7ca2ba619e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/TextboxType.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/TextboxType.h @@ -12,6 +12,7 @@ namespace DocFileFormat ShapeConcentricFill = true; Joins = miter; Path = _T("m,l,21600r21600,l21600,xe"); + } virtual ~TextboxType() @@ -19,31 +20,4 @@ namespace DocFileFormat } }; - - class TextStop : public ShapeType - { - public: - TextStop () : ShapeType(msosptTextStop) - { - Joins = miter; - Path = _T("m0@4l@2,l@3,l21600@4em0@5l@2,21600l@3,21600l21600@5e"); - - Formulas.push_back(_T("val #0")); - Formulas.push_back(_T("prod width 1 3")); - Formulas.push_back(_T("sum 0 @1 0")); - Formulas.push_back(_T("sum width 0 @1")); - Formulas.push_back(_T("sum 0 @0 0")); - Formulas.push_back(_T("sum height 0 @0")); - - AdjustmentValues = _T("5400"); - Handle one; - one.position = _T("0,@0"); - Handles.push_back (one); - } - - virtual ~TextStop () - { - - } - }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/WordArtText.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/WordArtText.h new file mode 100644 index 0000000000..f28699827b --- /dev/null +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Shapetypes/WordArtText.h @@ -0,0 +1,95 @@ +#pragma once + +#include "../ShapeType.h" + +namespace DocFileFormat +{ + class WordArtTextType: public ShapeType + { + public: + WordArtTextType(int txStyle): + ShapeType((MSOSPT)txStyle) + { + this->Path = _T( "m@7,l@8,m@5,21600l@6,21600e" ); + this->Textpath = _T(" on=\"t\" style=\"v-text-kern:t\" fitpath=\"t\""); + + AdjustmentValues = _T("10800"); + } + + virtual ~WordArtTextType() + { + } + }; + + class WordArtTextStop : public WordArtTextType + { + public: + WordArtTextStop () : WordArtTextType(msosptTextStop) + { + this->Joins = miter; + this->Path = _T("m0@4l@2,l@3,l21600@4em0@5l@2,21600l@3,21600l21600@5e"); + + Formulas.push_back(_T("val #0")); + Formulas.push_back(_T("prod width 1 3")); + Formulas.push_back(_T("sum 0 @1 0")); + Formulas.push_back(_T("sum width 0 @1")); + Formulas.push_back(_T("sum 0 @0 0")); + Formulas.push_back(_T("sum height 0 @0")); + + AdjustmentValues = _T("5400"); + Handle one; + one.position = _T("0,@0"); + Handles.push_back (one); + } + + virtual ~WordArtTextStop () + { + + } + }; + + class WordArtTextArchUpCurve : public WordArtTextType + { + public: + WordArtTextArchUpCurve () : WordArtTextType(msosptTextArchUpCurve) + { + Path = _T("al10800,10800,10800,10800@2@14e"); + + Formulas.push_back(_T("val #1")); + Formulas.push_back(_T("val #0")); + Formulas.push_back(_T("sum 0 0 #0")); + Formulas.push_back(_T("sumangle #0 0 180")); + Formulas.push_back(_T("sumangle #0 0 90")); + Formulas.push_back(_T("prod @4 2 1")); + Formulas.push_back(_T("sumangle #0 90 0")); + Formulas.push_back(_T("prod @6 2 1")); + Formulas.push_back(_T("abs #0")); + Formulas.push_back(_T("sumangle @8 0 90")); + Formulas.push_back(_T("if @9 @7 @5")); + Formulas.push_back(_T("sumangle @10 0 360")); + Formulas.push_back(_T("if @10 @11 @10")); + Formulas.push_back(_T("sumangle @12 0 360")); + Formulas.push_back(_T("if @12 @13 @12")); + Formulas.push_back(_T("sum 0 0 @14")); + Formulas.push_back(_T("val 10800")); + Formulas.push_back(_T("cos 10800 #0")); + Formulas.push_back(_T("sin 10800 #0")); + Formulas.push_back(_T("sum @17 10800 0")); + Formulas.push_back(_T("sum @18 10800 0")); + Formulas.push_back(_T("sum 10800 0 @17")); + Formulas.push_back(_T("if @9 0 21600")); + Formulas.push_back(_T("sum 10800 0 @18")); + + AdjustmentValues = _T("11796480"); + Handle one; + one.position = _T("@16,#0"); + one.polar = _T("10800,10800"); + Handles.push_back (one); + } + + virtual ~WordArtTextArchUpCurve () + { + + } + }; +} diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp index c56c08faa7..5f44b9ce37 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp @@ -12,18 +12,7 @@ #include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h" #include "../../DesktopEditor/common/File.h" -inline static std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace) -{ - size_t pos = 0; - while ((pos = subject.find(search, pos)) != std::string::npos) - { - subject.replace(pos, search.length(), replace); - pos += replace.length(); - } - - return subject; -} namespace DocFileFormat { diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp index 64e62afe06..0756c21e0d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp @@ -1,8 +1,25 @@  #include "VMLPictureMapping.h" +#include "OfficeDrawing/GeometryBooleanProperties.h" +#include "OfficeDrawing/GeometryTextBooleanProperties.h" + +#include "../../DesktopEditor/common/String.h" + + namespace DocFileFormat { + void VMLPictureMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const + { + if ( b != NULL ) + { + b->operator += ( propName ); + b->operator += ( _T( ":" ) ); + b->operator += ( propValue ); + b->operator +=( _T( ";" ) ); + } + } + VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XmlUtils::CXmlWriter* writer, bool olePreview, IMapping* caller, bool isBulletPicture) : PropertiesMapping(writer) { m_ctx = ctx; @@ -37,7 +54,7 @@ namespace DocFileFormat { PictureDescriptor* pict = static_cast(visited); - if (CopyPicture(pict->blipStoreEntry)) + if (pict->shapeContainer || pict->blipStoreEntry) { Shape* shape = static_cast(*(pict->shapeContainer->Children.begin())); list options = pict->shapeContainer->ExtractOptions(); @@ -148,10 +165,13 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE ); - //v:imageData - appendValueAttribute(m_imageData, _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str()); - appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" )); - m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str()); + if (CopyPicture(pict->blipStoreEntry)) + { + //v:imageData + appendValueAttribute(m_imageData, _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str()); + appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" )); + m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str()); + } //borders writePictureBorder( _T( "bordertop" ), pict->brcTop ); @@ -175,7 +195,7 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeBegin( ( wstring( _T( "w10:" ) ) + wstring( name ) ).c_str(), true ); m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() ); m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() ); - m_pXmlWriter->WriteNodeEnd( _T( "" ), true ); + m_pXmlWriter->WriteNodeEnd ( _T( "" ), true ); } /// Copies the picture from the binary stream to the zip archive diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h index 4c3a2c2962..d2d8559c0d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h @@ -24,6 +24,7 @@ namespace DocFileFormat private: /// Writes a border element void writePictureBorder (const wchar_t* name, const BorderCode* brc); + void appendStyleProperty( wstring* b, const wstring& propName, const wstring& propValue ) const; protected: /// Copies the picture from the binary stream to the zip archive diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index c6edf62abe..8c0ea5f2b0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -21,9 +21,11 @@ #include "OfficeDrawing/GroupShapeBooleanProperties.h" #include "OfficeDrawing/ProtectionBooleanProperties.h" +#include "../../DesktopEditor/common/String.h" + namespace DocFileFormat { - VMLShapeMapping::VMLShapeMapping (XmlUtils::CXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, ConversionContext* pConv, IMapping* pCaller, bool bullet) : PropertiesMapping(pWriter) + VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XmlUtils::CXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool bullet) : PropertiesMapping(pWriter) { m_bBullet = bullet; @@ -126,7 +128,7 @@ namespace DocFileFormat ShapeContainer* pChildShape = static_cast(container->Children[i]); if (pChildShape) { - VMLShapeMapping vmlShapeMapping(m_pXmlWriter, m_pSpa, NULL, m_ctx, m_pCaller); + VMLShapeMapping vmlShapeMapping(m_ctx, m_pXmlWriter, m_pSpa, NULL, m_pCaller); pChildShape->Convert(&vmlShapeMapping); } } @@ -148,7 +150,7 @@ namespace DocFileFormat { m_pXmlWriter->WriteNodeBegin( _T( "w10:wrap" ), TRUE ); m_pXmlWriter->WriteAttribute( _T( "type" ), wrap.c_str() ); - m_pXmlWriter->WriteNodeEnd( _T( "w10:wrap" ), TRUE ); + m_pXmlWriter->WriteNodeEnd ( _T( "w10:wrap" ), TRUE ); } } @@ -221,17 +223,16 @@ namespace DocFileFormat int nAdjValues = 0; int nLTxID = -1; - std::wstring adjValues[8]; - ShadowStyleBooleanProperties shadowBoolean(0); - std::vector arrInscribe; + std::wstring adjValues[8]; + ShadowStyleBooleanProperties shadowBoolean(0); + std::vector arrInscribe; std::list::const_iterator end = options.end(); for (std::list::const_iterator iter = options.begin(); iter != end; ++iter) { switch (iter->pid) { - //BOOLEANS - + //BOOLEANS case geometryBooleans: { GeometryBooleanProperties booleans(iter->op); @@ -676,61 +677,65 @@ namespace DocFileFormat case dyTextTop:{ndyTextTop = (int)iter->op;break;} case dxTextRight:{ndxTextRight = (int)iter->op;break;} case dyTextBottom:{ndyTextBottom = (int)iter->op;break;} - /*// TEXT PATH (Word Art) + + // TEXT PATH (Word Art) - case ShapeOptions.PropertyId.gtextUNICODE: - String text = Encoding.Unicode.GetString(entry.opComplex); - text = text.Replace("\n", ""); - text = text.Replace("\0", ""); - appendValueAttribute(_textpath, "", "string", text, ""); - break; + case gtextUNICODE: + { + std::wstring text = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op-2)/2); - case ShapeOptions.PropertyId.gtextFont: - String font = Encoding.Unicode.GetString(entry.opComplex); - font = font.Replace("\0", ""); - appendStyleProperty(_textPathStyle, "font-family", "\""+font+"\""); - break; + text = FormatUtils::XmlEncode(text); + text = ReplaceString(text, _T("\n"), _T(" ")); + appendValueAttribute(&m_textpath, L"string", text.c_str()); + }break; - case ShapeOptions.PropertyId.GeometryTextBooleanProperties: - GeometryTextBooleanProperties props = new GeometryTextBooleanProperties(entry.op); - if (props.fUsegtextFBestFit && props.gtextFBestFit) - { - appendValueAttribute(_textpath, "", "fitshape", "t", ""); - } - if (props.fUsegtextFShrinkFit && props.gtextFShrinkFit) - { - appendValueAttribute(_textpath, "", "trim", "t", ""); - } - if (props.fUsegtextFVertical && props.gtextFVertical) - { - appendStyleProperty(_textPathStyle, "v-rotate-letters", "t"); - //_twistDimension = true; - } - if (props.fUsegtextFKern && props.gtextFKern) - { - appendStyleProperty(_textPathStyle, "v-text-kern", "t"); - } - if (props.fUsegtextFItalic && props.gtextFItalic) - { - appendStyleProperty(_textPathStyle, "font-style", "italic"); - } - if (props.fUsegtextFBold && props.gtextFBold) - { - appendStyleProperty(_textPathStyle, "font-weight", "bold"); - } - break;*/ + case gtextFont: + { + std::wstring font = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op-8)/2); + font = std::wstring(_T("\"")) + font + std::wstring(_T("\"")); + appendStyleProperty(&m_textPathStyle, L"font-family", font); + }break; - // PATH - case shapePath : + case geometryTextBooleanProperties: + { + GeometryTextBooleanProperties props(iter->op); + if (props.fUsegtextFBestFit && props.gtextFBestFit) { - bHavePath = true; - - std::wstring path = ParsePath(options); - - if (false == path.empty()) - m_pXmlWriter->WriteAttribute (_T( "path" ), path.c_str()); + appendValueAttribute(&m_textpath, L"fitshape", _T("t")); } - break; + if (props.fUsegtextFShrinkFit && props.gtextFShrinkFit) + { + appendValueAttribute(&m_textpath, L"trim", _T("t")); + } + if (props.fUsegtextFVertical && props.gtextFVertical) + { + appendStyleProperty(&m_textPathStyle, L"v-rotate-letters", L"t"); + //_twistDimension = true; + } + if (props.fUsegtextFKern && props.gtextFKern) + { + appendStyleProperty(&m_textPathStyle, L"v-text-kern", L"t"); + } + if (props.fUsegtextFItalic && props.gtextFItalic) + { + appendStyleProperty(&m_textPathStyle, L"font-style", L"italic"); + } + if (props.fUsegtextFBold && props.gtextFBold) + { + appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold"); + } + }break; + + // PATH + case shapePath : + { + bHavePath = true; + + std::wstring path = ParsePath(options); + + if (false == path.empty()) + m_pXmlWriter->WriteAttribute (_T( "path" ), path.c_str()); + }break; } } @@ -912,7 +917,7 @@ namespace DocFileFormat { m_pXmlWriter->WriteNodeBegin( _T( "w10:wrap" ), TRUE ); m_pXmlWriter->WriteAttribute( _T( "type" ), wrap.c_str() ); - m_pXmlWriter->WriteNodeEnd( _T( "w10:wrap" ), TRUE ); + m_pXmlWriter->WriteNodeEnd ( _T( "w10:wrap" ), TRUE ); } } @@ -931,7 +936,7 @@ namespace DocFileFormat // text path if (m_textpath.GetAttributeCount()) { - appendValueAttribute(&m_textpath, _T( "style" ), m_textPathStyle.c_str()); + appendValueAttribute(&m_textpath, _T( "style" ), FormatUtils::XmlEncode(m_textPathStyle).c_str()); m_pXmlWriter->WriteString(m_textpath.GetXMLString().c_str()); } @@ -992,6 +997,13 @@ namespace DocFileFormat } WriteEndShapeNode(pShape); + + //ShapeType + if (NULL != pShape->GetShapeType() && !m_bBullet) + { + VMLShapeTypeMapping oXmlMapper(m_pXmlWriter); + pShape->GetShapeType()->Convert(&oXmlMapper); + } } } } @@ -1023,13 +1035,6 @@ namespace DocFileFormat } else { - //SHAPE - if (NULL != pShape->GetShapeType() && !m_bBullet) - { - VMLShapeTypeMapping oXmlMapper(m_pXmlWriter); - pShape->GetShapeType()->Convert(&oXmlMapper); - } - m_pXmlWriter->WriteNodeBegin(_T( "v:shape" ), TRUE); } } diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index 7678001f12..98dc9bd2de 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -28,7 +28,7 @@ namespace DocFileFormat { public: - VMLShapeMapping (XmlUtils::CXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, ConversionContext* ctx , IMapping* caller, bool bullet = false); + VMLShapeMapping (ConversionContext* ctx ,XmlUtils::CXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false); virtual ~VMLShapeMapping(); virtual void Apply(IVisitable* visited); diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp index d01abdc8ef..8a99fa7c2e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp @@ -39,9 +39,10 @@ namespace DocFileFormat m_pXmlWriter->WriteAttribute( _T("adj"), pShape->AdjustmentValues.c_str() ); // Path - if (pShape->Path.length()) + if (!pShape->Path.empty()) m_pXmlWriter->WriteAttribute( _T("path"), pShape->Path.c_str() ); + //Default fill / stroke if ( !pShape->Filled ) { @@ -58,8 +59,15 @@ namespace DocFileFormat m_pXmlWriter->WriteAttribute( _T( "o:preferrelative" ), _T( "t" ) ); } - m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false ); + m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );//закрытие атрибутов + //Textpath + if (!pShape->Textpath.empty()) + { + m_pXmlWriter->WriteNodeBegin( _T( "v:textpath" ), true ); + m_pXmlWriter->WriteString( pShape->Textpath.c_str() ); + m_pXmlWriter->WriteNodeEnd( _T( "" ), true ); + } // Stroke m_pXmlWriter->WriteNodeBegin( _T( "v:stroke" ), true ); m_pXmlWriter->WriteAttribute( _T( "joinstyle" ), FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ).c_str() ); diff --git a/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj b/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj index 088a61fadc..e192a0ce7f 100644 --- a/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj +++ b/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj @@ -359,10 +359,6 @@ - - @@ -391,14 +387,6 @@ RelativePath="..\..\DocDocxConverter\ByteStructure.h" > - - - - @@ -407,10 +395,6 @@ RelativePath="..\..\DocDocxConverter\CharacterRange.h" > - - @@ -431,14 +415,6 @@ RelativePath="..\..\DocDocxConverter\DateAndTime.h" > - - - - @@ -463,10 +439,6 @@ RelativePath="..\..\DocDocxConverter\EndnoteDescriptor.h" > - - @@ -487,30 +459,10 @@ RelativePath="..\..\DocDocxConverter\FontFamilyName.h" > - - - - - - - - - - @@ -543,14 +495,6 @@ RelativePath="..\..\DocDocxConverter\HeaderAndFooterTable.h" > - - - - @@ -567,14 +511,6 @@ RelativePath="..\..\DocDocxConverter\LanguageId.h" > - - - - @@ -615,26 +551,10 @@ RelativePath="..\..\DocDocxConverter\ListTable.h" > - - - - - - - - @@ -643,10 +563,6 @@ RelativePath="..\..\DocDocxConverter\OleObject.h" > - - @@ -663,14 +579,6 @@ RelativePath="..\..\DocDocxConverter\ParagraphHeight.h" > - - - - @@ -703,14 +611,6 @@ RelativePath="..\..\DocDocxConverter\Plex.h" > - - - - @@ -735,26 +635,10 @@ RelativePath="..\..\DocDocxConverter\SectionDescriptor.h" > - - - - - - - - @@ -807,70 +691,22 @@ RelativePath="..\..\DocDocxConverter\StyleSheetInformation.h" > - - - - - - - - - - - - - - - - - - - - - - - - @@ -879,30 +715,6 @@ RelativePath="..\..\DocDocxConverter\VirtualStreamReader.h" > - - - - - - - - - - - - @@ -1217,8 +1029,204 @@ RelativePath="..\..\DocDocxConverter\OfficeDrawing\Shapetypes\TrapezoidType.h" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +