Don't search for old (<= 2.0) .NET SDK anymore
[LibreOffice.git] / include / sfx2 / Metadatable.hxx
blobbd9f3bb659fe5bc2a8b359c99813ba83bfee5d59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_METADATABLE_HXX
20 #define INCLUDED_SFX2_METADATABLE_HXX
22 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
26 #include <cppuhelper/implbase.hxx>
27 #include <com/sun/star/rdf/XMetadatable.hpp>
29 #include <memory>
32 namespace com { namespace sun { namespace star {
33 namespace frame { class XModel; }
34 } } }
36 namespace sfx2 {
37 class IXmlIdRegistry;
40 namespace sfx2 {
42 class XmlIdRegistry;
43 class MetadatableUndo;
46 // XML ID handling ---------------------------------------------------
49 /// create a sfx2::XmlIdRegistryDocument or a sfx2::XmlIdRegistryClipboard
50 SFX2_DLLPUBLIC ::sfx2::IXmlIdRegistry *
51 createXmlIdRegistry(const bool i_DocIsClipboard);
54 /** base class for core objects that may have xml:id.
56 <p>The interface of this class consists of 3 parts:
57 <ul><li>implementations that are used by the MetadatableMixin
58 below</li>
59 <li>hooks to be called by the sw core whenever actions that are
60 relevant to the uniqueness of xml:ids are taken (copying,
61 splitting, merging, deletion, undo, etc.)</li>
62 <li>abstract methods that are called by the implementation of the
63 previous hooks</li></ul>
64 </p>
66 class SFX2_DLLPUBLIC Metadatable
68 public:
69 Metadatable() : m_pReg(nullptr) {}
71 // destructor calls RemoveMetadataReference
72 virtual ~Metadatable();
74 // for MetadatableMixin ----------------------------------------------
76 css::beans::StringPair GetMetadataReference() const;
77 void SetMetadataReference( const css::beans::StringPair & i_rReference);
78 void EnsureMetadataReference();
80 // hooks -------------------------------------------------------------
82 // called from dtor!
83 void RemoveMetadataReference();
85 /** register this as a copy of i_rSource */
86 void RegisterAsCopyOf(Metadatable const & i_rSource,
87 const bool i_bCopyPrecedesSource = false);
89 /** create an Undo Metadatable, which remembers this' reference */
90 std::shared_ptr<MetadatableUndo> CreateUndo() const;
91 std::shared_ptr<MetadatableUndo> CreateUndoForDelete();
93 /** restore this from Undo Metadatable */
94 void RestoreMetadata(std::shared_ptr<MetadatableUndo> const& i_pUndo);
96 /** merge this and i_rOther into this */
97 void JoinMetadatable(Metadatable const & i_rOther,
98 const bool i_isMergedEmpty, const bool i_isOtherEmpty);
100 // abstract methods --------------------------------------------------
102 /** get the registry from the SwDoc */
103 virtual ::sfx2::IXmlIdRegistry& GetRegistry() = 0;
105 /** is this in a clipboard document? */
106 virtual bool IsInClipboard() const = 0;
108 /** is this in undo array? */
109 virtual bool IsInUndo() const = 0;
111 /** which stream is this in? true: content.xml; false: styles.xml */
112 virtual bool IsInContent() const = 0;
114 /** create XMetadatable from this.
115 note: if IsInUndo or IsInClipboard return true,
116 MakeUnoObject <em>must not</em> be called!
118 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() = 0;
120 private:
121 Metadatable(const Metadatable&) = delete;
122 Metadatable& operator=(const Metadatable&) = delete;
124 friend class MetadatableClipboard;
125 friend class MetadatableUndo;
127 // note that Reg may be a XmlIdRegistryDocument or a XmlIdRegistryClipboard
128 XmlIdRegistry* m_pReg; // null => no XmlId
132 /** base class for UNO objects that implement XMetadatable.
134 <p>An instance of this base class is associated with an instance of
135 Metadatable.</p>
137 class SFX2_DLLPUBLIC MetadatableMixin :
138 public cppu::WeakImplHelper<css::rdf::XMetadatable>
141 public:
142 MetadatableMixin() {};
144 // css::rdf::XNode:
145 virtual OUString SAL_CALL getStringValue() override;
147 // css::rdf::XURI:
148 virtual OUString SAL_CALL getLocalName() override;
149 virtual OUString SAL_CALL getNamespace() override;
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;
157 protected:
158 /// get the core object corresponding to this UNO object.
159 virtual Metadatable * GetCoreObject() = 0;
160 /// get the XModel for the document
161 virtual css::uno::Reference< css::frame::XModel >
162 GetModel() = 0;
166 } // namespace sfx2
168 #endif // INCLUDED_SFX2_METADATABLE_HXX
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */