From 04eba5f599b8ac2accfc1d6abc74a91c38616691 Mon Sep 17 00:00:00 2001 From: Rosemary Sebastian Date: Fri, 29 Jan 2016 19:15:08 +0530 Subject: Export and import of file name field Change-Id: Ic2c8ce0ff2a54079ef81f6ce2770497a9d22c7b6 Reviewed-on: https://gerrit.libreoffice.org/21902 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- oox/source/drawingml/textfield.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'oox/source/drawingml') 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(1)); + break; + case 2: // File name without extension + xProps->setPropertyValue("FileFormat", makeAny(2)); + break; + case 3: // File name with extension + xProps->setPropertyValue("FileFormat", makeAny(3)); + break; + default: // Path/File name + xProps->setPropertyValue("FileFormat", makeAny(0)); + } + } } } // namespace -- cgit