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,
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 void AppendStyleList(const std::vector<OUString>& rLst,
185 bool bUsed,
186 bool bTestHidden,
187 bool bOnlyHidden,
188 SwGetPoolIdFromName nSection,
189 SfxStyleFamily eFamily);
190
191public:
194 virtual ~SwStyleSheetIterator() override;
195
196 virtual sal_Int32 Count() override;
197 virtual SfxStyleSheetBase *operator[](sal_Int32 nIdx) override;
198 virtual SfxStyleSheetBase* First() override;
199 virtual SfxStyleSheetBase* Next() override;
200 virtual SfxStyleSheetBase* Find(const OUString& rStr) override;
201
202 virtual void Notify( SfxBroadcaster&, const SfxHint& ) override;
203
204 void InvalidateIterator();
205};
206
208{
211 bool m_bOrganizer : 1;
212
213 virtual rtl::Reference<SfxStyleSheetBase> Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits nMask) override;
215
217
218public:
219 SwDocStyleSheetPool( SwDoc&, bool bOrganizer );
220
221 virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
222 SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
223
224 virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
225 SfxStyleSearchBits n=SfxStyleSearchBits::All ) const override;
226
227 virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
228 const OUString &rParent ) override;
229
230 virtual void Remove( SfxStyleSheetBase* pStyle) override;
231
232 bool IsOrganizerMode() const { return m_bOrganizer; }
233
234 virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override;
235
236 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) const
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:232
SwDocStyleSheetPool(SwDoc &, bool bOrganizer)
Definition: docstyle.cxx:2421
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const override
Definition: docstyle.cxx:2587
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2433
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: docstyle.cxx:2461
virtual bool SetParent(SfxStyleFamily eFam, const OUString &rStyle, const OUString &rParent) override
Definition: docstyle.cxx:2531
SwDoc & GetDoc() const
Definition: docstyle.hxx:236
virtual void Remove(SfxStyleSheetBase *pStyle) override
Definition: docstyle.cxx:2471
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits nMask) override
Definition: docstyle.cxx:2454
virtual ~SwDocStyleSheetPool() override
Definition: docstyle.cxx:2429
rtl::Reference< SwDocStyleSheet > mxStyleSheet
Definition: docstyle.hxx:209
bool m_bOrganizer
Organizer.
Definition: docstyle.hxx:211
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:194
Style of a layout element.
Definition: frmfmt.hxx:62
void RemoveName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:385
sal_uInt32 FindName(SfxStyleFamily eFam, const OUString &rName)
Definition: docstyle.cxx:360
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:398
const std::pair< SfxStyleFamily, OUString > & operator[](sal_uInt32 nIdx)
Definition: docstyle.hxx:175
virtual SfxStyleSheetBase * Find(const OUString &rStr) override
Definition: docstyle.cxx:3136
rtl::Reference< SwDocStyleSheet > mxIterSheet
Definition: docstyle.hxx:178
virtual SfxStyleSheetBase * First() override
Definition: docstyle.cxx:2704
SwStyleSheetIterator(SwDocStyleSheetPool &rBase, SfxStyleFamily eFam, SfxStyleSearchBits n)
Definition: docstyle.cxx:2667
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:3231
virtual ~SwStyleSheetIterator() override
Definition: docstyle.cxx:2678
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx) override
Definition: docstyle.cxx:2691
virtual sal_Int32 Count() override
Definition: docstyle.cxx:2683
void AppendStyleList(const std::vector< OUString > &rLst, bool bUsed, bool bTestHidden, bool bOnlyHidden, SwGetPoolIdFromName nSection, SfxStyleFamily eFamily)
Definition: docstyle.cxx:3158
virtual SfxStyleSheetBase * Next() override
Definition: docstyle.cxx:3116
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
OUString aName
MapUnit
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:76
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