[Libreoffice-commits] .: writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Apr 5 03:11:15 PDT 2012


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   25 +++++++++++++++++++++-
 writerfilter/source/dmapper/PropertyIds.cxx       |    1 
 writerfilter/source/dmapper/PropertyIds.hxx       |    1 
 3 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 1cb273098188b5749109b8f58516e7003600a704
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Apr 5 12:06:39 2012 +0200

    n#751017 dmapper: fix handling of GetExpression and SetExpression fields

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5ba7ddc..5b1f4d2 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2157,6 +2157,8 @@ void DomainMapper_Impl::handleFieldAsk
         uno::Reference< beans::XPropertySet > xMaster =
             FindOrCreateFieldMaster
             ("com.sun.star.text.FieldMaster.SetExpression", sVariable );
+        // An ASK field is always a string of characters
+        xMaster->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
 
         // attach the master to the field
         uno::Reference< text::XDependentTextField > xDependentField
@@ -2170,6 +2172,9 @@ void DomainMapper_Impl::handleFieldAsk
         xFieldProperties->setPropertyValue(
             rPropNameSupplier.GetName(PROP_HINT),
             uno::makeAny( sHint ));
+        xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
+        // The ASK has no field value to display
+        xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_IS_VISIBLE), uno::makeAny(sal_False));
     }
     else
     {
@@ -2889,6 +2894,13 @@ void DomainMapper_Impl::CloseFieldCommand()
                         bool bPageRef = aIt->second.eFieldId == FIELD_PAGEREF;
                         ::rtl::OUString sBookmark = lcl_ExtractParameter(pContext->GetCommand(),
                                 (bPageRef ? sizeof(" PAGEREF") : sizeof(" REF")));
+
+                        // Do we need a GetReference (default) or a GetExpression field?
+                        uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier( GetTextDocument(), uno::UNO_QUERY );
+                        uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
+
+                        if (!xFieldMasterAccess->hasByName("com.sun.star.text.FieldMaster.SetExpression." + sBookmark))
+                        {
                         xFieldProperties->setPropertyValue(
                             rPropNameSupplier.GetName(PROP_REFERENCE_FIELD_SOURCE),
                             uno::makeAny( sal_Int16(text::ReferenceFieldSource::BOOKMARK)) );
@@ -2919,6 +2931,14 @@ void DomainMapper_Impl::CloseFieldCommand()
                         }
                         xFieldProperties->setPropertyValue(
                                 rPropNameSupplier.GetName( PROP_REFERENCE_FIELD_PART ), uno::makeAny( nFieldPart ));
+                        }
+                        else
+                        {
+                            xFieldInterface = m_xTextFactory->createInstance("com.sun.star.text.TextField.GetExpression");
+                            xFieldProperties.set(xFieldInterface, uno::UNO_QUERY);
+                            xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_CONTENT), uno::makeAny(sBookmark));
+                            xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
+                        }
                     }
                     break;
                     case FIELD_REVNUM       : break;
@@ -3067,8 +3087,11 @@ void DomainMapper_Impl::SetFieldResult( ::rtl::OUString& rResult )
                     else
                     {
                         uno::Reference< beans::XPropertySet > xFieldProperties( xTextField, uno::UNO_QUERY_THROW);
+                        // In case of SetExpression, the field result contains the content of the variable.
+                        uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY);
+                        bool bIsSetExpression = xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression");
                         xFieldProperties->setPropertyValue(
-                                rPropNameSupplier.GetName(PROP_CURRENT_PRESENTATION),
+                                rPropNameSupplier.GetName(bIsSetExpression ? PROP_CONTENT : PROP_CURRENT_PRESENTATION),
                              uno::makeAny( rResult ));
                     }
                 }
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 4c176cb..64f562a 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -321,6 +321,7 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_HEADING_STYLE_NAME:    sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); break;
             case PROP_FRM_DIRECTION:        sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FRMDirection")); break;
             case PROP_EMBEDDED_OBJECT           :    sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EmbeddedObject")); break;
+            case PROP_IS_VISIBLE: sName = "IsVisible"; break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 686cf7e..c6e5369 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -187,6 +187,7 @@ enum PropertyIds
         ,PROP_IS_LANDSCAPE
         ,PROP_IS_ON
         ,PROP_IS_SPLIT_ALLOWED
+        ,PROP_IS_VISIBLE
         ,PROP_KEYWORDS
         ,PROP_LEFT_BORDER
         ,PROP_LEFT_BORDER_DISTANCE


More information about the Libreoffice-commits mailing list