/src/libreoffice/include/svx/ClassificationField.hxx
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 | | #ifndef INCLUDED_SVX_CLASSIFICATIONFIELD_HXX |
12 | | #define INCLUDED_SVX_CLASSIFICATIONFIELD_HXX |
13 | | |
14 | | #include <sal/config.h> |
15 | | #include <svx/svxdllapi.h> |
16 | | #include <editeng/flditem.hxx> |
17 | | #include <utility> |
18 | | |
19 | | namespace svx { |
20 | | |
21 | | enum class ClassificationType |
22 | | { |
23 | | CATEGORY, |
24 | | MARKING, |
25 | | TEXT, |
26 | | INTELLECTUAL_PROPERTY_PART, |
27 | | PARAGRAPH, |
28 | | }; |
29 | | |
30 | | class SVX_DLLPUBLIC ClassificationResult |
31 | | { |
32 | | public: |
33 | | ClassificationType meType; |
34 | | OUString msName; //< Display text or 'Name' field (from example.xml). |
35 | | OUString msAbbreviatedName; //< Abbreviated name, displayed instead of Name. |
36 | | OUString msIdentifier; //< The identifier of this entry (from example.xml). |
37 | | |
38 | | ClassificationResult(ClassificationType eType, OUString sName, |
39 | | OUString sAbbreviatedName, OUString sIdentifier = u""_ustr) |
40 | 0 | : meType(eType) |
41 | 0 | , msName(std::move(sName)) |
42 | 0 | , msAbbreviatedName(std::move(sAbbreviatedName)) |
43 | 0 | , msIdentifier(std::move(sIdentifier)) |
44 | 0 | { |
45 | 0 | } |
46 | | |
47 | | /// Returns the text to display, which is the Abbreviated Name, if provided, otherwise Name. |
48 | | OUString const & getDisplayText() const |
49 | 0 | { |
50 | 0 | return !msAbbreviatedName.isEmpty() ? msAbbreviatedName : msName; |
51 | 0 | } |
52 | | |
53 | | bool operator==(const ClassificationResult& rOther) const |
54 | 0 | { |
55 | 0 | return (meType == rOther.meType && |
56 | 0 | msName == rOther.msName && |
57 | 0 | msAbbreviatedName == rOther.msAbbreviatedName && |
58 | 0 | msIdentifier == rOther.msIdentifier); |
59 | 0 | } |
60 | | }; |
61 | | |
62 | | class SVX_DLLPUBLIC ClassificationField final : public SvxFieldData |
63 | | { |
64 | | public: |
65 | | ClassificationType meType; |
66 | | OUString msDescription; |
67 | | OUString msFullClassName; |
68 | | OUString msIdentifier; |
69 | | |
70 | | ClassificationField(ClassificationType eType, OUString sDescription, OUString sFullClassName, OUString sIdentifier) |
71 | 0 | : meType(eType) |
72 | 0 | , msDescription(std::move(sDescription)) |
73 | 0 | , msFullClassName(std::move(sFullClassName)) |
74 | 0 | , msIdentifier(std::move(sIdentifier)) |
75 | 0 | {} |
76 | | |
77 | | ~ClassificationField() override; |
78 | | |
79 | | std::unique_ptr<SvxFieldData> Clone() const override |
80 | 0 | { |
81 | 0 | return std::make_unique<ClassificationField>(meType, msDescription, msFullClassName, msIdentifier); |
82 | 0 | } |
83 | | |
84 | | bool operator==(const SvxFieldData& rOther) const override |
85 | 0 | { |
86 | 0 | if (typeid(rOther) != typeid(*this)) |
87 | 0 | return false; |
88 | | |
89 | 0 | const ClassificationField& rOtherField = static_cast<const ClassificationField&>(rOther); |
90 | 0 | return (meType == rOtherField.meType && |
91 | 0 | msDescription == rOtherField.msDescription && |
92 | 0 | msFullClassName == rOtherField.msFullClassName && |
93 | 0 | msIdentifier == rOtherField.msIdentifier); |
94 | 0 | } |
95 | | }; |
96 | | |
97 | | } // end svx namespace |
98 | | |
99 | | #endif // INCLUDED_SVX_CLASSIFICATIONFIELD_HXX |
100 | | |
101 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |