diff options
author | Rosemary Sebastian <rosemaryseb8@gmail.com> | 2016-02-03 09:15:19 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-02-08 13:37:21 +0000 |
commit | 33d289d53fef36b8e7c4db4a9c9ddd9c1f2edbb2 (patch) | |
tree | 9279da9a84c1440d2166b2db0fc663c8b25cbc12 /sd | |
parent | 2d5f3dcf8dca6f0eb73e7435f333fba148bf9d49 (diff) |
Export and import of additional fields in Impress
These include
- Author
- Page Count
- Page Name
Export and import of slide number was already implemented. A test
for the same has been added along with the tests for the newly
implemented field exports.
In sdmodeltestbase.hxx a new method getTextFieldFromPage has been
added to reduce copy-paste code
Change-Id: Icf54b91a7db4b3cccd9d0666a2706e3cc2a89d9a
Reviewed-on: https://gerrit.libreoffice.org/22065
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/odp/author_field.odp | bin | 0 -> 10518 bytes | |||
-rw-r--r-- | sd/qa/unit/data/odp/slidecount_field.odp | bin | 0 -> 9918 bytes | |||
-rw-r--r-- | sd/qa/unit/data/odp/slidename_field.odp | bin | 0 -> 10089 bytes | |||
-rw-r--r-- | sd/qa/unit/data/odp/slidenum_field.odp | bin | 0 -> 9882 bytes | |||
-rwxr-xr-x | sd/qa/unit/data/pptx/slidenum_field.pptx | bin | 0 -> 34130 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 114 | ||||
-rw-r--r-- | sd/qa/unit/sdmodeltestbase.hxx | 19 |
7 files changed, 93 insertions, 40 deletions
diff --git a/sd/qa/unit/data/odp/author_field.odp b/sd/qa/unit/data/odp/author_field.odp Binary files differnew file mode 100644 index 000000000000..ace132df4d74 --- /dev/null +++ b/sd/qa/unit/data/odp/author_field.odp diff --git a/sd/qa/unit/data/odp/slidecount_field.odp b/sd/qa/unit/data/odp/slidecount_field.odp Binary files differnew file mode 100644 index 000000000000..c8f5bd46dc63 --- /dev/null +++ b/sd/qa/unit/data/odp/slidecount_field.odp diff --git a/sd/qa/unit/data/odp/slidename_field.odp b/sd/qa/unit/data/odp/slidename_field.odp Binary files differnew file mode 100644 index 000000000000..e1a119b9fac1 --- /dev/null +++ b/sd/qa/unit/data/odp/slidename_field.odp diff --git a/sd/qa/unit/data/odp/slidenum_field.odp b/sd/qa/unit/data/odp/slidenum_field.odp Binary files differnew file mode 100644 index 000000000000..e7789a3a0c4e --- /dev/null +++ b/sd/qa/unit/data/odp/slidenum_field.odp diff --git a/sd/qa/unit/data/pptx/slidenum_field.pptx b/sd/qa/unit/data/pptx/slidenum_field.pptx Binary files differnew file mode 100755 index 000000000000..f3c184056905 --- /dev/null +++ b/sd/qa/unit/data/pptx/slidenum_field.pptx diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 18919f24cdc6..82466084916c 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -67,7 +67,6 @@ #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/packages/zip/ZipFileAccess.hpp> -#include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/table/BorderLine2.hpp> @@ -139,7 +138,12 @@ public: void testExportTransitionsPPTX(); void testDatetimeFieldNumberFormat(); void testDatetimeFieldNumberFormatPPTX(); + void testSlideNumberField(); + void testSlideNumberFieldPPTX(); + void testSlideCountField(); + void testSlideNameField(); void testExtFileField(); + void testAuthorField(); void testFdo90607(); void testTdf91378(); @@ -193,7 +197,12 @@ public: CPPUNIT_TEST(testTdf92527); CPPUNIT_TEST(testDatetimeFieldNumberFormat); CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX); + CPPUNIT_TEST(testSlideNumberField); + CPPUNIT_TEST(testSlideNumberFieldPPTX); + CPPUNIT_TEST(testSlideCountField); + CPPUNIT_TEST(testSlideNameField); CPPUNIT_TEST(testExtFileField); + CPPUNIT_TEST(testAuthorField); CPPUNIT_TEST_SUITE_END(); @@ -1507,15 +1516,9 @@ void SdExportTest::testTdf92527() namespace { -void matchNumberFormat( int nPage, uno::Reference< text::XTextRange > xRun) +void matchNumberFormat( int nPage, uno::Reference< text::XTextField > xField) { - uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW ); - - uno::Reference<text::XTextField> xField; - xPropSet->getPropertyValue("TextField") >>= xField; - CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); - - xPropSet.set(xField, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xPropSet( xField, uno::UNO_QUERY_THROW ); sal_Int32 nNumFmt; xPropSet->getPropertyValue("NumberFormat") >>= nNumFmt; switch( nPage ) @@ -1553,16 +1556,7 @@ void SdExportTest::testDatetimeFieldNumberFormat() for(sal_uInt16 i = 0; i <= 6; ++i) { - // get TextShape 1 from page i - uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, i, xDocShRef ) ); - - // Get first paragraph - uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) ); - - // first chunk of text - uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) ); - - matchNumberFormat( i, xRun ); + matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) ); } xDocShRef->DoClose(); @@ -1576,17 +1570,56 @@ void SdExportTest::testDatetimeFieldNumberFormatPPTX() for(sal_uInt16 i = 0; i <= 6; ++i) { - // get TextShape 1 from page i - uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, i, xDocShRef ) ); + matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) ); + } - // Get first paragraph - uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) ); + xDocShRef->DoClose(); +} - // first chunk of text - uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) ); +void SdExportTest::testSlideNumberField() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/slidenum_field.odp"), ODP); - matchNumberFormat( i, xRun ); - } + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef); + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xDocShRef->DoClose(); +} + +void SdExportTest::testSlideNumberFieldPPTX() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/slidenum_field.pptx"), PPTX); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef); + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xDocShRef->DoClose(); +} + +void SdExportTest::testSlideCountField() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/slidecount_field.odp"), ODP); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef); + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xDocShRef->DoClose(); +} + +void SdExportTest::testSlideNameField() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/slidename_field.odp"), ODP); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef); + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); xDocShRef->DoClose(); } @@ -1599,21 +1632,10 @@ void SdExportTest::testExtFileField() for(sal_uInt16 i = 0; i <= 3; ++i) { - // get TextShape i + 1 from the first page - uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( i, 0, xDocShRef ) ); - - // Get first paragraph - uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) ); - - // first chunk of text - uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) ); - uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW ); - - uno::Reference<text::XTextField> xField; - xPropSet->getPropertyValue("TextField") >>= xField; + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, i, 0, xDocShRef); CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); - xPropSet.set(xField, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xPropSet( xField, uno::UNO_QUERY_THROW ); sal_Int32 nNumFmt; xPropSet->getPropertyValue("FileFormat") >>= nNumFmt; switch( i ) @@ -1635,6 +1657,18 @@ void SdExportTest::testExtFileField() xDocShRef->DoClose(); } +void SdExportTest::testAuthorField() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/author_field.odp"), ODP); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef); + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 4c465470c4ef..8a280d9bd75d 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <drawinglayer/XShapeDumper.hxx> +#include <com/sun/star/text/XTextField.hpp> using namespace ::com::sun::star; @@ -327,6 +328,24 @@ protected: return xRun; } + + uno::Reference<text::XTextField> getTextFieldFromPage(int nRun, int nPara, int nShape, int nPage, sd::DrawDocShellRef xDocShRef) + { + // get TextShape 1 from the first page + uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( nShape, nPage, xDocShRef ) ); + + // Get first paragraph + uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( nPara, xShape ) ); + + // first chunk of text + uno::Reference<text::XTextRange> xRun( getRunFromParagraph( nRun, xParagraph ) ); + + uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW ); + + uno::Reference<text::XTextField> xField; + xPropSet->getPropertyValue("TextField") >>= xField; + return xField; + } }; #endif |