summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosemary Sebastian <rosemaryseb8@gmail.com>2016-02-03 09:15:19 +0530
committerKatarina Behrens <Katarina.Behrens@cib.de>2016-02-08 13:37:21 +0000
commit33d289d53fef36b8e7c4db4a9c9ddd9c1f2edbb2 (patch)
tree9279da9a84c1440d2166b2db0fc663c8b25cbc12
parent2d5f3dcf8dca6f0eb73e7435f333fba148bf9d49 (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>
-rw-r--r--oox/source/drawingml/textfield.cxx15
-rw-r--r--oox/source/export/drawingml.cxx12
-rw-r--r--sd/qa/unit/data/odp/author_field.odpbin0 -> 10518 bytes
-rw-r--r--sd/qa/unit/data/odp/slidecount_field.odpbin0 -> 9918 bytes
-rw-r--r--sd/qa/unit/data/odp/slidename_field.odpbin0 -> 10089 bytes
-rw-r--r--sd/qa/unit/data/odp/slidenum_field.odpbin0 -> 9882 bytes
-rwxr-xr-xsd/qa/unit/data/pptx/slidenum_field.pptxbin0 -> 34130 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx114
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx19
9 files changed, 120 insertions, 40 deletions
diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx
index 7a338981c42e..0db6692aea81 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 282436b351fe..22e67ad1a3a6 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 000000000000..ace132df4d74
--- /dev/null
+++ b/sd/qa/unit/data/odp/author_field.odp
Binary files 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 000000000000..c8f5bd46dc63
--- /dev/null
+++ b/sd/qa/unit/data/odp/slidecount_field.odp
Binary files 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 000000000000..e1a119b9fac1
--- /dev/null
+++ b/sd/qa/unit/data/odp/slidename_field.odp
Binary files 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 000000000000..e7789a3a0c4e
--- /dev/null
+++ b/sd/qa/unit/data/odp/slidenum_field.odp
Binary files 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 000000000000..f3c184056905
--- /dev/null
+++ b/sd/qa/unit/data/pptx/slidenum_field.pptx
Binary files differ
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