diff options
author | Regényi Balázs <regenyi.balazs@nisz.hu> | 2020-12-01 12:16:12 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-12-10 12:03:39 +0100 |
commit | aefb6aaf6475b71668bab7e11ce51b0fdc34f299 (patch) | |
tree | 38353099670125a3cb96189e0dc1fb155b73d2e1 /oox/source/export/vmlexport.cxx | |
parent | 172b81479451f0af2978dfa2eba1f9d105b946c9 (diff) |
tdf#41466 DOCX import: fix VML v:shape/v:textbox
VML v:shape/v:textbox element was imported only as
a text frame, losing (otherwise recognized) preset
shape geometry, i.e. replacing a callout bubble
(wedgeRectCallout) and other special shapes with a
plain rectangle.
Thanks to Attila Bakos for the initial help.
Change-Id: I03a608822ed54a20ed07406a08c3539e72958f5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105299
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit bda05ba17362222b74727872579b65b3fa14e3d8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107486
Diffstat (limited to 'oox/source/export/vmlexport.cxx')
-rw-r--r-- | oox/source/export/vmlexport.cxx | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 430ade878bf2..5ef5ed096b2e 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -46,6 +46,8 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/XTextFrame.hpp> #include <cstdio> @@ -1470,15 +1472,49 @@ void VMLExport::EndShape( sal_Int32 nShapeElement ) if (m_pTextExport && lcl_isTextBox(m_pSdrObject)) { - uno::Reference<beans::XPropertySet> xPropertySet(const_cast<SdrObject*>(m_pSdrObject)->getUnoShape(), uno::UNO_QUERY); - comphelper::SequenceAsHashMap aCustomShapeProperties(xPropertySet->getPropertyValue("CustomShapeGeometry")); - sax_fastparser::FastAttributeList* pTextboxAttrList = FastSerializerHelper::createAttrList(); - if (aCustomShapeProperties.find("TextPreRotateAngle") != aCustomShapeProperties.end()) + uno::Reference<drawing::XShape> xShape {const_cast<SdrObject*>(m_pSdrObject)->getUnoShape(), uno::UNO_QUERY}; + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + bool bBottomToTop = false; + if (xPropertySetInfo->hasPropertyByName("CustomShapeGeometry")) { - sal_Int32 nTextRotateAngle = aCustomShapeProperties["TextPreRotateAngle"].get<sal_Int32>(); - if (nTextRotateAngle == -270) - pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top"); + // In this case a DrawingML DOCX was imported. + comphelper::SequenceAsHashMap aCustomShapeProperties( + xPropertySet->getPropertyValue("CustomShapeGeometry")); + if (aCustomShapeProperties.find("TextPreRotateAngle") != aCustomShapeProperties.end()) + { + sal_Int32 nTextRotateAngle = aCustomShapeProperties["TextPreRotateAngle"].get<sal_Int32>(); + if (nTextRotateAngle == -270) + bBottomToTop = true; + } } + else + { + // In this case a pure VML DOCX was imported, so there is no CustomShapeGeometry. + auto pTextExport = m_pTextExport->GetDrawingML().GetTextExport(); + // FIXME: somewhy pTextExport is always nullptr, we should find its reason + if (pTextExport) + { + auto xTextFrame = pTextExport->GetUnoTextFrame(xShape); + uno::Reference<beans::XPropertySet> xPropSet(xTextFrame, uno::UNO_QUERY); + auto aAny = xPropSet->getPropertyValue("WritingMode"); + sal_Int16 nWritingMode; + if (aAny >>= nWritingMode) + { + switch (nWritingMode) + { + case text::WritingMode2::BT_LR: + bBottomToTop = true; + break; + default: + break; + } + } + } + } + sax_fastparser::FastAttributeList* pTextboxAttrList = FastSerializerHelper::createAttrList(); + if (bBottomToTop) + pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top"); sax_fastparser::XFastAttributeListRef xTextboxAttrList(pTextboxAttrList); pTextboxAttrList = nullptr; m_pSerializer->startElementNS(XML_v, XML_textbox, xTextboxAttrList); |