LibreOffice Module sw (master) 1
fmtmeta.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
20#ifndef INCLUDED_SW_INC_FMTMETA_HXX
21#define INCLUDED_SW_INC_FMTMETA_HXX
22
23#include "calbck.hxx"
24
25#include <unotools/weakref.hxx>
26
27#include <svl/poolitem.hxx>
28#include <sfx2/Metadatable.hxx>
29
30#include <memory>
31#include <vector>
32
33namespace com::sun::star {
34 namespace document {
35 class XDocumentProperties;
36 }
37 namespace text {
38 class XTextField;
39 }
40}
41
80class SwTextMeta;
81class SwXMeta;
82class SwXMetaField;
83class SwTextNode;
84class SwDoc;
85namespace sw {
86 class Meta;
87 class MetaFieldManager;
88}
89
91class SwFormatMeta final
92 : public SfxPoolItem
93{
94private:
95 friend class SwTextMeta;
96 friend class ::sw::Meta;
97
98 std::shared_ptr< ::sw::Meta > m_pMeta;
100
102 void SetTextAttr(SwTextMeta * const i_pTextAttr);
103
105 void DoCopy(::sw::MetaFieldManager & i_rTargetDocManager,
106 SwTextNode & i_rTargetTextNode);
107
108 explicit SwFormatMeta( const sal_uInt16 i_nWhich );
109
110public:
112 explicit SwFormatMeta( std::shared_ptr< ::sw::Meta > i_pMeta,
113 const sal_uInt16 i_nWhich );
114 virtual ~SwFormatMeta() override;
115
117 virtual bool operator==( const SfxPoolItem & ) const override;
118 virtual SwFormatMeta* Clone( SfxItemPool *pPool = nullptr ) const override;
119
121 void NotifyChangeTextNode(SwTextNode *const pTextNode);
122 static SwFormatMeta * CreatePoolDefault( const sal_uInt16 i_nWhich );
123 ::sw::Meta * GetMeta() { return m_pMeta.get(); }
124};
125
126namespace sw {
127
134class Meta
135 : public ::sfx2::Metadatable
136 , public sw::BroadcastingModify
137{
138 friend class ::SwFormatMeta;
139 friend class ::SwXMeta;
140
142
145
146protected:
147
148 SwTextMeta * GetTextAttr() const;
149 SwTextNode * GetTextNode() const { return m_pTextNode;}
150
152 void SetFormatMeta( SwFormatMeta * const i_pFormat ) { m_pFormat = i_pFormat; };
153
154 void NotifyChangeTextNode(SwTextNode *const pTextNode);
155
157 { return m_wXMeta; }
158 void SetXMeta(rtl::Reference<SwXMeta> const& xMeta);
159
160 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
161
162public:
163 explicit Meta(SwFormatMeta * const i_pFormat);
164 virtual ~Meta() override;
165
167 virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
168 virtual bool IsInClipboard() const override;
169 virtual bool IsInUndo() const override;
170 virtual bool IsInContent() const override;
171 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
172};
173
174class MetaField final
175 : public Meta
176{
177private:
178 friend class ::SwFormatMeta;
179 friend class ::SwXMetaField;
180 friend class ::sw::MetaFieldManager;
181
182 sal_uInt32 m_nNumberFormat;
184
185 sal_uInt32 GetNumberFormat(const OUString& aContent) const;
186 void SetNumberFormat(sal_uInt32 nNumberFormat);
187 bool IsFixedLanguage() const { return m_bIsFixedLanguage; }
189
190 explicit MetaField(SwFormatMeta * const i_pFormat,
191 const sal_uInt32 nNumberFormat,
192 const bool bIsFixedLanguage );
193
194public:
197 OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor);
198};
199
202{
203private:
204 typedef std::vector< std::weak_ptr<MetaField> > MetaFieldList_t;
207 css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
208
211
212public:
214 std::shared_ptr<MetaField> makeMetaField(
215 SwFormatMeta * const i_pFormat = nullptr,
216 const sal_uInt32 nNumberFormat = SAL_MAX_UINT32,
217 const bool bIsFixedLanguage = false );
219 std::vector< css::uno::Reference<css::text::XTextField> > getMetaFields();
221 void copyDocumentProperties(const SwDoc& rSource);
222 const css::uno::Reference<css::document::XDocumentProperties>& getDocumentProperties() const;
223};
224
225} // namespace sw
226
227#endif // INCLUDED_SW_INC_FMTMETA_HXX
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:197
SwFormatMeta is a pool item subclass that owns a Meta.
Definition: fmtmeta.hxx:93
SwTextMeta * GetTextAttr()
Definition: fmtmeta.hxx:101
std::shared_ptr< ::sw::Meta > m_pMeta
Definition: fmtmeta.hxx:98
SwTextMeta * m_pTextAttr
Definition: fmtmeta.hxx:99
static SwFormatMeta * CreatePoolDefault(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:540
void NotifyChangeTextNode(SwTextNode *const pTextNode)
notify clients registered at m_pMeta that this meta is being (re-)moved
Definition: fmtatr2.cxx:611
void DoCopy(::sw::MetaFieldManager &i_rTargetDocManager, SwTextNode &i_rTargetTextNode)
this method must be called when the hint is actually copied
Definition: fmtatr2.cxx:624
SwFormatMeta(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:545
virtual bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
Definition: fmtatr2.cxx:575
::sw::Meta * GetMeta()
Definition: fmtmeta.hxx:123
virtual SwFormatMeta * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:581
void SetTextAttr(SwTextMeta *const i_pTextAttr)
Definition: fmtatr2.cxx:588
virtual ~SwFormatMeta() override
Definition: fmtatr2.cxx:566
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
knows all meta-fields in the document.
Definition: fmtmeta.hxx:202
MetaFieldList_t m_MetaFields
Definition: fmtmeta.hxx:205
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Document properties of a clipboard document, empty for non-clipboard documents.
Definition: fmtmeta.hxx:207
MetaFieldManager(MetaFieldManager const &)=delete
std::vector< std::weak_ptr< MetaField > > MetaFieldList_t
Definition: fmtmeta.hxx:204
MetaFieldManager & operator=(MetaFieldManager const &)=delete
sal_uInt32 m_nNumberFormat
Definition: fmtmeta.hxx:182
MetaField(SwFormatMeta *const i_pFormat, const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
Definition: fmtatr2.cxx:740
void SetIsFixedLanguage(bool b)
Definition: fmtmeta.hxx:188
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:748
bool IsFixedLanguage() const
Definition: fmtmeta.hxx:187
sal_uInt32 GetNumberFormat(const OUString &aContent) const
Definition: fmtatr2.cxx:770
void SetNumberFormat(sal_uInt32 nNumberFormat)
Definition: fmtatr2.cxx:783
bool m_bIsFixedLanguage
Definition: fmtmeta.hxx:183
Meta is an annotation on a range of text.
Definition: fmtmeta.hxx:137
SwTextNode * GetTextNode() const
Definition: fmtmeta.hxx:149
SwFormatMeta * GetFormatMeta() const
Definition: fmtmeta.hxx:151
SwTextMeta * GetTextAttr() const
Definition: fmtatr2.cxx:663
virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override
Definition: fmtatr2.cxx:735
unotools::WeakReference< SwXMeta > const & GetXMeta() const
Definition: fmtmeta.hxx:156
Meta(SwFormatMeta *const i_pFormat)
Definition: fmtatr2.cxx:651
virtual ~Meta() override
Definition: fmtatr2.cxx:659
void SetXMeta(rtl::Reference< SwXMeta > const &xMeta)
Definition: fmtatr2.cxx:668
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: fmtatr2.cxx:703
virtual bool IsInUndo() const override
Definition: fmtatr2.cxx:721
void SetFormatMeta(SwFormatMeta *const i_pFormat)
Definition: fmtmeta.hxx:152
virtual bool IsInClipboard() const override
Definition: fmtatr2.cxx:714
unotools::WeakReference< SwXMeta > m_wXMeta
Definition: fmtmeta.hxx:141
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: fmtatr2.cxx:688
SwTextNode * m_pTextNode
Definition: fmtmeta.hxx:144
SwFormatMeta * m_pFormat
Definition: fmtmeta.hxx:143
virtual bool IsInContent() const override
Definition: fmtatr2.cxx:728
void NotifyChangeTextNode(SwTextNode *const pTextNode)
Definition: fmtatr2.cxx:671
def text(shape, orig_st)
Dialog to specify the properties of date form field.
#define SW_DLLPUBLIC
Definition: swdllapi.h:28