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 <vector>
32 
33 class SwDoc;
35 class SwPageDesc;
36 class SwCharFormat;
37 class SwTextFormatColl;
38 class SwFrameFormat;
39 class SwNumRule;
40 class SwTableAutoFormat;
41 class SwBoxAutoFormat;
42 enum class SwGetPoolIdFromName : sal_uInt16;
43 
44 // Temporary StyleSheet.
46 {
47  friend class SwDocStyleSheetPool;
48  friend class SwStyleSheetIterator;
49 
53  const SwPageDesc* pDesc;
59 
60  bool bPhysical;
61 
63  SAL_DLLPRIVATE void Create();
64 
71  };
72 
73  SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
74  std::unique_ptr<SfxItemSet> * o_ppFlatSet = nullptr);
75 
76  virtual ~SwDocStyleSheet() override;
77 
78 public:
79  SwDocStyleSheet( SwDoc& rDoc,
80  SwDocStyleSheetPool& rPool);
81 
83 
84  void Reset();
85 
86  void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
87 
88  bool IsPhysical() const { return bPhysical; }
89  void SetPhysical(bool bPhys);
90 
91  virtual void SetHidden( bool bHidden ) override;
92  virtual bool IsHidden( ) const override;
93  void SetGrabBagItem(const css::uno::Any& rVal);
94  void GetGrabBagItem(css::uno::Any& rVal) const;
95 
100  void SetItemSet( const SfxItemSet& rSet,
101  const bool bResetIndentAttrsAtParagraphStyle = false );
102 
103  virtual SfxItemSet& GetItemSet() override;
104  virtual std::unique_ptr<SfxItemSet> GetItemSetForPreview() override;
108  virtual const OUString& GetParent() const override;
109  virtual const OUString& GetFollow() const override;
110 
111  virtual sal_uLong GetHelpId( OUString& rFile ) override;
112  virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
113 
116  void PresetName(const OUString& rName) { aName = rName; }
117  void PresetNameAndFamily(const OUString& rName);
118  void PresetParent(const OUString& rName){ aParent = rName; }
119  void PresetFollow(const OUString& rName){ aFollow = rName; }
120 
121  virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
122  virtual bool SetParent( const OUString& rStr) override;
123  virtual bool SetFollow( const OUString& rStr) override;
124 
125  virtual bool HasFollowSupport() const override;
126  virtual bool HasParentSupport() const override;
127  virtual bool HasClearParentSupport() const override;
128  virtual OUString GetDescription(MapUnit eUnit) override;
129 
130  virtual OUString GetUsedBy() override;
131 
135  const SwPageDesc* GetPageDesc();
136  const SwNumRule* GetNumRule();
137  void SetNumRule(const SwNumRule& rRule);
139 
140  virtual bool IsUsed() const override;
141 };
142 
143 // Iterator for Pool.
145 {
146  // Local helper class.
148  {
149  std::vector<OUString> maImpl;
150  typedef std::unordered_map<OUString, sal_uInt32> UniqueHash;
151  UniqueHash maUnique;
152  void rehash();
153  public:
155  void Append( char cChar, const OUString& rStr );
156  void clear() { maImpl.clear(); maUnique.clear(); }
157  size_t size() { return maImpl.size(); }
158  bool empty() { return maImpl.empty(); }
159  sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName);
160  void RemoveName(SfxStyleFamily eFam, const OUString &rName);
161  const OUString &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
162  };
163 
167  sal_uInt32 nLastPos;
169 
170  void AppendStyleList(const std::vector<OUString>& rLst,
171  bool bUsed,
172  bool bTestHidden,
173  bool bOnlyHidden,
174  SwGetPoolIdFromName nSection,
175  char cType);
176 
177 public:
180  virtual ~SwStyleSheetIterator() override;
181 
182  virtual sal_uInt16 Count() override;
183  virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx) override;
184  virtual SfxStyleSheetBase* First() override;
185  virtual SfxStyleSheetBase* Next() override;
186  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
187 
188  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
189 
190  void InvalidateIterator();
191 };
192 
194 {
197  bool bOrganizer : 1;
198 
199  virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
200  virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) override;
201 
203 
204 public:
206 
207  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
208  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
209 
210  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
211  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
212 
213  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
214  const OUString &rParent ) override;
215 
216  virtual void Remove( SfxStyleSheetBase* pStyle) override;
217 
218  bool IsOrganizerMode() const { return bOrganizer; }
219 
220  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
221 
222  SwDoc& GetDoc() const { return rDoc; }
223 
224  void dispose();
225 
226  void InvalidateIterator();
227 
228 protected:
229  virtual ~SwDocStyleSheetPool() override;
230 
231 private:
232  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
233 };
234 
235 #endif
236 
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2437
virtual bool IsUsed() const
virtual const OUString & GetFollow() const
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2644
void PresetNameAndFamily(const OUString &rName)
Definition: docstyle.cxx:2193
std::unordered_map< OUString, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:150
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwDoc & GetDoc() const
Definition: docstyle.hxx:222
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2182
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::unique_ptr< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1854
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2176
const OUString & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:161
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2680
virtual bool SetParent(const OUString &)
virtual bool IsHidden() const
sal_uIntPtr sal_uLong
SwDoc & rDoc
Definition: docstyle.hxx:57
Definition: doc.hxx:186
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:553
SwPoolFormatList aLst
Definition: docstyle.hxx:166
virtual const OUString & GetParent() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
virtual SfxItemSet & GetItemSet()
virtual sal_uLong GetHelpId(OUString &rFile)
std::vector< OUString > maImpl
Definition: docstyle.hxx:149
virtual void SetHelpId(const OUString &r, sal_uLong nId)
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2397
void Append(char cChar, const OUString &rStr)
Definition: docstyle.cxx:438
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2405
bool IsPhysical() const
Definition: docstyle.hxx:88
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:164
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3093
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2221
virtual bool SetFollow(const OUString &)
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:370
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2161
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2147
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2507
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:118
SwTableAutoFormat * pTableFormat
Definition: docstyle.hxx:55
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3112
Style of a layout element.
Definition: frmfmt.hxx:57
const SwPageDesc * pDesc
Definition: docstyle.hxx:53
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:3133
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3206
SwCharFormat * pCharFormat
Definition: docstyle.hxx:50
virtual SfxStyleSheetBase * Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2430
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:1405
const SwNumRule * pNumRule
Definition: docstyle.hxx:54
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:119
void SetItemSet(const SfxItemSet &rSet, const bool bResetIndentAttrsAtParagraphStyle=false)
add optional parameter , default value false, which indicates that...
Definition: docstyle.cxx:1437
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:452
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2208
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2072
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2409
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:425
SwFrameFormat * pFrameFormat
Definition: docstyle.hxx:52
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:66
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2655
sal_uInt32 nLastPos
Definition: docstyle.hxx:167
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:116
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2154
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2563
virtual ~SwDocStyleSheet() override
virtual OUString GetUsedBy()
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:165
OUString aName
bool bOrganizer
Organizer.
Definition: docstyle.hxx:197
virtual sal_uInt16 Count() override
Definition: docstyle.cxx:2660
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:86
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:218
virtual std::unique_ptr< SfxItemSet > GetItemSetForPreview()
SwTextFormatColl * pColl
Definition: docstyle.hxx:51
virtual bool HasParentSupport() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase * operator[](sal_uInt16 nIdx) override
Definition: docstyle.cxx:2668
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:195
virtual OUString GetDescription(MapUnit eMetric)
SfxItemSet aCoreSet
Definition: docstyle.hxx:58
const SwBoxAutoFormat * pBoxFormat
Definition: docstyle.hxx:56
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2447