LibreOffice Module sw (master)  1
docstyle.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 #ifndef INCLUDED_SW_INC_DOCSTYLE_HXX
20 #define INCLUDED_SW_INC_DOCSTYLE_HXX
21 
22 #include <rtl/ref.hxx>
23 #include <rtl/ustring.hxx>
24 
25 #include <svl/style.hxx>
26 #include <svl/itemset.hxx>
27 #include "swdllapi.h"
28 
29 #include <unordered_map>
30 #include <memory>
31 #include <optional>
32 #include <vector>
33 
34 class SwDoc;
36 class SwPageDesc;
37 class SwCharFormat;
38 class SwTextFormatColl;
39 class SwFrameFormat;
40 class SwNumRule;
41 class SwTableAutoFormat;
42 class SwBoxAutoFormat;
43 enum class SwGetPoolIdFromName : sal_uInt16;
44 
45 // Temporary StyleSheet.
47 {
48  friend class SwDocStyleSheetPool;
49  friend class SwStyleSheetIterator;
50 
60 
62  OUString m_aLink;
63 
65  SAL_DLLPRIVATE void Create();
66 
73  };
74 
75  SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
76  std::optional<SfxItemSet> * o_ppFlatSet = nullptr);
77 
78  virtual ~SwDocStyleSheet() override;
79 
80 public:
81  SwDocStyleSheet( SwDoc& rDoc,
82  SwDocStyleSheetPool& rPool);
83 
85 
86  void Reset();
87 
88  void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
89 
90  bool IsPhysical() const { return m_bPhysical; }
91  void SetPhysical(bool bPhys);
92 
93  virtual void SetHidden( bool bHidden ) override;
94  virtual bool IsHidden( ) const override;
95  void SetGrabBagItem(const css::uno::Any& rVal);
96  void GetGrabBagItem(css::uno::Any& rVal) const;
97 
102  void SetItemSet( const SfxItemSet& rSet,
103  const bool bResetIndentAttrsAtParagraphStyle = false );
104 
105  virtual SfxItemSet& GetItemSet() override;
106  virtual std::optional<SfxItemSet> GetItemSetForPreview() override;
110  virtual const OUString& GetParent() const override;
111  virtual const OUString& GetFollow() const override;
112  const OUString& GetLink() const;
113 
114  virtual sal_uLong GetHelpId( OUString& rFile ) override;
115  virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
116 
119  void PresetName(const OUString& rName) { aName = rName; }
120  void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName);
121  void PresetParent(const OUString& rName){ aParent = rName; }
122  void PresetFollow(const OUString& rName){ aFollow = rName; }
123 
124  virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
125  virtual bool SetParent( const OUString& rStr) override;
126  virtual bool SetFollow( const OUString& rStr) override;
127  void SetLink(const OUString& rStr);
128 
129  virtual bool HasFollowSupport() const override;
130  virtual bool HasParentSupport() const override;
131  virtual bool HasClearParentSupport() const override;
132  virtual OUString GetDescription(MapUnit eUnit) override;
133 
134  virtual OUString GetUsedBy() override;
135 
139  const SwPageDesc* GetPageDesc();
140  const SwNumRule* GetNumRule();
141  void SetNumRule(const SwNumRule& rRule);
143 
144  virtual bool IsUsed() const override;
145 };
146 
147 namespace std {
148 template<>
149 struct hash<std::pair<SfxStyleFamily,OUString>>
150 {
151  std::size_t operator()(std::pair<SfxStyleFamily,OUString> const & pair) const
152  { return static_cast<std::size_t>(pair.first) ^ std::size_t(pair.second.hashCode()); }
153 };
154 }
155 
156 
157 // Iterator for Pool.
159 {
160  // Local helper class.
162  {
163  std::vector<std::pair<SfxStyleFamily, OUString>> maImpl;
164  typedef std::unordered_map<std::pair<SfxStyleFamily, OUString>, sal_uInt32> UniqueHash;
165  UniqueHash maUnique;
166  void rehash();
167  public:
169  void Append( SfxStyleFamily eFam, const OUString& rStr );
170  void clear() { maImpl.clear(); maUnique.clear(); }
171  size_t size() { return maImpl.size(); }
172  bool empty() { return maImpl.empty(); }
173  sal_uInt32 FindName(SfxStyleFamily eFam, const OUString& rName);
174  void RemoveName(SfxStyleFamily eFam, const OUString& rName);
175  const std::pair<SfxStyleFamily,OUString> &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
176  };
177 
181  sal_uInt32 m_nLastPos;
183 
184  void AppendStyleList(const std::vector<OUString>& rLst,
185  bool bUsed,
186  bool bTestHidden,
187  bool bOnlyHidden,
188  SwGetPoolIdFromName nSection,
189  SfxStyleFamily eFamily);
190 
191 public:
194  virtual ~SwStyleSheetIterator() override;
195 
196  virtual sal_Int32 Count() override;
197  virtual SfxStyleSheetBase *operator[](sal_Int32 nIdx) override;
198  virtual SfxStyleSheetBase* First() override;
199  virtual SfxStyleSheetBase* Next() override;
200  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
201 
202  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
203 
204  void InvalidateIterator();
205 };
206 
208 {
211  bool m_bOrganizer : 1;
212 
213  virtual rtl::Reference<SfxStyleSheetBase> Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
215 
217 
218 public:
219  SwDocStyleSheetPool( SwDoc&, bool bOrganizer );
220 
221  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
222  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
223 
224  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
225  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
226 
227  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
228  const OUString &rParent ) override;
229 
230  virtual void Remove( SfxStyleSheetBase* pStyle) override;
231 
232  bool IsOrganizerMode() const { return m_bOrganizer; }
233 
234  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
235 
236  SwDoc& GetDoc() const { return m_rDoc; }
237 
238  void dispose();
239 
240  void InvalidateIterator();
241 
242 private:
243  virtual ~SwDocStyleSheetPool() override;
244 
245  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
246 };
247 
248 #endif
249 
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2455
const OUString & GetLink() const
Definition: docstyle.cxx:769
virtual bool IsUsed() const
virtual const OUString & GetFollow() const
virtual std::optional< SfxItemSet > GetItemSetForPreview()
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2662
std::unordered_map< std::pair< SfxStyleFamily, OUString >, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:164
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
bool m_bOrganizer
Organizer.
Definition: docstyle.hxx:211
SwDoc & GetDoc() const
Definition: docstyle.hxx:236
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2208
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2202
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2699
virtual bool SetParent(const OUString &)
virtual bool IsHidden() const
sal_uIntPtr sal_uLong
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2448
Definition: doc.hxx:187
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:513
virtual const OUString & GetParent() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
SwPoolFormatList m_aLst
Definition: docstyle.hxx:180
OUString m_aLink
Definition: docstyle.hxx:62
virtual SfxItemSet & GetItemSet()
std::size_t operator()(std::pair< SfxStyleFamily, OUString > const &pair) const
Definition: docstyle.hxx:151
SfxItemSet m_aCoreSet
Definition: docstyle.hxx:59
virtual sal_uLong GetHelpId(OUString &rFile)
virtual void SetHelpId(const OUString &r, sal_uLong nId)
void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString &rName)
Definition: docstyle.cxx:2219
std::vector< std::pair< SfxStyleFamily, OUString > > maImpl
Definition: docstyle.hxx:163
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2415
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2686
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2423
bool IsPhysical() const
Definition: docstyle.hxx:90
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:178
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3111
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2239
virtual bool SetFollow(const OUString &)
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:360
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2187
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2173
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2525
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:121
SwTableAutoFormat * m_pTableFormat
Definition: docstyle.hxx:56
const std::pair< SfxStyleFamily, OUString > & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:175
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3131
Style of a layout element.
Definition: frmfmt.hxx:59
SwCharFormat * m_pCharFormat
Definition: docstyle.hxx:51
void Append(SfxStyleFamily eFam, const OUString &rStr)
Definition: docstyle.cxx:398
sal_uInt32 m_nLastPos
Definition: docstyle.hxx:181
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: docstyle.cxx:464
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3226
virtual bool HasFollowSupport() const
void MergeIndentAttrsOfListStyle(SfxItemSet &rSet)
new method for paragraph styles to merge indent attributes of applied list style into the given item ...
Definition: docstyle.cxx:1420
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:122
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter , default value false, which indicates that...
Definition: docstyle.cxx:1452
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:410
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2226
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Represents the style of a text portion.
Definition: charfmt.hxx:26
SwFrameFormat * m_pFrameFormat
Definition: docstyle.hxx:53
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2098
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2427
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:385
const SwBoxAutoFormat * m_pBoxFormat
Definition: docstyle.hxx:57
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:68
const SwNumRule * m_pNumRule
Definition: docstyle.hxx:55
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2673
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3153
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:119
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2180
const SwPageDesc * m_pDesc
Definition: docstyle.hxx:54
SwDoc & m_rDoc
Definition: docstyle.hxx:58
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2581
SwTextFormatColl * m_pColl
Definition: docstyle.hxx:52
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy()
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:179
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::optional< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1862
OUString aName
void SetLink(const OUString &rStr)
Definition: docstyle.cxx:735
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:88
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2678
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:232
virtual bool HasParentSupport() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:76
SfxStyleSearchBits
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:209
virtual OUString GetDescription(MapUnit eMetric)
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2465