summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-04-05 12:06:39 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-04-05 12:08:57 +0200
commit1cb273098188b5749109b8f58516e7003600a704 (patch)
treead388e98a1847c4ba0d6ee22a25dce67b4945e3e /writerfilter
parentRemove macro RTL_CONSTASCII_USTRINGPARAM (diff)
downloadcore-1cb273098188b5749109b8f58516e7003600a704.tar.gz
core-1cb273098188b5749109b8f58516e7003600a704.zip
n#751017 dmapper: fix handling of GetExpression and SetExpression fields
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx25
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
3 files changed, 26 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5ba7ddcd2d51..5b1f4d2839eb 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 4c176cb0760b..64f562a07673 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 686cf7eef48f..c6e5369d7b00 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