LibreOffice Module sfx2 (master) 1
classificationhelper.hxx
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#ifndef INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX
11#define INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX
12
13#include <memory>
14#include <string_view>
15#include <vector>
16
17#include <o3tl/string_view.hxx>
18#include <rtl/ustring.hxx>
19#include <sfx2/dllapi.h>
20#include <sfx2/infobar.hxx>
21
23{
24class XPropertyContainer;
25}
27{
28class XDocumentProperties;
29}
30
31class SfxViewFrame;
32
35{
36 None = 1,
39};
40
43{
44 ExportControl = 1,
47};
48
51{
52 class SAL_DLLPRIVATE Impl;
53 std::unique_ptr<Impl> m_pImpl;
54
55public:
57 static bool IsClassified(
58 const css::uno::Reference<css::document::XDocumentProperties>& xDocumentProperties);
61 CheckPaste(const css::uno::Reference<css::document::XDocumentProperties>& xSource,
62 const css::uno::Reference<css::document::XDocumentProperties>& xDestination);
64 static bool ShowPasteInfo(SfxClassificationCheckPasteResult eResult);
65
67 const css::uno::Reference<css::document::XDocumentProperties>& xDocumentProperties,
68 bool bUseLocalizedPolicy = true);
71 const OUString& GetBACName(SfxClassificationPolicyType eType) const;
73 std::vector<OUString> GetBACNames();
75 std::vector<OUString> GetBACIdentifiers();
77 const OUString& GetAbbreviatedBACName(const OUString& sFullName);
79 OUString GetBACNameForIdentifier(std::u16string_view sIdentifier);
81 std::vector<OUString> GetAbbreviatedBACNames();
83 void SetBACName(const OUString& rName, SfxClassificationPolicyType eType);
85 OUString GetHigherClass(const OUString& first, const OUString& second);
87 bool HasImpactLevel();
88 InfobarType GetImpactLevelType();
90 sal_Int32 GetImpactLevel();
92 OUString GetImpactScale();
93 OUString GetDocumentWatermark();
95 bool HasDocumentHeader();
97 bool HasDocumentFooter();
98 void UpdateInfobar(SfxViewFrame& rViewFrame);
99
100 std::vector<OUString> const& GetMarkings() const;
101 std::vector<OUString> const& GetIntellectualPropertyParts() const;
102 std::vector<OUString> const& GetIntellectualPropertyPartNumbers() const;
103
105 static SfxClassificationPolicyType stringToPolicyType(std::u16string_view rType);
107 static const OUString& policyTypeToString(SfxClassificationPolicyType eType);
108
110 static const OUString& PROP_DOCHEADER();
112 static const OUString& PROP_DOCFOOTER();
114 static const OUString& PROP_DOCWATERMARK();
116 static const OUString& PROP_PREFIX_INTELLECTUALPROPERTY();
117
118 static SfxClassificationPolicyType getPolicyType();
119};
120
121namespace sfx
122{
125{
126 NONE,
128 MANUAL
129};
130
132{
133private:
135 const OUString m_sPolicy;
136 sal_Int32 m_nTextNumber;
139
140 OUString const& getPolicyKey() const { return m_sPolicy; }
141
142public:
144 : m_ePolicyType(ePolicyType)
145 , m_sPolicy(SfxClassificationHelper::policyTypeToString(m_ePolicyType))
146 , m_nTextNumber(1)
147 , m_nIPPartNumber(1)
149 {
150 }
151
152 OUString makeTextKey() const { return getPolicyKey() + "Custom:Text"; }
153
155 {
156 return makeTextKey() + ":n" + OUString::number(m_nTextNumber++);
157 }
158
159 bool isMarkingTextKey(std::u16string_view aKey) const
160 {
161 return o3tl::starts_with(aKey, makeTextKey());
162 }
163
164 OUString makeCategoryNameKey() const
165 {
166 return getPolicyKey() + "BusinessAuthorizationCategory:Name";
167 }
168
169 bool isCategoryNameKey(std::u16string_view aKey) const
170 {
172 }
173
175 {
176 return getPolicyKey() + "BusinessAuthorizationCategory:Identifier";
177 }
178
179 bool isCategoryIdentifierKey(std::u16string_view aKey) const
180 {
182 }
183
184 OUString makeMarkingKey() const { return getPolicyKey() + "Custom:Marking"; }
185
187 {
188 return makeMarkingKey() + ":n" + OUString::number(m_nMarkingNumber++);
189 }
190
191 bool isMarkingKey(std::u16string_view aKey) const
192 {
193 return o3tl::starts_with(aKey, makeMarkingKey());
194 }
195
197 {
198 return getPolicyKey() + "Custom:IntellectualPropertyPart";
199 }
200
202 {
203 return makeIntellectualPropertyPartKey() + ":n" + OUString::number(m_nIPPartNumber++);
204 }
205
206 bool isIntellectualPropertyPartKey(std::u16string_view aKey) const
207 {
209 }
210
212 {
213 return getPolicyKey() + "Custom:FullTexturalRepresentation";
214 }
215
217 OUString makeCreationOriginKey() const { return getPolicyKey() + "CreationOrigin"; }
218};
219
221 css::uno::Reference<css::beans::XPropertyContainer> const& rxPropertyContainer,
222 sfx::ClassificationKeyCreator const& rKeyCreator);
223}
224
225#endif
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Implementation details of SfxClassificationHelper.
Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties.
std::unique_ptr< Impl > m_pImpl
SfxClassificationPolicyType
Specifies a policy type, to be used with SetBACName(). Getters always use IntellectualProperty for no...
SfxClassificationCheckPasteResult
Return code of SfxClassificationHelper::CheckPaste().
OUString makeCreationOriginKey() const
Classification creation origin key.
bool isMarkingKey(std::u16string_view aKey) const
OUString makeFullTextualRepresentationKey() const
bool isMarkingTextKey(std::u16string_view aKey) const
OUString const & getPolicyKey() const
const SfxClassificationPolicyType m_ePolicyType
bool isCategoryIdentifierKey(std::u16string_view aKey) const
bool isCategoryNameKey(std::u16string_view aKey) const
ClassificationKeyCreator(SfxClassificationPolicyType ePolicyType)
OUString makeIntellectualPropertyPartKey() const
bool isIntellectualPropertyPartKey(std::u16string_view aKey) const
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
InfobarType
Definition: infobar.hxx:22
MANUAL
NONE
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
None
sfx::ClassificationCreationOrigin getCreationOriginProperty(uno::Reference< beans::XPropertyContainer > const &rxPropertyContainer, sfx::ClassificationKeyCreator const &rKeyCreator)
ClassificationCreationOrigin
Specifies the origin: either defined by the BAF policy or manual via. the advanced classification dia...