LibreOffice Module sfx2 (master) 1
Metadatable.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SFX2_METADATABLE_HXX
20#define INCLUDED_SFX2_METADATABLE_HXX
21
22#include <sal/config.h>
23
24#include <sfx2/dllapi.h>
25
27#include <com/sun/star/rdf/XMetadatable.hpp>
28
29#include <memory>
30
31
32namespace com::sun::star {
33 namespace frame { class XModel; }
34}
35
36namespace sfx2 {
37 class IXmlIdRegistry;
38}
39
40namespace sfx2 {
41
42class XmlIdRegistry;
43class MetadatableUndo;
44
45
46// XML ID handling ---------------------------------------------------
47
48
50SFX2_DLLPUBLIC ::sfx2::IXmlIdRegistry *
51createXmlIdRegistry(const bool i_DocIsClipboard);
52
53
66class SFX2_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") Metadatable
67{
68public:
69 Metadatable() : m_pReg(nullptr) {}
70
71 // destructor calls RemoveMetadataReference
72 virtual ~Metadatable();
73
74 // for MetadatableMixin ----------------------------------------------
75
76 css::beans::StringPair GetMetadataReference() const;
77 void SetMetadataReference( const css::beans::StringPair & i_rReference);
78 void EnsureMetadataReference();
79
80 // hooks -------------------------------------------------------------
81
82 // called from dtor!
83 void RemoveMetadataReference();
84
86 void RegisterAsCopyOf(Metadatable const & i_rSource,
87 const bool i_bCopyPrecedesSource = false);
88
90 std::shared_ptr<MetadatableUndo> CreateUndo() const;
91 std::shared_ptr<MetadatableUndo> CreateUndoForDelete();
92
94 void RestoreMetadata(std::shared_ptr<MetadatableUndo> const& i_pUndo);
95
97 void JoinMetadatable(Metadatable const & i_rOther,
98 const bool i_isMergedEmpty, const bool i_isOtherEmpty);
99
100 // abstract methods --------------------------------------------------
101
103 virtual ::sfx2::IXmlIdRegistry& GetRegistry() = 0;
104
106 virtual bool IsInClipboard() const = 0;
107
109 virtual bool IsInUndo() const = 0;
110
112 virtual bool IsInContent() const = 0;
113
118 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() = 0;
119
120private:
121 Metadatable(const Metadatable&) = delete;
122 Metadatable& operator=(const Metadatable&) = delete;
123
124 friend class MetadatableClipboard;
125 friend class MetadatableUndo;
126
127 // note that Reg may be a XmlIdRegistryDocument or a XmlIdRegistryClipboard
128 XmlIdRegistry* m_pReg; // null => no XmlId
129};
130
131
138 public cppu::WeakImplHelper<css::rdf::XMetadatable>
139{
140
141public:
143
144 // css::rdf::XNode:
145 virtual OUString SAL_CALL getStringValue() override;
146
147 // css::rdf::XURI:
148 virtual OUString SAL_CALL getLocalName() override;
149 virtual OUString SAL_CALL getNamespace() override;
150
151 // css::rdf::XMetadatable:
152 virtual css::beans::StringPair SAL_CALL getMetadataReference() override;
153 virtual void SAL_CALL setMetadataReference(
154 const css::beans::StringPair & i_rReference) override;
155 virtual void SAL_CALL ensureMetadataReference() override;
156
157protected:
159 virtual Metadatable * GetCoreObject() = 0;
161 virtual css::uno::Reference< css::frame::XModel >
162 GetModel() = 0;
163
164};
165
166} // namespace sfx2
167
168#endif // INCLUDED_SFX2_METADATABLE_HXX
169
170/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
base class for UNO objects that implement XMetadatable.
virtual css::uno::Reference< css::frame::XModel > GetModel()=0
get the XModel for the document
virtual Metadatable * GetCoreObject()=0
get the core object corresponding to this UNO object.
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") DigitalSignatures
Extension of css::security::XDocumentDigitalSignatures for internal purposes.
::sfx2::IXmlIdRegistry * createXmlIdRegistry(const bool i_DocIsClipboard)
create a sfx2::XmlIdRegistryDocument or a sfx2::XmlIdRegistryClipboard