/src/libreoffice/include/svx/nbdtmg.hxx
Line | Count | Source |
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_SVX_NBDTMG_HXX |
20 | | #define INCLUDED_SVX_NBDTMG_HXX |
21 | | #include <svx/svxdllapi.h> |
22 | | #include <memory> |
23 | | #include <vector> |
24 | | #include <editeng/numitem.hxx> |
25 | | #include <tools/mapunit.hxx> |
26 | | #include <vcl/font.hxx> |
27 | | |
28 | | class SfxItemSet; |
29 | | |
30 | | namespace svx::sidebar { |
31 | | |
32 | 0 | #define DEFAULT_BULLET_TYPES 8 |
33 | 0 | #define DEFAULT_NUM_VALUESET_COUNT 8 |
34 | 0 | #define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION 0x10 |
35 | | |
36 | | enum class NBOType |
37 | | { |
38 | | Bullets = 1, Numbering, Outline |
39 | | }; |
40 | | |
41 | | class SVX_DLLPUBLIC NumSettings_Impl |
42 | | { |
43 | | public: |
44 | | SvxNumType nNumberType; |
45 | | short nParentNumbering; |
46 | | SvxNumberFormat::LabelFollowedBy eLabelFollowedBy; |
47 | | tools::Long nTabValue; |
48 | | SvxAdjust eNumAlign; |
49 | | tools::Long nNumAlignAt; |
50 | | tools::Long nNumIndentAt; |
51 | | OUString sPrefix; |
52 | | OUString sSuffix; |
53 | | OUString sBulletChar; |
54 | | OUString sBulletFont; |
55 | | SvxBrushItem *pBrushItem; |
56 | | Size aSize; |
57 | | |
58 | | public: |
59 | | NumSettings_Impl() |
60 | 0 | : nNumberType(SVX_NUM_CHARS_UPPER_LETTER) |
61 | 0 | , nParentNumbering(0) |
62 | 0 | , eLabelFollowedBy(SvxNumberFormat::NOTHING) |
63 | 0 | , nTabValue (0) |
64 | 0 | , eNumAlign(SvxAdjust::Left) |
65 | 0 | , nNumAlignAt(0) |
66 | 0 | , nNumIndentAt(0) |
67 | 0 | , pBrushItem(nullptr) |
68 | 0 | , aSize(0,0) |
69 | 0 | {} |
70 | | }; |
71 | | |
72 | | typedef std::vector< std::shared_ptr<NumSettings_Impl> > NumSettingsArr_Impl; |
73 | | |
74 | | class SVX_DLLPUBLIC BulletsSettings |
75 | | { |
76 | | public: |
77 | | vcl::Font aFont; |
78 | | sal_UCS4 cBulletChar; |
79 | | bool bIsCustomized; |
80 | 0 | BulletsSettings() : cBulletChar(0), bIsCustomized(false) {} |
81 | | }; |
82 | | |
83 | | |
84 | | class SVX_DLLPUBLIC NumberSettings_Impl |
85 | | { |
86 | | public: |
87 | | bool bIsCustomized; |
88 | | OUString sDescription; |
89 | | NumSettings_Impl* pNumSetting; |
90 | | public: |
91 | | NumberSettings_Impl() : |
92 | 0 | bIsCustomized(false), |
93 | 0 | pNumSetting(nullptr) |
94 | 0 | {} |
95 | | }; |
96 | | |
97 | | typedef std::vector< std::shared_ptr<NumberSettings_Impl> > NumberSettingsArr_Impl; |
98 | | |
99 | | class SVX_DLLPUBLIC OutlineSettings_Impl |
100 | | { |
101 | | public: |
102 | | bool bIsCustomized; |
103 | | OUString sDescription; |
104 | | NumSettingsArr_Impl *pNumSettingsArr; |
105 | | public: |
106 | | OutlineSettings_Impl() : |
107 | 0 | bIsCustomized(false), |
108 | 0 | pNumSettingsArr(nullptr) |
109 | 0 | {} |
110 | | }; |
111 | | |
112 | | class SVX_DLLPUBLIC NBOTypeMgrBase |
113 | | { |
114 | | private: |
115 | | const SfxItemSet* pSet; |
116 | | MapUnit eCoreUnit; |
117 | | // store the attributes passed from pSet |
118 | | OUString aBulletCharFmtName; |
119 | | OUString aNumCharFmtName; |
120 | | bool bIsLoading; |
121 | | |
122 | | NBOTypeMgrBase(const NBOTypeMgrBase&) = delete; |
123 | | |
124 | | public: |
125 | | NBOTypeMgrBase() |
126 | 0 | : pSet(nullptr) |
127 | 0 | , eCoreUnit(MapUnit::MapTwip) |
128 | 0 | , bIsLoading(false) |
129 | 0 | {} |
130 | 0 | virtual ~NBOTypeMgrBase() {} |
131 | | virtual void Init()=0; |
132 | | virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) = 0; |
133 | | virtual void ReplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) = 0; |
134 | | virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) = 0; |
135 | | virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault)=0; |
136 | | virtual bool IsCustomized(sal_uInt16 nIndex)=0; |
137 | | static sal_uInt16 IsSingleLevel(sal_uInt16 nCurLevel); |
138 | | // store the attributes passed from pSet |
139 | | void SetItems(const SfxItemSet* pArg); |
140 | | protected: |
141 | 0 | const OUString& GetBulletCharFmtName() const { return aBulletCharFmtName;} |
142 | 0 | const OUString& GetNumCharFmtName() const { return aNumCharFmtName;} |
143 | 0 | MapUnit GetMapUnit() const { return eCoreUnit;} |
144 | | protected: |
145 | | void ImplLoad(std::u16string_view filename); |
146 | | void ImplStore(std::u16string_view filename); |
147 | | |
148 | | }; |
149 | | |
150 | | |
151 | | class SVX_DLLPUBLIC BulletsTypeMgr final : public NBOTypeMgrBase |
152 | | { |
153 | | friend class OutlineTypeMgr; |
154 | | friend class NumberingTypeMgr; |
155 | | private: |
156 | | BulletsTypeMgr(const BulletsTypeMgr&) = delete; |
157 | | public: |
158 | | static const sal_Unicode aDynamicBulletTypes[DEFAULT_BULLET_TYPES]; |
159 | | static const sal_Unicode aDynamicRTLBulletTypes[DEFAULT_BULLET_TYPES]; |
160 | | static BulletsSettings* pActualBullets[DEFAULT_BULLET_TYPES]; |
161 | | public: |
162 | | BulletsTypeMgr(); |
163 | | virtual void Init() override; |
164 | | virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override; |
165 | | virtual void ReplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override; |
166 | | virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override; |
167 | | void ApplyCustomRule(SvxNumRule& aNum, std::u16string_view sBullet, const OUString& sFont, sal_uInt16 mLevel); |
168 | | virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override; |
169 | | virtual bool IsCustomized(sal_uInt16 nIndex) override; |
170 | | static BulletsTypeMgr& GetInstance(); |
171 | | }; |
172 | | |
173 | | |
174 | | class NumberingTypeMgr final : public NBOTypeMgrBase |
175 | | { |
176 | | NumberingTypeMgr(const NumberingTypeMgr&) = delete; |
177 | | public: |
178 | | NumberingTypeMgr(); |
179 | | virtual ~NumberingTypeMgr() override; |
180 | | virtual void Init() override; |
181 | | virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override; |
182 | | virtual void ReplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override; |
183 | | virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override; |
184 | | virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override; |
185 | | virtual bool IsCustomized(sal_uInt16 nIndex) override; |
186 | | static NumberingTypeMgr& GetInstance(); |
187 | | private: |
188 | | NumberSettingsArr_Impl maNumberSettingsArr; |
189 | | NumberSettingsArr_Impl maDefaultNumberSettingsArr; |
190 | | }; |
191 | | |
192 | | class OutlineTypeMgr final : public NBOTypeMgrBase |
193 | | { |
194 | | OutlineTypeMgr(const OutlineTypeMgr&) = delete; |
195 | | public: |
196 | | OutlineTypeMgr(); |
197 | | virtual void Init() override; |
198 | | virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override; |
199 | | virtual void ReplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override; |
200 | | virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override; |
201 | | virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override; |
202 | | virtual bool IsCustomized(sal_uInt16 nIndex) override; |
203 | | static OutlineTypeMgr& GetInstance(); |
204 | | private: |
205 | | OutlineSettings_Impl* pOutlineSettingsArrs[DEFAULT_NUM_VALUESET_COUNT]; |
206 | | OutlineSettings_Impl* pDefaultOutlineSettingsArrs[DEFAULT_NUM_VALUESET_COUNT]; |
207 | | }; |
208 | | } |
209 | | #endif |
210 | | |
211 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |