[Libreoffice-commits] .: writerfilter/source

Noel Power noelp at kemper.freedesktop.org
Thu Feb 24 13:41:20 PST 2011


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    4 +-
 writerfilter/source/dmapper/FormControlHelper.cxx |   42 +++++++++++-----------
 writerfilter/source/dmapper/FormControlHelper.hxx |    2 -
 3 files changed, 25 insertions(+), 23 deletions(-)

New commits:
commit 92853e24c8a010312f1098fb30762fa7e3646a4d
Author: Noel Power <noel.power at novell.com>
Date:   Thu Feb 24 21:40:15 2011 +0000

    fix for fdo#34663

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3e57a56..7061fe5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -138,7 +138,7 @@ void lcl_handleDropdownField( const uno::Reference< beans::XPropertySet >& rxFie
 
 void lcl_handleTextField( const uno::Reference< beans::XPropertySet >& rxFieldProps, FFDataHandler::Pointer_t pFFDataHandler, PropertyNameSupplier& rPropNameSupplier )
 {
-    if ( rxFieldProps.is() )
+    if ( rxFieldProps.is() && pFFDataHandler )
     {
         rxFieldProps->setPropertyValue
             (rPropNameSupplier.GetName(PROP_HINT),
@@ -2897,7 +2897,7 @@ void DomainMapper_Impl::PopFieldContext()
                     else
                     {
                         FormControlHelper::Pointer_t pFormControlHelper(pContext->getFormControlHelper());
-                        if (pFormControlHelper.get() != NULL)
+                        if (pFormControlHelper.get() != NULL && pFormControlHelper->hasFFDataHandler() )
                         {
                             uno::Reference< text::XFormField > xFormField( pContext->GetFormField() );
                             xToInsert.set(xFormField, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/FormControlHelper.cxx b/writerfilter/source/dmapper/FormControlHelper.cxx
index 6088620..8d66e41 100644
--- a/writerfilter/source/dmapper/FormControlHelper.cxx
+++ b/writerfilter/source/dmapper/FormControlHelper.cxx
@@ -223,12 +223,14 @@ bool FormControlHelper::createCheckbox(uno::Reference<text::XTextRange> xTextRan
 
 bool FormControlHelper::processField(uno::Reference<text::XFormField> xFormField)
 {
+    bool bRes = true;
     uno::Reference<container::XNameContainer> xNameCont = xFormField->getParameters();
-    if (m_pImpl->m_eFieldId == FIELD_FORMTEXT )
+    if ( m_pFFData && xNameCont.is() )
     {
-        xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMTEXT)));
-        if ( xNameCont.is() )
+
+        if (m_pImpl->m_eFieldId == FIELD_FORMTEXT )
         {
+            xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMTEXT)));
             if (  m_pFFData->getName().getLength() )
             {
                 if ( xNameCont->hasByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMTEXT_NAME)) ) )
@@ -244,22 +246,19 @@ bool FormControlHelper::processField(uno::Reference<text::XFormField> xFormField
                     xNameCont->insertByName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMTEXT_DEFAULT)), uno::makeAny( m_pFFData->getTextDefault() ) );
             }
         }
-    }
-    else if (m_pImpl->m_eFieldId == FIELD_FORMCHECKBOX )
-    {
-        xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_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)));
-        if ( xNameCont.is() )
+        else if (m_pImpl->m_eFieldId == FIELD_FORMCHECKBOX )
         {
+            xFormField->setFieldType( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_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::Sequence< rtl::OUString > sItems;
             sItems.realloc( m_pFFData->getDropDownEntries().size() );
             ::std::copy( m_pFFData->getDropDownEntries().begin(), m_pFFData->getDropDownEntries().end(), ::comphelper::stl_begin(sItems));
@@ -281,13 +280,16 @@ bool FormControlHelper::processField(uno::Reference<text::XFormField> xFormField
             }
         }
     }
-    return false;
+    else
+        bRes = false;
+    return bRes;
 }
 
 bool FormControlHelper::insertControl(uno::Reference<text::XTextRange> xTextRange)
 {
     bool bCreated = false;
-    
+    if ( !m_pFFData )
+        return false;
     uno::Reference<container::XNameContainer> xFormCompsByName(m_pImpl->getForm(), uno::UNO_QUERY);
     uno::Reference<container::XIndexContainer> xFormComps(m_pImpl->getFormComps());
     if (! xFormComps.is())
diff --git a/writerfilter/source/dmapper/FormControlHelper.hxx b/writerfilter/source/dmapper/FormControlHelper.hxx
index 4cd8897..3f51986 100644
--- a/writerfilter/source/dmapper/FormControlHelper.hxx
+++ b/writerfilter/source/dmapper/FormControlHelper.hxx
@@ -50,7 +50,7 @@ public:
 
     bool insertControl(uno::Reference<text::XTextRange> xTextRange);
     bool processField(uno::Reference<text::XFormField> xFormField);
-
+    bool hasFFDataHandler() { return (m_pFFData != NULL); }
 private:
     FFDataHandler::Pointer_t m_pFFData;
     struct FormControlHelper_Impl;


More information about the Libreoffice-commits mailing list