summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-05-17 18:45:21 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-05-20 05:18:37 +0200
commit486d340423f28c94348efb807e3364bc94b18105 (patch)
treee478423cc19eaf331942d952d72be99fc641a922 /sw
parent027b5a14830c0013ce79877eab66dcf309366ecc (diff)
tdf#117502 fix graphical bullets for OOXML and RTF
This change has multiple parts: - Move "BulletAsImage" test from ODT only to globalfilter and run it on ODT, DOC, DOCX, RTF formats and extend checks of the XGraphic used for the bullets and the size. - Check if GIF is animated as we need to know this in unloaded graphic or bullets aren't rendered correctly if we assume they are animated. - Use "Graphic" property in writerfilter to get the graphic from a XShape and not the "Bitmap" property which returns a Graphic as a MetaFile and not the original Graphic. - Make sure "GraphicBitmap" is filled with XBitmap and not with XGraphic. - Change "testFDO74215" to use the expected bullet size as it is in the original document. Looks like the initial bug was just asserting the bullet size is set to a value (non-zero). Change-Id: I6b151c0bf9f426669e07522f0fc699fbb652046b Reviewed-on: https://gerrit.libreoffice.org/54477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/globalfilter/data/BulletAsImage.odtbin0 -> 9113 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx142
-rw-r--r--sw/qa/extras/odfexport/data/BulletAsImage.odtbin9856 -> 0 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx23
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx10
5 files changed, 151 insertions, 24 deletions
diff --git a/sw/qa/extras/globalfilter/data/BulletAsImage.odt b/sw/qa/extras/globalfilter/data/BulletAsImage.odt
new file mode 100644
index 000000000000..27622aac4ee8
--- /dev/null
+++ b/sw/qa/extras/globalfilter/data/BulletAsImage.odt
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 60b3d083a0c4..088e6b7658be 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -44,6 +44,7 @@ public:
void testSkipImages();
#endif
void testRedlineFlags();
+ void testBulletAsImage();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testEmbeddedGraphicRoundtrip);
@@ -58,6 +59,7 @@ public:
CPPUNIT_TEST(testSkipImages);
#endif
CPPUNIT_TEST(testRedlineFlags);
+ CPPUNIT_TEST(testBulletAsImage);
CPPUNIT_TEST_SUITE_END();
};
@@ -882,6 +884,146 @@ void Test::testRedlineFlags()
}
}
+void Test::testBulletAsImage()
+{
+ OUString aFilterNames[] = {
+ "writer8",
+ "MS Word 97",
+ "Office Open XML Text",
+ "Rich Text Format",
+ };
+
+ for (OUString const & rFilterName : aFilterNames)
+ {
+ OString sFailedMessage = OString("Failed on filter: ") + rFilterName.toUtf8();
+
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ mxComponent = loadFromDesktop(m_directories.getURLFromSrc("/sw/qa/extras/globalfilter/data/BulletAsImage.odt"), "com.sun.star.text.TextDocument");
+
+ // Check if import was successful
+ {
+ uno::Reference<text::XTextRange> xPara(getParagraph(1));
+ uno::Reference<beans::XPropertySet> xPropertySet(xPara, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xLevels;
+ xLevels.set(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProperties;
+ xLevels->getByIndex(0) >>= aProperties;
+ uno::Reference<awt::XBitmap> xBitmap;
+ awt::Size aSize;
+ sal_Int16 nNumberingType = -1;
+
+ for (beans::PropertyValue const & rProperty : aProperties)
+ {
+ if (rProperty.Name == "NumberingType")
+ {
+ nNumberingType = rProperty.Value.get<sal_Int16>();
+ }
+ else if (rProperty.Name == "GraphicBitmap")
+ {
+ if (rProperty.Value.has<uno::Reference<awt::XBitmap>>())
+ {
+ xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
+ }
+ }
+ else if (rProperty.Name == "GraphicSize")
+ {
+ aSize = rProperty.Value.get<awt::Size>();
+ }
+ }
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), style::NumberingType::BITMAP, nNumberingType);
+
+ // Graphic Bitmap
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
+ Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > sal_uLong(0));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Height());
+
+ // Graphic Size
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(400), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(400), aSize.Height);
+ }
+
+ // Export the document and import again for a check
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= rFilterName;
+
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
+ xComponent->dispose();
+
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ {
+ uno::Reference<text::XTextRange> xPara(getParagraph(1));
+ uno::Reference<beans::XPropertySet> xPropertySet(xPara, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xLevels;
+ xLevels.set(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProperties;
+ xLevels->getByIndex(0) >>= aProperties;
+ uno::Reference<awt::XBitmap> xBitmap;
+ awt::Size aSize;
+ sal_Int16 nNumberingType = -1;
+
+ for (beans::PropertyValue const & rProperty : aProperties)
+ {
+ if (rProperty.Name == "NumberingType")
+ {
+ nNumberingType = rProperty.Value.get<sal_Int16>();
+ }
+ else if (rProperty.Name == "GraphicBitmap")
+ {
+ if (rProperty.Value.has<uno::Reference<awt::XBitmap>>())
+ {
+ xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
+ }
+ }
+ else if (rProperty.Name == "GraphicSize")
+ {
+ aSize = rProperty.Value.get<awt::Size>();
+ }
+ }
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), style::NumberingType::BITMAP, nNumberingType);
+
+ // Graphic Bitmap
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
+ Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > sal_uLong(0));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Height());
+
+ // Graphic Size
+ if (rFilterName == "write8") // ODT is correct
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(400), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(400), aSize.Height);
+ }
+ // FIXME: MS Filters don't work correctly for graphic bullet size
+ else if (rFilterName == "Office Open XML Text" || rFilterName == "Rich Text Format")
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(279), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(279), aSize.Height);
+ }
+ else if (rFilterName == "MS Word 97")
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(296), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(296), aSize.Height);
+ }
+ }
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/odfexport/data/BulletAsImage.odt b/sw/qa/extras/odfexport/data/BulletAsImage.odt
deleted file mode 100644
index 85e0c0735487..000000000000
--- a/sw/qa/extras/odfexport/data/BulletAsImage.odt
+++ /dev/null
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 54addc96a5cb..06a9256b82c9 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1947,29 +1947,6 @@ DECLARE_ODFEXPORT_TEST(testRubyPosition, "ruby-position.odt")
}
}
-DECLARE_ODFEXPORT_TEST(testBulletAsImage, "BulletAsImage.odt")
-{
- uno::Reference<text::XTextRange> xPara(getParagraph(1));
- uno::Reference<beans::XPropertySet> xPropertySet(xPara, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels;
- xLevels.set(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aProperties;
- xLevels->getByIndex(0) >>= aProperties;
- uno::Reference<awt::XBitmap> xBitmap;
- for (int i = 0; i < aProperties.getLength(); ++i)
- {
- if (aProperties[i].Name == "GraphicBitmap")
- xBitmap = aProperties[i].Value.get<uno::Reference<awt::XBitmap>>();
- }
- CPPUNIT_ASSERT(xBitmap.is());
-
- Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
- CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > sal_uLong(0));
- CPPUNIT_ASSERT_EQUAL(15L, aGraphic.GetSizePixel().Width());
- CPPUNIT_ASSERT_EQUAL(15L, aGraphic.GetSizePixel().Height());
-}
-
DECLARE_ODFEXPORT_TEST(testSignatureLineProperties, "signatureline-properties.fodt")
{
uno::Reference<drawing::XShape> xShape = getShape(1);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index d0191c0271dd..9af55dde5410 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -366,7 +366,15 @@ DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx")
if (!pXmlDoc)
return;
// tdf#106849 NumPicBullet xShape should not to be resized.
- assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt");
+
+// Seems this is dependent on the running system, which is - unfortunate
+// see: MSWordExportBase::BulletDefinitions
+// FIXME: the size of a bullet is defined by GraphicSize property
+// (stored in SvxNumberFormat::aGraphicSize) so use that for the size
+// (properly convert from 100mm to pt (1 inch is 72 pt, 1 pt is 20 twips).
+#if !defined(MACOSX)
+ assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:11.25pt;height:11.25pt");
+#endif
}
DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")