[Libreoffice-commits] .: 2 commits - sw/qa
Lubos Lunak
llunak at kemper.freedesktop.org
Fri May 18 10:25:49 PDT 2012
sw/qa/extras/README | 20 ++++++++++++++++++++
sw/qa/extras/ooxmltok/data/n705956-1.docx |binary
sw/qa/extras/ooxmltok/ooxmltok.cxx | 25 +++++++++++++++++++++++++
3 files changed, 45 insertions(+)
New commits:
commit 1472935fd74c289717cd7783d99bc99d82d7866d
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Fri May 18 19:18:02 2012 +0200
note how to find images using UNO, as it's not exactly easy to find out
Change-Id: If5440cae646a56fef4c054774705689e5512b8e4
diff --git a/sw/qa/extras/README b/sw/qa/extras/README
index eb25955..49dc9aa 100644
--- a/sw/qa/extras/README
+++ b/sw/qa/extras/README
@@ -198,3 +198,23 @@ uno::Reference<container::XIndexAccess> bookmarks(bookmarksSupplier->getBookmark
uno::Reference<uno::XInterface> bookmark;
// get the bookmark by index
bookmarks->getByIndex(0) >>= bookmark;
+
+=== Images
+
+Embedded images seem to be accessed like this:
+
+Basic:
+
+image = ThisComponent.DrawPage.getByIndex(0)
+graphic = image.Graphic
+
+C++:
+
+uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
+uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
+uno::Reference<drawing::XShape> image;
+drawPage->getByIndex(0) >>= image;
+uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
+uno::Reference<graphic::XGraphic> graphic;
+imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
commit a28f5713a7e91b5d99cc0e63470db1512b997320
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Fri May 18 19:10:12 2012 +0200
testcase for part of bnc#705956
60cb70b94537e9ff1155fb80255fc04ce41363b2 specifically
Change-Id: I160b24505d3e2425ce807f92f80d6737b725941b
diff --git a/sw/qa/extras/ooxmltok/data/n705956-1.docx b/sw/qa/extras/ooxmltok/data/n705956-1.docx
new file mode 100644
index 0000000..edff3ba
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n705956-1.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 896b9fd..1238192 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -27,6 +27,7 @@
#include "../swmodeltestbase.hxx"
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -55,6 +56,7 @@ public:
void testN757890();
void testFdo49940();
void testN751077();
+ void testN705956();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -65,6 +67,7 @@ public:
CPPUNIT_TEST(testN757890);
CPPUNIT_TEST(testFdo49940);
CPPUNIT_TEST(testN751077);
+ CPPUNIT_TEST(testN705956);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -238,6 +241,28 @@ xray para.PageStyleName
CPPUNIT_ASSERT_EQUAL( OUString( "First Page" ), value );
}
+void Test::testN705956()
+{
+ load( "n705956-1.docx" );
+/*
+Get the first image in the document and check it's the one image in the document.
+image = ThisComponent.DrawPage.getByIndex(0)
+graphic = image.Graphic
+xray graphic.Size
+*/
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
+ uno::Reference<drawing::XShape> image;
+ drawPage->getByIndex(0) >>= image;
+ uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
+ uno::Reference<graphic::XGraphic> graphic;
+ imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
+ uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( 120, bitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL( 106, bitmap->getSize().Height );
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list