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 <string_view>
33 #include <vector>
34 
35 class SwDoc;
37 class SwPageDesc;
38 class SwCharFormat;
39 class SwTextFormatColl;
40 class SwFrameFormat;
41 class SwNumRule;
42 class SwTableAutoFormat;
43 class SwBoxAutoFormat;
44 enum class SwGetPoolIdFromName : sal_uInt16;
45 
46 // Temporary StyleSheet.
48 {
49  friend class SwDocStyleSheetPool;
50  friend class SwStyleSheetIterator;
51 
61 
63  OUString m_aLink;
64 
66  SAL_DLLPRIVATE void Create();
67 
74  };
75 
76  SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
77  std::optional<SfxItemSet> * o_ppFlatSet = nullptr);
78 
79  virtual ~SwDocStyleSheet() override;
80 
81 public:
82  SwDocStyleSheet( SwDoc& rDoc,
83  SwDocStyleSheetPool& rPool);
84 
86 
87  void Reset();
88 
89  void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
90 
91  bool IsPhysical() const { return m_bPhysical; }
92  void SetPhysical(bool bPhys);
93 
94  virtual void SetHidden( bool bHidden ) override;
95  virtual bool IsHidden( ) const override;
96  void SetGrabBagItem(const css::uno::Any& rVal);
97  void GetGrabBagItem(css::uno::Any& rVal) const;
98 
103  void SetItemSet( const SfxItemSet& rSet,
104  const bool bResetIndentAttrsAtParagraphStyle = false );
105 
106  virtual SfxItemSet& GetItemSet() override;
107  virtual std::optional<SfxItemSet> GetItemSetForPreview() override;
111  virtual const OUString& GetParent() const override;
112  virtual const OUString& GetFollow() const override;
113  const OUString& GetLink() const;
114 
115  virtual sal_uLong GetHelpId( OUString& rFile ) override;
116  virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
117 
120  void PresetName(const OUString& rName) { aName = rName; }
121  void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName);
122  void PresetParent(const OUString& rName){ aParent = rName; }
123  void PresetFollow(const OUString& rName){ aFollow = rName; }
124 
125  virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
126  virtual bool SetParent( const OUString& rStr) override;
127  virtual bool SetFollow( const OUString& rStr) override;
128  void SetLink(const OUString& rStr);
129 
130  virtual bool HasFollowSupport() const override;
131  virtual bool HasParentSupport() const override;
132  virtual bool HasClearParentSupport() const override;
133  virtual OUString GetDescription(MapUnit eUnit) override;
134 
135  virtual OUString GetUsedBy() override;
136 
140  const SwPageDesc* GetPageDesc();
141  const SwNumRule* GetNumRule();
142  void SetNumRule(const SwNumRule& rRule);
144 
145  virtual bool IsUsed() const override;
146 };
147 
148 namespace std {
149 template<>
150 struct hash<std::pair<SfxStyleFamily,OUString>>
151 {
152  std::size_t operator()(std::pair<SfxStyleFamily,OUString> const & pair) const
153  { return static_cast<std::size_t>(pair.first) ^ std::size_t(pair.second.hashCode()); }
154 };
155 }
156 
157 
158 // Iterator for Pool.
160 {
161  // Local helper class.
163  {
164  std::vector<std::pair<SfxStyleFamily, OUString>> maImpl;
165  typedef std::unordered_map<std::pair<SfxStyleFamily, OUString>, sal_uInt32> UniqueHash;
166  UniqueHash maUnique;
167  void rehash();
168  public:
170  void Append( SfxStyleFamily eFam, const OUString& rStr );
171  void clear() { maImpl.clear(); maUnique.clear(); }
172  size_t size() { return maImpl.size(); }
173  bool empty() { return maImpl.empty(); }
174  sal_uInt32 FindName(SfxStyleFamily eFam, const OUString& rName);
175  void RemoveName(SfxStyleFamily eFam, const OUString& rName);
176  const std::pair<SfxStyleFamily,OUString> &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
177  };
178 
182  sal_uInt32 m_nLastPos;
184 
185  void AppendStyleList(const std::vector<OUString>& rLst,
186  bool bUsed,
187  bool bTestHidden,
188  bool bOnlyHidden,
189  SwGetPoolIdFromName nSection,
190  SfxStyleFamily eFamily);
191 
192 public:
195  virtual ~SwStyleSheetIterator() override;
196 
197  virtual sal_Int32 Count() override;
198  virtual SfxStyleSheetBase *operator[](sal_Int32 nIdx) override;
199  virtual SfxStyleSheetBase* First() override;
200  virtual SfxStyleSheetBase* Next() override;
201  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
202 
203  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
204 
205  void InvalidateIterator();
206 };
207 
209 {
212  bool m_bOrganizer : 1;
213 
214  virtual rtl::Reference<SfxStyleSheetBase> Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
216 
218 
219 public:
220  SwDocStyleSheetPool( SwDoc&, bool bOrganizer );
221 
222  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
223  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
224 
225  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
226  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
227 
228  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
229  const OUString &rParent ) override;
230 
231  virtual void Remove( SfxStyleSheetBase* pStyle) override;
232 
233  bool IsOrganizerMode() const { return m_bOrganizer; }
234 
235  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
236 
237  SwDoc& GetDoc() const { return m_rDoc; }
238 
239  void dispose();
240 
241  void InvalidateIterator();
242 
243 private:
244  virtual ~SwDocStyleSheetPool() override;
245 
246  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
247 };
248 
249 #endif
250 
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2461
const OUString & GetLink() const
Definition: docstyle.cxx:770
virtual bool IsUsed() const
virtual const OUString & GetFollow() const
virtual std::optional< SfxItemSet > GetItemSetForPreview()
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2668
std::unordered_map< std::pair< SfxStyleFamily, OUString >, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:165
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
bool m_bOrganizer
Organizer.
Definition: docstyle.hxx:212
SwDoc & GetDoc() const
Definition: docstyle.hxx:237
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2214
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2208
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2705
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:2454
Definition: doc.hxx:188
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:514
virtual const OUString & GetParent() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
SwPoolFormatList m_aLst
Definition: docstyle.hxx:181
OUString m_aLink
Definition: docstyle.hxx:63
virtual SfxItemSet & GetItemSet()
std::size_t operator()(std::pair< SfxStyleFamily, OUString > const &pair) const
Definition: docstyle.hxx:152
SfxItemSet m_aCoreSet
Definition: docstyle.hxx:60
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:2225
std::vector< std::pair< SfxStyleFamily, OUString > > maImpl
Definition: docstyle.hxx:164
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2421
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2692
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2429
bool IsPhysical() const
Definition: docstyle.hxx:91
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:179
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3117
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2245
virtual bool SetFollow(const OUString &)
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:361
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2193
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2179
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2531
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:122
SwTableAutoFormat * m_pTableFormat
Definition: docstyle.hxx:57
const std::pair< SfxStyleFamily, OUString > & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:176
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3137
Style of a layout element.
Definition: frmfmt.hxx:59
SwCharFormat * m_pCharFormat
Definition: docstyle.hxx:52
void Append(SfxStyleFamily eFam, const OUString &rStr)
Definition: docstyle.cxx:399
sal_uInt32 m_nLastPos
Definition: docstyle.hxx:182
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: docstyle.cxx:465
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3232
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:1421
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:123
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter , default value false, which indicates that...
Definition: docstyle.cxx:1453
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:411
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2232
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Represents the style of a text portion.
Definition: charfmt.hxx:26
SwFrameFormat * m_pFrameFormat
Definition: docstyle.hxx:54
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2104
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2433
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:386
const SwBoxAutoFormat * m_pBoxFormat
Definition: docstyle.hxx:58
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:69
const SwNumRule * m_pNumRule
Definition: docstyle.hxx:56
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2679
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3159
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:120
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2186
const SwPageDesc * m_pDesc
Definition: docstyle.hxx:55
SwDoc & m_rDoc
Definition: docstyle.hxx:59
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2587
SwTextFormatColl * m_pColl
Definition: docstyle.hxx:53
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy()
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:180
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::optional< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1868
OUString aName
void SetLink(const OUString &rStr)
Definition: docstyle.cxx:736
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:89
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2684
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:233
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:210
virtual OUString GetDescription(MapUnit eMetric)
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2471