[Libreoffice-commits] core.git: 2 commits - sw/CppunitTest_sw_ooxmlimport.mk sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Feb 18 20:23:27 CET 2014


 sw/CppunitTest_sw_ooxmlimport.mk                  |    1 
 sw/qa/extras/ooxmlimport/data/ole-anchor.docx     |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx          |    6 +++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   26 ++++++----------------
 4 files changed, 15 insertions(+), 18 deletions(-)

New commits:
commit 2a35f5c7945d00b6f6e21fc7cf5b05b184eba88f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 18 19:54:32 2014 +0100

    DOCX OLE import: inherit anchor type from replacement graphic
    
    Change-Id: Ic8b6f423acae5cc7e3799cf20e672b56a9cc8c0c

diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk
index d72f93e..1171001 100644
--- a/sw/CppunitTest_sw_ooxmlimport.mk
+++ b/sw/CppunitTest_sw_ooxmlimport.mk
@@ -51,6 +51,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\
 	basic/util/sb \
     chart2/source/controller/chartcontroller \
     chart2/source/chartcore \
+	canvas/source/factory/canvasfactory \
     comphelper/util/comphelp \
     configmgr/source/configmgr \
     drawinglayer/drawinglayer \
diff --git a/sw/qa/extras/ooxmlimport/data/ole-anchor.docx b/sw/qa/extras/ooxmlimport/data/ole-anchor.docx
new file mode 100755
index 0000000..11df239
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/ole-anchor.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f264f0c..3c7c473 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1783,6 +1783,12 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(EMU_TO_MM100(9142730)), getShape(1)->getSize().Height);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testOleAnchor, "ole-anchor.docx")
+{
+    // This was AS_CHARACTER, even if the VML style explicitly contains "position:absolute".
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capitalization.docx")
 {
     // Capitalization inside a group shape was not imported
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b60c2a8..9e290e6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1231,9 +1231,13 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, OLEHandlerPtr pO
         uno::Reference< graphic::XGraphic > xGraphic = pOLEHandler->getReplacement();
         xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_GRAPHIC ),
                         uno::makeAny(xGraphic));
-        // mimic the treatment of graphics here.. it seems anchoring as character
-        // gives a better ( visually ) result
-        xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ),  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
+        uno::Reference<beans::XPropertySet> xReplacementProperties(pOLEHandler->getShape(), uno::UNO_QUERY);
+        if (xReplacementProperties.is())
+            xOLEProperties->setPropertyValue("AnchorType", xReplacementProperties->getPropertyValue("AnchorType"));
+        else
+            // mimic the treatment of graphics here.. it seems anchoring as character
+            // gives a better ( visually ) result
+            xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ),  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
         // remove ( if valid ) associated shape ( used for graphic replacement )
         m_aAnchoredStack.top( ).bToRemove = true;
         RemoveLastParagraph();
commit ff02109b65052a1d17d18f1f66a43480c8792691
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 18 18:34:01 2014 +0100

    Clean up DomainMapper_Impl::PushShapeContext()
    
    It doesn't make sense to set anchor type here: either the VML import
    already set it, or it should be set when the anchor/inline token
    arrives.
    
    Additionally, this basically ensured that non-inline pictures are either
    inline or at-page anchored, and both of those values are incorrect.
    
    Change-Id: Ic71aeca9da333665a2749bb0aabbb9b63cee0c00

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2cbc737..b60c2a8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1732,18 +1732,8 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
 #ifdef DEBUG_DOMAINMAPPER
             dmapper_logger->unoPropertySet(xProps);
 #endif
-            bool bIsGraphic = xSInfo->supportsService( "com.sun.star.drawing.GraphicObjectShape" );
-
-            // If there are position properties, the shape should not be inserted "as character".
-            sal_Int32 nHoriPosition = 0, nVertPosition = 0;
-            xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION)) >>= nHoriPosition;
-            xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION)) >>= nVertPosition;
-            if (nHoriPosition != 0 || nVertPosition != 0)
-                bIsGraphic = false;
             text::TextContentAnchorType nAnchorType(text::TextContentAnchorType_AT_PARAGRAPH);
             xProps->getPropertyValue(rPropNameSupplier.GetName( PROP_ANCHOR_TYPE )) >>= nAnchorType;
-            if (nAnchorType == text::TextContentAnchorType_AT_PAGE)
-                bIsGraphic = false;
 
             if (!m_bInHeaderFooterImport)
                 xProps->setPropertyValue(
@@ -1772,11 +1762,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
                 // we need to re-set this value to xTextContent, then only values are preserved.
                 xPropertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
             }
-            else if (nAnchorType != text::TextContentAnchorType_AS_CHARACTER)
-            {
-                xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic  ?  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) );
-            }
-            else
+            else if (nAnchorType == text::TextContentAnchorType_AS_CHARACTER)
             {
                 // Fix spacing for as-character objects. If the paragraph has CT_Spacing_after set,
                 // it needs to be set on the object too, as that's what object placement code uses.


More information about the Libreoffice-commits mailing list