summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-07-08 15:32:29 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-15 11:52:58 +0200
commit0d5b053436eebac00948e95d64a87e150d195c07 (patch)
treec0c6a514c0121e65cf6e7894f25c99a630613dde
parent51add78184c7c5facdf98e7edf52c023522c3525 (diff)
DOCX FILEOPEN VML Shape (image) is lost on import fdo#81031
ShapeContextHandler::getDrawingShapeContext mxDrawingShapeContext is set once and never reset. So in a file which has numPicBullets and vml shapes in document.xml there is a problem. First the fragment path is set as word/numbering.xml. But when msRelationFragmentPath changes to word/document.xml, mxDrawingShapeContext is not reset and hence the relationships are not resolved. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/10180 Change-Id: I4a1401103797972731257145430f2048b94a04bc
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx14
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo81031.docxbin0 -> 25264 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx16
3 files changed, 29 insertions, 1 deletions
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 53a692774e19..4ed6298e36fa 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -205,7 +205,19 @@ ShapeContextHandler::getDrawingShapeContext()
(new oox::vml::DrawingFragment
( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
}
-
+ else
+ {
+ // Reset the handler if fragment path has changed
+ OUString sHandlerFragmentPath = dynamic_cast<ContextHandler *>(mxDrawingFragmentHandler.get())->getFragmentPath();
+ if ( !msRelationFragmentPath.equals(sHandlerFragmentPath) )
+ {
+ mxDrawingFragmentHandler.clear();
+ mxDrawingFragmentHandler.set
+ (dynamic_cast<ContextHandler *>
+ (new oox::vml::DrawingFragment
+ ( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
+ }
+ }
return mxDrawingFragmentHandler;
}
diff --git a/sw/qa/extras/ooxmlexport/data/fdo81031.docx b/sw/qa/extras/ooxmlexport/data/fdo81031.docx
new file mode 100644
index 000000000000..d80111dec584
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo81031.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0c530fba0b2b..7dd37a2d04d9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
@@ -3783,6 +3785,20 @@ DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
}
+DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx")
+{
+ // vml image was not rendered
+ // As there are also numPicBullets in the file,
+ // the fragmentPath was not changed hence relationships were not resolved.
+
+ uno::Reference<drawing::XShape> image = getShape(1);
+ uno::Reference<beans::XPropertySet> xImage(image, uno::UNO_QUERY);
+ uno::Reference<graphic::XGraphic> xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(381), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(148), xBitmap->getSize().Height );
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */