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
90class SwFormatMeta final
91 : public SfxPoolItem
92{
93private:
94 friend class SwTextMeta;
95 friend class ::sw::Meta;
96
97 std::shared_ptr< ::sw::Meta > m_pMeta;
99
101 void SetTextAttr(SwTextMeta * const i_pTextAttr);
102
104 void DoCopy(::sw::MetaFieldManager & i_rTargetDocManager,
105 SwTextNode & i_rTargetTextNode);
106
107 explicit SwFormatMeta( const sal_uInt16 i_nWhich );
108
109public:
111 explicit SwFormatMeta( std::shared_ptr< ::sw::Meta > i_pMeta,
112 const sal_uInt16 i_nWhich );
113 virtual ~SwFormatMeta() override;
114
116 virtual bool operator==( const SfxPoolItem & ) const override;
117 virtual SwFormatMeta* Clone( SfxItemPool *pPool = nullptr ) const override;
118
120 void NotifyChangeTextNode(SwTextNode *const pTextNode);
121 static SwFormatMeta * CreatePoolDefault( const sal_uInt16 i_nWhich );
122 ::sw::Meta * GetMeta() { return m_pMeta.get(); }
123};
124
125namespace sw {
126
127class Meta
128 : public ::sfx2::Metadatable
129 , public sw::BroadcastingModify
130{
131 friend class ::SwFormatMeta;
132 friend class ::SwXMeta;
133
135
138
139protected:
140
141 SwTextMeta * GetTextAttr() const;
142 SwTextNode * GetTextNode() const { return m_pTextNode;}
143
145 void SetFormatMeta( SwFormatMeta * const i_pFormat ) { m_pFormat = i_pFormat; };
146
147 void NotifyChangeTextNode(SwTextNode *const pTextNode);
148
150 { return m_wXMeta; }
151 void SetXMeta(rtl::Reference<SwXMeta> const& xMeta);
152
153 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
154
155public:
156 explicit Meta(SwFormatMeta * const i_pFormat);
157 virtual ~Meta() override;
158
160 virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
161 virtual bool IsInClipboard() const override;
162 virtual bool IsInUndo() const override;
163 virtual bool IsInContent() const override;
164 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
165};
166
167class MetaField final
168 : public Meta
169{
170private:
171 friend class ::SwFormatMeta;
172 friend class ::SwXMetaField;
173 friend class ::sw::MetaFieldManager;
174
175 sal_uInt32 m_nNumberFormat;
177
178 sal_uInt32 GetNumberFormat(std::u16string_view aContent) const;
179 void SetNumberFormat(sal_uInt32 nNumberFormat);
180 bool IsFixedLanguage() const { return m_bIsFixedLanguage; }
182
183 explicit MetaField(SwFormatMeta * const i_pFormat,
184 const sal_uInt32 nNumberFormat,
185 const bool bIsFixedLanguage );
186
187public:
190 OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor);
191};
192
195{
196private:
197 typedef std::vector< std::weak_ptr<MetaField> > MetaFieldList_t;
200 css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
201
204
205public:
207 std::shared_ptr<MetaField> makeMetaField(
208 SwFormatMeta * const i_pFormat = nullptr,
209 const sal_uInt32 nNumberFormat = SAL_MAX_UINT32,
210 const bool bIsFixedLanguage = false );
212 std::vector< css::uno::Reference<css::text::XTextField> > getMetaFields();
214 void copyDocumentProperties(const SwDoc& rSource);
215 const css::uno::Reference<css::document::XDocumentProperties>& getDocumentProperties() const;
216};
217
218} // namespace sw
219
220#endif // INCLUDED_SW_INC_FMTMETA_HXX
221
222/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:194
SwTextMeta * GetTextAttr()
Definition: fmtmeta.hxx:100
std::shared_ptr< ::sw::Meta > m_pMeta
Definition: fmtmeta.hxx:97
SwTextMeta * m_pTextAttr
Definition: fmtmeta.hxx:98
static SwFormatMeta * CreatePoolDefault(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:529
void NotifyChangeTextNode(SwTextNode *const pTextNode)
notify clients registered at m_pMeta that this meta is being (re-)moved
Definition: fmtatr2.cxx:600
void DoCopy(::sw::MetaFieldManager &i_rTargetDocManager, SwTextNode &i_rTargetTextNode)
this method must be called when the hint is actually copied
Definition: fmtatr2.cxx:613
SwFormatMeta(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:534
virtual bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
Definition: fmtatr2.cxx:564
::sw::Meta * GetMeta()
Definition: fmtmeta.hxx:122
virtual SwFormatMeta * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:570
void SetTextAttr(SwTextMeta *const i_pTextAttr)
Definition: fmtatr2.cxx:577
virtual ~SwFormatMeta() override
Definition: fmtatr2.cxx:555
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
knows all meta-fields in the document.
Definition: fmtmeta.hxx:195
MetaFieldList_t m_MetaFields
Definition: fmtmeta.hxx:198
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Document properties of a clipboard document, empty for non-clipboard documents.
Definition: fmtmeta.hxx:200
MetaFieldManager(MetaFieldManager const &)=delete
std::vector< std::weak_ptr< MetaField > > MetaFieldList_t
Definition: fmtmeta.hxx:197
MetaFieldManager & operator=(MetaFieldManager const &)=delete
sal_uInt32 GetNumberFormat(std::u16string_view aContent) const
Definition: fmtatr2.cxx:759
sal_uInt32 m_nNumberFormat
Definition: fmtmeta.hxx:175
MetaField(SwFormatMeta *const i_pFormat, const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
Definition: fmtatr2.cxx:729
void SetIsFixedLanguage(bool b)
Definition: fmtmeta.hxx:181
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:737
bool IsFixedLanguage() const
Definition: fmtmeta.hxx:180
void SetNumberFormat(sal_uInt32 nNumberFormat)
Definition: fmtatr2.cxx:772
bool m_bIsFixedLanguage
Definition: fmtmeta.hxx:176
SwTextNode * GetTextNode() const
Definition: fmtmeta.hxx:142
SwFormatMeta * GetFormatMeta() const
Definition: fmtmeta.hxx:144
SwTextMeta * GetTextAttr() const
Definition: fmtatr2.cxx:652
virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override
Definition: fmtatr2.cxx:724
unotools::WeakReference< SwXMeta > const & GetXMeta() const
Definition: fmtmeta.hxx:149
Meta(SwFormatMeta *const i_pFormat)
Definition: fmtatr2.cxx:640
virtual ~Meta() override
Definition: fmtatr2.cxx:648
void SetXMeta(rtl::Reference< SwXMeta > const &xMeta)
Definition: fmtatr2.cxx:657
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: fmtatr2.cxx:692
virtual bool IsInUndo() const override
Definition: fmtatr2.cxx:710
void SetFormatMeta(SwFormatMeta *const i_pFormat)
Definition: fmtmeta.hxx:145
virtual bool IsInClipboard() const override
Definition: fmtatr2.cxx:703
unotools::WeakReference< SwXMeta > m_wXMeta
Definition: fmtmeta.hxx:134
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: fmtatr2.cxx:677
SwTextNode * m_pTextNode
Definition: fmtmeta.hxx:137
SwFormatMeta * m_pFormat
Definition: fmtmeta.hxx:136
virtual bool IsInContent() const override
Definition: fmtatr2.cxx:717
void NotifyChangeTextNode(SwTextNode *const pTextNode)
Definition: fmtatr2.cxx:660
def text(shape, orig_st)
Dialog to specify the properties of date form field.
#define SW_DLLPUBLIC
Definition: swdllapi.h:28