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 protected:
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 
134  const SwPageDesc* GetPageDesc();
135  const SwNumRule* GetNumRule();
136  void SetNumRule(const SwNumRule& rRule);
138 
139  virtual bool IsUsed() const override;
140 };
141 
142 // Iterator for Pool.
144 {
145  // Local helper class.
147  {
148  std::vector<OUString> maImpl;
149  typedef std::unordered_map<OUString, sal_uInt32> UniqueHash;
150  UniqueHash maUnique;
151  void rehash();
152  public:
154  void Append( char cChar, const OUString& rStr );
155  void clear() { maImpl.clear(); maUnique.clear(); }
156  size_t size() { return maImpl.size(); }
157  bool empty() { return maImpl.empty(); }
158  sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName);
159  void RemoveName(SfxStyleFamily eFam, const OUString &rName);
160  const OUString &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
161  };
162 
166  sal_uInt32 nLastPos;
168 
169  void AppendStyleList(const std::vector<OUString>& rLst,
170  bool bUsed,
171  bool bTestHidden,
172  bool bOnlyHidden,
173  SwGetPoolIdFromName nSection,
174  char cType);
175 
176 public:
179  virtual ~SwStyleSheetIterator() override;
180 
181  virtual sal_uInt16 Count() override;
182  virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx) override;
183  virtual SfxStyleSheetBase* First() override;
184  virtual SfxStyleSheetBase* Next() override;
185  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
186 
187  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
188 
189  void InvalidateIterator();
190 };
191 
193 {
196  bool bOrganizer : 1;
197 
198  virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
199  virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) override;
200 
202 
203 public:
205 
206  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
207  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
208 
209  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
210  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
211 
212  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
213  const OUString &rParent ) override;
214 
215  virtual void Remove( SfxStyleSheetBase* pStyle) override;
216 
217  bool IsOrganizerMode() const { return bOrganizer; }
218 
219  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask ) override;
220 
221  SwDoc& GetDoc() const { return rDoc; }
222 
223  void dispose();
224 
225  void InvalidateIterator();
226 
227 protected:
228  virtual ~SwDocStyleSheetPool() override;
229 
230 private:
231  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
232 };
233 
234 #endif
235 
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool IsUsed() const
virtual const OUString & GetFollow() const
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2643
void PresetNameAndFamily(const OUString &rName)
Definition: docstyle.cxx:2197
std::unordered_map< OUString, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:149
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwDoc & GetDoc() const
Definition: docstyle.hxx:221
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2186
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::unique_ptr< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1857
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2180
const OUString & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:160
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2679
virtual bool SetParent(const OUString &)
virtual bool IsHidden() const
sal_uIntPtr sal_uLong
SwDoc & rDoc
Definition: docstyle.hxx:57
Definition: doc.hxx:185
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: docstyle.cxx:554
SwPoolFormatList aLst
Definition: docstyle.hxx:165
virtual const OUString & GetParent() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
virtual SfxItemSet & GetItemSet()
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2436
virtual sal_uLong GetHelpId(OUString &rFile)
std::vector< OUString > maImpl
Definition: docstyle.hxx:148
virtual void SetHelpId(const OUString &r, sal_uLong nId)
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2396
void Append(char cChar, const OUString &rStr)
Definition: docstyle.cxx:439
SfxStyleSearchBits nMask
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2404
bool IsPhysical() const
Definition: docstyle.hxx:89
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:163
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3093
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2225
virtual bool SetFollow(const OUString &)
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:371
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2165
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2151
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2506
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:119
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:505
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:3205
SwCharFormat * pCharFormat
Definition: docstyle.hxx:50
virtual SfxStyleSheetBase * Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2429
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:1406
const SwNumRule * pNumRule
Definition: docstyle.hxx:54
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:1438
SwDocStyleSheet(SwDoc &rDoc, SwDocStyleSheetPool &rPool)
Definition: docstyle.cxx:453
void SetPhysical(bool bPhys)
Definition: docstyle.cxx:2212
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2076
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2408
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:426
SwFrameFormat * pFrameFormat
Definition: docstyle.hxx:52
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:66
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2654
sal_uInt32 nLastPos
Definition: docstyle.hxx:166
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:117
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2158
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2562
virtual ~SwDocStyleSheet() override
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:164
bool bOrganizer
Organizer.
Definition: docstyle.hxx:196
virtual sal_uInt16 Count() override
Definition: docstyle.cxx:2659
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:87
OString const aName
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:217
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:2667
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:75
SfxStyleSearchBits
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:194
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:2446