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 <string_view>
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 
54  const SwPageDesc* pDesc;
60 
61  bool bPhysical;
62 
64  SAL_DLLPRIVATE void Create();
65 
72  };
73 
74  SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
75  std::unique_ptr<SfxItemSet> * o_ppFlatSet = nullptr);
76 
77  virtual ~SwDocStyleSheet() override;
78 
79 public:
80  SwDocStyleSheet( SwDoc& rDoc,
81  SwDocStyleSheetPool& rPool);
82 
84 
85  void Reset();
86 
87  void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
88 
89  bool IsPhysical() const { return bPhysical; }
90  void SetPhysical(bool bPhys);
91 
92  virtual void SetHidden( bool bHidden ) override;
93  virtual bool IsHidden( ) const override;
94  void SetGrabBagItem(const css::uno::Any& rVal);
95  void GetGrabBagItem(css::uno::Any& rVal) const;
96 
101  void SetItemSet( const SfxItemSet& rSet,
102  const bool bResetIndentAttrsAtParagraphStyle = false );
103 
104  virtual SfxItemSet& GetItemSet() override;
105  virtual std::unique_ptr<SfxItemSet> GetItemSetForPreview() override;
109  virtual const OUString& GetParent() const override;
110  virtual const OUString& GetFollow() const override;
111 
112  virtual sal_uLong GetHelpId( OUString& rFile ) override;
113  virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
114 
117  void PresetName(const OUString& rName) { aName = rName; }
118  void PresetNameAndFamily(const OUString& rName);
119  void PresetParent(const OUString& rName){ aParent = rName; }
120  void PresetFollow(const OUString& rName){ aFollow = rName; }
121 
122  virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
123  virtual bool SetParent( const OUString& rStr) override;
124  virtual bool SetFollow( const OUString& rStr) override;
125 
126  virtual bool HasFollowSupport() const override;
127  virtual bool HasParentSupport() const override;
128  virtual bool HasClearParentSupport() const override;
129  virtual OUString GetDescription(MapUnit eUnit) override;
130 
131  virtual OUString GetUsedBy() override;
132 
136  const SwPageDesc* GetPageDesc();
137  const SwNumRule* GetNumRule();
138  void SetNumRule(const SwNumRule& rRule);
140 
141  virtual bool IsUsed() const override;
142 };
143 
144 // Iterator for Pool.
146 {
147  // Local helper class.
149  {
150  std::vector<OUString> maImpl;
151  typedef std::unordered_map<OUString, sal_uInt32> UniqueHash;
152  UniqueHash maUnique;
153  void rehash();
154  public:
156  void Append( char cChar, std::u16string_view rStr );
157  void clear() { maImpl.clear(); maUnique.clear(); }
158  size_t size() { return maImpl.size(); }
159  bool empty() { return maImpl.empty(); }
160  sal_uInt32 FindName(SfxStyleFamily eFam, std::u16string_view rName);
161  void RemoveName(SfxStyleFamily eFam, std::u16string_view rName);
162  const OUString &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
163  };
164 
168  sal_uInt32 nLastPos;
170 
171  void AppendStyleList(const std::vector<OUString>& rLst,
172  bool bUsed,
173  bool bTestHidden,
174  bool bOnlyHidden,
175  SwGetPoolIdFromName nSection,
176  char cType);
177 
178 public:
181  virtual ~SwStyleSheetIterator() override;
182 
183  virtual sal_Int32 Count() override;
184  virtual SfxStyleSheetBase *operator[](sal_Int32 nIdx) override;
185  virtual SfxStyleSheetBase* First() override;
186  virtual SfxStyleSheetBase* Next() override;
187  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
188 
189  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
190 
191  void InvalidateIterator();
192 };
193 
195 {
198  bool bOrganizer : 1;
199 
200  virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
201  virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) override;
202 
204 
205 public:
207 
208  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
209  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
210 
211  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
212  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
213 
214  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
215  const OUString &rParent ) override;
216 
217  virtual void Remove( SfxStyleSheetBase* pStyle) override;
218 
219  bool IsOrganizerMode() const { return bOrganizer; }
220 
221  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
222 
223  SwDoc& GetDoc() const { return rDoc; }
224 
225  void dispose();
226 
227  void InvalidateIterator();
228 
229 protected:
230  virtual ~SwDocStyleSheetPool() override;
231 
232 private:
233  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
234 };
235 
236 #endif
237 
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2442
virtual bool IsUsed() const
virtual const OUString & GetFollow() const
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2649
void PresetNameAndFamily(const OUString &rName)
Definition: docstyle.cxx:2198
std::unordered_map< OUString, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:151
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
SwDoc & GetDoc() const
Definition: docstyle.hxx:223
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2187
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::unique_ptr< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1859
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2181
const OUString & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:162
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2685
virtual bool SetParent(const OUString &)
virtual bool IsHidden() const
sal_uIntPtr sal_uLong
SwDoc & rDoc
Definition: docstyle.hxx:58
Definition: doc.hxx:186
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:553
SwPoolFormatList aLst
Definition: docstyle.hxx:167
virtual const OUString & GetParent() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
void RemoveName(SfxStyleFamily eFam, std::u16string_view rName)
Definition: docstyle.cxx:425
virtual SfxItemSet & GetItemSet()
virtual sal_uLong GetHelpId(OUString &rFile)
std::vector< OUString > maImpl
Definition: docstyle.hxx:150
virtual void SetHelpId(const OUString &r, sal_uLong nId)
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2402
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2673
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2410
bool IsPhysical() const
Definition: docstyle.hxx:89
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:165
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3097
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2226
virtual bool SetFollow(const OUString &)
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2166
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2152
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2512
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:119
SwTableAutoFormat * pTableFormat
Definition: docstyle.hxx:56
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3116
Style of a layout element.
Definition: frmfmt.hxx:58
const SwPageDesc * pDesc
Definition: docstyle.hxx:54
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: docstyle.cxx:504
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, char cType)
Definition: docstyle.cxx:3137
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3210
SwCharFormat * pCharFormat
Definition: docstyle.hxx:51
virtual SfxStyleSheetBase * Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2435
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:1412
const SwNumRule * pNumRule
Definition: docstyle.hxx:55
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:120
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter , default value false, which indicates that...
Definition: docstyle.cxx:1444
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:452
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2213
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
void Append(char cChar, std::u16string_view rStr)
Definition: docstyle.cxx:438
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2077
sal_uInt32 FindName(SfxStyleFamily eFam, std::u16string_view rName)
Definition: docstyle.cxx:370
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2414
SwFrameFormat * pFrameFormat
Definition: docstyle.hxx:53
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:67
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2660
sal_uInt32 nLastPos
Definition: docstyle.hxx:168
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:117
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2159
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2568
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy()
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:166
OUString aName
bool bOrganizer
Organizer.
Definition: docstyle.hxx:198
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:87
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2665
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:219
virtual std::unique_ptr< SfxItemSet > GetItemSetForPreview()
SwTextFormatColl * pColl
Definition: docstyle.hxx:52
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:74
SfxStyleSearchBits
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:196
virtual OUString GetDescription(MapUnit eMetric)
SfxItemSet aCoreSet
Definition: docstyle.hxx:59
const SwBoxAutoFormat * pBoxFormat
Definition: docstyle.hxx:57
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2452