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 { namespace sun { namespace 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 
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 SfxPoolItem * 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 SwModify
130  , public sw::BroadcasterMixin
131 {
132  friend class ::SwFormatMeta;
133  friend class ::SwXMeta;
134 
135  css::uno::WeakReference<
136  css::rdf::XMetadatable> m_wXMeta;
137 
140 
141 protected:
142 
143  SwTextMeta * GetTextAttr() const;
144  SwTextNode * GetTextNode() const { return m_pTextNode;}
145 
146  SwFormatMeta * GetFormatMeta() const { return m_pFormat; }
147  void SetFormatMeta( SwFormatMeta * const i_pFormat ) { m_pFormat = i_pFormat; };
148 
149  void NotifyChangeTextNode(SwTextNode *const pTextNode);
150 
151  css::uno::WeakReference<css::rdf::XMetadatable> const& GetXMeta() const
152  { return m_wXMeta; }
153  void SetXMeta(css::uno::Reference<css::rdf::XMetadatable> const& xMeta)
154  { m_wXMeta = xMeta; }
155 
157  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) override;
158 
159 public:
160  explicit Meta(SwFormatMeta * const i_pFormat);
161  virtual ~Meta() override;
162 
164  virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
165  virtual bool IsInClipboard() const override;
166  virtual bool IsInUndo() const override;
167  virtual bool IsInContent() const override;
168  virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
169 };
170 
172  : public Meta
173 {
174 private:
175  friend class ::SwFormatMeta;
176  friend class ::SwXMetaField;
177  friend class ::sw::MetaFieldManager;
178 
179  sal_uInt32 m_nNumberFormat;
181 
182  sal_uInt32 GetNumberFormat(OUString const & rContent) const;
183  void SetNumberFormat(sal_uInt32 nNumberFormat);
184  bool IsFixedLanguage() const { return m_bIsFixedLanguage; }
185  void SetIsFixedLanguage(bool b) { m_bIsFixedLanguage = b; }
186 
187  explicit MetaField(SwFormatMeta * const i_pFormat,
188  const sal_uInt32 nNumberFormat,
189  const bool bIsFixedLanguage );
190 
191 public:
193  void GetPrefixAndSuffix(
194  OUString *const o_pPrefix, OUString *const o_pSuffix);
195 };
196 
199 {
200 private:
201  typedef std::vector< std::weak_ptr<MetaField> > MetaFieldList_t;
202  MetaFieldList_t m_MetaFields;
204  css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
205 
206  MetaFieldManager(MetaFieldManager const&) = delete;
207  MetaFieldManager& operator=(MetaFieldManager const&) = delete;
208 
209 public:
211  std::shared_ptr<MetaField> makeMetaField(
212  SwFormatMeta * const i_pFormat = nullptr,
213  const sal_uInt32 nNumberFormat = SAL_MAX_UINT32,
214  const bool bIsFixedLanguage = false );
216  std::vector< css::uno::Reference<css::text::XTextField> > getMetaFields();
218  void copyDocumentProperties(const SwDoc& rSource);
219  const css::uno::Reference<css::document::XDocumentProperties>& getDocumentProperties();
220 };
221 
222 } // namespace sw
223 
224 #endif // INCLUDED_SW_INC_FMTMETA_HXX
225 
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFormatMeta * CreatePoolDefault(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:528
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:733
SwFormatMeta * GetFormatMeta() const
Definition: fmtmeta.hxx:146
SwTextMeta * GetTextAttr()
Definition: fmtmeta.hxx:100
virtual bool IsInContent() const override
Definition: fmtatr2.cxx:713
void DoCopy(::sw::MetaFieldManager &i_rTargetDocManager, SwTextNode &i_rTargetTextNode)
this method must be called when the hint is actually copied
Definition: fmtatr2.cxx:613
knows all meta-fields in the document.
Definition: fmtmeta.hxx:198
Definition: doc.hxx:185
void NotifyChangeTextNode(SwTextNode *const pTextNode)
notify clients registered at m_pMeta that this meta is being (re-)moved
Definition: fmtatr2.cxx:600
bool IsFixedLanguage() const
Definition: fmtmeta.hxx:184
MetaField(SwFormatMeta *const i_pFormat, const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
Definition: fmtatr2.cxx:725
virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override
Definition: fmtatr2.cxx:720
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
Meta(SwFormatMeta *const i_pFormat)
Definition: fmtatr2.cxx:640
virtual ~Meta() override
Definition: fmtatr2.cxx:648
virtual bool IsInUndo() const override
Definition: fmtatr2.cxx:706
SwFormatMeta * m_pFormat
Definition: fmtmeta.hxx:138
void SetFormatMeta(SwFormatMeta *const i_pFormat)
Definition: fmtmeta.hxx:147
sal_uInt32 m_nNumberFormat
Definition: fmtmeta.hxx:179
css::uno::WeakReference< css::rdf::XMetadatable > const & GetXMeta() const
Definition: fmtmeta.hxx:151
::sw::Meta * GetMeta()
Definition: fmtmeta.hxx:122
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: fmtatr2.cxx:688
SwTextMeta * GetTextAttr() const
Definition: fmtatr2.cxx:652
void SetIsFixedLanguage(bool b)
Definition: fmtmeta.hxx:185
void SetXMeta(css::uno::Reference< css::rdf::XMetadatable > const &xMeta)
Definition: fmtmeta.hxx:153
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Document properties of a clipboard document, empty for non-clipboard documents.
Definition: fmtmeta.hxx:204
void NotifyChangeTextNode(SwTextNode *const pTextNode)
Definition: fmtatr2.cxx:658
css::uno::WeakReference< css::rdf::XMetadatable > m_wXMeta
Definition: fmtmeta.hxx:136
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SwTextNode * GetTextNode() const
Definition: fmtmeta.hxx:144
SwTextNode * m_pTextNode
Definition: fmtmeta.hxx:139
virtual bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
Definition: fmtatr2.cxx:563
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
std::vector< std::weak_ptr< MetaField > > MetaFieldList_t
Definition: fmtmeta.hxx:201
std::shared_ptr< ::sw::Meta > m_pMeta
Definition: fmtmeta.hxx:97
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
SwClient.
Definition: fmtatr2.cxx:676
MetaFieldList_t m_MetaFields
Definition: fmtmeta.hxx:202
sal_uInt32 GetNumberFormat(OUString const &rContent) const
Definition: fmtatr2.cxx:756
void SetTextAttr(SwTextMeta *const i_pTextAttr)
Definition: fmtatr2.cxx:577
bool m_bIsFixedLanguage
Definition: fmtmeta.hxx:180
virtual bool IsInClipboard() const override
Definition: fmtatr2.cxx:699
def text(shape, st)
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
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:570