/src/libreoffice/editeng/source/items/CustomPropertyField.cxx
Line | Count | Source |
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 | | |
11 | | #include <editeng/CustomPropertyField.hxx> |
12 | | #include <utility> |
13 | | #include <com/sun/star/beans/XPropertyContainer.hpp> |
14 | | #include <com/sun/star/beans/XPropertySet.hpp> |
15 | | #include <com/sun/star/document/XDocumentProperties.hpp> |
16 | | |
17 | | using namespace css; |
18 | | |
19 | | namespace editeng |
20 | | { |
21 | | |
22 | | CustomPropertyField::CustomPropertyField(OUString aName, OUString aCurrentPresentation) |
23 | 0 | : msName(std::move(aName)) |
24 | 0 | , msCurrentPresentation(std::move(aCurrentPresentation)) |
25 | 0 | {} |
26 | | |
27 | | CustomPropertyField::~CustomPropertyField() |
28 | 0 | {} |
29 | | |
30 | | std::unique_ptr<SvxFieldData> CustomPropertyField::Clone() const |
31 | 0 | { |
32 | 0 | return std::make_unique<CustomPropertyField>(msName, msCurrentPresentation); |
33 | 0 | } |
34 | | |
35 | | bool CustomPropertyField::operator==(const SvxFieldData& rOther) const |
36 | 0 | { |
37 | 0 | if (typeid(rOther) != typeid(*this)) |
38 | 0 | return false; |
39 | | |
40 | 0 | const CustomPropertyField& rOtherField = static_cast<const CustomPropertyField&>(rOther); |
41 | 0 | return (msName == rOtherField.msName && |
42 | 0 | msCurrentPresentation == rOtherField.msCurrentPresentation); |
43 | 0 | } |
44 | | |
45 | | const OUString & CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentProperties> const & xDocumentProperties) |
46 | 0 | { |
47 | 0 | if (msName.isEmpty()) |
48 | 0 | return EMPTY_OUSTRING; |
49 | 0 | if (!xDocumentProperties.is()) |
50 | 0 | return EMPTY_OUSTRING; |
51 | 0 | uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties(); |
52 | 0 | if (!xPropertyContainer.is()) |
53 | 0 | return EMPTY_OUSTRING; |
54 | 0 | uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY); |
55 | 0 | if (!xPropertySet.is()) |
56 | 0 | return EMPTY_OUSTRING; |
57 | 0 | uno::Any aAny = xPropertySet->getPropertyValue(msName); |
58 | 0 | if (!aAny.has<OUString>()) |
59 | 0 | return EMPTY_OUSTRING; |
60 | 0 | msCurrentPresentation = aAny.get<OUString>(); |
61 | 0 | return msCurrentPresentation; |
62 | 0 | } |
63 | | |
64 | | } // end editeng namespace |
65 | | |
66 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |