diff options
Diffstat (limited to 'writerfilter/source')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 15 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 13 |
5 files changed, 38 insertions, 12 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 41a44ce10715..d453b1cbe9c0 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1671,7 +1671,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con // Remember what objects are anchored to this paragraph. // That list is only used for Word compat purposes, and // it is only relevant for body text. - AnchoredObjectInfo aInfo; + AnchoredObjectsInfo aInfo; aInfo.m_xParagraph = xTextRange; aInfo.m_aAnchoredObjects = rAppendContext.m_aAnchoredObjects; m_aAnchoredObjectAnchors.push_back(aInfo); @@ -6132,8 +6132,18 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties appendTextContent( xTextContent, uno::Sequence< beans::PropertyValue >() ); if (eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR && !m_aTextAppendStack.empty()) + { // Remember this object is anchored to the current paragraph. - m_aTextAppendStack.top().m_aAnchoredObjects.push_back(xTextContent); + AnchoredObjectInfo aInfo; + aInfo.m_xAnchoredObject = xTextContent; + if (m_pGraphicImport) + { + // We still have the graphic import around, remember the original margin, so later + // SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing() can use it. + aInfo.m_nLeftMargin = m_pGraphicImport->GetLeftMarginOrig(); + } + m_aTextAppendStack.top().m_aAnchoredObjects.push_back(aInfo); + } } // Clear the reference, so in case the embedded object is inside a diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 507150ec4e50..490e4f625401 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -226,7 +226,7 @@ struct TextAppendContext * Objects anchored to the current paragraph, may affect the paragraph * spacing. */ - std::vector<css::uno::Reference<css::text::XTextContent>> m_aAnchoredObjects; + std::vector<AnchoredObjectInfo> m_aAnchoredObjects; TextAppendContext(const css::uno::Reference<css::text::XTextAppend>& xAppend, const css::uno::Reference<css::text::XTextCursor>& xCur) : xTextAppend(xAppend) @@ -387,11 +387,18 @@ struct FloatingTableInfo css::uno::Any getPropertyValue(const OUString &propertyName); }; -/// Stores info about objects anchored to a given paragraph. +/// Stores original/in-file-format info about a single anchored object. struct AnchoredObjectInfo { + css::uno::Reference<css::text::XTextContent> m_xAnchoredObject; + sal_Int32 m_nLeftMargin = 0; +}; + +/// Stores info about objects anchored to a given paragraph. +struct AnchoredObjectsInfo +{ css::uno::Reference<css::text::XTextRange> m_xParagraph; - std::vector<css::uno::Reference<css::text::XTextContent>> m_aAnchoredObjects; + std::vector<AnchoredObjectInfo> m_aAnchoredObjects; }; struct SymbolData @@ -982,7 +989,7 @@ public: std::vector<FloatingTableInfo> m_aPendingFloatingTables; /// Paragraphs with anchored objects in the current section. - std::vector<AnchoredObjectInfo> m_aAnchoredObjectAnchors; + std::vector<AnchoredObjectsInfo> m_aAnchoredObjectAnchors; /// Append a property to a sub-grabbag if necessary (e.g. 'lineRule', 'auto') void appendGrabBag(std::vector<css::beans::PropertyValue>& rInteropGrabBag, const OUString& aKey, const OUString& aValue); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 7b1916df0268..74fa991eeb10 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -211,6 +211,7 @@ public: WrapPolygon::Pointer_t mpWrapPolygon; sal_Int32 nLeftMargin; + sal_Int32 nLeftMarginOrig = 0; sal_Int32 nRightMargin; sal_Int32 nTopMargin; sal_Int32 nBottomMargin; @@ -986,6 +987,7 @@ void GraphicImport::ProcessShapeOptions(Value const & rValue) { case NS_ooxml::LN_CT_Anchor_distL: m_pImpl->nLeftMargin = nIntValue / 360; + m_pImpl->nLeftMarginOrig = m_pImpl->nLeftMargin; break; case NS_ooxml::LN_CT_Anchor_distT: //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustULWrapForWordMargins() @@ -1501,6 +1503,11 @@ bool GraphicImport::IsGraphic() const return m_pImpl->bIsGraphic; } +sal_Int32 GraphicImport::GetLeftMarginOrig() const +{ + return m_pImpl->nLeftMarginOrig; +} + } } diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx index a54a6980ef5f..d83f41cb161d 100644 --- a/writerfilter/source/dmapper/GraphicImport.hxx +++ b/writerfilter/source/dmapper/GraphicImport.hxx @@ -97,6 +97,7 @@ public: css::uno::Reference<css::text::XTextContent> GetGraphicObject(); const css::uno::Reference<css::drawing::XShape>& GetXShapeObject() const { return m_xShape;} bool IsGraphic() const; + sal_Int32 GetLeftMarginOrig() const; private: // Properties diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index d6e9794a9728..00678668845f 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1225,7 +1225,7 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& sal_Int32 nPageWidth = GetPageWidth(); sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin(); - std::vector<AnchoredObjectInfo>& rAnchoredObjectAnchors = rDM_Impl.m_aAnchoredObjectAnchors; + std::vector<AnchoredObjectsInfo>& rAnchoredObjectAnchors = rDM_Impl.m_aAnchoredObjectAnchors; for (const auto& rAnchor : rAnchoredObjectAnchors) { // Ignore this paragraph when there are not enough shapes to trigger the Word bug we @@ -1238,11 +1238,11 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& sal_Int32 nShapesWidth = 0; for (const auto& rAnchored : rAnchor.m_aAnchoredObjects) { - uno::Reference<drawing::XShape> xShape(rAnchored, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(rAnchored.m_xAnchoredObject, uno::UNO_QUERY); if (!xShape.is()) continue; - uno::Reference<beans::XPropertySet> xPropertySet(rAnchored, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); if (!xPropertySet.is()) continue; @@ -1252,8 +1252,9 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& if (eWrap == text::WrapTextMode_THROUGH) continue; - sal_Int32 nLeftMargin = 0; - xPropertySet->getPropertyValue("LeftMargin") >>= nLeftMargin; + // Use the original left margin, in case GraphicImport::lcl_sprm() reduced the doc model + // one to 0. + sal_Int32 nLeftMargin = rAnchored.m_nLeftMargin; sal_Int32 nRightMargin = 0; xPropertySet->getPropertyValue("RightMargin") >>= nRightMargin; nShapesWidth += xShape->getSize().Width + nLeftMargin + nRightMargin; @@ -1266,7 +1267,7 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& sal_Int32 nHeight = 0; for (const auto& rAnchored : rAnchor.m_aAnchoredObjects) { - uno::Reference<drawing::XShape> xShape(rAnchored, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(rAnchored.m_xAnchoredObject, uno::UNO_QUERY); if (!xShape.is()) continue; |