summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-10-30 12:21:49 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-11-01 11:15:35 +0100
commit2884d57d4717afc3c31baee0ebc4a3e8b1c1d2f2 (patch)
tree7895b0b38b75fd35011ed24245d81a9340246c13 /sd/source
parent2d928a87788644f7c6d46b70ab03bc13a8bf89d3 (diff)
TSCP: Support DocInfo.Custom field for ODP file format
Impress has a limited support for fields - this includes support for DocInfo.Custom field, which shows the user defined custom fields that are used in TSCP. This commit adds minimal support (only what is needed for TSCP) for DocInfo.Custom field but only supports string fields for now. It is not possible to add the field manually, at least not until the full support is added. Change-Id: Ib3b73ab22fd4fe65ab6fb5173fe035a3359deea5 Reviewed-on: https://gerrit.libreoffice.org/44041 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/ui/app/sdmod2.cxx16
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx6
-rw-r--r--sd/source/ui/view/drviews2.cxx14
3 files changed, 28 insertions, 8 deletions
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 29b8b9798228..b7b51f41917c 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -349,7 +349,21 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
}
else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
{
- pInfo->SetRepresentation(pCustomPropertyField->GetFormatted(SfxObjectShell::Current()->getDocProperties()));
+ try
+ {
+ if (SfxObjectShell::Current() && SfxObjectShell::Current()->IsLoadingFinished())
+ {
+ auto pNonConstCustomPropertyField = const_cast<editeng::CustomPropertyField*>(pCustomPropertyField);
+ OUString sCurrent = pNonConstCustomPropertyField->GetFormatted(SfxObjectShell::Current()->getDocProperties());
+ pInfo->SetRepresentation(sCurrent);
+ }
+ else
+ pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
+ }
+ catch (...)
+ {
+ pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
+ }
}
else
{
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 63964904173b..4cd01e61acff 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -926,6 +926,12 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::PAGE_NAME ));
}
+ if (aServiceSpecifier == "com.sun.star.text.TextField.DocInfo.Custom" ||
+ aServiceSpecifier == "com.sun.star.text.textfield.DocInfo.Custom")
+ {
+ return static_cast<cppu::OWeakObject *>(new SvxUnoTextField(text::textfield::Type::DOCINFO_CUSTOM));
+ }
+
if( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" )
{
static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 };
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 4d1eca41992b..6959bd726536 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -244,7 +244,7 @@ const SvxFieldItem* findField(editeng::Section const & rSection)
return nullptr;
}
-bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, OUString const & rKey)
+bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, OUString const & rName)
{
for (editeng::Section const & rSection : aSections)
{
@@ -252,7 +252,7 @@ bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, OUS
if (pFieldItem)
{
const editeng::CustomPropertyField* pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField());
- if (pCustomPropertyField && pCustomPropertyField->GetKey() == rKey)
+ if (pCustomPropertyField && pCustomPropertyField->GetName() == rName)
return true;
}
}
@@ -315,7 +315,7 @@ private:
if (pFieldItem)
{
const auto* pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField());
- OUString aKey = pCustomPropertyField->GetKey();
+ OUString aKey = pCustomPropertyField->GetName();
if (aKeyCreator.isMarkingTextKey(aKey))
{
OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
@@ -490,14 +490,14 @@ public:
{
OUString sKey = aKeyCreator.makeNumberedMarkingTextKey();
addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey), EE_FEATURE_FIELD), aPosition);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
}
break;
case svx::ClassificationType::CATEGORY:
{
OUString sKey = aKeyCreator.makeCategoryKey();
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey), EE_FEATURE_FIELD), aPosition);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
}
break;
@@ -505,7 +505,7 @@ public:
{
OUString sKey = aKeyCreator.makeMarkingKey();
addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey), EE_FEATURE_FIELD), aPosition);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
}
break;
@@ -513,7 +513,7 @@ public:
{
OUString sKey = aKeyCreator.makeIntellectualPropertyPartKey();
addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey), EE_FEATURE_FIELD), aPosition);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
}
break;