Kaydet (Commit) 04eba5f5 authored tarafından Rosemary Sebastian's avatar Rosemary Sebastian Kaydeden (comit) Katarina Behrens

Export and import of file name field

Change-Id: Ic2c8ce0ff2a54079ef81f6ce2770497a9d22c7b6
Reviewed-on: https://gerrit.libreoffice.org/21902Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 90dfa7cb
...@@ -140,6 +140,30 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields, ...@@ -140,6 +140,30 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields,
xIface = xFactory->createInstance( "com.sun.star.text.TextField.PageNumber" ); xIface = xFactory->createInstance( "com.sun.star.text.TextField.PageNumber" );
aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) ); 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 } // namespace
......
...@@ -1530,6 +1530,21 @@ OUString DrawingML::GetFieldValue( css::uno::Reference< css::text::XTextRange > ...@@ -1530,6 +1530,21 @@ OUString DrawingML::GetFieldValue( css::uno::Reference< css::text::XTextRange >
break; 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
}
}
} }
} }
} }
......
...@@ -139,6 +139,7 @@ public: ...@@ -139,6 +139,7 @@ public:
void testExportTransitionsPPTX(); void testExportTransitionsPPTX();
void testDatetimeFieldNumberFormat(); void testDatetimeFieldNumberFormat();
void testDatetimeFieldNumberFormatPPTX(); void testDatetimeFieldNumberFormatPPTX();
void testExtFileField();
void testFdo90607(); void testFdo90607();
void testTdf91378(); void testTdf91378();
...@@ -192,6 +193,7 @@ public: ...@@ -192,6 +193,7 @@ public:
CPPUNIT_TEST(testTdf92527); CPPUNIT_TEST(testTdf92527);
CPPUNIT_TEST(testDatetimeFieldNumberFormat); CPPUNIT_TEST(testDatetimeFieldNumberFormat);
CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX); CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX);
CPPUNIT_TEST(testExtFileField);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -1589,6 +1591,50 @@ void SdExportTest::testDatetimeFieldNumberFormatPPTX() ...@@ -1589,6 +1591,50 @@ void SdExportTest::testDatetimeFieldNumberFormatPPTX()
xDocShRef->DoClose(); 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_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment