summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-08-13 18:04:14 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-08-18 09:49:50 +0200
commitea358f5d5b04a2a8e11a73d35643cd0afc5cb63b (patch)
tree0b1d5a43b54516f185dba609ad36c5ad8eceb65c /sw
parent47e24bfed80342ae3f1c45e745b717aa8f557ec0 (diff)
CharBrd 8.2: Tests for UNO API and ODF filter
Use just those API tests which still alive. Export filter test use import so no need for distinct import tests. Change-Id: Idddc2ece10e20027551538f4e8c224edffa9bfe8
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx27
-rw-r--r--sw/qa/extras/odfexport/data/charborder.odtbin0 -> 8841 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx176
3 files changed, 203 insertions, 0 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 38c5a47b01d5..9bd8a46a0cd6 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -10,12 +10,15 @@
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/XAutoStylesSupplier.hpp>
+#include <com/sun/star/style/XAutoStyleFamily.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
@@ -120,6 +123,15 @@ protected:
return xStyleFamily;
}
+ /// Get a family of auto styles, see com.sun.star.style.StyleFamilies for possible values.
+ uno::Reference<style::XAutoStyleFamily> getAutoStyles(OUString aFamily)
+ {
+ uno::Reference< style::XAutoStylesSupplier > xAutoStylesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference< style::XAutoStyles > xAutoStyles(xAutoStylesSupplier->getAutoStyles());
+ uno::Reference< style::XAutoStyleFamily > xAutoStyleFamily(xAutoStyles->getByName(aFamily), uno::UNO_QUERY);
+ return xAutoStyleFamily;
+ }
+
/**
* Extract a value from the layout dump using an XPath expression and an attribute name.
*
@@ -326,6 +338,21 @@ protected:
return xCursor->getPage();
}
+ void assertEqualBorder(
+ const table::BorderLine2& rLeft, const sal_Int32 nLeftDist,
+ const table::BorderLine2& rRight, const sal_Int32 nRightDist )
+ {
+ // Border
+ CPPUNIT_ASSERT_EQUAL(rLeft.Color, rRight.Color);
+ CPPUNIT_ASSERT_EQUAL(rLeft.InnerLineWidth, rRight.InnerLineWidth);
+ CPPUNIT_ASSERT_EQUAL(rLeft.LineDistance, rRight.LineDistance);
+ CPPUNIT_ASSERT_EQUAL(rLeft.LineStyle, rRight.LineStyle);
+ CPPUNIT_ASSERT_EQUAL(rLeft.LineWidth, rRight.LineWidth);
+ CPPUNIT_ASSERT_EQUAL(rLeft.OuterLineWidth, rRight.OuterLineWidth);
+ // Padding
+ CPPUNIT_ASSERT_EQUAL(nLeftDist, nRightDist);
+ }
+
uno::Reference<lang::XComponent> mxComponent;
xmlBufferPtr mpXmlBuffer;
diff --git a/sw/qa/extras/odfexport/data/charborder.odt b/sw/qa/extras/odfexport/data/charborder.odt
new file mode 100644
index 000000000000..9f37d58b76c1
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/charborder.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index efbd931dcd6e..3fbf196d4c5e 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -19,6 +19,7 @@ public:
void testTextframeGradient();
void testFdo60769();
void testFdo58949();
+ void testCharacterBorder();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -38,6 +39,7 @@ void Test::run()
{"textframe-gradient.odt", &Test::testTextframeGradient},
{"fdo60769.odt", &Test::testFdo60769},
{"fdo58949.docx", &Test::testFdo58949},
+ {"charborder.odt", &Test::testCharacterBorder },
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -162,6 +164,180 @@ void Test::testFdo58949()
CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("Obj102")));
}
+void Test::testCharacterBorder()
+{
+ // Make sure paragraph and character attributes don't interfere
+ // First paragraph has a paragraph border and a character border included by the paragraph style
+
+ // Paragraph border of first paragraph
+ {
+ const table::BorderLine2 aFirstParTopBorder(6711039,0,26,26,7,53);
+ const sal_Int32 aFirstParTopPadding(150);
+ uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
+
+ // Top border
+ assertEqualBorder(
+ aFirstParTopBorder, aFirstParTopPadding,
+ getProperty<table::BorderLine2>(xSet,"TopBorder"),
+ getProperty<sal_Int32>(xSet,"TopBorderDistance"));
+
+ // Bottom border (same as top border)
+ assertEqualBorder(
+ aFirstParTopBorder, aFirstParTopPadding,
+ getProperty<table::BorderLine2>(xSet,"BottomBorder"),
+ getProperty<sal_Int32>(xSet,"BottomBorderDistance"));
+
+ // Left border (same as top border)
+ assertEqualBorder(
+ aFirstParTopBorder, aFirstParTopPadding,
+ getProperty<table::BorderLine2>(xSet,"LeftBorder"),
+ getProperty<sal_Int32>(xSet,"LeftBorderDistance"));
+
+ // Right border (same as top border)
+ assertEqualBorder(
+ aFirstParTopBorder, aFirstParTopPadding,
+ getProperty<table::BorderLine2>(xSet,"RightBorder"),
+ getProperty<sal_Int32>(xSet,"RightBorderDistance"));
+ }
+
+ // Character border for first paragraph
+ {
+ const table::BorderLine2 aFirstParCharTopBorder(16724787,0,37,0,2,37);
+ const sal_Int32 aFirstParCharTopPadding(450);
+ uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
+
+ // Top border
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharTopBorder"),
+ getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
+
+ // Bottom border (same as top border)
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharBottomBorder"),
+ getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
+
+ // Left border (same as top border)
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharLeftBorder"),
+ getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
+
+ // Right border (same as top border)
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharRightBorder"),
+ getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
+
+ // Check autostyle
+ {
+ uno::Reference< style::XAutoStyleFamily > xAutoStyleFamily(getAutoStyles("ParagraphStyles"));
+ uno::Reference < container::XEnumeration > xAutoStylesEnum( xAutoStyleFamily->createEnumeration() );
+ CPPUNIT_ASSERT_EQUAL((bool)xAutoStylesEnum->hasMoreElements(), true);
+
+ // First paragraph autostyle
+ uno::Reference < beans::XPropertySet > xPSet( xAutoStylesEnum->nextElement(), uno::UNO_QUERY );
+
+ // Top border
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharTopBorder"),
+ getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
+
+ // Bottom border
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharBottomBorder"),
+ getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
+
+ // Left border
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharLeftBorder"),
+ getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
+
+ // Right border
+ assertEqualBorder(
+ aFirstParCharTopBorder, aFirstParCharTopPadding,
+ getProperty<table::BorderLine2>(xSet,"CharRightBorder"),
+ getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
+ }
+ }
+
+ // Second paragraph's second text portion has a character style named CharDiffBor
+ // This style includes border with different sides
+ {
+
+ table::BorderLine2 aBorderArray[4] =
+ {
+ table::BorderLine2(16724787,26,2,4,13,35), // Top
+ table::BorderLine2(10092390,26,26,53,11,106), // Bottom
+ table::BorderLine2(6711039,9,26,9,12,71), // Left
+ table::BorderLine2(0,0,0,0,0,0) // Right
+ };
+
+ sal_Int32 aDistances[4] = { 400 /*Top*/, 300 /*Bottom*/, 250 /*Left*/, 0 /*Right*/ };
+
+ // Get second text portion of second paragraph
+ uno::Reference < beans::XPropertySet > xSet( getRun(getParagraph(2),2), uno::UNO_QUERY );
+
+ // Top border
+ assertEqualBorder(
+ aBorderArray[0], aDistances[0],
+ getProperty<table::BorderLine2>(xSet,"CharTopBorder"),
+ getProperty<sal_Int32>(xSet,"CharTopBorderDistance"));
+
+ // Bottom border
+ assertEqualBorder(
+ aBorderArray[1], aDistances[1],
+ getProperty<table::BorderLine2>(xSet,"CharBottomBorder"),
+ getProperty<sal_Int32>(xSet,"CharBottomBorderDistance"));
+
+ // Left border
+ assertEqualBorder(
+ aBorderArray[2], aDistances[2],
+ getProperty<table::BorderLine2>(xSet,"CharLeftBorder"),
+ getProperty<sal_Int32>(xSet,"CharLeftBorderDistance"));
+
+ // Right border
+ assertEqualBorder(
+ aBorderArray[3], aDistances[3],
+ getProperty<table::BorderLine2>(xSet,"CharRightBorder"),
+ getProperty<sal_Int32>(xSet,"CharRightBorderDistance"));
+
+ // Check character style
+ {
+ uno::Reference< container::XNameAccess > xStyleFamily(getStyles("CharacterStyles"), uno::UNO_QUERY);
+ uno::Reference < beans::XPropertySet > xStyleSet(xStyleFamily->getByName("CharDiffBor"), uno::UNO_QUERY);
+
+ // Top border
+ assertEqualBorder(
+ aBorderArray[0], aDistances[0],
+ getProperty<table::BorderLine2>(xStyleSet,"CharTopBorder"),
+ getProperty<sal_Int32>(xStyleSet,"CharTopBorderDistance"));
+
+ // Bottom border
+ assertEqualBorder(
+ aBorderArray[1], aDistances[1],
+ getProperty<table::BorderLine2>(xStyleSet,"CharBottomBorder"),
+ getProperty<sal_Int32>(xStyleSet,"CharBottomBorderDistance"));
+
+ // Left border
+ assertEqualBorder(
+ aBorderArray[2], aDistances[2],
+ getProperty<table::BorderLine2>(xStyleSet,"CharLeftBorder"),
+ getProperty<sal_Int32>(xStyleSet,"CharLeftBorderDistance"));
+
+ // Right border
+ assertEqualBorder(
+ aBorderArray[3], aDistances[3],
+ getProperty<table::BorderLine2>(xStyleSet,"CharRightBorder"),
+ getProperty<sal_Int32>(xStyleSet,"CharRightBorderDistance"));
+ }
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();