Use o3tl::convert in Math
[LibreOffice.git] / editeng / source / items / CustomPropertyField.cxx
blobbe6b4a626722ab65f077c594f9dcc67d87cb4ed8
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 : msName(rName)
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))
38 return false;
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)
52 if (msName.isEmpty())
53 return OUString();
54 if (!xDocumentProperties.is())
55 return OUString();
56 uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
57 if (!xPropertyContainer.is())
58 return OUString();
59 uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
60 if (!xPropertySet.is())
61 return OUString();
62 uno::Any aAny = xPropertySet->getPropertyValue(msName);
63 if (!aAny.has<OUString>())
64 return OUString();
65 msCurrentPresentation = aAny.get<OUString>();
66 return msCurrentPresentation;
69 } // end editeng namespace
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */