bump product version to 6.4.0.3
[LibreOffice.git] / editeng / source / items / CustomPropertyField.cxx
blobb90c191a8587b3a56befa8d57e2630fe81fdfce7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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>
17 using namespace css;
19 namespace editeng
22 CustomPropertyField::CustomPropertyField(OUString const & rName, OUString const & rCurrentPresentation)
23 : SvxFieldData()
24 , msName(rName)
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))
39 return false;
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)
53 if (msName.isEmpty())
54 return OUString();
55 if (!xDocumentProperties.is())
56 return OUString();
57 uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
58 if (!xPropertyContainer.is())
59 return OUString();
60 uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
61 if (!xPropertySet.is())
62 return OUString();
63 uno::Any aAny = xPropertySet->getPropertyValue(msName);
64 if (!aAny.has<OUString>())
65 return OUString();
66 msCurrentPresentation = aAny.get<OUString>();
67 return msCurrentPresentation;
70 } // end editeng namespace
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */