summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-06-13 13:18:46 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-06-19 11:52:40 +0200
commit544ab2ed627e207adb54a0db9b31388e29d041a8 (patch)
tree8be2713d30dcb9481db5a3f58e9522a6cca0a57e /sw
parent831c2d95289f41529ea1f85c90f8bb112e522d97 (diff)
add finding out page width to a testcase
Change-Id: I0de5e694adedf8812cc31036860991c853f38d93
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/README23
-rw-r--r--sw/qa/extras/ooxmltok/ooxmltok.cxx19
2 files changed, 40 insertions, 2 deletions
diff --git a/sw/qa/extras/README b/sw/qa/extras/README
index ae174a553372..57447fb55962 100644
--- a/sw/qa/extras/README
+++ b/sw/qa/extras/README
@@ -218,3 +218,26 @@ drawPage->getByIndex(0) >>= image;
uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> graphic;
imageProperties->getPropertyValue( "Graphic" ) >>= graphic;
+
+
+=== Styles
+
+Styles provide information about many properties of (parts of) the document, for example
+page width:
+
+Basic:
+
+ThisComponent.StyleFamilies.PageStyles.Default.Width
+
+C++:
+
+uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+uno::Reference<style::XStyleFamiliesSupplier> styleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
+uno::Reference<container::XNameAccess> styleFamilies = styleFamiliesSupplier->getStyleFamilies();
+uno::Reference<container::XNameAccess> pageStyles;
+styleFamilies->getByName("PageStyles") >>= pageStyles;
+uno::Reference<uno::XInterface> defaultStyle;
+pageStyles->getByName("Default") >>= defaultStyle;
+uno::Reference<beans::XPropertySet> styleProperties( defaultStyle, uno::UNO_QUERY );
+sal_Int32 width;
+styleProperties->getPropertyValue( "Width" ) >>= width;
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 3afb8b797278..2282b47aed6d 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/SetVariableType.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
@@ -498,6 +499,12 @@ void Test::testSmartart()
void Test::testN764745()
{
load( "n764745-alignment.docx" );
+/*
+shape = ThisComponent.DrawPage.getByIndex(0)
+xray shape.AnchorType
+xray shape.AnchorPosition.X
+xray ThisComponent.StyleFamilies.PageStyles.Default.Width
+*/
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
@@ -508,8 +515,16 @@ void Test::testN764745()
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, anchorType);
awt::Point pos;
xPropertySet->getPropertyValue("AnchorPosition") >>= pos;
- // not sure how to find out the document width, but in my test the anchor x is >12000
- CPPUNIT_ASSERT( pos.X > 10000 );
+ uno::Reference<style::XStyleFamiliesSupplier> styleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> styleFamilies = styleFamiliesSupplier->getStyleFamilies();
+ uno::Reference<container::XNameAccess> pageStyles;
+ styleFamilies->getByName("PageStyles") >>= pageStyles;
+ uno::Reference<uno::XInterface> defaultStyle;
+ pageStyles->getByName("Default") >>= defaultStyle;
+ uno::Reference<beans::XPropertySet> styleProperties( defaultStyle, uno::UNO_QUERY );
+ sal_Int32 width;
+ styleProperties->getPropertyValue( "Width" ) >>= width;
+ CPPUNIT_ASSERT( pos.X > width / 2 );
}
void Test::testN766477()