[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Jul 8 03:45:29 PDT 2015


 sw/qa/extras/ooxmlexport/data/tdf89890.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx         |   23 +++++++++++++++++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx        |    2 +-
 writerfilter/source/dmapper/NumberingManager.cxx |   14 ++++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit e3d78d605905ef23b15002a29f0f3a6de5cc12ac
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jun 26 09:02:31 2015 +0200

    tdf#89890 DOCX import: fix too large num pic bullet
    
    Reading SwWW8ImplReader::CoreLoad()'s "update graphic bullet
    information" block, it turns out that the numbering picture bullet's
    height should be independent from the supplied bitmap, and only its
    aspect ratio should be respected.
    
    Reviewed-on: https://gerrit.libreoffice.org/16500
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit eab89b7f024a8c86decdcb3362c40c40a7df37df)
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    
    Change-Id: I1300aa0397a8098df2a3170af795fbba47fd2a9e
    Reviewed-on: https://gerrit.libreoffice.org/16844
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf89890.docx b/sw/qa/extras/ooxmlexport/data/tdf89890.docx
new file mode 100644
index 0000000..8b3e8eb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf89890.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ac4b246..2e4b8a3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -638,6 +638,29 @@ DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx")
 
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf89890, "tdf89890.docx")
+{
+    // Numbering picture bullet was too large.
+    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(0) >>= aProps; // 1st level
+
+    bool bFound = false;
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+
+        if (rProp.Name == "GraphicSize")
+        {
+            // Height of the graphic was too large: 4382 after import, then 2485 after roundtrip.
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(279), rProp.Value.get<awt::Size>().Height);
+            bFound = true;
+        }
+    }
+    CPPUNIT_ASSERT(bFound);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index e187959..9a495fd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -353,7 +353,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx")
     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     if (!pXmlDoc)
         return;
-    assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt");
+    assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:7.9pt;height:7.9pt");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 2412f8c..17786ea 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -877,6 +877,20 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
             case NS_ooxml::LN_CT_NumPicBullet_pict:
             {
                 uno::Reference<drawing::XShape> xShape = m_rDMapper.PopPendingShape();
+
+                // Respect only the aspect ratio of the picture, not its size.
+                awt::Size aPrefSize = xShape->getSize();
+                // See SwDefBulletConfig::InitFont(), default height is 14.
+                const int nFontHeight = 14;
+                // Point -> mm100.
+                const int nHeight = nFontHeight * 35;
+                if (aPrefSize.Height * aPrefSize.Width != 0)
+                {
+                    int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height;
+                    awt::Size aSize(nWidth, nHeight);
+                    xShape->setSize(aSize);
+                }
+
                 m_pCurrentNumPicBullet->SetShape(xShape);
             }
             break;


More information about the Libreoffice-commits mailing list