make ValueTransfer easier to understand
[LibreOffice.git] / include / svx / nbdtmg.hxx
blob7d397687ab37ecf962d88626c7b5c7384f39a7e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <vcl/font.hxx>
27 namespace svx::sidebar {
29 #define DEFAULT_BULLET_TYPES 8
30 #define DEFAULT_NUM_VALUSET_COUNT 8
31 #define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION 0x10
33 enum class NBOType
35 Bullets = 1, Numbering, Outline
38 class SVX_DLLPUBLIC NumSettings_Impl
40 public:
41 SvxNumType nNumberType;
42 short nParentNumbering;
43 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy;
44 tools::Long nTabValue;
45 SvxAdjust eNumAlign;
46 tools::Long nNumAlignAt;
47 tools::Long nNumIndentAt;
48 OUString sPrefix;
49 OUString sSuffix;
50 OUString sBulletChar;
51 OUString sBulletFont;
52 SvxBrushItem *pBrushItem;
53 Size aSize;
55 public:
56 NumSettings_Impl()
57 : nNumberType(SVX_NUM_CHARS_UPPER_LETTER)
58 , nParentNumbering(0)
59 , eLabelFollowedBy(SvxNumberFormat::NOTHING)
60 , nTabValue (0)
61 , eNumAlign(SvxAdjust::Left)
62 , nNumAlignAt(0)
63 , nNumIndentAt(0)
64 , pBrushItem(nullptr)
65 , aSize(0,0)
69 typedef std::vector< std::shared_ptr<NumSettings_Impl> > NumSettingsArr_Impl;
71 class SVX_DLLPUBLIC BulletsSettings
73 public:
74 vcl::Font aFont;
75 OUString sDescription;
76 sal_UCS4 cBulletChar;
77 bool bIsCustomized;
78 BulletsSettings() : cBulletChar(0), bIsCustomized(false) {}
82 class SVX_DLLPUBLIC NumberSettings_Impl
84 public:
85 bool bIsCustomized;
86 OUString sDescription;
87 NumSettings_Impl* pNumSetting;
88 public:
89 NumberSettings_Impl() :
90 bIsCustomized(false),
91 pNumSetting(nullptr)
95 typedef std::vector< std::shared_ptr<NumberSettings_Impl> > NumberSettingsArr_Impl;
97 class SVX_DLLPUBLIC OutlineSettings_Impl
99 public:
100 bool bIsCustomized;
101 OUString sDescription;
102 NumSettingsArr_Impl *pNumSettingsArr;
103 public:
104 OutlineSettings_Impl() :
105 bIsCustomized(false),
106 pNumSettingsArr(nullptr)
110 class SVX_DLLPUBLIC NBOTypeMgrBase
112 private:
113 const SfxItemSet* pSet;
114 MapUnit eCoreUnit;
115 // store the attributes passed from pSet
116 OUString aBulletCharFmtName;
117 OUString aNumCharFmtName;
118 bool bIsLoading;
120 NBOTypeMgrBase(const NBOTypeMgrBase&) = delete;
122 public:
123 NBOTypeMgrBase()
124 : pSet(nullptr)
125 , eCoreUnit(MapUnit::MapTwip)
126 , bIsLoading(false)
128 virtual ~NBOTypeMgrBase() {}
129 virtual void Init()=0;
130 virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) = 0;
131 virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) = 0;
132 virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) = 0;
133 virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault)=0;
134 virtual bool IsCustomized(sal_uInt16 nIndex)=0;
135 static sal_uInt16 IsSingleLevel(sal_uInt16 nCurLevel);
136 // store the attributes passed from pSet
137 void SetItems(const SfxItemSet* pArg);
138 protected:
139 const OUString& GetBulletCharFmtName() const { return aBulletCharFmtName;}
140 const OUString& GetNumCharFmtName() const { return aNumCharFmtName;}
141 MapUnit GetMapUnit() const { return eCoreUnit;}
142 protected:
143 void ImplLoad(std::u16string_view filename);
144 void ImplStore(std::u16string_view filename);
149 class BulletsTypeMgr final : public NBOTypeMgrBase
151 friend class OutlineTypeMgr;
152 friend class NumberingTypeMgr;
153 private:
154 BulletsTypeMgr(const BulletsTypeMgr&) = delete;
155 public:
156 static sal_Unicode aDynamicBulletTypes[DEFAULT_BULLET_TYPES];
157 static sal_Unicode aDynamicRTLBulletTypes[DEFAULT_BULLET_TYPES];
158 static BulletsSettings* pActualBullets[DEFAULT_BULLET_TYPES];
159 public:
160 BulletsTypeMgr();
161 virtual void Init() override;
162 virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override;
163 virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override;
164 virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override;
165 virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override;
166 virtual bool IsCustomized(sal_uInt16 nIndex) override;
167 static BulletsTypeMgr& GetInstance();
171 class NumberingTypeMgr final : public NBOTypeMgrBase
173 private:
174 NumberingTypeMgr(const NumberingTypeMgr&) = delete;
175 public:
176 NumberSettingsArr_Impl maNumberSettingsArr;
177 NumberSettingsArr_Impl maDefaultNumberSettingsArr;
178 public:
179 NumberingTypeMgr();
180 virtual ~NumberingTypeMgr() override;
181 virtual void Init() override;
182 virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override;
183 virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override;
184 virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override;
185 virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override;
186 virtual bool IsCustomized(sal_uInt16 nIndex) override;
187 static NumberingTypeMgr& GetInstance();
190 class OutlineTypeMgr final : public NBOTypeMgrBase
192 private:
193 OutlineTypeMgr(const OutlineTypeMgr&) = delete;
194 public:
195 OutlineSettings_Impl* pOutlineSettingsArrs[DEFAULT_NUM_VALUSET_COUNT];
196 OutlineSettings_Impl* pDefaultOutlineSettingsArrs[DEFAULT_NUM_VALUSET_COUNT];
197 public:
198 OutlineTypeMgr();
199 virtual void Init() override;
200 virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override;
201 virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override;
202 virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override;
203 virtual OUString GetDescription(sal_uInt16 nIndex, bool isDefault) override;
204 virtual bool IsCustomized(sal_uInt16 nIndex) override;
205 static OutlineTypeMgr& GetInstance();
208 #endif
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */