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 <vector>
33
34class SwDoc;
36class SwPageDesc;
37class SwCharFormat;
39class SwFrameFormat;
40class SwNumRule;
42class SwBoxAutoFormat;
43enum class SwGetPoolIdFromName : sal_uInt16;
44
45// Temporary StyleSheet.
47{
48 friend class SwDocStyleSheetPool;
50
60
62 OUString m_aLink;
63
65 SAL_DLLPRIVATE void Create();
66
73 };
74
75 SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
76 std::optional<SfxItemSet> * o_ppFlatSet = nullptr);
77
78 virtual ~SwDocStyleSheet() override;
79
80public:
82 SwDocStyleSheetPool& rPool);
83
85
86 void Reset();
87
88 void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
89
90 bool IsPhysical() const { return m_bPhysical; }
91 void SetPhysical(bool bPhys);
92
93 virtual void SetHidden( bool bHidden ) override;
94 virtual bool IsHidden( ) const override;
95 void SetGrabBagItem(const css::uno::Any& rVal);
96 void GetGrabBagItem(css::uno::Any& rVal) const;
97
102 void SetItemSet( const SfxItemSet& rSet, const bool bBroadcast = true,
103 const bool bResetIndentAttrsAtParagraphStyle = false );
104
105 virtual SfxItemSet& GetItemSet() override;
106 virtual std::optional<SfxItemSet> GetItemSetForPreview() override;
109 void MergeIndentAttrsOfListStyle( SfxItemSet& rSet );
110 virtual const OUString& GetParent() const override;
111 virtual const OUString& GetFollow() const override;
112 const OUString& GetLink() const;
113
114 virtual sal_uLong GetHelpId( OUString& rFile ) override;
115 virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
116
119 void PresetName(const OUString& rName) { aName = rName; }
120 void PresetNameAndFamily(SfxStyleFamily eFamily, const OUString& rName);
121 void PresetParent(const OUString& rName){ aParent = rName; }
122 void PresetFollow(const OUString& rName){ aFollow = rName; }
123
124 virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
125 virtual bool SetParent( const OUString& rStr) override;
126 virtual bool SetFollow( const OUString& rStr) override;
127 void SetLink(const OUString& rStr);
128
129 virtual bool HasFollowSupport() const override;
130 virtual bool HasParentSupport() const override;
131 virtual bool HasClearParentSupport() const override;
132 virtual OUString GetDescription(MapUnit eUnit) override;
133
134 virtual OUString GetUsedBy() override;
135
136 SwCharFormat* GetCharFormat();
137 SwTextFormatColl* GetCollection();
138 SwFrameFormat* GetFrameFormat();
139 const SwPageDesc* GetPageDesc();
140 const SwNumRule* GetNumRule();
141 void SetNumRule(const SwNumRule& rRule);
142 SwTableAutoFormat* GetTableFormat();
143
144 virtual bool IsUsed() const override;
145};
146
147namespace std {
148template<>
149struct hash<std::pair<SfxStyleFamily,OUString>>
150{
151 std::size_t operator()(std::pair<SfxStyleFamily,OUString> const & pair) const
152 { return static_cast<std::size_t>(pair.first) ^ std::size_t(pair.second.hashCode()); }
153};
154}
155
156
157// Iterator for Pool.
159{
160 // Local helper class.
162 {
163 std::vector<std::pair<SfxStyleFamily, OUString>> maImpl;
164 typedef std::unordered_map<std::pair<SfxStyleFamily, OUString>, sal_uInt32> UniqueHash;
166 void rehash();
167 public:
169 void Append( SfxStyleFamily eFam, const OUString& rStr );
170 void clear() { maImpl.clear(); maUnique.clear(); }
171 size_t size() { return maImpl.size(); }
172 bool empty() { return maImpl.empty(); }
173 sal_uInt32 FindName(SfxStyleFamily eFam, const OUString& rName);
174 void RemoveName(SfxStyleFamily eFam, const OUString& rName);
175 const std::pair<SfxStyleFamily,OUString> &operator[](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
176 };
177
181 sal_uInt32 m_nLastPos;
183
184 bool IsUsedInComments(const OUString& rName) const;
185 void AppendStyleList(const std::vector<OUString>& rLst,
186 bool bUsed,
187 bool bTestHidden,
188 bool bOnlyHidden,
189 SwGetPoolIdFromName nSection,
190 SfxStyleFamily eFamily);
191
192public:
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{
213 bool m_bOrganizer : 1;
214
215 virtual rtl::Reference<SfxStyleSheetBase> Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
217
219
220public:
221 SwDocStyleSheetPool( SwDoc&, bool bOrganizer );
222
223 virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
224 SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
225
226 virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
227 SfxStyleSearchBits n=SfxStyleSearchBits::All ) override;
228
229 virtual void Remove( SfxStyleSheetBase* pStyle) override;
230
231 bool IsOrganizerMode() const { return m_bOrganizer; }
232
233 virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
234
235 SwDoc& GetDoc() const { return m_rDoc; }
237
238 void dispose();
239
240 void InvalidateIterator();
241
242private:
243 virtual ~SwDocStyleSheetPool() override;
244
246};
247
248#endif
249
250/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwGetPoolIdFromName
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual bool HasClearParentSupport() const
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
virtual const OUString & GetParent() const
virtual bool HasFollowSupport() const
virtual void SetHidden(bool bValue)
virtual sal_uLong GetHelpId(OUString &rFile)
virtual void SetHelpId(const OUString &r, sal_uLong nId)
virtual bool HasParentSupport() const
virtual const OUString & GetFollow() const
virtual bool IsHidden() const
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
virtual bool IsUsed() const
virtual bool SetFollow(const OUString &)
virtual OUString GetUsedBy()
virtual OUString GetDescription(MapUnit eMetric)
virtual std::optional< SfxItemSet > GetItemSetForPreview()
Represents the style of a text portion.
Definition: charfmt.hxx:27
SwDocStyleSheetPool(const SwDocStyleSheetPool &)=delete
bool IsOrganizerMode() const
Definition: docstyle.hxx:231
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2603
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2616
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2644
rtl::Reference< SfxStyleSheetPool > mxEEStyleSheetPool
Definition: docstyle.hxx:211
SfxStyleSheetPool * GetEEStyleSheetPool() const
Definition: docstyle.hxx:236
SwDoc & GetDoc() const
Definition: docstyle.hxx:235
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2655
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2637
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2612
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:210
bool m_bOrganizer
Organizer.
Definition: docstyle.hxx:213
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2715
SwTextFormatColl * m_pColl
Definition: docstyle.hxx:52
bool IsPhysical() const
Definition: docstyle.hxx:90
SwDoc & m_rDoc
Definition: docstyle.hxx:58
const SwNumRule * m_pNumRule
Definition: docstyle.hxx:55
void SetFamily(SfxStyleFamily eFam)
Definition: docstyle.hxx:88
SwCharFormat * m_pCharFormat
Definition: docstyle.hxx:51
SwTableAutoFormat * m_pTableFormat
Definition: docstyle.hxx:56
SwDocStyleSheet(const SwDocStyleSheet &)
void PresetName(const OUString &rName)
Preset the members without physical access.
Definition: docstyle.hxx:119
void PresetFollow(const OUString &rName)
Definition: docstyle.hxx:122
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:121
SwFrameFormat * m_pFrameFormat
Definition: docstyle.hxx:53
OUString m_aLink
Definition: docstyle.hxx:62
const SwPageDesc * m_pDesc
Definition: docstyle.hxx:54
const SwBoxAutoFormat * m_pBoxFormat
Definition: docstyle.hxx:57
virtual ~SwDocStyleSheet() override
FillStyleType
Fill StyleSheet with data.
Definition: docstyle.hxx:68
SfxItemSet m_aCoreSet
Definition: docstyle.hxx:59
Definition: doc.hxx:197
Style of a layout element.
Definition: frmfmt.hxx:72
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:545
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:520
std::unordered_map< std::pair< SfxStyleFamily, OUString >, sal_uInt32 > UniqueHash
Definition: docstyle.hxx:164
std::vector< std::pair< SfxStyleFamily, OUString > > maImpl
Definition: docstyle.hxx:163
void Append(SfxStyleFamily eFam, const OUString &rStr)
Definition: docstyle.cxx:558
const std::pair< SfxStyleFamily, OUString > & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:175
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3264
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:178
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2832
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2795
bool IsUsedInComments(const OUString &rName) const
Definition: docstyle.cxx:3343
sal_uInt32 m_nLastPos
Definition: docstyle.hxx:181
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:179
SwPoolFormatList m_aLst
Definition: docstyle.hxx:180
virtual void Notify(SfxBroadcaster &, const SfxHint &) override
Definition: docstyle.cxx:3366
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2806
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2819
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2811
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3286
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3244
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
OUString aName
MapUnit
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:74
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
sal_uIntPtr sal_uLong
std::size_t operator()(std::pair< SfxStyleFamily, OUString > const &pair) const
Definition: docstyle.hxx:151
SfxStyleFamily
SfxStyleSearchBits
#define SW_DLLPUBLIC
Definition: swdllapi.h:28