1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <editeng/CustomPropertyField.hxx>
12 #include <vcl/metaact.hxx>
13 #include <com/sun/star/beans/XPropertyContainer.hpp>
14 #include <com/sun/star/beans/XPropertySet.hpp>
15 #include <com/sun/star/document/XDocumentProperties.hpp>
22 CustomPropertyField::CustomPropertyField(OUString
const & rName
, OUString
const & rCurrentPresentation
)
25 , msCurrentPresentation(rCurrentPresentation
)
28 CustomPropertyField::~CustomPropertyField()
31 std::unique_ptr
<SvxFieldData
> CustomPropertyField::Clone() const
33 return std::make_unique
<CustomPropertyField
>(msName
, msCurrentPresentation
);
36 bool CustomPropertyField::operator==(const SvxFieldData
& rOther
) const
38 if (typeid(rOther
) != typeid(*this))
41 const CustomPropertyField
& rOtherField
= static_cast<const CustomPropertyField
&>(rOther
);
42 return (msName
== rOtherField
.msName
&&
43 msCurrentPresentation
== rOtherField
.msCurrentPresentation
);
46 MetaAction
* CustomPropertyField::createBeginComment() const
48 return new MetaCommentAction("FIELD_SEQ_BEGIN");
51 OUString
CustomPropertyField::GetFormatted(uno::Reference
<document::XDocumentProperties
> const & xDocumentProperties
)
55 if (!xDocumentProperties
.is())
57 uno::Reference
<beans::XPropertyContainer
> xPropertyContainer
= xDocumentProperties
->getUserDefinedProperties();
58 if (!xPropertyContainer
.is())
60 uno::Reference
<beans::XPropertySet
> xPropertySet(xPropertyContainer
, uno::UNO_QUERY
);
61 if (!xPropertySet
.is())
63 uno::Any aAny
= xPropertySet
->getPropertyValue(msName
);
64 if (!aAny
.has
<OUString
>())
66 msCurrentPresentation
= aAny
.get
<OUString
>();
67 return msCurrentPresentation
;
70 } // end editeng namespace
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */