[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - oox/source sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Fri Nov 27 01:58:16 PST 2015


 oox/source/vml/vmlshape.cxx                 |   27 ++++++++++++++++++---------
 sw/qa/extras/ooxmlimport/data/tdf78902.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx    |    6 ++++++
 3 files changed, 24 insertions(+), 9 deletions(-)

New commits:
commit d66df3d35030bf725fa7e3d78420344ddd44478c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 24 09:22:16 2015 +0100

    tdf#78902 VML import: workaround for extreme top margin
    
    Regression from commit 2b78f2cd7b9e4bab0f3b3b9119238f36a1bbc7b2 (rhbz#988516:
    DOCX import: fix context stack when importing header/footer, 2014-03-05),
    though that just made an existing Writer layout problem visible.
    
    RTF/WW8/newer (drawingML) DOCX import doesn't have this problem, as those
    import pictures as sw graphics, not draw ones.
    
    <w10:wrap type="through"/> is normally mapped to our page wrap (as it uses
    "through" in the "not only wrap around, but also in the holes of the shape, if
    it has any" context, not in our "text should go through it, so no wrapping"
    one), but for some reason in this case (most probably due to the extreme large
    negative margins) Word handles the situation as our through, i.e. the text
    should not go to the second page, as it would normally happen with a "Word
    through" wrapping.
    
    Work around the strange situation by ignoring the wrapping request for extreme
    top margin values.
    
    (cherry picked from commit 37b5f1ed3139b8569bfec0fcb5077f6b66b79acd)
    
    Conflicts:
    	oox/source/vml/vmlshape.cxx
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    
    Change-Id: I20555b1fa7a769e20c40a3a5ff3873807403e937
    Reviewed-on: https://gerrit.libreoffice.org/20212
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5394677..aa07015 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -527,11 +527,18 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) :
 {
 }
 
-void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
+void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel, const GraphicHelper& rGraphicHelper)
 {
+    OUString aWrapType = rTypeModel.moWrapType.get();
+
+    // Extreme negative top margin? Then the shape will end up at the top of the page, it's pointless to perform any kind of wrapping.
+    sal_Int32 nMarginTop = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, rTypeModel.maMarginTop, 0, false, true);
+    if (nMarginTop < -35277) // Less than 1000 points.
+        aWrapType.clear();
+
     sal_Int32 nSurround = com::sun::star::text::WrapTextMode_THROUGHT;
-    if ( rTypeModel.moWrapType.get() == "square" || rTypeModel.moWrapType .get()== "tight" ||
-         rTypeModel.moWrapType.get() == "through" )
+    if ( aWrapType == "square" || aWrapType == "tight" ||
+         aWrapType == "through" )
     {
         nSurround = com::sun::star::text::WrapTextMode_PARALLEL;
         if ( rTypeModel.moWrapSide.get() == "left" )
@@ -539,13 +546,13 @@ void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
         else if ( rTypeModel.moWrapSide.get() == "right" )
             nSurround = com::sun::star::text::WrapTextMode_RIGHT;
     }
-    else if ( rTypeModel.moWrapType.get() == "topAndBottom" )
+    else if ( aWrapType == "topAndBottom" )
         nSurround = com::sun::star::text::WrapTextMode_NONE;
 
     rPropSet.setProperty(PROP_Surround, nSurround);
 }
 
-void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
+void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel, const GraphicHelper& rGraphicHelper)
 {
     if ( rTypeModel.maPositionHorizontal == "center" )
         rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::CENTER));
@@ -608,7 +615,7 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
     {
         rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER);
     }
-    lcl_setSurround( rPropSet, rTypeModel );
+    lcl_setSurround( rPropSet, rTypeModel, rGraphicHelper );
 }
 
 void lcl_SetRotation(PropertySet& rPropSet, const sal_Int32 nRotation)
@@ -810,7 +817,7 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
         }
     }
 
-    lcl_SetAnchorType(aPropertySet, maTypeModel);
+    lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper);
 
     return xShape;
 }
@@ -839,7 +846,8 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >
         if ( !maTypeModel.maRotation.isEmpty() )
             lcl_SetRotation( aPropSet, maTypeModel.maRotation.toInt32() );
 
-        lcl_SetAnchorType(aPropSet, maTypeModel);
+        const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
+        lcl_SetAnchorType(aPropSet, maTypeModel, rGraphicHelper);
     }
     return xShape;
 }
@@ -1228,7 +1236,8 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes >
     }
     // Make sure group shapes are inline as well, unless there is an explicit different style.
     PropertySet aPropertySet(xGroupShape);
-    lcl_SetAnchorType(aPropertySet, maTypeModel);
+    const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
+    lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper);
     if (!maTypeModel.maRotation.isEmpty())
         lcl_SetRotation(aPropertySet, maTypeModel.maRotation.toInt32());
     return xGroupShape;
diff --git a/sw/qa/extras/ooxmlimport/data/tdf78902.docx b/sw/qa/extras/ooxmlimport/data/tdf78902.docx
new file mode 100644
index 0000000..3cf3a44
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf78902.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index c56ed5e..87435f5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2853,6 +2853,12 @@ DECLARE_OOXMLIMPORT_TEST(testTdf85232, "tdf85232.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2267), xShape->getPosition().X);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf78902, "tdf78902.docx")
+{
+    // This hung in layout.
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list