diff options
author | Rosemary Sebastian <rosemaryseb8@gmail.com> | 2016-01-29 19:15:08 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-02-02 09:10:43 +0000 |
commit | 04eba5f599b8ac2accfc1d6abc74a91c38616691 (patch) | |
tree | 395e782ae9db48cd14c304011e294b75d8fc0dd8 | |
parent | 90dfa7cbcaf32aab6005b94b393c7c409ff1af8f (diff) |
Export and import of file name field
Change-Id: Ic2c8ce0ff2a54079ef81f6ce2770497a9d22c7b6
Reviewed-on: https://gerrit.libreoffice.org/21902
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | oox/source/drawingml/textfield.cxx | 24 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 15 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/extfile_field.odp | bin | 0 -> 10918 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 46 |
4 files changed, 85 insertions, 0 deletions
diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx index 7c5fba03b1c2..7a338981c42e 100644 --- a/oox/source/drawingml/textfield.cxx +++ b/oox/source/drawingml/textfield.cxx @@ -140,6 +140,30 @@ 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.startsWith("file") ) + { + OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8); + OString p( s.pData->buffer + 4 ); + int idx = p.toInt32(); + xIface = xFactory->createInstance( "com.sun.star.text.TextField.FileName" ); + aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) ); + Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW ); + + switch( idx ) + { + case 1: // Path + xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(1)); + break; + case 2: // File name without extension + xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(2)); + break; + case 3: // File name with extension + xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(3)); + break; + default: // Path/File name + xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(0)); + } + } } } // namespace diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f9902127951e..4d8672692c0a 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1530,6 +1530,21 @@ OUString DrawingML::GetFieldValue( css::uno::Reference< css::text::XTextRange > break; } } + else if(aFieldKind == "ExtFile") + { + sal_Int32 nNumFmt = -1; + rXPropSet->getPropertyValue(UNO_TC_PROP_FILE_FORMAT) >>= nNumFmt; + switch(nNumFmt) + { + case 0: aFieldValue = "file"; // Path/File name + break; + case 1: aFieldValue = "file1"; // Path + break; + case 2: aFieldValue = "file2"; // File name without extension + break; + case 3: aFieldValue = "file3"; // File name with extension + } + } } } } diff --git a/sd/qa/unit/data/odp/extfile_field.odp b/sd/qa/unit/data/odp/extfile_field.odp Binary files differnew file mode 100644 index 000000000000..e5425beade3f --- /dev/null +++ b/sd/qa/unit/data/odp/extfile_field.odp diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 17ecbd2f91f0..18919f24cdc6 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -139,6 +139,7 @@ public: void testExportTransitionsPPTX(); void testDatetimeFieldNumberFormat(); void testDatetimeFieldNumberFormatPPTX(); + void testExtFileField(); void testFdo90607(); void testTdf91378(); @@ -192,6 +193,7 @@ public: CPPUNIT_TEST(testTdf92527); CPPUNIT_TEST(testDatetimeFieldNumberFormat); CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX); + CPPUNIT_TEST(testExtFileField); CPPUNIT_TEST_SUITE_END(); @@ -1589,6 +1591,50 @@ void SdExportTest::testDatetimeFieldNumberFormatPPTX() xDocShRef->DoClose(); } +void SdExportTest::testExtFileField() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/extfile_field.odp"), ODP); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + 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; + CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() ); + + xPropSet.set(xField, uno::UNO_QUERY); + sal_Int32 nNumFmt; + xPropSet->getPropertyValue("FileFormat") >>= nNumFmt; + switch( i ) + { + case 0: // Path/File name + CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(0), nNumFmt); + break; + case 1: // Path + CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(1), nNumFmt); + break; + case 2: // File name without extension + CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(2), nNumFmt); + break; + case 3: // File name with extension + CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(3), nNumFmt); + } + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |