oox/source/drawingml/textfield.cxx | 15 ++++ oox/source/export/drawingml.cxx | 12 +++ sd/qa/unit/data/odp/author_field.odp |binary sd/qa/unit/data/odp/slidecount_field.odp |binary sd/qa/unit/data/odp/slidename_field.odp |binary sd/qa/unit/data/odp/slidenum_field.odp |binary sd/qa/unit/data/pptx/slidenum_field.pptx |binary sd/qa/unit/export-tests.cxx | 114 ++++++++++++++++++++----------- sd/qa/unit/sdmodeltestbase.hxx | 19 +++++ 9 files changed, 120 insertions(+), 40 deletions(-)
New commits: commit 33d289d53fef36b8e7c4db4a9c9ddd9c1f2edbb2 Author: Rosemary Sebastian <rosemarys...@gmail.com> Date: Wed Feb 3 09:15:19 2016 +0530 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 <c...@libreoffice.org> Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx index 7a33898..0db6692 100644 --- a/oox/source/drawingml/textfield.cxx +++ b/oox/source/drawingml/textfield.cxx @@ -140,6 +140,16 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields, xIface = xFactory->createInstance( "com.sun.star.text.TextField.PageNumber" ); aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) ); } + else if ( sType == "slidecount" ) + { + xIface = xFactory->createInstance( "com.sun.star.text.TextField.PageCount" ); + aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) ); + } + else if ( sType == "slidename" ) + { + xIface = xFactory->createInstance( "com.sun.star.text.TextField.PageName" ); + aFields.push_back( Reference< XTextField > ( xIface, uno::UNO_QUERY ) ); + } else if ( sType.startsWith("file") ) { OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8); @@ -164,6 +174,11 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields, xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(0)); } } + else if( sType == "author" ) + { + xIface = xFactory->createInstance( "com.sun.star.text.TextField.Author" ); + aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) ); + } } } // namespace diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 282436b..22e67ad 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1491,6 +1491,14 @@ OUString DrawingML::GetFieldValue( css::uno::Reference< css::text::XTextRange > { aFieldValue = "slidenum"; } + else if( aFieldKind == "Pages" ) + { + aFieldValue = "slidecount"; + } + else if( aFieldKind == "PageName" ) + { + aFieldValue = "slidename"; + } else if( aFieldKind == "URL" ) { bIsURLField = true; @@ -1545,6 +1553,10 @@ OUString DrawingML::GetFieldValue( css::uno::Reference< css::text::XTextRange > case 3: aFieldValue = "file3"; // File name with extension } } + else if(aFieldKind == "Author") + { + aFieldValue = "author"; + } } } } diff --git a/sd/qa/unit/data/odp/author_field.odp b/sd/qa/unit/data/odp/author_field.odp new file mode 100644 index 0000000..ace132d Binary files /dev/null and b/sd/qa/unit/data/odp/author_field.odp differ diff --git a/sd/qa/unit/data/odp/slidecount_field.odp b/sd/qa/unit/data/odp/slidecount_field.odp new file mode 100644 index 0000000..c8f5bd4 Binary files /dev/null and b/sd/qa/unit/data/odp/slidecount_field.odp differ diff --git a/sd/qa/unit/data/odp/slidename_field.odp b/sd/qa/unit/data/odp/slidename_field.odp new file mode 100644 index 0000000..e1a119b Binary files /dev/null and b/sd/qa/unit/data/odp/slidename_field.odp differ diff --git a/sd/qa/unit/data/odp/slidenum_field.odp b/sd/qa/unit/data/odp/slidenum_field.odp new file mode 100644 index 0000000..e7789a3 Binary files /dev/null and b/sd/qa/unit/data/odp/slidenum_field.odp differ diff --git a/sd/qa/unit/data/pptx/slidenum_field.pptx b/sd/qa/unit/data/pptx/slidenum_field.pptx new file mode 100755 index 0000000..f3c1840 Binary files /dev/null and b/sd/qa/unit/data/pptx/slidenum_field.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 18919f2..8246608 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 4c46547..8a280d9 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits