[Libreoffice-commits] .: writerfilter/prj writerfilter/source

Noel Power noelp at kemper.freedesktop.org
Mon Feb 21 04:42:24 PST 2011


 writerfilter/prj/build.lst                        |    2 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |  162 +++++++++++++++++++---
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    5 
 writerfilter/source/dmapper/FormControlHelper.cxx |  133 +++++-------------
 writerfilter/source/dmapper/FormControlHelper.hxx |    2 
 5 files changed, 195 insertions(+), 109 deletions(-)

New commits:
commit d201535c777bae4e2f73410a8406e0510f5e7595
Author: Noel Power <noel.power at novell.com>
Date:   Mon Feb 21 12:09:00 2011 +0000

    make docx import cater for enhanced fields
    
    also removed erroneous import of dropdown ( when not using enhanced fields as awt control ) now uses dropdown textfield instead

diff --git a/writerfilter/prj/build.lst b/writerfilter/prj/build.lst
index e70b99a..b97a227 100644
--- a/writerfilter/prj/build.lst
+++ b/writerfilter/prj/build.lst
@@ -1,4 +1,4 @@
-wf	writerfilter	: soltools sal BOOST:boost cppu cppuhelper ucbhelper tools svx LIBXSLT:libxslt oox NULL
+wf	writerfilter	: soltools sal BOOST:boost cppu cppuhelper ucbhelper tools svx LIBXSLT:libxslt oox xmloff NULL
 wf	writerfilter	usr1	-	all	wf_mkout NULL
 wf	writerfilter\source\resourcemodel	nmake	-	all	wf_resourcemodel NULL
 wf	writerfilter\source\doctok	nmake	-	all	wf_doctok wf_resourcemodel NULL
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ae959bd..4343690 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -65,6 +65,7 @@
 #include <com/sun/star/text/XTextCopy.hpp>
 #include <com/sun/star/text/XTextField.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/text/XFormField.hpp>
 #include <com/sun/star/style/DropCapFormat.hpp>
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
@@ -88,10 +89,53 @@
 
 #include <map>
 
+#include <comphelper/configurationhelper.hxx>
+#include <comphelper/stlunosequence.hxx>
+
 using namespace ::com::sun::star;
 using namespace ::rtl;
 namespace writerfilter {
 namespace dmapper{
+
+sal_Bool lcl_IsUsingEnhancedFields( const uno::Reference< lang::XMultiServiceFactory >& rFac )
+{
+    bool bResult(sal_False);
+    try
+    {
+        rtl::OUString writerConfig = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common"));
+
+        uno::Reference< uno::XInterface > xCfgAccess = ::comphelper::ConfigurationHelper::openConfig( rFac, writerConfig, ::comphelper::ConfigurationHelper::E_READONLY );
+        ::comphelper::ConfigurationHelper::readRelativeKey( xCfgAccess, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Filter/Microsoft/Import" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ImportWWFieldsAsEnhancedFields" ) ) ) >>= bResult;
+
+    }
+    catch( uno::Exception& e)
+    {
+    }
+    return bResult;
+}
+
+// Populate Dropdown Field properties from FFData structure
+void lcl_handleDropdownField( const uno::Reference< beans::XPropertySet >& rxFieldProps, FFDataHandler::Pointer_t pFFDataHandler )
+{
+    if ( rxFieldProps.is() )
+    {
+        if ( pFFDataHandler->getName().getLength() )
+            rxFieldProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), uno::makeAny( pFFDataHandler->getName() ) );
+
+        const FFDataHandler::DropDownEntries_t& rEntries = pFFDataHandler->getDropDownEntries();
+        uno::Sequence< rtl::OUString > sItems( rEntries.size() );
+        ::std::copy( rEntries.begin(), rEntries.end(), ::comphelper::stl_begin(sItems));
+        if ( sItems.getLength() )
+            rxFieldProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Items") ), uno::makeAny( sItems ) );
+
+        sal_Int32 nResult = pFFDataHandler->getDropDownResult().toInt32();
+        if ( nResult )
+            rxFieldProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItem") ), uno::makeAny( sItems[ nResult ] ) );
+        if ( pFFDataHandler->getHelpText().getLength() )
+             rxFieldProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Help") ), uno::makeAny( pFFDataHandler->getHelpText() ) );
+    }
+}
+
 struct FieldConversion
 {
     ::rtl::OUString     sWordCommand;
@@ -163,6 +207,8 @@ DomainMapper_Impl::DomainMapper_Impl(
     getTableManager( ).setHandler(pTableHandler);
 
     getTableManager( ).startLevel();
+    m_bUsingEnhancedFields = lcl_IsUsingEnhancedFields( uno::Reference< lang::XMultiServiceFactory >( m_xComponentContext->getServiceManager(), uno::UNO_QUERY ) );
+
 }
 
 
@@ -1766,7 +1812,10 @@ typedef std::multimap < sal_Int32, ::rtl::OUString > TOCStyleMap;
 const FieldConversionMap_t & lcl_GetFieldConversion()
 {
 static FieldConversionMap_t aFieldConversionMap;
+static FieldConversionMap_t aEnhancedFieldConversionMap;
+
 static bool bFilled = false;
+
 if(!bFilled)
 {
     static const FieldConversion aFields[] =
@@ -1789,7 +1838,7 @@ if(!bFilled)
 //            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILESIZE")),      "",                         "", FIELD_FILESIZE     },
 //            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMULA")),     "",                           "", FIELD_FORMULA },
             {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMCHECKBOX")),     "",                           "", FIELD_FORMCHECKBOX},
-            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMDROPDOWN")),     "",                           "", FIELD_FORMDROPDOWN},
+            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMDROPDOWN")),     "DropDown",                           "", FIELD_FORMDROPDOWN},
             {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMTEXT")),     "Input", "", FIELD_FORMTEXT},
 //            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GOTOBUTTON")),    "",                         "", FIELD_GOTOBUTTON   },
             {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HYPERLINK")),     "",                         "", FIELD_HYPERLINK    },
@@ -1831,7 +1880,7 @@ if(!bFilled)
 //            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")), "", "", FIELD_},
 
         };
-        size_t nConversions = sizeof(aFields)/sizeof(FieldConversion);
+        size_t nConversions = SAL_N_ELEMENTS(aFields);
         for( size_t nConversion = 0; nConversion < nConversions; ++nConversion)
         {
             aFieldConversionMap.insert( FieldConversionMap_t::value_type(
@@ -1845,6 +1894,31 @@ if(!bFilled)
     return aFieldConversionMap;
 }
 
+const FieldConversionMap_t & lcl_GetEnhancedFieldConversion()
+{
+    static FieldConversionMap_t aEnhancedFieldConversionMap;
+
+    static bool bFilled = false;
+
+    if(!bFilled)
+    {
+        static const FieldConversion aEnhancedFields[] =
+        {
+            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMCHECKBOX")),     "ODFFormCheckbox",                           "", FIELD_FORMCHECKBOX},
+            {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMDROPDOWN")),     "ODFFormListbox",                           "", FIELD_FORMDROPDOWN},
+        };
+
+        size_t nConversions = SAL_N_ELEMENTS(aEnhancedFields);
+        for( size_t nConversion = 0; nConversion < nConversions; ++nConversion)
+        {
+            aEnhancedFieldConversionMap.insert( FieldConversionMap_t::value_type(
+                aEnhancedFields[nConversion].sWordCommand,
+                aEnhancedFields[nConversion] ));
+        }
+    }
+    return aEnhancedFieldConversionMap;
+}
+
 void DomainMapper_Impl::handleFieldAsk
     (FieldContextPtr pContext,
      PropertyNameSupplier& rPropNameSupplier,
@@ -2254,6 +2328,7 @@ void DomainMapper_Impl::CloseFieldCommand()
     {
         m_bSetUserFieldContent = false;
         FieldConversionMap_t aFieldConversionMap = lcl_GetFieldConversion();
+        bool bCreateEnhancedField = false;
 
         try
         {
@@ -2275,18 +2350,44 @@ void DomainMapper_Impl::CloseFieldCommand()
                 case FIELD_DOCPROPERTY:
                 case FIELD_TOC:
                 case FIELD_TC:
-                case FIELD_FORMCHECKBOX:
-                case FIELD_FORMDROPDOWN:
-                    bCreateField = false;
+                case FIELD_FORMCHECKBOX :
+                case FIELD_FORMDROPDOWN :
+                {
+                    // If we use 'enhanced' fields then FIELD_FORMCHECKBOX
+                    // & FIELD_FORMDROPDOWN are treated specially
+                    if ( m_bUsingEnhancedFields  && ( aIt->second.eFieldId == FIELD_FORMCHECKBOX || aIt->second.eFieldId == FIELD_FORMDROPDOWN ) )
+                    {
+                        bCreateField = false;
+                        bCreateEnhancedField = true;
+                    }
+                    // if we aren't using enhanced fields and this is a
+                    // drown down then *don't* set bCreateField to false..
+                    // we want to create the field
+                    else if ( aIt->second.eFieldId != FIELD_FORMDROPDOWN )
+                        bCreateField = false;
                     break;
+                }
                 default:
                     break;
                 }
-                if( bCreateField)
+
+                if( bCreateField || bCreateEnhancedField )
                 {
                     //add the service prefix
-                    OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField."));
-                    sServiceName += ::rtl::OUString::createFromAscii(aIt->second.cFieldServiceName );
+                    OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text."));
+                    if ( bCreateEnhancedField )
+                    {
+                        sServiceName += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FormFieldmark."));
+                        FieldConversionMap_t aEnhancedFieldConversionMap = lcl_GetEnhancedFieldConversion();
+                        FieldConversionMap_t::iterator aEnhancedIt = aEnhancedFieldConversionMap.find(sCommand);
+                        if ( aEnhancedIt != aEnhancedFieldConversionMap.end())
+                            sServiceName += ::rtl::OUString::createFromAscii(aEnhancedIt->second.cFieldServiceName );
+                    }
+                    else
+                    {
+                        sServiceName += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextField."));
+                        sServiceName += ::rtl::OUString::createFromAscii(aIt->second.cFieldServiceName );
+                    }
 
 #ifdef DEBUG_DOMAINMAPPER
                     dmapper_logger->startElement("fieldService");
@@ -2378,16 +2479,28 @@ void DomainMapper_Impl::CloseFieldCommand()
                     case FIELD_FORMCHECKBOX :
                     case FIELD_FORMDROPDOWN :
                         {
-                            FFDataHandler::Pointer_t
+                            uno::Reference< text::XTextField > xTextField( xFieldInterface, uno::UNO_QUERY );
+                            if ( !xTextField.is() )
+                            {
+                                FFDataHandler::Pointer_t
                                 pFFDataHandler(pContext->getFFDataHandler());
-                            FieldId eFieldId = FIELD_FORMCHECKBOX;
-                            if ( aIt->second.eFieldId == FIELD_FORMDROPDOWN )
-                                eFieldId = FIELD_FORMDROPDOWN;
-                            FormControlHelper::Pointer_t
-                                pFormControlHelper(new FormControlHelper
-                                                   (eFieldId,
-                                                    m_xTextDocument, pFFDataHandler));
-                            pContext->setFormControlHelper(pFormControlHelper);
+                                FormControlHelper::Pointer_t
+                                    pFormControlHelper(new FormControlHelper
+                                                       (m_bUsingEnhancedFields ? aIt->second.eFieldId : FIELD_FORMCHECKBOX,
+
+                                                        m_xTextDocument, pFFDataHandler));
+                                pContext->setFormControlHelper(pFormControlHelper);
+                                uno::Reference< text::XFormField > xFormField( xFieldInterface, uno::UNO_QUERY );
+                                uno::Reference< container::XNamed > xNamed( xFormField, uno::UNO_QUERY );
+                                if ( xNamed.is() )
+                                {
+                                    if ( pFFDataHandler && pFFDataHandler->getName().getLength() )
+                                        xNamed->setName(  pFFDataHandler->getName() );
+                                    pContext->SetFormField( xFormField );
+                                }
+                            }
+                            else
+                                lcl_handleDropdownField( xFieldProperties, pContext->getFFDataHandler() );
                         }
                         break;
                     case FIELD_FORMTEXT :
@@ -2778,8 +2891,19 @@ void DomainMapper_Impl::PopFieldContext()
                         FormControlHelper::Pointer_t pFormControlHelper(pContext->getFormControlHelper());
                         if (pFormControlHelper.get() != NULL)
                         {
-                            uno::Reference<text::XTextRange> xTxtRange(xCrsr, uno::UNO_QUERY);
-                            pFormControlHelper->insertControl(xTxtRange);
+                            uno::Reference< text::XFormField > xFormField( pContext->GetFormField() );
+                            xToInsert.set(xFormField, uno::UNO_QUERY);
+                            if ( xFormField.is() && xToInsert.is() )
+                            {
+                                uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( xTextAppend, uno::UNO_QUERY_THROW );
+                                xTextAppendAndConvert->appendTextContent( xToInsert, uno::Sequence< beans::PropertyValue >() );
+                                pFormControlHelper->processField( xFormField );
+                            }
+                            else
+                            {
+                                uno::Reference<text::XTextRange> xTxtRange(xCrsr, uno::UNO_QUERY);
+                                pFormControlHelper->insertControl(xTxtRange);
+                            }
                         }
                         else if(pContext->GetHyperlinkURL().getLength())
                         {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c1c274c..a2e238d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -70,6 +70,7 @@ namespace com{ namespace sun{ namespace star{
         namespace text
         {
                 class XTextField;
+                class XFormField;
         }
         namespace beans{ class XPropertySet;}
 }}}
@@ -134,6 +135,7 @@ class FieldContext
     ::rtl::OUString                                                                 m_sCommand;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField >          m_xTextField;
+    ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField >          m_xFormField;
     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xTOC;//TOX
     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xTC;//TOX entry
     ::rtl::OUString                                                                 m_sHyperlinkURL;
@@ -154,6 +156,8 @@ public:
 
     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField >      GetTextField() const { return m_xTextField;}
     void    SetTextField(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > xTextField) { m_xTextField = xTextField;}
+    ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField >      GetFormField() const { return m_xFormField;}
+    void    SetFormField(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > xFormField) { m_xFormField = xFormField;}
 
     void    SetTOC( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xTOC ) { m_xTOC = xTOC; }
     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   GetTOC() { return m_xTOC; }
@@ -344,6 +348,7 @@ private:
 
     bool                            m_bParaChanged;
     bool                            m_bIsLastParaInSection;
+    bool                            m_bUsingEnhancedFields;
 
     //annotation import
     uno::Reference< beans::XPropertySet >                                      m_xAnnotationField;
diff --git a/writerfilter/source/dmapper/FormControlHelper.cxx b/writerfilter/source/dmapper/FormControlHelper.cxx
index c5b8806..0bf02b7 100644
--- a/writerfilter/source/dmapper/FormControlHelper.cxx
+++ b/writerfilter/source/dmapper/FormControlHelper.cxx
@@ -44,6 +44,8 @@
 #include <com/sun/star/uno/Type.hxx>
 
 #include "FormControlHelper.hxx"
+#include <xmloff/odffields.hxx>
+#include <comphelper/stlunosequence.hxx>
 
 namespace writerfilter {
 namespace dmapper {
@@ -153,92 +155,6 @@ FormControlHelper::~FormControlHelper()
 {  
 }
 
-bool FormControlHelper::createDropdown(uno::Reference<text::XTextRange> xTextRange,
-                                       const ::rtl::OUString & rControlName)
-{
-    uno::Reference<lang::XMultiServiceFactory>
-        xServiceFactory(m_pImpl->getServiceFactory());
-
-    if (! xServiceFactory.is())
-        return false;
-
-    uno::Reference<uno::XInterface> xInterface =
-        xServiceFactory->createInstance
-        (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.ComboBox")));
-
-    if (!xInterface.is())
-        return false;
-
-    m_pImpl->rFormComponent = uno::Reference<form::XFormComponent>(xInterface, uno::UNO_QUERY);
-    if (!m_pImpl->rFormComponent.is())
-        return false;
-
-    uno::Reference<beans::XPropertySet> xPropSet(xInterface, uno::UNO_QUERY);
-
-    uno::Any aAny;
-
-    aAny <<= rControlName;
-    xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aAny);
-    xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dropdown")), uno::makeAny( sal_True ));
-
-    uno::Sequence< rtl::OUString > sItems;
-
-    sal_Int32 nMaxChars = 0;
-    if ( m_pFFData->getDropDownEntries().size() )
-    {
-        sItems.realloc( m_pFFData->getDropDownEntries().size() );
-        FFDataHandler::DropDownEntries_t::const_iterator it_end =  m_pFFData->getDropDownEntries().end();
-        FFDataHandler::DropDownEntries_t::const_iterator it =  m_pFFData->getDropDownEntries().begin();
-
-        rtl::OUString* pItem = sItems.getArray();
-
-        for( ;it != it_end; ++it, ++pItem )
-        {
-           *pItem = *it;
-           if ( (*pItem).getLength() > nMaxChars )
-               nMaxChars = (*pItem).getLength();
-        }
-    }
-
-    if ( sItems.getLength() )
-    {
-        aAny <<= sItems;
-        xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringItemList")), aAny);
-        if ( m_pFFData->getDropDownResult().getLength() )
-        {
-            sal_Int32 nResult = m_pFFData->getDropDownResult().toInt32();
-            if ( nResult )
-            {
-                aAny <<= sItems[ nResult ];
-                xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text")), aAny);
-            }
-        }
-    }
-
-    // some fallback values ( to display something )
-
-    m_pImpl->aSize.Width = 2381;
-    m_pImpl->aSize.Height = 713;
-
-    try
-    {
-        uno::Reference<beans::XPropertySet> xTextRangeProps(xTextRange, uno::UNO_QUERY_THROW);
-        static ::rtl::OUString sCharHeight(RTL_CONSTASCII_USTRINGPARAM("CharHeight"));
-        // #FIXME improve the auto height width calculation ( but this
-        // should be removed when we use form fields instead of controls
-        float fComboBoxHeight = 0.0;
-        xTextRangeProps->getPropertyValue(sCharHeight) >>= fComboBoxHeight;
-        m_pImpl->aSize.Height = floor(fComboBoxHeight * 35.3);
-        if ( nMaxChars )
-            m_pImpl->aSize.Width =  m_pImpl->aSize.Height * nMaxChars;
-    }
-    catch( uno::Exception& e )
-    {
-    }
-    return true;
-}
-
-
 bool FormControlHelper::createCheckbox(uno::Reference<text::XTextRange> xTextRange,
                                        const ::rtl::OUString & rControlName)
 {
@@ -305,6 +221,48 @@ bool FormControlHelper::createCheckbox(uno::Reference<text::XTextRange> xTextRan
     return true;
 }
 
+bool FormControlHelper::processField(uno::Reference<text::XFormField> xFormField)
+{
+    if (m_pImpl->m_eFieldId == FIELD_FORMCHECKBOX )
+    {
+        xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.oasis.opendocument.field.FORMCHECKBOX")));
+        uno::Reference<beans::XPropertySet> xPropSet(xFormField, uno::UNO_QUERY);
+        uno::Any aAny;
+        aAny <<= m_pFFData->getCheckboxChecked();
+        if ( xPropSet.is() )
+            xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Checked")), aAny);
+        rtl::OUString sName;
+    }
+    else if (m_pImpl->m_eFieldId == FIELD_FORMDROPDOWN )
+    {
+        xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN)));
+        uno::Reference<container::XNameContainer> xNameCont = xFormField->getParameters();
+        if ( xNameCont.is() )
+        {
+            uno::Sequence< rtl::OUString > sItems;
+            sItems.realloc( m_pFFData->getDropDownEntries().size() );
+            ::std::copy( m_pFFData->getDropDownEntries().begin(), m_pFFData->getDropDownEntries().end(), ::comphelper::stl_begin(sItems));
+            if ( sItems.getLength() )
+            {
+                if ( xNameCont->hasByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_LISTENTRY)) ) )
+                    xNameCont->replaceByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_LISTENTRY)), uno::makeAny( sItems ) );
+                else
+                    xNameCont->insertByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_LISTENTRY)), uno::makeAny( sItems ) );
+
+                sal_Int32 nResult = m_pFFData->getDropDownResult().toInt32();
+                if ( nResult )
+                {
+                    if ( xNameCont->hasByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_RESULT)) ) )
+                        xNameCont->replaceByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_RESULT)), uno::makeAny( nResult ) );
+                    else
+                        xNameCont->insertByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMDROPDOWN_RESULT)), uno::makeAny( nResult ) );
+                }
+            }
+        }
+    }
+    return false;
+}
+
 bool FormControlHelper::insertControl(uno::Reference<text::XTextRange> xTextRange)
 {
     bool bCreated = false;
@@ -336,9 +294,6 @@ bool FormControlHelper::insertControl(uno::Reference<text::XTextRange> xTextRang
 
     switch (m_pImpl->m_eFieldId)
     {
-    case FIELD_FORMDROPDOWN:
-        bCreated = createDropdown(xTextRange, sControlName);
-        break;
     case FIELD_FORMCHECKBOX:
         bCreated = createCheckbox(xTextRange, sControlName);
         break;
diff --git a/writerfilter/source/dmapper/FormControlHelper.hxx b/writerfilter/source/dmapper/FormControlHelper.hxx
index 9ef58ca..4cd8897 100644
--- a/writerfilter/source/dmapper/FormControlHelper.hxx
+++ b/writerfilter/source/dmapper/FormControlHelper.hxx
@@ -30,6 +30,7 @@
 
 #include <FFDataHandler.hxx>
 #include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XFormField.hpp>
 #include <com/sun/star/uno/Reference.hxx>
 #include "FieldTypes.hxx"
 
@@ -48,6 +49,7 @@ public:
     ~FormControlHelper();
 
     bool insertControl(uno::Reference<text::XTextRange> xTextRange);
+    bool processField(uno::Reference<text::XFormField> xFormField);
 
 private:
     FFDataHandler::Pointer_t m_pFFData;


More information about the Libreoffice-commits mailing list