LibreOffice Module editeng (master) 1
CustomPropertyField.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
12#include <utility>
13#include <vcl/metaact.hxx>
14#include <com/sun/star/beans/XPropertyContainer.hpp>
15#include <com/sun/star/beans/XPropertySet.hpp>
16#include <com/sun/star/document/XDocumentProperties.hpp>
17
18using namespace css;
19
20namespace editeng
21{
22
23CustomPropertyField::CustomPropertyField(OUString aName, OUString aCurrentPresentation)
24 : msName(std::move(aName))
25 , msCurrentPresentation(std::move(aCurrentPresentation))
26{}
27
29{}
30
31std::unique_ptr<SvxFieldData> CustomPropertyField::Clone() const
32{
33 return std::make_unique<CustomPropertyField>(msName, msCurrentPresentation);
34}
35
37{
38 if (typeid(rOther) != typeid(*this))
39 return false;
40
41 const CustomPropertyField& rOtherField = static_cast<const CustomPropertyField&>(rOther);
42 return (msName == rOtherField.msName &&
44}
45
47{
48 return new MetaCommentAction("FIELD_SEQ_BEGIN");
49}
50
51OUString CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentProperties> const & xDocumentProperties)
52{
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>();
68}
69
70} // end editeng namespace
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool operator==(const SvxFieldData &) const override
OUString GetFormatted(css::uno::Reference< css::document::XDocumentProperties > const &xDocumentProperties)
CustomPropertyField(OUString aName, OUString aCurrentPresentation)
virtual std::unique_ptr< SvxFieldData > Clone() const override
virtual MetaAction * createBeginComment() const override
virtual ~CustomPropertyField() override
OUString aName
OUString msName