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 
133  const SwPageDesc* GetPageDesc();
134  const SwNumRule* GetNumRule();
135  void SetNumRule(const SwNumRule& rRule);
137 
138  virtual bool IsUsed() const override;
139 };
140 
141 // Iterator for Pool.
143 {
144  // Local helper class.
146  {
147  std::vector<OUString> maImpl;
148  typedef std::unordered_map<OUString, sal_uInt32> UniqueHash;
149  UniqueHash maUnique;
150  void rehash();
151  public:
153  void Append( char cChar, const OUString& rStr );
154  void clear() { maImpl.clear(); maUnique.clear(); }
155  size_t size() { return maImpl.size(); }
156  bool empty() { return maImpl.empty(); }
157  sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName);
158  void RemoveName(SfxStyleFamily eFam, const OUString &rName);
159  const OUString &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
160  };
161 
165  sal_uInt32 nLastPos;
167 
168  void AppendStyleList(const std::vector<OUString>& rLst,
169  bool bUsed,
170  bool bTestHidden,
171  bool bOnlyHidden,
172  SwGetPoolIdFromName nSection,
173  char cType);
174 
175 public:
178  virtual ~SwStyleSheetIterator() override;
179 
180  virtual sal_uInt16 Count() override;
181  virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx) override;
182  virtual SfxStyleSheetBase* First() override;
183  virtual SfxStyleSheetBase* Next() override;
184  virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
185 
186  virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
187 
188  void InvalidateIterator();
189 };
190 
192 {
195  bool bOrganizer : 1;
196 
197  virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
198  virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) override;
199 
201 
202 public:
204 
205  virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
206  SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
207 
208  virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
209  SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
210 
211  virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
212  const OUString &rParent ) override;
213 
214  virtual void Remove( SfxStyleSheetBase* pStyle) override;
215 
216  bool IsOrganizerMode() const { return bOrganizer; }
217 
218  virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask ) override;
219 
220  SwDoc& GetDoc() const { return rDoc; }
221 
222  void dispose();
223 
224  void InvalidateIterator();
225 
226 protected:
227  virtual ~SwDocStyleSheetPool() override;
228 
229 private:
230  SwDocStyleSheetPool( const SwDocStyleSheetPool& ) = delete;
231 };
232 
233 #endif
234 
235 /* 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:2641
void PresetNameAndFamily(const OUString &rName)
Definition: docstyle.cxx:2195
std::unordered_map< OUString, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:148
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwDoc & GetDoc() const
Definition: docstyle.hxx:220
virtual bool HasClearParentSupport() const
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2184
SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType, std::unique_ptr< SfxItemSet > *o_ppFlatSet=nullptr)
Definition: docstyle.cxx:1855
void SetNumRule(const SwNumRule &rRule)
Definition: docstyle.cxx:2178
const OUString & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:159
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2677
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:164
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:2434
virtual sal_uLong GetHelpId(OUString &rFile)
std::vector< OUString > maImpl
Definition: docstyle.hxx:147
virtual void SetHelpId(const OUString &r, sal_uLong nId)
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2394
void Append(char cChar, const OUString &rStr)
Definition: docstyle.cxx:439
SfxStyleSearchBits nMask
virtual void SetHidden(bool bValue)
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2402
bool IsPhysical() const
Definition: docstyle.hxx:88
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:162
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3091
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2223
virtual bool SetFollow(const OUString &)
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:371
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2163
SfxStyleFamily
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2149
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2504
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:3110
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:3131
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3203
SwCharFormat * pCharFormat
Definition: docstyle.hxx:50
virtual SfxStyleSheetBase * Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2427
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:119
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:2210
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SAL_DLLPRIVATE void Create()
Make empty shell a real StyleSheet (Core).
Definition: docstyle.cxx:2074
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2406
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:2652
sal_uInt32 nLastPos
Definition: docstyle.hxx:165
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:116
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2156
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2560
virtual ~SwDocStyleSheet() override
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:163
bool bOrganizer
Organizer.
Definition: docstyle.hxx:195
virtual sal_uInt16 Count() override
Definition: docstyle.cxx:2657
SwGetPoolIdFromName
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:86
OString const aName
MapUnit
bool IsOrganizerMode() const
Definition: docstyle.hxx:216
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:2665
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:193
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:2444