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 <cppuhelper/weakref.hxx>
26 
27 #include <svl/poolitem.hxx>
28 #include <sfx2/Metadatable.hxx>
29 
30 #include <memory>
31 #include <vector>
32 
33 namespace com::sun::star {
34  namespace document {
35  class XDocumentProperties;
36  }
37  namespace text {
38  class XTextField;
39  }
40 }
41 
80 class SwTextMeta;
81 class SwXMeta;
82 class SwXMetaField;
83 class SwTextNode;
84 class SwDoc;
85 namespace sw {
86  class Meta;
87  class MetaFieldManager;
88 }
89 
90 class SwFormatMeta final
91  : public SfxPoolItem
92 {
93 private:
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 
109 public:
111  explicit SwFormatMeta( std::shared_ptr< ::sw::Meta > const & 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 
125 namespace sw {
126 
127 class Meta
128  : public ::sfx2::Metadatable
129  , public sw::BroadcastingModify
130 {
131  friend class ::SwFormatMeta;
132  friend class ::SwXMeta;
133 
134  css::uno::WeakReference<
135  css::rdf::XMetadatable> m_wXMeta;
136 
139 
140 protected:
141 
142  SwTextMeta * GetTextAttr() const;
143  SwTextNode * GetTextNode() const { return m_pTextNode;}
144 
145  SwFormatMeta * GetFormatMeta() const { return m_pFormat; }
146  void SetFormatMeta( SwFormatMeta * const i_pFormat ) { m_pFormat = i_pFormat; };
147 
148  void NotifyChangeTextNode(SwTextNode *const pTextNode);
149 
150  css::uno::WeakReference<css::rdf::XMetadatable> const& GetXMeta() const
151  { return m_wXMeta; }
152  void SetXMeta(css::uno::Reference<css::rdf::XMetadatable> const& xMeta)
153  { m_wXMeta = xMeta; }
154 
155  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
156 
157 public:
158  explicit Meta(SwFormatMeta * const i_pFormat);
159  virtual ~Meta() override;
160 
162  virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
163  virtual bool IsInClipboard() const override;
164  virtual bool IsInUndo() const override;
165  virtual bool IsInContent() const override;
166  virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
167 };
168 
169 class MetaField final
170  : public Meta
171 {
172 private:
173  friend class ::SwFormatMeta;
174  friend class ::SwXMetaField;
175  friend class ::sw::MetaFieldManager;
176 
177  sal_uInt32 m_nNumberFormat;
179 
180  sal_uInt32 GetNumberFormat(OUString const & rContent) const;
181  void SetNumberFormat(sal_uInt32 nNumberFormat);
182  bool IsFixedLanguage() const { return m_bIsFixedLanguage; }
183  void SetIsFixedLanguage(bool b) { m_bIsFixedLanguage = b; }
184 
185  explicit MetaField(SwFormatMeta * const i_pFormat,
186  const sal_uInt32 nNumberFormat,
187  const bool bIsFixedLanguage );
188 
189 public:
191  void GetPrefixAndSuffix(
192  OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor);
193 };
194 
197 {
198 private:
199  typedef std::vector< std::weak_ptr<MetaField> > MetaFieldList_t;
200  MetaFieldList_t m_MetaFields;
202  css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
203 
204  MetaFieldManager(MetaFieldManager const&) = delete;
205  MetaFieldManager& operator=(MetaFieldManager const&) = delete;
206 
207 public:
209  std::shared_ptr<MetaField> makeMetaField(
210  SwFormatMeta * const i_pFormat = nullptr,
211  const sal_uInt32 nNumberFormat = SAL_MAX_UINT32,
212  const bool bIsFixedLanguage = false );
214  std::vector< css::uno::Reference<css::text::XTextField> > getMetaFields();
216  void copyDocumentProperties(const SwDoc& rSource);
217  const css::uno::Reference<css::document::XDocumentProperties>& getDocumentProperties() const;
218 };
219 
220 } // namespace sw
221 
222 #endif // INCLUDED_SW_INC_FMTMETA_HXX
223 
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFormatMeta * CreatePoolDefault(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:528
SwFormatMeta * GetFormatMeta() const
Definition: fmtmeta.hxx:145
SwTextMeta * GetTextAttr()
Definition: fmtmeta.hxx:100
virtual bool IsInContent() const override
Definition: fmtatr2.cxx:714
void DoCopy(::sw::MetaFieldManager &i_rTargetDocManager, SwTextNode &i_rTargetTextNode)
this method must be called when the hint is actually copied
Definition: fmtatr2.cxx:612
virtual SwFormatMeta * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:569
knows all meta-fields in the document.
Definition: fmtmeta.hxx:196
Definition: doc.hxx:188
void NotifyChangeTextNode(SwTextNode *const pTextNode)
notify clients registered at m_pMeta that this meta is being (re-)moved
Definition: fmtatr2.cxx:599
bool IsFixedLanguage() const
Definition: fmtmeta.hxx:182
MetaField(SwFormatMeta *const i_pFormat, const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
Definition: fmtatr2.cxx:726
virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override
Definition: fmtatr2.cxx:721
Dialog to specify the properties of date form field.
Meta(SwFormatMeta *const i_pFormat)
Definition: fmtatr2.cxx:639
virtual ~Meta() override
Definition: fmtatr2.cxx:647
virtual bool IsInUndo() const override
Definition: fmtatr2.cxx:707
SwFormatMeta * m_pFormat
Definition: fmtmeta.hxx:137
void SetFormatMeta(SwFormatMeta *const i_pFormat)
Definition: fmtmeta.hxx:146
sal_uInt32 m_nNumberFormat
Definition: fmtmeta.hxx:177
css::uno::WeakReference< css::rdf::XMetadatable > const & GetXMeta() const
Definition: fmtmeta.hxx:150
::sw::Meta * GetMeta()
Definition: fmtmeta.hxx:122
exports com.sun.star. text
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: fmtatr2.cxx:689
SwTextMeta * GetTextAttr() const
Definition: fmtatr2.cxx:651
void SetIsFixedLanguage(bool b)
Definition: fmtmeta.hxx:183
void SetXMeta(css::uno::Reference< css::rdf::XMetadatable > const &xMeta)
Definition: fmtmeta.hxx:152
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Document properties of a clipboard document, empty for non-clipboard documents.
Definition: fmtmeta.hxx:202
void NotifyChangeTextNode(SwTextNode *const pTextNode)
Definition: fmtatr2.cxx:657
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: fmtatr2.cxx:674
css::uno::WeakReference< css::rdf::XMetadatable > m_wXMeta
Definition: fmtmeta.hxx:135
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SwTextNode * GetTextNode() const
Definition: fmtmeta.hxx:143
SwTextNode * m_pTextNode
Definition: fmtmeta.hxx:138
virtual bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
Definition: fmtatr2.cxx:563
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
exports com.sun.star. document
std::vector< std::weak_ptr< MetaField > > MetaFieldList_t
Definition: fmtmeta.hxx:199
std::shared_ptr< ::sw::Meta > m_pMeta
Definition: fmtmeta.hxx:97
MetaFieldList_t m_MetaFields
Definition: fmtmeta.hxx:200
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:734
sal_uInt32 GetNumberFormat(OUString const &rContent) const
Definition: fmtatr2.cxx:756
void SetTextAttr(SwTextMeta *const i_pTextAttr)
Definition: fmtatr2.cxx:576
bool m_bIsFixedLanguage
Definition: fmtmeta.hxx:178
virtual bool IsInClipboard() const override
Definition: fmtatr2.cxx:700
virtual ~SwFormatMeta() override
Definition: fmtatr2.cxx:554
SwTextMeta * m_pTextAttr
Definition: fmtmeta.hxx:98
SwFormatMeta(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:533
void SetNumberFormat(sal_uInt32 nNumberFormat)
Definition: fmtatr2.cxx:769