[Libreoffice-commits] core.git: oox/source sd/qa

Rosemary Sebastian rosemaryseb8 at gmail.com
Tue Feb 2 09:11:23 UTC 2016


 oox/source/drawingml/textfield.cxx    |   24 +++++++++++++++++
 oox/source/export/drawingml.cxx       |   15 +++++++++++
 sd/qa/unit/data/odp/extfile_field.odp |binary
 sd/qa/unit/export-tests.cxx           |   46 ++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)

New commits:
commit 04eba5f599b8ac2accfc1d6abc74a91c38616691
Author: Rosemary Sebastian <rosemaryseb8 at gmail.com>
Date:   Fri Jan 29 19:15:08 2016 +0530

    Export and import of file name field
    
    Change-Id: Ic2c8ce0ff2a54079ef81f6ce2770497a9d22c7b6
    Reviewed-on: https://gerrit.libreoffice.org/21902
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx
index 7c5fba0..7a33898 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 f990212..4d867269 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
new file mode 100644
index 0000000..e5425be
Binary files /dev/null and b/sd/qa/unit/data/odp/extfile_field.odp differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 17ecbd2..18919f2 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();


More information about the Libreoffice-commits mailing list