diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-10-30 12:21:49 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-11-01 11:15:35 +0100 |
commit | 2884d57d4717afc3c31baee0ebc4a3e8b1c1d2f2 (patch) | |
tree | 7895b0b38b75fd35011ed24245d81a9340246c13 /editeng | |
parent | TSCP: simplify key creation and detection (diff) | |
download | core-2884d57d4717afc3c31baee0ebc4a3e8b1c1d2f2.tar.gz core-2884d57d4717afc3c31baee0ebc4a3e8b1c1d2f2.zip |
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 'editeng')
-rw-r--r-- | editeng/source/accessibility/AccessibleEditableTextPara.cxx | 3 | ||||
-rw-r--r-- | editeng/source/items/CustomPropertyField.cxx | 19 | ||||
-rw-r--r-- | editeng/source/items/flditem.cxx | 11 | ||||
-rw-r--r-- | editeng/source/uno/unofield.cxx | 41 |
4 files changed, 67 insertions, 7 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index a8e7a90017ed..b7931eef21c4 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -901,6 +901,9 @@ namespace case text::textfield::Type::DOCINFO_TITLE: strFldType = "file name"; break; + case text::textfield::Type::DOCINFO_CUSTOM: + strFldType = "custom document property"; + break; default: break; } diff --git a/editeng/source/items/CustomPropertyField.cxx b/editeng/source/items/CustomPropertyField.cxx index 7145bc72c650..70a6a40197b2 100644 --- a/editeng/source/items/CustomPropertyField.cxx +++ b/editeng/source/items/CustomPropertyField.cxx @@ -22,9 +22,10 @@ CustomPropertyField::CustomPropertyField() : SvxFieldData() {} -CustomPropertyField::CustomPropertyField(OUString const & rKey) +CustomPropertyField::CustomPropertyField(OUString const & rName, OUString const & rCurrentPresentation) : SvxFieldData() - , msKey(rKey) + , msName(rName) + , msCurrentPresentation(rCurrentPresentation) {} CustomPropertyField::~CustomPropertyField() @@ -34,7 +35,7 @@ SV_IMPL_PERSIST1(CustomPropertyField); SvxFieldData* CustomPropertyField::Clone() const { - return new CustomPropertyField(msKey); + return new CustomPropertyField(msName, msCurrentPresentation); } bool CustomPropertyField::operator==(const SvxFieldData& rOther) const @@ -43,7 +44,8 @@ bool CustomPropertyField::operator==(const SvxFieldData& rOther) const return false; const CustomPropertyField& rOtherField = static_cast<const CustomPropertyField&>(rOther); - return (msKey == rOtherField.msKey); + return (msName == rOtherField.msName && + msCurrentPresentation == rOtherField.msCurrentPresentation); } MetaAction* CustomPropertyField::createBeginComment() const @@ -51,8 +53,10 @@ MetaAction* CustomPropertyField::createBeginComment() const return new MetaCommentAction("FIELD_SEQ_BEGIN"); } -OUString CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentProperties> const & xDocumentProperties) const +OUString CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentProperties> const & xDocumentProperties) { + if (msName.isEmpty()) + return OUString(); if (!xDocumentProperties.is()) return OUString(); uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties(); @@ -61,10 +65,11 @@ OUString CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentPro uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY); if (!xPropertySet.is()) return OUString(); - uno::Any aAny = xPropertySet->getPropertyValue(msKey); + uno::Any aAny = xPropertySet->getPropertyValue(msName); if (!aAny.has<OUString>()) return OUString(); - return aAny.get<OUString>(); + msCurrentPresentation = aAny.get<OUString>(); + return msCurrentPresentation; } } // end editeng namespace diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx index bbdd2b7036d0..4435fcf490b9 100644 --- a/editeng/source/items/flditem.cxx +++ b/editeng/source/items/flditem.cxx @@ -24,6 +24,7 @@ #include <tools/urlobj.hxx> #include <editeng/flditem.hxx> +#include <editeng/CustomPropertyField.hxx> #include <editeng/measfld.hxx> #include <editeng/unonames.hxx> @@ -216,6 +217,16 @@ SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTe return new SvxFooterField(); case text::textfield::Type::PRESENTATION_DATE_TIME: return new SvxDateTimeField(); + case text::textfield::Type::DOCINFO_CUSTOM: + { + OUString sName; + xPropSet->getPropertyValue(UNO_TC_PROP_NAME) >>= sName; + + OUString sCurrentPresentation; + xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= sCurrentPresentation; + + return new editeng::CustomPropertyField(sName, sCurrentPresentation); + } default: ; }; diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index 55fb74bcc999..b2f416c7c78e 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -25,6 +25,7 @@ #include <editeng/eeitem.hxx> #include <editeng/flditem.hxx> +#include <editeng/CustomPropertyField.hxx> #include <editeng/measfld.hxx> #include <editeng/unofield.hxx> #include <editeng/unotext.hxx> @@ -128,6 +129,17 @@ const SfxItemPropertySet* ImplGetFieldItemPropertySet( sal_Int32 mnId ) }; static const SfxItemPropertySet aMeasureFieldPropertySet_Impl(aMeasureFieldPropertyMap_Impl); + static const SfxItemPropertyMapEntry aDocInfoCustomFieldPropertyMap_Impl[] = + { + { OUString(UNO_TC_PROP_NAME), WID_STRING1, cppu::UnoType<OUString>::get(), 0, 0 }, + { OUString(UNO_TC_PROP_CURRENT_PRESENTATION), WID_STRING2, cppu::UnoType<OUString>::get(), 0, 0 }, + { OUString(UNO_TC_PROP_IS_FIXED), WID_BOOL1, cppu::UnoType<bool>::get(), 0, 0 }, + { OUString(UNO_TC_PROP_NUMFORMAT), WID_INT32, cppu::UnoType<sal_Int32>::get(), 0, 0 }, + { OUString(UNO_TC_PROP_IS_FIXED_LANGUAGE), WID_BOOL2, cppu::UnoType<bool>::get(), 0, 0 }, + { OUString(), 0, css::uno::Type(), 0, 0 } + }; + static const SfxItemPropertySet aDocInfoCustomFieldPropertySet_Impl(aDocInfoCustomFieldPropertyMap_Impl); + switch( mnId ) { case text::textfield::Type::EXTENDED_TIME: @@ -143,6 +155,8 @@ const SfxItemPropertySet* ImplGetFieldItemPropertySet( sal_Int32 mnId ) return &aAuthorFieldPropertySet_Impl; case text::textfield::Type::MEASURE: return &aMeasureFieldPropertySet_Impl; + case text::textfield::Type::DOCINFO_CUSTOM: + return &aDocInfoCustomFieldPropertySet_Impl; default: return &aEmptyPropertySet_Impl; } @@ -281,6 +295,12 @@ SvxUnoTextField::SvxUnoTextField( sal_Int32 nServiceId ) throw() mpImpl->mnInt16 = static_cast<sal_uInt16>(SdrMeasureFieldKind::Value); break; + case text::textfield::Type::DOCINFO_CUSTOM: + mpImpl->mbBoolean1 = true; + mpImpl->mbBoolean2 = true; + mpImpl->mnInt32 = 0; + break; + default: mpImpl->mbBoolean1 = false; mpImpl->mbBoolean2 = false; @@ -364,6 +384,14 @@ SvxUnoTextField::SvxUnoTextField( uno::Reference< text::XTextRange > const & xAn mpImpl->mnInt16 = sal::static_int_cast< sal_Int16 >(static_cast<const SdrMeasureField*>(pData)->GetMeasureFieldKind()); break; + case text::textfield::Type::DOCINFO_CUSTOM: + mpImpl->msString1 = static_cast<const editeng::CustomPropertyField*>(pData)->GetName(); + mpImpl->msString2 = static_cast<const editeng::CustomPropertyField*>(pData)->GetCurrentPresentation(); + mpImpl->mbBoolean1 = false; + mpImpl->mbBoolean2 = false; + mpImpl->mnInt32 = 0; + break; + default: SAL_WARN("editeng", "Id service unknown: " << mnServiceId); break; @@ -512,6 +540,9 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw() case text::textfield::Type::PAGE_NAME: pData = new SvxPageTitleField(); break; + case text::textfield::Type::DOCINFO_CUSTOM: + pData = new editeng::CustomPropertyField(mpImpl->msString1, mpImpl->msString2); + break; }; return pData; @@ -611,6 +642,8 @@ OUString SAL_CALL SvxUnoTextField::getPresentation( sal_Bool bShowCommand ) return OUString("DateTime"); case text::textfield::Type::PAGE_NAME: return OUString("PageName"); + case text::textfield::Type::DOCINFO_CUSTOM: + return OUString("Custom"); default: return OUString("Unknown"); } @@ -853,6 +886,10 @@ uno::Sequence< OUString > SAL_CALL SvxUnoTextField::getSupportedServiceNames() pServices[2] = "com.sun.star.text.TextField.PageName"; pServices[3] = "com.sun.star.text.textfield.PageName"; break; + case text::textfield::Type::DOCINFO_CUSTOM: + pServices[2] = "com.sun.star.text.TextField.DocInfo.Custom"; + pServices[3] = "com.sun.star.text.textfield.DocInfo.Custom"; + break; default: aSeq.realloc(0); } @@ -918,6 +955,10 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoTextCreateTextField( const OUSt { nId = text::textfield::Type::MEASURE; } + else if (aFieldType == "DocInfo.Custom") + { + nId = text::textfield::Type::DOCINFO_CUSTOM; + } if (nId != text::textfield::Type::UNSPECIFIED) xRet = static_cast<cppu::OWeakObject *>(new SvxUnoTextField( nId )); |