diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-03 17:45:57 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-03 22:12:15 +0100 |
commit | d8efc393bff9c0ed38eac00f48ce1d525e1d08ce (patch) | |
tree | c444f68ae5facfcad0b9bb411020592be601e562 /sw/source | |
parent | e11ff5a47a5e82de797e78e60f88acd9ff446149 (diff) |
Turn on clang-format for these files
I (tried to) keep these files consistent locally with astyle in the past,
switching to clang-format makes sure that the recent problem with introducing
inconsistencies with automatic loplugin rewrites doesn't happen again.
Change-Id: If49c96b6e9e6ed50beb69c70e37125dff5607f76
Reviewed-on: https://gerrit.libreoffice.org/47332
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 969 |
1 files changed, 506 insertions, 463 deletions
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index cdeb103d66e6..b8c4f47dfc63 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -41,8 +41,8 @@ using namespace oox; namespace { - -uno::Sequence<beans::PropertyValue> lclGetProperty(const uno::Reference<drawing::XShape>& rShape, const OUString& rPropName) +uno::Sequence<beans::PropertyValue> lclGetProperty(const uno::Reference<drawing::XShape>& rShape, + const OUString& rPropName) { uno::Sequence<beans::PropertyValue> aResult; uno::Reference<beans::XPropertySet> xPropertySet(rShape, uno::UNO_QUERY); @@ -62,14 +62,15 @@ uno::Sequence<beans::PropertyValue> lclGetProperty(const uno::Reference<drawing: OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) { OUString aResult; - uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), + uno::UNO_QUERY); OUString aGrabBagName; uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY); if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) aGrabBagName = "FrameInteropGrabBag"; else aGrabBagName = "InteropGrabBag"; - uno::Sequence< beans::PropertyValue > propList = lclGetProperty(xShape, aGrabBagName); + uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, aGrabBagName); for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString aPropName = propList[nProp].Name; @@ -97,33 +98,30 @@ void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, sal_Int64 while (nRotation > 9000) nRotation = (18000 - (nRotation % 18000)); - double fVal = (double) nRotation * F_PI18000; - double fCos = cos(fVal); - double fSin = sin(fVal); + double fVal = (double)nRotation * F_PI18000; + double fCos = cos(fVal); + double fSin = sin(fVal); - double nWidthHalf = (double) rSize.Width() / 2; - double nHeightHalf = (double) rSize.Height() / 2; + double nWidthHalf = (double)rSize.Width() / 2; + double nHeightHalf = (double)rSize.Height() / 2; - double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf; - double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf; + double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf; + double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf; aPos.X += nXDiff; aPos.Y += nYDiff; } - } -ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd, ww8::Frame const* pParentFrame) +ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd, + ww8::Frame const* pParentFrame) : m_rExport(rExport) { m_rExport.SaveData(nStt, nEnd); m_rExport.m_pParentFrame = pParentFrame; } -ExportDataSaveRestore::~ExportDataSaveRestore() -{ - m_rExport.RestoreData(); -} +ExportDataSaveRestore::~ExportDataSaveRestore() { m_rExport.RestoreData(); } /// Holds data used by DocxSdrExport only. struct DocxSdrExport::Impl @@ -152,23 +150,24 @@ struct DocxSdrExport::Impl /// Preserved rotation for TextFrames. sal_Int32 m_nDMLandVMLTextFrameRotation; - Impl(DocxSdrExport& rSdrExport, DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML) - : m_rSdrExport(rSdrExport), - m_rExport(rExport), - m_pSerializer(std::move(pSerializer)), - m_pDrawingML(pDrawingML), - m_pFlyFrameSize(nullptr), - m_bTextFrameSyntax(false), - m_bDMLTextFrameSyntax(false), - m_bFrameBtLr(false), - m_bDrawingOpen(false), - m_bParagraphSdtOpen(false), - m_bParagraphHasDrawing(false), - m_bFlyFrameGraphic(false), - m_pFlyWrapAttrList(nullptr), - m_pBodyPrAttrList(nullptr), - m_bDMLAndVMLDrawingOpen(false), - m_nDMLandVMLTextFrameRotation(0) + Impl(DocxSdrExport& rSdrExport, DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, + oox::drawingml::DrawingML* pDrawingML) + : m_rSdrExport(rSdrExport) + , m_rExport(rExport) + , m_pSerializer(std::move(pSerializer)) + , m_pDrawingML(pDrawingML) + , m_pFlyFrameSize(nullptr) + , m_bTextFrameSyntax(false) + , m_bDMLTextFrameSyntax(false) + , m_bFrameBtLr(false) + , m_bDrawingOpen(false) + , m_bParagraphSdtOpen(false) + , m_bParagraphHasDrawing(false) + , m_bFlyFrameGraphic(false) + , m_pFlyWrapAttrList(nullptr) + , m_pBodyPrAttrList(nullptr) + , m_bDMLAndVMLDrawingOpen(false) + , m_nDMLandVMLTextFrameRotation(0) { } @@ -180,7 +179,8 @@ struct DocxSdrExport::Impl bool checkFrameBtlr(SwNode* pStartNode, bool bDML); }; -DocxSdrExport::DocxSdrExport(DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML) +DocxSdrExport::DocxSdrExport(DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, + oox::drawingml::DrawingML* pDrawingML) : m_pImpl(o3tl::make_unique<Impl>(*this, rExport, pSerializer, pDrawingML)) { } @@ -192,20 +192,11 @@ void DocxSdrExport::setSerializer(const sax_fastparser::FSHelperPtr& pSerializer m_pImpl->m_pSerializer = pSerializer; } -const Size* DocxSdrExport::getFlyFrameSize() -{ - return m_pImpl->m_pFlyFrameSize; -} +const Size* DocxSdrExport::getFlyFrameSize() { return m_pImpl->m_pFlyFrameSize; } -bool DocxSdrExport::getTextFrameSyntax() -{ - return m_pImpl->m_bTextFrameSyntax; -} +bool DocxSdrExport::getTextFrameSyntax() { return m_pImpl->m_bTextFrameSyntax; } -bool DocxSdrExport::getDMLTextFrameSyntax() -{ - return m_pImpl->m_bDMLTextFrameSyntax; -} +bool DocxSdrExport::getDMLTextFrameSyntax() { return m_pImpl->m_bDMLTextFrameSyntax; } rtl::Reference<sax_fastparser::FastAttributeList>& DocxSdrExport::getFlyAttrList() { @@ -217,35 +208,20 @@ rtl::Reference<sax_fastparser::FastAttributeList>& DocxSdrExport::getTextboxAttr return m_pImpl->m_pTextboxAttrList; } -OStringBuffer& DocxSdrExport::getTextFrameStyle() -{ - return m_pImpl->m_aTextFrameStyle; -} +OStringBuffer& DocxSdrExport::getTextFrameStyle() { return m_pImpl->m_aTextFrameStyle; } -bool DocxSdrExport::getFrameBtLr() -{ - return m_pImpl->m_bFrameBtLr; -} +bool DocxSdrExport::getFrameBtLr() { return m_pImpl->m_bFrameBtLr; } -bool DocxSdrExport::IsDrawingOpen() -{ - return m_pImpl->m_bDrawingOpen; -} +bool DocxSdrExport::IsDrawingOpen() { return m_pImpl->m_bDrawingOpen; } void DocxSdrExport::setParagraphSdtOpen(bool bParagraphSdtOpen) { m_pImpl->m_bParagraphSdtOpen = bParagraphSdtOpen; } -bool DocxSdrExport::IsDMLAndVMLDrawingOpen() -{ - return m_pImpl->m_bDMLAndVMLDrawingOpen; -} +bool DocxSdrExport::IsDMLAndVMLDrawingOpen() { return m_pImpl->m_bDMLAndVMLDrawingOpen; } -bool DocxSdrExport::IsParagraphHasDrawing() -{ - return m_pImpl->m_bParagraphHasDrawing; -} +bool DocxSdrExport::IsParagraphHasDrawing() { return m_pImpl->m_bParagraphHasDrawing; } void DocxSdrExport::setParagraphHasDrawing(bool bParagraphHasDrawing) { @@ -305,21 +281,21 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons sal_Int32 nShadowWidth(TwipsToEMU(aShadowItem.GetWidth())); switch (aShadowItem.GetLocation()) { - case SvxShadowLocation::TopLeft: - nTopExt = nLeftExt = nShadowWidth; - break; - case SvxShadowLocation::TopRight: - nTopExt = nRightExt = nShadowWidth; - break; - case SvxShadowLocation::BottomLeft: - nBottomExt = nLeftExt = nShadowWidth; - break; - case SvxShadowLocation::BottomRight: - nBottomExt = nRightExt = nShadowWidth; - break; - case SvxShadowLocation::NONE: - case SvxShadowLocation::End: - break; + case SvxShadowLocation::TopLeft: + nTopExt = nLeftExt = nShadowWidth; + break; + case SvxShadowLocation::TopRight: + nTopExt = nRightExt = nShadowWidth; + break; + case SvxShadowLocation::BottomLeft: + nBottomExt = nLeftExt = nShadowWidth; + break; + case SvxShadowLocation::BottomRight: + nBottomExt = nRightExt = nShadowWidth; + break; + case SvxShadowLocation::NONE: + case SvxShadowLocation::End: + break; } } else if (const SdrObject* pObject = pFrameFormat->FindRealSdrObject()) @@ -348,31 +324,42 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons if (isAnchor) { - sax_fastparser::FastAttributeList* attrList = sax_fastparser::FastSerializerHelper::createAttrList(); + sax_fastparser::FastAttributeList* attrList + = sax_fastparser::FastSerializerHelper::createAttrList(); bool bOpaque = pFrameFormat->GetOpaque().GetValue(); - awt::Point aPos(pFrameFormat->GetHoriOrient().GetPos(), pFrameFormat->GetVertOrient().GetPos()); + awt::Point aPos(pFrameFormat->GetHoriOrient().GetPos(), + pFrameFormat->GetVertOrient().GetPos()); const SdrObject* pObj = pFrameFormat->FindRealSdrObject(); if (pObj != nullptr) { // SdrObjects know their layer, consider that instead of the frame format. - bOpaque = pObj->GetLayer() != pFrameFormat->GetDoc()->getIDocumentDrawModelAccess().GetHellId() && pObj->GetLayer() != pFrameFormat->GetDoc()->getIDocumentDrawModelAccess().GetInvisibleHellId(); + bOpaque = pObj->GetLayer() + != pFrameFormat->GetDoc()->getIDocumentDrawModelAccess().GetHellId() + && pObj->GetLayer() + != pFrameFormat->GetDoc() + ->getIDocumentDrawModelAccess() + .GetInvisibleHellId(); lclMovePositionWithRotation(aPos, rSize, pObj->GetRotateAngle()); } attrList->add(XML_behindDoc, bOpaque ? "0" : "1"); // The type of dist* attributes is unsigned, so make sure no negative value is written. - sal_Int64 nDistT = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetUpper()) - nTopExt); + sal_Int64 nDistT + = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetUpper()) - nTopExt); attrList->add(XML_distT, OString::number(nDistT).getStr()); - sal_Int64 nDistB = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetLower()) - nBottomExt); + sal_Int64 nDistB + = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aULSpaceItem.GetLower()) - nBottomExt); attrList->add(XML_distB, OString::number(nDistB).getStr()); - sal_Int64 nDistL = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetLeft()) - nLeftExt); + sal_Int64 nDistL + = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetLeft()) - nLeftExt); attrList->add(XML_distL, OString::number(nDistL).getStr()); - sal_Int64 nDistR = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetRight()) - nRightExt); + sal_Int64 nDistR + = std::max(static_cast<sal_Int64>(0), TwipsToEMU(aLRSpaceItem.GetRight()) - nRightExt); attrList->add(XML_distR, OString::number(nDistR).getStr()); attrList->add(XML_simplePos, "0"); attrList->add(XML_locked, "0"); attrList->add(XML_layoutInCell, "1"); - attrList->add(XML_allowOverlap, "1"); // TODO + attrList->add(XML_allowOverlap, "1"); // TODO if (pObj != nullptr) // It seems 0 and 1 have special meaning: just start counting from 2 to avoid issues with that. attrList->add(XML_relativeHeight, OString::number(pObj->GetOrdNum() + 2)); @@ -383,100 +370,105 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons { OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj); if (!sAnchorId.isEmpty()) - attrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); + attrList->addNS(XML_wp14, XML_anchorId, + OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); } sax_fastparser::XFastAttributeListRef xAttrList(attrList); m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_anchor, xAttrList); - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND); // required, unused + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", + FSEND); // required, unused const char* relativeFromH; const char* relativeFromV; const char* alignH = nullptr; const char* alignV = nullptr; switch (pFrameFormat->GetVertOrient().GetRelationOrient()) { - case text::RelOrientation::PAGE_PRINT_AREA: - relativeFromV = "margin"; - break; - case text::RelOrientation::PAGE_FRAME: - relativeFromV = "page"; - break; - case text::RelOrientation::FRAME: - relativeFromV = "paragraph"; - break; - case text::RelOrientation::TEXT_LINE: - default: - relativeFromV = "line"; - break; + case text::RelOrientation::PAGE_PRINT_AREA: + relativeFromV = "margin"; + break; + case text::RelOrientation::PAGE_FRAME: + relativeFromV = "page"; + break; + case text::RelOrientation::FRAME: + relativeFromV = "paragraph"; + break; + case text::RelOrientation::TEXT_LINE: + default: + relativeFromV = "line"; + break; } switch (pFrameFormat->GetVertOrient().GetVertOrient()) { - case text::VertOrientation::TOP: - case text::VertOrientation::CHAR_TOP: - case text::VertOrientation::LINE_TOP: - if (pFrameFormat->GetVertOrient().GetRelationOrient() == text::RelOrientation::TEXT_LINE) - alignV = "bottom"; - else - alignV = "top"; - break; - case text::VertOrientation::BOTTOM: - case text::VertOrientation::CHAR_BOTTOM: - case text::VertOrientation::LINE_BOTTOM: - if (pFrameFormat->GetVertOrient().GetRelationOrient() == text::RelOrientation::TEXT_LINE) - alignV = "top"; - else - alignV = "bottom"; - break; - case text::VertOrientation::CENTER: - case text::VertOrientation::CHAR_CENTER: - case text::VertOrientation::LINE_CENTER: - alignV = "center"; - break; - default: - break; + case text::VertOrientation::TOP: + case text::VertOrientation::CHAR_TOP: + case text::VertOrientation::LINE_TOP: + if (pFrameFormat->GetVertOrient().GetRelationOrient() + == text::RelOrientation::TEXT_LINE) + alignV = "bottom"; + else + alignV = "top"; + break; + case text::VertOrientation::BOTTOM: + case text::VertOrientation::CHAR_BOTTOM: + case text::VertOrientation::LINE_BOTTOM: + if (pFrameFormat->GetVertOrient().GetRelationOrient() + == text::RelOrientation::TEXT_LINE) + alignV = "top"; + else + alignV = "bottom"; + break; + case text::VertOrientation::CENTER: + case text::VertOrientation::CHAR_CENTER: + case text::VertOrientation::LINE_CENTER: + alignV = "center"; + break; + default: + break; } switch (pFrameFormat->GetHoriOrient().GetRelationOrient()) { - case text::RelOrientation::PAGE_PRINT_AREA: - relativeFromH = "margin"; - break; - case text::RelOrientation::PAGE_FRAME: - relativeFromH = "page"; - break; - case text::RelOrientation::CHAR: - relativeFromH = "character"; - break; - case text::RelOrientation::PAGE_RIGHT: - relativeFromH = "rightMargin"; - break; - case text::RelOrientation::PAGE_LEFT: - relativeFromH = "leftMargin"; - break; - case text::RelOrientation::FRAME: - default: - relativeFromH = "column"; - break; + case text::RelOrientation::PAGE_PRINT_AREA: + relativeFromH = "margin"; + break; + case text::RelOrientation::PAGE_FRAME: + relativeFromH = "page"; + break; + case text::RelOrientation::CHAR: + relativeFromH = "character"; + break; + case text::RelOrientation::PAGE_RIGHT: + relativeFromH = "rightMargin"; + break; + case text::RelOrientation::PAGE_LEFT: + relativeFromH = "leftMargin"; + break; + case text::RelOrientation::FRAME: + default: + relativeFromH = "column"; + break; } switch (pFrameFormat->GetHoriOrient().GetHoriOrient()) { - case text::HoriOrientation::LEFT: - alignH = "left"; - break; - case text::HoriOrientation::RIGHT: - alignH = "right"; - break; - case text::HoriOrientation::CENTER: - alignH = "center"; - break; - case text::HoriOrientation::INSIDE: - alignH = "inside"; - break; - case text::HoriOrientation::OUTSIDE: - alignH = "outside"; - break; - default: - break; + case text::HoriOrientation::LEFT: + alignH = "left"; + break; + case text::HoriOrientation::RIGHT: + alignH = "right"; + break; + case text::HoriOrientation::CENTER: + alignH = "center"; + break; + case text::HoriOrientation::INSIDE: + alignH = "inside"; + break; + case text::HoriOrientation::OUTSIDE: + alignH = "outside"; + break; + default: + break; } - m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_positionH, XML_relativeFrom, relativeFromH, FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_positionH, XML_relativeFrom, + relativeFromH, FSEND); /** * Sizes of integral types * climits header defines constants with the limits of integral types for the specific system and compiler implementation used. @@ -518,7 +510,8 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons m_pImpl->m_pSerializer->endElementNS(XML_wp, XML_posOffset); } m_pImpl->m_pSerializer->endElementNS(XML_wp, XML_positionH); - m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_positionV, XML_relativeFrom, relativeFromV, FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_positionV, XML_relativeFrom, + relativeFromV, FSEND); sal_Int64 nPosYEMU = TwipsToEMU(aPos.Y); @@ -526,9 +519,9 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons // wrap top+bottom or other wraps is affecting the line directly // above the anchor line, which seems odd, but a tiny adjustment // here to bring the top down convinces msoffice to wrap like us - if (nPosYEMU == 0 && - (strcmp(relativeFromV, "line") == 0 || strcmp(relativeFromV, "paragraph") == 0) && - (!alignV || strcmp(alignV, "top") == 0)) + if (nPosYEMU == 0 + && (strcmp(relativeFromV, "line") == 0 || strcmp(relativeFromV, "paragraph") == 0) + && (!alignV || strcmp(alignV, "top") == 0)) { alignV = nullptr; nPosYEMU = 635; @@ -558,7 +551,8 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons } else { - sax_fastparser::FastAttributeList* aAttrList = sax_fastparser::FastSerializerHelper::createAttrList(); + sax_fastparser::FastAttributeList* aAttrList + = sax_fastparser::FastSerializerHelper::createAttrList(); aAttrList->add(XML_distT, OString::number(TwipsToEMU(aULSpaceItem.GetUpper())).getStr()); aAttrList->add(XML_distB, OString::number(TwipsToEMU(aULSpaceItem.GetLower())).getStr()); aAttrList->add(XML_distL, OString::number(TwipsToEMU(aLRSpaceItem.GetLeft())).getStr()); @@ -568,7 +562,8 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons { OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj); if (!sAnchorId.isEmpty()) - aAttrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); + aAttrList->addNS(XML_wp14, XML_anchorId, + OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); } m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_inline, aAttrList); } @@ -592,8 +587,8 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons * 2147483647( MAX_INTEGER_VALUE ). * Therefore changing the following accordingly so that LO sync's up with MSO. **/ - sal_uInt64 cx = 0 ; - sal_uInt64 cy = 0 ; + sal_uInt64 cx = 0; + sal_uInt64 cy = 0; const sal_Int64 MAX_INTEGER_VALUE = SAL_MAX_INT32; // the 'Size' type uses 'long' for width and height, so on @@ -601,46 +596,46 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons // larger than the max signed 32-bit integer. #if SAL_TYPES_SIZEOFLONG > 4 if (rSize.Width() > MAX_INTEGER_VALUE) - cx = MAX_INTEGER_VALUE ; + cx = MAX_INTEGER_VALUE; else #endif { if (0 > rSize.Width()) - cx = 0 ; + cx = 0; else cx = rSize.Width(); } #if SAL_TYPES_SIZEOFLONG > 4 if (rSize.Height() > MAX_INTEGER_VALUE) - cy = MAX_INTEGER_VALUE ; + cy = MAX_INTEGER_VALUE; else #endif { if (0 > rSize.Height()) - cy = 0 ; + cy = 0; else cy = rSize.Height(); } OString aWidth(OString::number(TwipsToEMU(cx))); //we explicitly check the converted EMU value for the range as mentioned in above comment. - aWidth = (aWidth.toInt64() > 0 ? (aWidth.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE) : aWidth.getStr()): "0"); + aWidth = (aWidth.toInt64() > 0 ? (aWidth.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE) + : aWidth.getStr()) + : "0"); OString aHeight(OString::number(TwipsToEMU(cy))); - aHeight = (aHeight.toInt64() > 0 ? (aHeight.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE) : aHeight.getStr()): "0"); + aHeight + = (aHeight.toInt64() > 0 ? (aHeight.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE) + : aHeight.getStr()) + : "0"); - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_extent, - XML_cx, aWidth, - XML_cy, aHeight, + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_extent, XML_cx, aWidth, XML_cy, aHeight, FSEND); // effectExtent, extent including the effect (shadow only for now) - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_effectExtent, - XML_l, OString::number(nLeftExt), - XML_t, OString::number(nTopExt), - XML_r, OString::number(nRightExt), - XML_b, OString::number(nBottomExt), - FSEND); + m_pImpl->m_pSerializer->singleElementNS( + XML_wp, XML_effectExtent, XML_l, OString::number(nLeftExt), XML_t, OString::number(nTopExt), + XML_r, OString::number(nRightExt), XML_b, OString::number(nBottomExt), FSEND); // See if we know the exact wrap type from grab-bag. sal_Int32 nWrapToken = 0; @@ -658,26 +653,27 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons else if (sType == "wrapThrough") nWrapToken = XML_wrapThrough; else - SAL_WARN("sw.ww8", "DocxSdrExport::startDMLAnchorInline: unexpected EG_WrapType value"); + SAL_WARN("sw.ww8", + "DocxSdrExport::startDMLAnchorInline: unexpected EG_WrapType value"); - m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken, - XML_wrapText, "bothSides", FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken, XML_wrapText, "bothSides", + FSEND); it = aGrabBag.find("CT_WrapPath"); if (it != aGrabBag.end()) { - m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon, - XML_edited, "0", + m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0", FSEND); - drawing::PointSequenceSequence aSeqSeq = it->second.get< drawing::PointSequenceSequence >(); - std::vector<awt::Point> aPoints(comphelper::sequenceToContainer<std::vector<awt::Point> >(aSeqSeq[0])); + drawing::PointSequenceSequence aSeqSeq + = it->second.get<drawing::PointSequenceSequence>(); + std::vector<awt::Point> aPoints( + comphelper::sequenceToContainer<std::vector<awt::Point>>(aSeqSeq[0])); for (auto i = aPoints.begin(); i != aPoints.end(); ++i) { awt::Point& rPoint = *i; - m_pImpl->m_pSerializer->singleElementNS(XML_wp, (i == aPoints.begin() ? XML_start : XML_lineTo), - XML_x, OString::number(rPoint.X), - XML_y, OString::number(rPoint.Y), - FSEND); + m_pImpl->m_pSerializer->singleElementNS( + XML_wp, (i == aPoints.begin() ? XML_start : XML_lineTo), XML_x, + OString::number(rPoint.X), XML_y, OString::number(rPoint.Y), FSEND); } m_pImpl->m_pSerializer->endElementNS(XML_wp, XML_wrapPolygon); } @@ -695,18 +691,16 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons if (pPolyPoly && pPolyPoly->Count()) { nWrapToken = XML_wrapTight; - m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken, - XML_wrapText, "bothSides", FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken, XML_wrapText, + "bothSides", FSEND); - m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon, - XML_edited, "0", + m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0", FSEND); tools::Polygon aPoly = sw::util::CorrectWordWrapPolygonForExport(*pPolyPoly, pNd); for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i) - m_pImpl->m_pSerializer->singleElementNS(XML_wp, (i == 0 ? XML_start : XML_lineTo), - XML_x, OString::number(aPoly[i].X()), - XML_y, OString::number(aPoly[i].Y()), - FSEND); + m_pImpl->m_pSerializer->singleElementNS( + XML_wp, (i == 0 ? XML_start : XML_lineTo), XML_x, + OString::number(aPoly[i].X()), XML_y, OString::number(aPoly[i].Y()), FSEND); m_pImpl->m_pSerializer->endElementNS(XML_wp, XML_wrapPolygon); m_pImpl->m_pSerializer->endElementNS(XML_wp, nWrapToken); @@ -719,21 +713,21 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons { switch (pFrameFormat->GetSurround().GetValue()) { - case css::text::WrapTextMode_NONE: - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapTopAndBottom, FSEND); - break; - case css::text::WrapTextMode_THROUGH: - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapNone, FSEND); - break; - case css::text::WrapTextMode_PARALLEL: - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapSquare, - XML_wrapText, "bothSides", FSEND); - break; - case css::text::WrapTextMode_DYNAMIC: - default: - m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapSquare, - XML_wrapText, "largest", FSEND); - break; + case css::text::WrapTextMode_NONE: + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapTopAndBottom, FSEND); + break; + case css::text::WrapTextMode_THROUGH: + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapNone, FSEND); + break; + case css::text::WrapTextMode_PARALLEL: + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText, + "bothSides", FSEND); + break; + case css::text::WrapTextMode_DYNAMIC: + default: + m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText, + "largest", FSEND); + break; } } } @@ -760,12 +754,13 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat bool bSwapInPage = false; if (!sdrObj->GetPage()) { - if (SdrModel* pModel = m_pImpl->m_rExport.m_pDoc->getIDocumentDrawModelAccess().GetDrawModel()) + if (SdrModel* pModel + = m_pImpl->m_rExport.m_pDoc->getIDocumentDrawModelAccess().GetDrawModel()) { if (SdrPage* pPage = pModel->GetPage(0)) { bSwapInPage = true; - const_cast< SdrObject* >(sdrObj)->SetPage(pPage); + const_cast<SdrObject*>(sdrObj)->SetPage(pPage); } } } @@ -776,22 +771,20 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient(); const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient(); - m_pImpl->m_rExport.VMLExporter().AddSdrObject(*sdrObj, - rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), - rHoriOri.GetRelationOrient(), - rVertOri.GetRelationOrient(), true); + m_pImpl->m_rExport.VMLExporter().AddSdrObject( + *sdrObj, rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(), + rVertOri.GetRelationOrient(), true); m_pImpl->m_pSerializer->endElementNS(XML_w, XML_pict); if (bSwapInPage) - const_cast< SdrObject* >(sdrObj)->SetPage(nullptr); + const_cast<SdrObject*>(sdrObj)->SetPage(nullptr); } bool lcl_isLockedCanvas(const uno::Reference<drawing::XShape>& xShape) { bool bRet = false; - uno::Sequence< beans::PropertyValue > propList = - lclGetProperty(xShape, "InteropGrabBag"); - for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag"); + for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString propName = propList[nProp].Name; if (propName == "LockedCanvas") @@ -807,9 +800,11 @@ bool lcl_isLockedCanvas(const uno::Reference<drawing::XShape>& xShape) return bRet; } -void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFormat* pFrameFormat, int nAnchorId) +void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFormat* pFrameFormat, + int nAnchorId) { - uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), + uno::UNO_QUERY_THROW); if (!Impl::isSupportedDMLShape(xShape)) return; @@ -819,13 +814,17 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFo Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight()); startDMLAnchorInline(pFrameFormat, aSize); - sax_fastparser::FastAttributeList* pDocPrAttrList = sax_fastparser::FastSerializerHelper::createAttrList(); + sax_fastparser::FastAttributeList* pDocPrAttrList + = sax_fastparser::FastSerializerHelper::createAttrList(); pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr()); - pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8).getStr()); + pDocPrAttrList->add(XML_name, + OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8).getStr()); if (!pSdrObject->GetTitle().isEmpty()) - pDocPrAttrList->add(XML_title, OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8)); + pDocPrAttrList->add(XML_title, + OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8)); if (!pSdrObject->GetDescription().isEmpty()) - pDocPrAttrList->add(XML_descr, OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8)); + pDocPrAttrList->add(XML_descr, + OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8)); sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList); pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef); @@ -835,17 +834,21 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFo pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"; else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")) pNamespace = "http://schemas.openxmlformats.org/drawingml/2006/picture"; - pFS->startElementNS(XML_a, XML_graphic, - FSNS(XML_xmlns, XML_a), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(), - FSEND); - pFS->startElementNS(XML_a, XML_graphicData, - XML_uri, pNamespace, - FSEND); + pFS->startElementNS( + XML_a, XML_graphic, FSNS(XML_xmlns, XML_a), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), + RTL_TEXTENCODING_UTF8) + .getStr(), + FSEND); + pFS->startElementNS(XML_a, XML_graphicData, XML_uri, pNamespace, FSEND); bool bLockedCanvas = lcl_isLockedCanvas(xShape); if (bLockedCanvas) - pFS->startElementNS(XML_lc, XML_lockedCanvas, - FSNS(XML_xmlns, XML_lc), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dmlLockedCanvas)), RTL_TEXTENCODING_UTF8).getStr(), + pFS->startElementNS(XML_lc, XML_lockedCanvas, FSNS(XML_xmlns, XML_lc), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL( + OOX_NS(dmlLockedCanvas)), + RTL_TEXTENCODING_UTF8) + .getStr(), FSEND); m_pImpl->m_rExport.OutputDML(xShape); @@ -859,21 +862,27 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFo if (pSdrObject->GetRelativeWidth()) { // At the moment drawinglayer objects are always relative from page. - pFS->startElementNS(XML_wp14, XML_sizeRelH, - XML_relativeFrom, (pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? "margin" : "page"), + pFS->startElementNS(XML_wp14, XML_sizeRelH, XML_relativeFrom, + (pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME + ? "margin" + : "page"), FSEND); pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND); - pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT)); + pFS->writeEscaped( + OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT)); pFS->endElementNS(XML_wp14, XML_pctWidth); pFS->endElementNS(XML_wp14, XML_sizeRelH); } if (pSdrObject->GetRelativeHeight()) { - pFS->startElementNS(XML_wp14, XML_sizeRelV, - XML_relativeFrom, (pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? "margin" : "page"), + pFS->startElementNS(XML_wp14, XML_sizeRelV, XML_relativeFrom, + (pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME + ? "margin" + : "page"), FSEND); pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND); - pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT)); + pFS->writeEscaped( + OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT)); pFS->endElementNS(XML_wp14, XML_pctHeight); pFS->endElementNS(XML_wp14, XML_sizeRelV); } @@ -891,38 +900,35 @@ void DocxSdrExport::Impl::textFrameShadow(const SwFrameFormat& rFrameFormat) OString aOffset; switch (aShadowItem.GetLocation()) { - case SvxShadowLocation::TopLeft: - aOffset = "-" + aShadowWidth + ",-" + aShadowWidth; - break; - case SvxShadowLocation::TopRight: - aOffset = aShadowWidth + ",-" + aShadowWidth; - break; - case SvxShadowLocation::BottomLeft: - aOffset = "-" + aShadowWidth + "," + aShadowWidth; - break; - case SvxShadowLocation::BottomRight: - aOffset = aShadowWidth + "," + aShadowWidth; - break; - case SvxShadowLocation::NONE: - case SvxShadowLocation::End: - break; + case SvxShadowLocation::TopLeft: + aOffset = "-" + aShadowWidth + ",-" + aShadowWidth; + break; + case SvxShadowLocation::TopRight: + aOffset = aShadowWidth + ",-" + aShadowWidth; + break; + case SvxShadowLocation::BottomLeft: + aOffset = "-" + aShadowWidth + "," + aShadowWidth; + break; + case SvxShadowLocation::BottomRight: + aOffset = aShadowWidth + "," + aShadowWidth; + break; + case SvxShadowLocation::NONE: + case SvxShadowLocation::End: + break; } if (aOffset.isEmpty()) return; OString aShadowColor = msfilter::util::ConvertColor(aShadowItem.GetColor()); - m_pSerializer->singleElementNS(XML_v, XML_shadow, - XML_on, "t", - XML_color, "#" + aShadowColor, - XML_offset, aOffset, - FSEND); + m_pSerializer->singleElementNS(XML_v, XML_shadow, XML_on, "t", XML_color, "#" + aShadowColor, + XML_offset, aOffset, FSEND); } bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XShape>& xShape) { uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW); if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape") - || xServiceInfo->supportsService("com.sun.star.drawing.PolyLineShape")) + || xServiceInfo->supportsService("com.sun.star.drawing.PolyLineShape")) return false; // For signature line shapes, we don't want DML, just the VML shape. @@ -938,7 +944,8 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XSha return true; } -void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat& rFrameFormat, int nAnchorId) +void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, + const SwFrameFormat& rFrameFormat, int nAnchorId) { bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen; m_pImpl->m_bDMLAndVMLDrawingOpen = true; @@ -946,24 +953,26 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrame // Depending on the shape type, we actually don't write the shape as DML. OUString sShapeType; ShapeFlag nMirrorFlags = ShapeFlag::NONE; - uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(sdrObj)->getUnoShape(), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(sdrObj)->getUnoShape(), + uno::UNO_QUERY_THROW); // Locked canvas is OK inside DML. if (lcl_isLockedCanvas(xShape)) bDMLAndVMLDrawingOpen = false; - MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType(xShape, nMirrorFlags, sShapeType); + MSO_SPT eShapeType + = EscherPropertyContainer::GetCustomShapeType(xShape, nMirrorFlags, sShapeType); // In case we are already inside a DML block, then write the shape only as VML, turn out that's allowed to do. // A common service created in util to check for VML shapes which are allowed to have textbox in content - if ((msfilter::util::HasTextBoxContent(eShapeType)) && Impl::isSupportedDMLShape(xShape) && !bDMLAndVMLDrawingOpen) + if ((msfilter::util::HasTextBoxContent(eShapeType)) && Impl::isSupportedDMLShape(xShape) + && !bDMLAndVMLDrawingOpen) { m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_AlternateContent, FSEND); auto pObjGroup = dynamic_cast<const SdrObjGroup*>(sdrObj); - m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_Choice, - XML_Requires, (pObjGroup ? "wpg" : "wps"), - FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_Choice, XML_Requires, + (pObjGroup ? "wpg" : "wps"), FSEND); writeDMLDrawing(sdrObj, &rFrameFormat, nAnchorId); m_pImpl->m_pSerializer->endElementNS(XML_mc, XML_Choice); @@ -1000,57 +1009,57 @@ void DocxSdrExport::writeDMLEffectLst(const SwFrameFormat& rFrameFormat) return; // Distance is measured diagonally from corner - double nShadowDist = sqrt((double)aShadowItem.GetWidth()*aShadowItem.GetWidth()*2.0); + double nShadowDist = sqrt((double)aShadowItem.GetWidth() * aShadowItem.GetWidth() * 2.0); OString aShadowDist(OString::number(TwipsToEMU(nShadowDist))); OString aShadowColor = msfilter::util::ConvertColor(aShadowItem.GetColor()); OString aShadowAlpha = lcl_ConvertTransparency(aShadowItem.GetColor()); sal_uInt32 nShadowDir = 0; switch (aShadowItem.GetLocation()) { - case SvxShadowLocation::TopLeft: - nShadowDir = 13500000; - break; - case SvxShadowLocation::TopRight: - nShadowDir = 18900000; - break; - case SvxShadowLocation::BottomLeft: - nShadowDir = 8100000; - break; - case SvxShadowLocation::BottomRight: - nShadowDir = 2700000; - break; - case SvxShadowLocation::NONE: - case SvxShadowLocation::End: - break; + case SvxShadowLocation::TopLeft: + nShadowDir = 13500000; + break; + case SvxShadowLocation::TopRight: + nShadowDir = 18900000; + break; + case SvxShadowLocation::BottomLeft: + nShadowDir = 8100000; + break; + case SvxShadowLocation::BottomRight: + nShadowDir = 2700000; + break; + case SvxShadowLocation::NONE: + case SvxShadowLocation::End: + break; } OString aShadowDir(OString::number(nShadowDir)); m_pImpl->m_pSerializer->startElementNS(XML_a, XML_effectLst, FSEND); - m_pImpl->m_pSerializer->startElementNS(XML_a, XML_outerShdw, - XML_dist, aShadowDist.getStr(), + m_pImpl->m_pSerializer->startElementNS(XML_a, XML_outerShdw, XML_dist, aShadowDist.getStr(), XML_dir, aShadowDir.getStr(), FSEND); if (aShadowAlpha.isEmpty()) - m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_srgbClr, - XML_val, aShadowColor.getStr(), FSEND); + m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_srgbClr, XML_val, aShadowColor.getStr(), + FSEND); else { - m_pImpl->m_pSerializer->startElementNS(XML_a, XML_srgbClr, XML_val, aShadowColor.getStr(), FSEND); - m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_alpha, XML_val, aShadowAlpha.getStr(), FSEND); + m_pImpl->m_pSerializer->startElementNS(XML_a, XML_srgbClr, XML_val, aShadowColor.getStr(), + FSEND); + m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_alpha, XML_val, aShadowAlpha.getStr(), + FSEND); m_pImpl->m_pSerializer->endElementNS(XML_a, XML_srgbClr); } m_pImpl->m_pSerializer->endElementNS(XML_a, XML_outerShdw); m_pImpl->m_pSerializer->endElementNS(XML_a, XML_effectLst); - - } -void DocxSdrExport::writeDiagramRels(const uno::Sequence< uno::Sequence< uno::Any > >& xRelSeq, - const uno::Reference<io::XOutputStream>& xOutStream, const OUString& sGrabBagProperyName, - int nAnchorId) +void DocxSdrExport::writeDiagramRels(const uno::Sequence<uno::Sequence<uno::Any>>& xRelSeq, + const uno::Reference<io::XOutputStream>& xOutStream, + const OUString& sGrabBagProperyName, int nAnchorId) { // add image relationships of OOXData, OOXDiagram OUString sType(oox::getRelationship(Relationship::IMAGE)); - uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(comphelper::getProcessComponentContext()); + uno::Reference<xml::sax::XWriter> xWriter + = xml::sax::Writer::create(comphelper::getProcessComponentContext()); xWriter->setOutputStream(xOutStream); // retrieve the relationships from Sequence @@ -1059,7 +1068,7 @@ void DocxSdrExport::writeDiagramRels(const uno::Sequence< uno::Sequence< uno::An // diagramDataRelTuple[0] => RID, // diagramDataRelTuple[1] => xInputStream // diagramDataRelTuple[2] => extension - uno::Sequence< uno::Any > diagramDataRelTuple = xRelSeq[j]; + uno::Sequence<uno::Any> diagramDataRelTuple = xRelSeq[j]; OUString sRelId, sExtension; diagramDataRelTuple[0] >>= sRelId; @@ -1073,24 +1082,27 @@ void DocxSdrExport::writeDiagramRels(const uno::Sequence< uno::Sequence< uno::An StreamDataSequence dataSeq; diagramDataRelTuple[1] >>= dataSeq; - uno::Reference<io::XInputStream> dataImagebin(new ::comphelper::SequenceInputStream(dataSeq)); + uno::Reference<io::XInputStream> dataImagebin( + new ::comphelper::SequenceInputStream(dataSeq)); OUString sFragment("../media/"); //nAnchorId is used to make the name unique irrespective of the number of smart arts. - sFragment += sGrabBagProperyName + OUString::number(nAnchorId) + "_" + OUString::number(j) + sExtension; + sFragment += sGrabBagProperyName + OUString::number(nAnchorId) + "_" + OUString::number(j) + + sExtension; PropertySet aProps(xOutStream); aProps.setAnyProperty(PROP_RelId, uno::makeAny(sRelId.toInt32())); m_pImpl->m_rExport.GetFilter().addRelation(xOutStream, sType, sFragment); - sFragment = sFragment.replaceFirst("..","word"); - uno::Reference< io::XOutputStream > xBinOutStream = m_pImpl->m_rExport.GetFilter().openFragmentStream(sFragment, sContentType); + sFragment = sFragment.replaceFirst("..", "word"); + uno::Reference<io::XOutputStream> xBinOutStream + = m_pImpl->m_rExport.GetFilter().openFragmentStream(sFragment, sContentType); try { sal_Int32 nBufferSize = 512; - uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize); + uno::Sequence<sal_Int8> aDataBuffer(nBufferSize); sal_Int32 nRead; do { @@ -1104,36 +1116,38 @@ void DocxSdrExport::writeDiagramRels(const uno::Sequence< uno::Sequence< uno::An } xBinOutStream->writeBytes(aDataBuffer); } - } - while (nRead); + } while (nRead); xBinOutStream->flush(); } catch (const uno::Exception& rException) { - SAL_WARN("sw.ww8", "DocxSdrExport::writeDiagramRels Failed to copy grabbaged Image: " << rException); + SAL_WARN("sw.ww8", "DocxSdrExport::writeDiagramRels Failed to copy grabbaged Image: " + << rException); } dataImagebin->closeInput(); } } -void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat& rFrameFormat, int nAnchorId) +void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat& rFrameFormat, + int nAnchorId) { sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; - uno::Reference< drawing::XShape > xShape(const_cast<SdrObject*>(sdrObject)->getUnoShape(), uno::UNO_QUERY); - uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(sdrObject)->getUnoShape(), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); uno::Reference<xml::dom::XDocument> dataDom; uno::Reference<xml::dom::XDocument> layoutDom; uno::Reference<xml::dom::XDocument> styleDom; uno::Reference<xml::dom::XDocument> colorDom; uno::Reference<xml::dom::XDocument> drawingDom; - uno::Sequence< uno::Sequence< uno::Any > > xDataRelSeq; - uno::Sequence< uno::Any > diagramDrawing; + uno::Sequence<uno::Sequence<uno::Any>> xDataRelSeq; + uno::Sequence<uno::Any> diagramDrawing; // retrieve the doms from the GrabBag - uno::Sequence< beans::PropertyValue > propList; + uno::Sequence<beans::PropertyValue> propList; xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= propList; - for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString propName = propList[nProp].Name; if (propName == "OOXData") @@ -1147,7 +1161,8 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat else if (propName == "OOXDrawing") { propList[nProp].Value >>= diagramDrawing; - diagramDrawing[0] >>= drawingDom; // if there is OOXDrawing property then set drawingDom here only. + diagramDrawing[0] + >>= drawingDom; // if there is OOXDrawing property then set drawingDom here only. } else if (propName == "OOXDiagramDataRels") propList[nProp].Value >>= xDataRelSeq; @@ -1163,7 +1178,8 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat startDMLAnchorInline(&rFrameFormat, aSize); // generate an unique id - sax_fastparser::FastAttributeList* pDocPrAttrList = sax_fastparser::FastSerializerHelper::createAttrList(); + sax_fastparser::FastAttributeList* pDocPrAttrList + = sax_fastparser::FastSerializerHelper::createAttrList(); pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr()); OUString sName = "Diagram" + OUString::number(nAnchorId); pDocPrAttrList->add(XML_name, OUStringToOString(sName, RTL_TEXTENCODING_UTF8).getStr()); @@ -1173,130 +1189,149 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrameFormat sal_Int32 diagramCount; diagramCount = nAnchorId; - pFS->singleElementNS(XML_wp, XML_cNvGraphicFramePr, - FSEND); + pFS->singleElementNS(XML_wp, XML_cNvGraphicFramePr, FSEND); - pFS->startElementNS(XML_a, XML_graphic, - FSNS(XML_xmlns, XML_a), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(), - FSEND); + pFS->startElementNS( + XML_a, XML_graphic, FSNS(XML_xmlns, XML_a), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), + RTL_TEXTENCODING_UTF8) + .getStr(), + FSEND); - pFS->startElementNS(XML_a, XML_graphicData, - XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/diagram", - FSEND); + pFS->startElementNS(XML_a, XML_graphicData, XML_uri, + "http://schemas.openxmlformats.org/drawingml/2006/diagram", FSEND); // add data relation OUString dataFileName = "diagrams/data" + OUString::number(diagramCount) + ".xml"; - OString dataRelId = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation(pFS->getOutputStream(), - oox::getRelationship(Relationship::DIAGRAMDATA), - dataFileName), RTL_TEXTENCODING_UTF8); - + OString dataRelId = OUStringToOString( + m_pImpl->m_rExport.GetFilter().addRelation( + pFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMDATA), dataFileName), + RTL_TEXTENCODING_UTF8); // add layout relation OUString layoutFileName = "diagrams/layout" + OUString::number(diagramCount) + ".xml"; - OString layoutRelId = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation(pFS->getOutputStream(), - oox::getRelationship(Relationship::DIAGRAMLAYOUT), - layoutFileName), RTL_TEXTENCODING_UTF8); + OString layoutRelId + = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation( + pFS->getOutputStream(), + oox::getRelationship(Relationship::DIAGRAMLAYOUT), layoutFileName), + RTL_TEXTENCODING_UTF8); // add style relation OUString styleFileName = "diagrams/quickStyle" + OUString::number(diagramCount) + ".xml"; - OString styleRelId = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation(pFS->getOutputStream(), - oox::getRelationship(Relationship::DIAGRAMQUICKSTYLE), - styleFileName), RTL_TEXTENCODING_UTF8); + OString styleRelId = OUStringToOString( + m_pImpl->m_rExport.GetFilter().addRelation( + pFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMQUICKSTYLE), + styleFileName), + RTL_TEXTENCODING_UTF8); // add color relation OUString colorFileName = "diagrams/colors" + OUString::number(diagramCount) + ".xml"; - OString colorRelId = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation(pFS->getOutputStream(), - oox::getRelationship(Relationship::DIAGRAMCOLORS), - colorFileName), RTL_TEXTENCODING_UTF8); + OString colorRelId + = OUStringToOString(m_pImpl->m_rExport.GetFilter().addRelation( + pFS->getOutputStream(), + oox::getRelationship(Relationship::DIAGRAMCOLORS), colorFileName), + RTL_TEXTENCODING_UTF8); OUString drawingFileName; if (drawingDom.is()) { // add drawing relation drawingFileName = "diagrams/drawing" + OUString::number(diagramCount) + ".xml"; - OUString drawingRelId = m_pImpl->m_rExport.GetFilter().addRelation(pFS->getOutputStream(), - oox::getRelationship(Relationship::DIAGRAMDRAWING), - drawingFileName); + OUString drawingRelId = m_pImpl->m_rExport.GetFilter().addRelation( + pFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMDRAWING), + drawingFileName); // the data dom contains a reference to the drawing relation. We need to update it with the new generated // relation value before writing the dom to a file // Get the dsp:damaModelExt node from the dom - uno::Reference< xml::dom::XNodeList > nodeList = - dataDom->getElementsByTagNameNS("http://schemas.microsoft.com/office/drawing/2008/diagram", "dataModelExt"); + uno::Reference<xml::dom::XNodeList> nodeList = dataDom->getElementsByTagNameNS( + "http://schemas.microsoft.com/office/drawing/2008/diagram", "dataModelExt"); // There must be one element only so get it - uno::Reference< xml::dom::XNode > node = nodeList->item(0); + uno::Reference<xml::dom::XNode> node = nodeList->item(0); // Get the list of attributes of the node - uno::Reference< xml::dom::XNamedNodeMap > nodeMap = node->getAttributes(); + uno::Reference<xml::dom::XNamedNodeMap> nodeMap = node->getAttributes(); // Get the node with the relId attribute and set its new value - uno::Reference< xml::dom::XNode > relIdNode = nodeMap->getNamedItem("relId"); + uno::Reference<xml::dom::XNode> relIdNode = nodeMap->getNamedItem("relId"); relIdNode->setNodeValue(drawingRelId); } - pFS->singleElementNS(XML_dgm, XML_relIds, - FSNS(XML_xmlns, XML_dgm), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dmlDiagram)), RTL_TEXTENCODING_UTF8).getStr(), - FSNS(XML_xmlns, XML_r), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr(), - FSNS(XML_r, XML_dm), dataRelId.getStr(), - FSNS(XML_r, XML_lo), layoutRelId.getStr(), - FSNS(XML_r, XML_qs), styleRelId.getStr(), - FSNS(XML_r, XML_cs), colorRelId.getStr(), - FSEND); + pFS->singleElementNS( + XML_dgm, XML_relIds, FSNS(XML_xmlns, XML_dgm), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dmlDiagram)), + RTL_TEXTENCODING_UTF8) + .getStr(), + FSNS(XML_xmlns, XML_r), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(officeRel)), + RTL_TEXTENCODING_UTF8) + .getStr(), + FSNS(XML_r, XML_dm), dataRelId.getStr(), FSNS(XML_r, XML_lo), layoutRelId.getStr(), + FSNS(XML_r, XML_qs), styleRelId.getStr(), FSNS(XML_r, XML_cs), colorRelId.getStr(), FSEND); pFS->endElementNS(XML_a, XML_graphicData); pFS->endElementNS(XML_a, XML_graphic); endDMLAnchorInline(&rFrameFormat); - uno::Reference< xml::sax::XSAXSerializable > serializer; - uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create(comphelper::getProcessComponentContext()); + uno::Reference<xml::sax::XSAXSerializable> serializer; + uno::Reference<xml::sax::XWriter> writer + = xml::sax::Writer::create(comphelper::getProcessComponentContext()); // write data file serializer.set(dataDom, uno::UNO_QUERY); - uno::Reference< io::XOutputStream > xDataOutputStream = m_pImpl->m_rExport.GetFilter().openFragmentStream( - "word/" + dataFileName, "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"); + uno::Reference<io::XOutputStream> xDataOutputStream + = m_pImpl->m_rExport.GetFilter().openFragmentStream( + "word/" + dataFileName, + "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"); writer->setOutputStream(xDataOutputStream); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), + uno::Sequence<beans::StringPair>()); // write the associated Images and rels for data file writeDiagramRels(xDataRelSeq, xDataOutputStream, "OOXDiagramDataRels", nAnchorId); // write layout file serializer.set(layoutDom, uno::UNO_QUERY); - writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream("word/" + layoutFileName, - "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml")); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream( + "word/" + layoutFileName, + "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml")); + serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), + uno::Sequence<beans::StringPair>()); // write style file serializer.set(styleDom, uno::UNO_QUERY); - writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream("word/" + styleFileName, - "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml")); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream( + "word/" + styleFileName, + "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml")); + serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), + uno::Sequence<beans::StringPair>()); // write color file serializer.set(colorDom, uno::UNO_QUERY); - writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream("word/" + colorFileName, - "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml")); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + writer->setOutputStream(m_pImpl->m_rExport.GetFilter().openFragmentStream( + "word/" + colorFileName, + "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml")); + serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), + uno::Sequence<beans::StringPair>()); // write drawing file if (drawingDom.is()) { serializer.set(drawingDom, uno::UNO_QUERY); - uno::Reference< io::XOutputStream > xDrawingOutputStream = m_pImpl->m_rExport.GetFilter().openFragmentStream("word/" + drawingFileName, + uno::Reference<io::XOutputStream> xDrawingOutputStream + = m_pImpl->m_rExport.GetFilter().openFragmentStream( + "word/" + drawingFileName, "application/vnd.openxmlformats-officedocument.drawingml.diagramDrawing+xml"); writer->setOutputStream(xDrawingOutputStream); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + serializer->serialize( + uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), + uno::Sequence<beans::StringPair>()); // write the associated Images and rels for drawing file - uno::Sequence< uno::Sequence< uno::Any > > xDrawingRelSeq; + uno::Sequence<uno::Sequence<uno::Any>> xDrawingRelSeq; diagramDrawing[1] >>= xDrawingRelSeq; writeDiagramRels(xDrawingRelSeq, xDrawingOutputStream, "OOXDiagramDrawingRels", nAnchorId); } @@ -1308,14 +1343,15 @@ void DocxSdrExport::writeOnlyTextOfFrame(ww8::Frame const* pParentFrame) const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx(); sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; - sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; + sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0; sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0; //Save data here and restore when out of scope ExportDataSaveRestore aDataGuard(m_pImpl->m_rExport, nStt, nEnd, pParentFrame); m_pImpl->m_pBodyPrAttrList = sax_fastparser::FastSerializerHelper::createAttrList(); - m_pImpl->m_bFrameBtLr = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/true); + m_pImpl->m_bFrameBtLr + = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/true); m_pImpl->m_bFlyFrameGraphic = true; m_pImpl->m_rExport.WriteText(); m_pImpl->m_bFlyFrameGraphic = false; @@ -1349,17 +1385,14 @@ void DocxSdrExport::writeBoxItemLine(const SvxBoxItem& rBox) } sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; - double fConverted(editeng::ConvertBorderWidthToWord(pBorderLine->GetBorderLineStyle(), pBorderLine->GetWidth())); + double fConverted(editeng::ConvertBorderWidthToWord(pBorderLine->GetBorderLineStyle(), + pBorderLine->GetWidth())); OString sWidth(OString::number(TwipsToEMU(fConverted))); - pFS->startElementNS(XML_a, XML_ln, - XML_w, sWidth.getStr(), - FSEND); + pFS->startElementNS(XML_a, XML_ln, XML_w, sWidth.getStr(), FSEND); pFS->startElementNS(XML_a, XML_solidFill, FSEND); OString sColor(msfilter::util::ConvertColor(pBorderLine->GetColor())); - pFS->singleElementNS(XML_a, XML_srgbClr, - XML_val, sColor, - FSEND); + pFS->singleElementNS(XML_a, XML_srgbClr, XML_val, sColor, FSEND); pFS->endElementNS(XML_a, XML_solidFill); if (SvxBorderLineStyle::DASHED == pBorderLine->GetBorderLineStyle()) // Line Style is Dash type @@ -1368,7 +1401,8 @@ void DocxSdrExport::writeBoxItemLine(const SvxBoxItem& rBox) pFS->endElementNS(XML_a, XML_ln); } -void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAnchorId, bool bTextBoxOnly) +void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAnchorId, + bool bTextBoxOnly) { bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen; m_pImpl->m_bDMLAndVMLDrawingOpen = true; @@ -1377,7 +1411,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat(); const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx(); - sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; + sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0; sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0; //Save data here and restore when out of scope @@ -1387,12 +1421,12 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho // to lots of contents, this size contains the real size. const Size aSize = pParentFrame->GetSize(); - uno::Reference< drawing::XShape > xShape; + uno::Reference<drawing::XShape> xShape; const SdrObject* pSdrObj = rFrameFormat.FindRealSdrObject(); if (pSdrObj) xShape.set(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY); - uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY); - uno::Reference< beans::XPropertySetInfo > xPropSetInfo; + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference<beans::XPropertySetInfo> xPropSetInfo; if (xPropertySet.is()) xPropSetInfo = xPropertySet->getPropertySetInfo(); @@ -1408,70 +1442,67 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho { startDMLAnchorInline(&rFrameFormat, aSize); - sax_fastparser::FastAttributeList* pDocPrAttrList = sax_fastparser::FastSerializerHelper::createAttrList(); + sax_fastparser::FastAttributeList* pDocPrAttrList + = sax_fastparser::FastSerializerHelper::createAttrList(); pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr()); - pDocPrAttrList->add(XML_name, OUStringToOString(rFrameFormat.GetName(), RTL_TEXTENCODING_UTF8).getStr()); + pDocPrAttrList->add( + XML_name, OUStringToOString(rFrameFormat.GetName(), RTL_TEXTENCODING_UTF8).getStr()); sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList); pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef); - pFS->startElementNS(XML_a, XML_graphic, - FSNS(XML_xmlns, XML_a), OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(), - FSEND); - pFS->startElementNS(XML_a, XML_graphicData, - XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + pFS->startElementNS( + XML_a, XML_graphic, FSNS(XML_xmlns, XML_a), + OUStringToOString(m_pImpl->m_rExport.GetFilter().getNamespaceURL(OOX_NS(dml)), + RTL_TEXTENCODING_UTF8) + .getStr(), + FSEND); + pFS->startElementNS(XML_a, XML_graphicData, XML_uri, + "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", FSEND); pFS->startElementNS(XML_wps, XML_wsp, FSEND); - pFS->singleElementNS(XML_wps, XML_cNvSpPr, - XML_txBox, "1", - FSEND); + pFS->singleElementNS(XML_wps, XML_cNvSpPr, XML_txBox, "1", FSEND); - uno::Any aRotation ; + uno::Any aRotation; m_pImpl->m_nDMLandVMLTextFrameRotation = 0; if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag")) { - uno::Sequence< beans::PropertyValue > propList; + uno::Sequence<beans::PropertyValue> propList; xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; - for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString propName = propList[nProp].Name; if (propName == "mso-rotation-angle") { - aRotation = propList[nProp].Value ; + aRotation = propList[nProp].Value; break; } } } - aRotation >>= m_pImpl->m_nDMLandVMLTextFrameRotation ; - OString sRotation(OString::number((OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(m_pImpl->m_nDMLandVMLTextFrameRotation)))); + aRotation >>= m_pImpl->m_nDMLandVMLTextFrameRotation; + OString sRotation(OString::number( + (OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(m_pImpl->m_nDMLandVMLTextFrameRotation)))); // Shape properties pFS->startElementNS(XML_wps, XML_spPr, FSEND); if (m_pImpl->m_nDMLandVMLTextFrameRotation) { - pFS->startElementNS(XML_a, XML_xfrm, - XML_rot, sRotation.getStr(), - FSEND); + pFS->startElementNS(XML_a, XML_xfrm, XML_rot, sRotation.getStr(), FSEND); } else { pFS->startElementNS(XML_a, XML_xfrm, FSEND); } - pFS->singleElementNS(XML_a, XML_off, - XML_x, "0", - XML_y, "0", - FSEND); + pFS->singleElementNS(XML_a, XML_off, XML_x, "0", XML_y, "0", FSEND); OString aWidth(OString::number(TwipsToEMU(aSize.Width()))); OString aHeight(OString::number(TwipsToEMU(aSize.Height()))); - pFS->singleElementNS(XML_a, XML_ext, - XML_cx, aWidth.getStr(), - XML_cy, aHeight.getStr(), + pFS->singleElementNS(XML_a, XML_ext, XML_cx, aWidth.getStr(), XML_cy, aHeight.getStr(), FSEND); pFS->endElementNS(XML_a, XML_xfrm); OUString shapeType = "rect"; if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag")) { - uno::Sequence< beans::PropertyValue > propList; + uno::Sequence<beans::PropertyValue> propList; xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; - for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString propName = propList[nProp].Name; if (propName == "mso-orig-shape-type") @@ -1485,9 +1516,8 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho if (shapeType.isEmpty()) shapeType = "rect"; - pFS->singleElementNS(XML_a, XML_prstGeom, - XML_prst, OUStringToOString(shapeType, RTL_TEXTENCODING_UTF8).getStr(), - FSEND); + pFS->singleElementNS(XML_a, XML_prstGeom, XML_prst, + OUStringToOString(shapeType, RTL_TEXTENCODING_UTF8).getStr(), FSEND); m_pImpl->m_bDMLTextFrameSyntax = true; m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrameFormat(), false, false, true); m_pImpl->m_bDMLTextFrameSyntax = false; @@ -1499,12 +1529,13 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho std::map<OUString, MSWordExportBase::LinkedTextboxInfo>::iterator linkedTextboxesIter; if (!m_pImpl->m_rExport.m_bLinkedTextboxesHelperInitialized) { - sal_Int32 nSeq=0; + sal_Int32 nSeq = 0; linkedTextboxesIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.begin(); while (linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end()) { //find the start of a textbox chain: has no PREVIOUS link, but does have NEXT link - if (linkedTextboxesIter->second.sPrevChain.isEmpty() && !linkedTextboxesIter->second.sNextChain.isEmpty()) + if (linkedTextboxesIter->second.sPrevChain.isEmpty() + && !linkedTextboxesIter->second.sNextChain.isEmpty()) { //assign this chain a unique ID and start a new sequence nSeq = 0; @@ -1514,8 +1545,9 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho OUString sCheckForBrokenChains = linkedTextboxesIter->first; //follow the chain and assign the same id, and incremental sequence numbers. - std::map<OUString, MSWordExportBase::LinkedTextboxInfo>::iterator followChainIter; - followChainIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find(linkedTextboxesIter->second.sNextChain); + std::map<OUString, MSWordExportBase::LinkedTextboxInfo>::iterator followChainIter; + followChainIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find( + linkedTextboxesIter->second.sNextChain); while (followChainIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end()) { //verify that the NEXT textbox also points to me as the PREVIOUS. @@ -1531,7 +1563,8 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho break; sCheckForBrokenChains = followChainIter->first; - followChainIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find(followChainIter->second.sNextChain); + followChainIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find( + followChainIter->second.sNextChain); } } ++linkedTextboxesIter; @@ -1540,8 +1573,8 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho } m_pImpl->m_rExport.m_pParentFrame = nullptr; - bool skipTxBxContent = false ; - bool isTxbxLinked = false ; + bool skipTxBxContent = false; + bool isTxbxLinked = false; OUString sLinkChainName; if (xPropSetInfo.is()) @@ -1556,39 +1589,39 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho linkedTextboxesIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find(sLinkChainName); if (linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end()) { - if ((linkedTextboxesIter->second.nId !=0) && (linkedTextboxesIter->second.nSeq != 0)) + if ((linkedTextboxesIter->second.nId != 0) && (linkedTextboxesIter->second.nSeq != 0)) { //not the first in the chain, so write the tag as linkedTxbx - pFS->singleElementNS(XML_wps, XML_linkedTxbx, - XML_id, I32S(linkedTextboxesIter->second.nId), - XML_seq, I32S(linkedTextboxesIter->second.nSeq), - FSEND); + pFS->singleElementNS(XML_wps, XML_linkedTxbx, XML_id, + I32S(linkedTextboxesIter->second.nId), XML_seq, + I32S(linkedTextboxesIter->second.nSeq), FSEND); /* no text content should be added to this tag, since the textbox is linked, the entire content is written in txbx block */ - skipTxBxContent = true ; + skipTxBxContent = true; } else if ((linkedTextboxesIter->second.nId != 0) && (linkedTextboxesIter->second.nSeq == 0)) { /* this is the first textbox in the chaining, we add the text content to this block*/ //since the text box is linked, it needs an id. - pFS->startElementNS(XML_wps, XML_txbx, - XML_id, I32S(linkedTextboxesIter->second.nId), + pFS->startElementNS(XML_wps, XML_txbx, XML_id, I32S(linkedTextboxesIter->second.nId), FSEND); - isTxbxLinked = true ; + isTxbxLinked = true; } } if (!skipTxBxContent) { if (!isTxbxLinked) - pFS->startElementNS(XML_wps, XML_txbx, FSEND);//text box is not linked, therefore no id. + pFS->startElementNS(XML_wps, XML_txbx, + FSEND); //text box is not linked, therefore no id. pFS->startElementNS(XML_w, XML_txbxContent, FSEND); - m_pImpl->m_bFrameBtLr = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/true); + m_pImpl->m_bFrameBtLr + = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/true); m_pImpl->m_bFlyFrameGraphic = true; m_pImpl->m_rExport.WriteText(); if (m_pImpl->m_bParagraphSdtOpen) @@ -1606,13 +1639,13 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho // We need to init padding to 0, if it's not set. // In LO the default is 0 and so ins attributes are not set when padding is 0 // but in MSO the default is 254 / 127, so we need to set 0 padding explicitly - if(!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_lIns)) + if (!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_lIns)) m_pImpl->m_pBodyPrAttrList->add(XML_lIns, OString::number(0)); - if(!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_tIns)) + if (!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_tIns)) m_pImpl->m_pBodyPrAttrList->add(XML_tIns, OString::number(0)); - if(!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_rIns)) + if (!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_rIns)) m_pImpl->m_pBodyPrAttrList->add(XML_rIns, OString::number(0)); - if(!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_bIns)) + if (!m_pImpl->m_pBodyPrAttrList->hasAttribute(XML_bIns)) m_pImpl->m_pBodyPrAttrList->add(XML_bIns, OString::number(0)); sax_fastparser::XFastAttributeListRef xBodyPrAttrList(m_pImpl->m_pBodyPrAttrList); @@ -1622,7 +1655,9 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho pFS->startElementNS(XML_wps, XML_bodyPr, xBodyPrAttrList); // AutoSize of the Text Frame. const SwFormatFrameSize& rSize = rFrameFormat.GetFrameSize(); - pFS->singleElementNS(XML_a, (rSize.GetHeightSizeType() == ATT_VAR_SIZE ? XML_spAutoFit : XML_noAutofit), FSEND); + pFS->singleElementNS( + XML_a, (rSize.GetHeightSizeType() == ATT_VAR_SIZE ? XML_spAutoFit : XML_noAutofit), + FSEND); pFS->endElementNS(XML_wps, XML_bodyPr); pFS->endElementNS(XML_wps, XML_wsp); @@ -1633,8 +1668,10 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho const sal_uInt8 nWidthPercent = rSize.GetWidthPercent(); if (nWidthPercent && nWidthPercent != SwFormatFrameSize::SYNCED) { - pFS->startElementNS(XML_wp14, XML_sizeRelH, - XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"), + pFS->startElementNS(XML_wp14, XML_sizeRelH, XML_relativeFrom, + (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME + ? "page" + : "margin"), FSEND); pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND); pFS->writeEscaped(OUString::number(nWidthPercent * oox::drawingml::PER_PERCENT)); @@ -1644,9 +1681,11 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho const sal_uInt8 nHeightPercent = rSize.GetHeightPercent(); if (nHeightPercent && nHeightPercent != SwFormatFrameSize::SYNCED) { - pFS->startElementNS(XML_wp14, XML_sizeRelV, - XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"), - FSEND); + pFS->startElementNS( + XML_wp14, XML_sizeRelV, XML_relativeFrom, + (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" + : "margin"), + FSEND); pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND); pFS->writeEscaped(OUString::number(nHeightPercent * oox::drawingml::PER_PERCENT)); pFS->endElementNS(XML_wp14, XML_pctHeight); @@ -1667,7 +1706,7 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat(); const SwNodeIndex* pNodeIndex = rFrameFormat.GetContent().GetContentIdx(); - sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; + sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex() + 1 : 0; sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0; //Save data here and restore when out of scope @@ -1695,11 +1734,13 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText { OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObject); if (!sAnchorId.isEmpty()) - m_pImpl->m_pFlyAttrList->addNS(XML_w14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); + m_pImpl->m_pFlyAttrList->addNS(XML_w14, XML_anchorId, + OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); } sax_fastparser::XFastAttributeListRef xFlyAttrList(m_pImpl->m_pFlyAttrList.get()); m_pImpl->m_pFlyAttrList.clear(); - m_pImpl->m_bFrameBtLr = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/false); + m_pImpl->m_bFrameBtLr + = m_pImpl->checkFrameBtlr(m_pImpl->m_rExport.m_pDoc->GetNodes()[nStt], /*bDML=*/false); sax_fastparser::XFastAttributeListRef xTextboxAttrList(m_pImpl->m_pTextboxAttrList.get()); m_pImpl->m_pTextboxAttrList.clear(); m_pImpl->m_bTextFrameSyntax = false; @@ -1713,13 +1754,15 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText m_pImpl->textFrameShadow(rFrameFormat); if (m_pImpl->m_pFlyFillAttrList.is()) { - sax_fastparser::XFastAttributeListRef xFlyFillAttrList(m_pImpl->m_pFlyFillAttrList.get()); + sax_fastparser::XFastAttributeListRef xFlyFillAttrList( + m_pImpl->m_pFlyFillAttrList.get()); m_pImpl->m_pFlyFillAttrList.clear(); pFS->singleElementNS(XML_v, XML_fill, xFlyFillAttrList); } if (m_pImpl->m_pDashLineStyleAttr.is()) { - sax_fastparser::XFastAttributeListRef xDashLineStyleAttr(m_pImpl->m_pDashLineStyleAttr.get()); + sax_fastparser::XFastAttributeListRef xDashLineStyleAttr( + m_pImpl->m_pDashLineStyleAttr.get()); m_pImpl->m_pDashLineStyleAttr.clear(); pFS->singleElementNS(XML_v, XML_stroke, xDashLineStyleAttr); } |