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
)
24 , msCurrentPresentation(rCurrentPresentation
)
27 CustomPropertyField::~CustomPropertyField()
30 std::unique_ptr
<SvxFieldData
> CustomPropertyField::Clone() const
32 return std::make_unique
<CustomPropertyField
>(msName
, msCurrentPresentation
);
35 bool CustomPropertyField::operator==(const SvxFieldData
& rOther
) const
37 if (typeid(rOther
) != typeid(*this))
40 const CustomPropertyField
& rOtherField
= static_cast<const CustomPropertyField
&>(rOther
);
41 return (msName
== rOtherField
.msName
&&
42 msCurrentPresentation
== rOtherField
.msCurrentPresentation
);
45 MetaAction
* CustomPropertyField::createBeginComment() const
47 return new MetaCommentAction("FIELD_SEQ_BEGIN");
50 OUString
CustomPropertyField::GetFormatted(uno::Reference
<document::XDocumentProperties
> const & xDocumentProperties
)
54 if (!xDocumentProperties
.is())
56 uno::Reference
<beans::XPropertyContainer
> xPropertyContainer
= xDocumentProperties
->getUserDefinedProperties();
57 if (!xPropertyContainer
.is())
59 uno::Reference
<beans::XPropertySet
> xPropertySet(xPropertyContainer
, uno::UNO_QUERY
);
60 if (!xPropertySet
.is())
62 uno::Any aAny
= xPropertySet
->getPropertyValue(msName
);
63 if (!aAny
.has
<OUString
>())
65 msCurrentPresentation
= aAny
.get
<OUString
>();
66 return msCurrentPresentation
;
69 } // end editeng namespace
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */