From c0d38c97f8a149a6479fd389638b924efedf641f Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 7 Mar 2019 18:30:28 +0300 Subject: [PATCH] DocFormat - fix bug #40798 --- .../DocDocxConverter/DocumentMapping.cpp | 27 ++- .../DocDocxConverter/DocumentMapping.h | 1 + .../DocDocxConverter/VMLPictureMapping.cpp | 31 ++- .../DocDocxConverter/VMLPictureMapping.h | 3 +- .../DocDocxConverter/VMLShapeMapping.cpp | 228 +++++++++++------- .../DocDocxConverter/VMLShapeMapping.h | 14 +- .../DocFormatTest/DocFormatTest.vcproj | 8 + 7 files changed, 195 insertions(+), 117 deletions(-) diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index 04f114ca11..b2943a39c9 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -716,7 +716,7 @@ namespace DocFileFormat RELEASEOBJECT( chpxs ); } } - oleWriter.WriteString( _lastOLEObject ); + oleWriter.WriteString( _lastOLEObject ); _lastOLEObject.clear(); oleWriter.WriteNodeEnd( L"w:object" ); if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation) @@ -912,6 +912,7 @@ namespace DocFileFormat pSpa = static_cast(m_document->OfficeDrawingPlexHeader->GetStruct(headerCp)); } + bool bPicture = false; if (pSpa) { PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion); @@ -925,6 +926,8 @@ namespace DocFileFormat pShape->Convert(&oVmlWriter); m_pXmlWriter->WriteNodeEnd (L"w:pict"); + + bPicture = true; } if (!pSpa->primitives.empty()) @@ -933,8 +936,13 @@ namespace DocFileFormat VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller); pSpa->primitives.Convert(&oVmlWriter); m_pXmlWriter->WriteNodeEnd (L"w:pict"); + + bPicture = true; } } + + if ((false == _fieldLevels.empty()) && (_fieldLevels.back().bSeparate)) + _fieldLevels.back().bResult = bPicture; } else if (TextMark::Picture == code && fSpec) { @@ -1004,10 +1012,23 @@ namespace DocFileFormat oPicture.shapeContainer->Convert(&oVmlMapper); } - pictWriter.WriteNodeEnd (L"w:pict"); + pictWriter.WriteNodeEnd (L"w:pict"); if (!bFormula) - m_pXmlWriter->WriteString(pictWriter.GetXmlString()); + { + if (false == _fieldLevels.empty()) + { + if (_fieldLevels.back().bSeparate && !_fieldLevels.back().bResult) //ege15.doc + { + m_pXmlWriter->WriteString(pictWriter.GetXmlString()); + _fieldLevels.back().bResult = true; + } + } + else + { + m_pXmlWriter->WriteString(pictWriter.GetXmlString()); + } + } } } diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h index d17d1c1b36..ed10a5588f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h @@ -161,6 +161,7 @@ namespace DocFileFormat { bool bBegin = false; bool bSeparate = false; + bool bResult = false; //bool bInstrText = false; bool bEnd = false; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp index 876ae1499b..8ea66b38af 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp @@ -220,15 +220,12 @@ namespace DocFileFormat return res; } //--------------------------------------------------------------- - void VMLPictureMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const + void VMLPictureMapping::appendStyleProperty(std::wstring& style, const std::wstring& propName, const std::wstring& propValue) const { - if ( b != NULL ) - { - b->operator += ( propName ); - b->operator += ( L":" ); - b->operator += ( propValue ); - b->operator +=( L";" ); - } + style += ( propName ); + style += ( L":" ); + style += ( propValue ); + style +=( L";" ); } VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer) @@ -295,6 +292,7 @@ namespace DocFileFormat type.Convert( vmlShapeTypeMapping ); RELEASEOBJECT( vmlShapeTypeMapping ); + } else if (pict->embeddedData) { @@ -420,23 +418,23 @@ namespace DocFileFormat std::wstring v = strHeight; strHeight = strWidth; strWidth = v; - appendStyleProperty(&strStyle, L"rotation", FormatUtils::DoubleToWideString(dAngle)); + appendStyleProperty(strStyle, L"rotation", FormatUtils::DoubleToWideString(dAngle)); }break; case posh: { - appendStyleProperty(&strStyle, L"mso-position-horizontal", VMLShapeMapping::mapHorizontalPosition((PositionHorizontal)iter->op)); + appendStyleProperty(strStyle, L"mso-position-horizontal", VMLShapeMapping::mapHorizontalPosition((PositionHorizontal)iter->op)); }break; case posrelh: { - appendStyleProperty(&strStyle, L"mso-position-horizontal-relative", VMLShapeMapping::mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op)); + appendStyleProperty(strStyle, L"mso-position-horizontal-relative", VMLShapeMapping::mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op)); }break; case posv: { - appendStyleProperty(&strStyle, L"mso-position-vertical", VMLShapeMapping::mapVerticalPosition((PositionVertical)iter->op)); + appendStyleProperty(strStyle, L"mso-position-vertical", VMLShapeMapping::mapVerticalPosition((PositionVertical)iter->op)); }break; case posrelv: { - appendStyleProperty(&strStyle, L"mso-position-vertical-relative", VMLShapeMapping::mapVerticalPositionRelative((PositionVerticalRelative)iter->op)); + appendStyleProperty(strStyle, L"mso-position-vertical-relative", VMLShapeMapping::mapVerticalPositionRelative((PositionVerticalRelative)iter->op)); }break; case groupShapeBooleans: { @@ -445,7 +443,7 @@ namespace DocFileFormat if (booleans->fUsefBehindDocument && booleans->fBehindDocument) { //The shape is behind the text, so the z-index must be negative. - appendStyleProperty(&strStyle, L"z-index", L"-1" ); + appendStyleProperty(strStyle, L"z-index", L"-1" ); } //else if (!m_isInlinePicture) //{ @@ -454,7 +452,7 @@ namespace DocFileFormat if (booleans->fHidden && booleans->fUsefHidden) { - appendStyleProperty(&strStyle, L"visibility", L"hidden"); + appendStyleProperty(strStyle, L"visibility", L"hidden"); } }break; default: @@ -499,7 +497,8 @@ namespace DocFileFormat appendValueAttribute(m_imageData, L"o:title", L"" ); m_pXmlWriter->WriteString(m_imageData->GetXMLString()); } - + else + m_isPictureBroken = true; {//borders writePictureBorder( L"bordertop", pict->brcTop ); diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h index 979f6b214b..4f7dca84d1 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h @@ -56,7 +56,7 @@ namespace DocFileFormat private: /// Writes a border element void writePictureBorder (const std::wstring & name, const BorderCode* brc); - void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const; + void appendStyleProperty( std::wstring& style, const std::wstring& propName, const std::wstring& propValue ) const; bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString ); bool ParseEmbeddedBlob(const std::string & xmlString, std::wstring & newXmlString); std::wstring GetShapeID(const Shape* pShape) const; @@ -74,6 +74,7 @@ namespace DocFileFormat bool m_isBullete; bool m_isEquation; bool m_isEmbedded; + bool m_isPictureBroken; std::string m_embeddedData; std::wstring m_equationXml; std::wstring m_blobXml; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index c56f3e1b58..a598fee574 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -52,6 +52,7 @@ namespace DocFileFormat { m_isInlineShape = isInlineShape; m_isBullete = false; + m_isPictureBroken = false; m_pSpa = pSpa; m_pCaller = pCaller; @@ -277,6 +278,7 @@ namespace DocFileFormat bool layoutInCell = true; //anmeldebogenfos.doc bool b3D = false; bool bShadow = false; + bool bPicturePresent = false; int ndxTextLeft = -1; int ndyTextTop = -1; @@ -565,6 +567,8 @@ namespace DocFileFormat { appendValueAttribute(&m_fill, L"r:id", std::wstring(( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) )); } + + bPicturePresent = true; }break; case fillBlipName: { @@ -647,6 +651,7 @@ namespace DocFileFormat appendValueAttribute(&m_imagedata, L"r:id", ( std::wstring( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) )); } } + bPicturePresent = true; }break; case pibName: { @@ -751,11 +756,11 @@ namespace DocFileFormat break; case 1: case 5://верт (склони голову направо) - appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical"); + appendStyleProperty(sTextboxStyle, L"layout-flow", L"vertical"); break; case 2://верт (склони голову налево) - appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical"); - appendStyleProperty(&sTextboxStyle, L"mso-layout-flow-alt", L"bottom-to-top"); + appendStyleProperty(sTextboxStyle, L"layout-flow", L"vertical"); + appendStyleProperty(sTextboxStyle, L"mso-layout-flow-alt", L"bottom-to-top"); break; } }break; @@ -789,18 +794,18 @@ namespace DocFileFormat if (i < font.size()) font.erase(font.begin() + i, font.end()); font = std::wstring(L"\"") + font + std::wstring(L"\""); - appendStyleProperty(&m_textPathStyle, L"font-family", font); + appendStyleProperty(m_textPathStyle, L"font-family", font); } }break; case gtextSize: { std::wstring fontSize = FormatUtils::IntToWideString(iter->op/65535); - appendStyleProperty(&m_textPathStyle, L"font-size", fontSize + L"pt"); + appendStyleProperty(m_textPathStyle, L"font-size", fontSize + L"pt"); }break; case gtextSpacing: { std::wstring spacing = FormatUtils::IntToWideString(iter->op); - appendStyleProperty(&m_textPathStyle, L"v-text-spacing", spacing + L"f"); + appendStyleProperty(m_textPathStyle, L"v-text-spacing", spacing + L"f"); }break; case geometryTextBooleanProperties: { @@ -815,20 +820,20 @@ namespace DocFileFormat } if (props->fUsegFVertical && props->fVertical) { - appendStyleProperty(&m_textPathStyle, L"v-rotate-letters", L"t"); + appendStyleProperty(m_textPathStyle, L"v-rotate-letters", L"t"); //_twistDimension = true; } if (props->fUsegFKern && props->fKern) { - appendStyleProperty(&m_textPathStyle, L"v-text-kern", L"t"); + appendStyleProperty(m_textPathStyle, L"v-text-kern", L"t"); } if (props->fUsegFItalic && props->fItalic) { - appendStyleProperty(&m_textPathStyle, L"font-style", L"italic"); + appendStyleProperty(m_textPathStyle, L"font-style", L"italic"); } if (props->fUsegFBold && props->fBold) { - appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold"); + appendStyleProperty(m_textPathStyle, L"font-weight", L"bold"); } }break; default: @@ -873,10 +878,10 @@ namespace DocFileFormat m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString( *xCoord ) + L"," + FormatUtils::IntToWideString( *yCoord ) )); } - int nCode = 0; + int nCode = 0; if (pShape->GetShapeType()) { - nCode = pShape->GetShapeType()->GetTypeCode(); + nCode = pShape->GetShapeType()->GetTypeCode(); } if (DocFileFormat::msosptRoundRectangle == nCode) @@ -886,6 +891,11 @@ namespace DocFileFormat m_pXmlWriter->WriteAttribute(L"arcsize", m_nAdjValues[0]); } } + else if (DocFileFormat::msosptPictureFrame == nCode) + { + if (bPicturePresent == false) + m_isPictureBroken = true; + } else { if (nAdjValues > 0) @@ -1391,9 +1401,9 @@ namespace DocFileFormat } } - void VMLShapeMapping::AppendDimensionToStyle(std::wstring* style, const PictureDescriptor* pict, bool twistDimensions) const + void VMLShapeMapping::AppendDimensionToStyle(std::wstring& style, const PictureDescriptor* pict, bool twistDimensions) const { - if ( ( style != NULL ) && ( pict != NULL ) ) + if ( pict != NULL ) { double xScaling = pict->mx / 1000.0; double yScaling = pict->my / 1000.0; @@ -1410,26 +1420,24 @@ namespace DocFileFormat std::wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() ); std::wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() ); - style->operator += ( std::wstring( L"width:" ) + widthString + std::wstring( L"pt;" ) ); - style->operator += ( std::wstring( L"height:" ) + heightString + std::wstring( L"pt;" ) ); + style += L"width:" + widthString + L"pt;" ; + style += L"height:" + heightString + L"pt;"; } } - void VMLShapeMapping::AppendDimensionToStyle(std::wstring* style, const Spa* pSpa, bool twistDimensions) const + void VMLShapeMapping::AppendDimensionToStyle(std::wstring& style, const Spa* pSpa, bool twistDimensions) const { - if ( ( style != NULL ) && (pSpa != NULL ) ) + if (pSpa != NULL ) { //append size and position ... //if (pSpa->fAnchorLock ) - //if (pSpa->bx == TEXT && pSpa->by == TEXT) - //{ + if (pSpa->bx == TEXT && pSpa->by == TEXT) + { // appendStyleProperty( style, L"position", L"static" ); - //} - //else - //{ - appendStyleProperty( style, L"position", L"absolute" ); - //} + } + else + appendStylePropertyFirst( style, L"position", L"absolute" ); TwipsValue left (pSpa->xaLeft); TwipsValue top (pSpa->yaTop); @@ -1452,9 +1460,9 @@ namespace DocFileFormat } } - void VMLShapeMapping::AppendDimensionToStyle(std::wstring* style, const ChildAnchor* anchor, bool twistDimensions) const + void VMLShapeMapping::AppendDimensionToStyle(std::wstring& style, const ChildAnchor* anchor, bool twistDimensions) const { - if ((style != NULL) && (anchor != NULL)) + if (anchor != NULL) { DocFileFormat::Rectangle bounds = anchor->rcgBounds; @@ -1464,34 +1472,40 @@ namespace DocFileFormat bounds.topLeftAngle.y = static_cast(((anchor->Bottom + anchor->Top) * 0.5 - (anchor->Right - anchor->Left) * 0.5)); } - appendStyleProperty(style, L"position", L"absolute"); - appendStyleProperty(style, L"left", FormatUtils::IntToWideString(bounds.topLeftAngle.x)); - appendStyleProperty(style, L"top", FormatUtils::IntToWideString(bounds.topLeftAngle.y)); + appendStylePropertyFirst(style, L"top", FormatUtils::IntToWideString(bounds.topLeftAngle.y)); + appendStylePropertyFirst(style, L"left", FormatUtils::IntToWideString(bounds.topLeftAngle.x)); + appendStylePropertyFirst(style, L"position", L"absolute"); if (twistDimensions) { - appendStyleProperty(style, L"width", FormatUtils::IntToWideString(bounds.size.cy)); - appendStyleProperty(style, L"height", FormatUtils::IntToWideString(bounds.size.cx)); + appendStylePropertyFirst(style, L"width", FormatUtils::IntToWideString(bounds.size.cy)); + appendStylePropertyFirst(style, L"height", FormatUtils::IntToWideString(bounds.size.cx)); } else { - appendStyleProperty(style, L"width", FormatUtils::IntToWideString(bounds.size.cx)); - appendStyleProperty(style, L"height", FormatUtils::IntToWideString(bounds.size.cy)); + appendStylePropertyFirst(style, L"width", FormatUtils::IntToWideString(bounds.size.cx)); + appendStylePropertyFirst(style, L"height", FormatUtils::IntToWideString(bounds.size.cy)); } } } - void VMLShapeMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const + void VMLShapeMapping::appendStyleProperty(std::wstring& style, const std::wstring& propName, const std::wstring& propValue) const { - if ( b != NULL ) - { - b->operator += ( propName ); - b->operator += ( L":" ); - b->operator += ( propValue ); - b->operator +=( L";" ); - } + style += ( propName ); + style += ( L":" ); + style += ( propValue ); + style +=( L";" ); + } + void VMLShapeMapping::appendStylePropertyFirst(std::wstring& style, const std::wstring& propName, const std::wstring& propValue) const + { + std::wstring s; + s += ( propName ); + s += ( L":" ); + s += ( propValue ); + s +=( L";" ); + + style = s + style; } - std::wstring VMLShapeMapping::getTextboxAnchor(unsigned int anchor) const { switch ( anchor ) @@ -1560,22 +1574,22 @@ namespace DocFileFormat PositionHorizontalRelative hRel = (PositionHorizontalRelative )hRel_; switch ( hRel ) { - case msoprhMargin: return L"margin"; - case msoprhPage: return L"page"; - case msoprhText: return L"text"; - case msoprhChar: return L"char"; + case msoprhMargin: return L"margin"; //0 //MARGIN = anchor + case msoprhPage: return L"page"; //1 //PAGE + case msoprhText: return L"text"; //2 //TEXT + case msoprhChar: return L"char"; //3 default: return L"margin"; } } - void VMLShapeMapping::AppendOptionsToStyle (std::wstring* oStyle, const std::vector& options, int zIndex) const + void VMLShapeMapping::AppendOptionsToStyle (std::wstring& oStyle, const std::vector& options, int zIndex) const { - bool bRelH = false; - bool bRelV = false; + int nRelH = -1; + int nRelV = -1; - bool bPosH = false; - bool bPosV = false; + int nPosH = -1; + int nPosV = -1; bool bZIndex = false; @@ -1587,36 +1601,40 @@ namespace DocFileFormat // POSITIONING case posh: { - appendStyleProperty(oStyle, L"mso-position-horizontal", mapHorizontalPosition((PositionHorizontal)iter->op)); - bPosH = true; + nPosH = iter->op; }break; case posrelh: { + nRelH = iter->op; appendStyleProperty(oStyle, L"mso-position-horizontal-relative", mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op)); - bRelH = true; }break; case posv: { - appendStyleProperty(oStyle, L"mso-position-vertical", mapVerticalPosition((PositionVertical)iter->op)); - bPosV = true; + nPosV = iter->op; }break; case posrelv: { + nRelV = iter->op; appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative((PositionVerticalRelative)iter->op)); - bRelV = true; }break; // BOOLEANS case groupShapeBooleans: { ODRAW::GroupShapeBooleanProperties* booleans = dynamic_cast(iter.get()); - if (booleans->fUsefBehindDocument && booleans->fBehindDocument && !bZIndex) + if (booleans->fUsefBehindDocument && booleans->fBehindDocument) { - //The shape is behind the text, so the z-index must be negative. - appendStyleProperty(oStyle, L"z-index", L"-1" ); - bZIndex = true; + //за текстом (The shape is behind the text, so the z-index must be negative.) + m_isInlineShape = false; + + if (!bZIndex) + { + appendStyleProperty(oStyle, L"z-index", FormatUtils::IntToWideString(-zIndex - 0x7ffff)); + bZIndex = true; + } } - else if (!m_isInlineShape && !bZIndex) + + if (!m_isInlineShape && !bZIndex) { appendStyleProperty( oStyle, L"z-index", FormatUtils::IntToWideString(zIndex + 0x7ffff)); bZIndex = true; @@ -1664,13 +1682,29 @@ namespace DocFileFormat } } - if (!bRelH && m_pSpa) + if (nRelH < 0 && m_pSpa) { - appendStyleProperty(oStyle, L"mso-position-horizontal-relative", mapHorizontalPositionRelative(m_pSpa->bx)); + if (m_pSpa->bx == TEXT && bZIndex) + { + m_pSpa->bx = PAGE; + } + else + { + nRelH = m_pSpa->bx; + appendStyleProperty(oStyle, L"mso-position-horizontal-relative", mapHorizontalPositionRelative(m_pSpa->bx)); + } } - if (!bRelV && m_pSpa) + if (nRelV < 0 && m_pSpa) { - appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->by)); + if (m_pSpa->by == TEXT && bZIndex) + { + m_pSpa->by = PAGE; + } + else + { + nRelV = m_pSpa->by; + appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->by)); + } } if (!m_isInlineShape && !bZIndex) { @@ -1678,6 +1712,19 @@ namespace DocFileFormat bZIndex = true; } + if (nRelH == 3 && nRelV == 3) + { + m_isInlineShape = true; + } + + if (nPosH >= 0 && !m_isInlineShape) + { + appendStyleProperty(oStyle, L"mso-position-horizontal", mapHorizontalPosition((PositionHorizontal)nPosH)); + } + if (nPosV >= 0 && !m_isInlineShape) + { + appendStyleProperty(oStyle, L"mso-position-vertical", mapVerticalPosition((PositionVertical)nPosV)); + } //if (!bPosH) //{ // appendStyleProperty(oStyle, L"mso-position-horizontal", L"absolute" ); @@ -1721,26 +1768,38 @@ namespace DocFileFormat } } + if ( shape->fFlipH ) + { + appendStyleProperty( style, L"flip", L"x" ); + } + + if ( shape->fFlipV ) + { + appendStyleProperty( style, L"flip", L"y" ); + } + + AppendOptionsToStyle( style, options, zIndex ); + //don't append the dimension info to lines, // because they have "from" and "to" attributes to decline the dimension - if(!shape->is()) + if(false == shape->is()) { if ( (m_pSpa != NULL) && ( anchor == NULL ) ) { //this shape is placed directly in the document, //so use the FSPA to build the style - AppendDimensionToStyle(&style, m_pSpa, twistDimensions); + AppendDimensionToStyle( style, m_pSpa, twistDimensions); } else if (anchor) { //the style is part of a group, //so use the anchor - AppendDimensionToStyle(&style, anchor, twistDimensions); + AppendDimensionToStyle( style, anchor, twistDimensions); } else if (m_pict) { // it is some kind of PICT shape (e.g. WordArt) - AppendDimensionToStyle(&style, m_pict, twistDimensions); + AppendDimensionToStyle( style, m_pict, twistDimensions); } } else @@ -1748,36 +1807,23 @@ namespace DocFileFormat //если не написать тип позиции, то будет inline if ( anchor != NULL ) { - appendStyleProperty( &style, L"position", L"absolute" ); + appendStylePropertyFirst( style, L"position", L"absolute" ); } else if (m_pSpa) { //append size and position ... //if (m_pSpa->fAnchorLock)//это возможность смены привязки , а не ее тип - //if (m_pSpa->bx == TEXT && m_pSpa->by == TEXT) - //{ - // appendStyleProperty( &style, L"position", L"static" ); - //} - //else + if (m_pSpa->bx == TEXT && m_pSpa->by == TEXT) { - appendStyleProperty( &style, L"position", L"absolute" ); + // appendStyleProperty( style, L"position", L"static" ); + } + else + { + appendStylePropertyFirst( style, L"position", L"absolute" ); } } } - - if ( shape->fFlipH ) - { - appendStyleProperty( &style, L"flip", L"x" ); - } - - if ( shape->fFlipV ) - { - appendStyleProperty( &style, L"flip", L"y" ); - } - - AppendOptionsToStyle( &style, options, zIndex ); - return style; } diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index 6523a3ecce..ae0856109f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -67,6 +67,7 @@ namespace DocFileFormat static std::wstring mapHorizontalPositionRelative(int hRel ); bool m_isBullete; + bool m_isPictureBroken; std::wstring m_shapeId; private: @@ -82,15 +83,16 @@ namespace DocFileFormat bool copyPicture( const BlipStoreEntry* bse ); std::wstring GetTargetExt( Global::BlipType _type ) const; - void AppendDimensionToStyle ( std::wstring* style, const PictureDescriptor* pict, bool twistDimensions ) const; - void AppendDimensionToStyle ( std::wstring* style, const Spa* pSpa, bool twistDimensions ) const; - void AppendDimensionToStyle ( std::wstring* style, const ChildAnchor* anchor, bool twistDimensions ) const; - void appendStyleProperty ( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const; + void AppendDimensionToStyle ( std::wstring& style, const PictureDescriptor* pict, bool twistDimensions ) const; + void AppendDimensionToStyle ( std::wstring& style, const Spa* pSpa, bool twistDimensions ) const; + void AppendDimensionToStyle ( std::wstring& style, const ChildAnchor* anchor, bool twistDimensions ) const; + void appendStyleProperty ( std::wstring& style, const std::wstring& propName, const std::wstring& propValue ) const; + void appendStylePropertyFirst( std::wstring& style, const std::wstring& propName, const std::wstring& propValue ) const; std::wstring getTextboxAnchor( unsigned int anchor ) const; std::wstring buildStyle ( const Shape* shape, const ChildAnchor* anchor, const std::vector& options, int zIndex ) const; - void AppendOptionsToStyle ( std::wstring* style, const std::vector& options, int zIndex ) const; + void AppendOptionsToStyle ( std::wstring& style, const std::vector& options, int zIndex ) const; int UpdateFromGuides(const int val) const; @@ -122,7 +124,7 @@ namespace DocFileFormat int m_nAdjValues[8]; std::vector m_arrGuides; - bool m_isInlineShape; + mutable bool m_isInlineShape; Spa* m_pSpa; IMapping* m_pCaller; BlipStoreContainer* m_pBlipStore; diff --git a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj index c6b770d293..ce5d2c44e7 100644 --- a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj +++ b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj @@ -345,6 +345,14 @@ RelativePath="..\..\DesktopEditor\common\Base64.cpp" > + + + +