/src/libreoffice/sw/source/uibase/inc/usrpref.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_SW_SOURCE_UIBASE_INC_USRPREF_HXX |
20 | | #define INCLUDED_SW_SOURCE_UIBASE_INC_USRPREF_HXX |
21 | | |
22 | | #include <memory> |
23 | | #include <unotools/configitem.hxx> |
24 | | #include <fldupde.hxx> |
25 | | #include <viewopt.hxx> |
26 | | #include <tools/fldunit.hxx> |
27 | | #include "SwBaselineGridConfig.hxx" |
28 | | |
29 | | class SwMasterUsrPref; |
30 | | |
31 | | class SwContentViewConfig final : public utl::ConfigItem |
32 | | { |
33 | | private: |
34 | | SwMasterUsrPref& m_rParent; |
35 | | bool m_bWeb; |
36 | | |
37 | | css::uno::Sequence<OUString> GetPropertyNames() const; |
38 | | |
39 | | virtual void ImplCommit() override; |
40 | | |
41 | | public: |
42 | | SwContentViewConfig(bool bWeb, SwMasterUsrPref& rParent); |
43 | | virtual ~SwContentViewConfig() override; |
44 | | |
45 | | // utl::ConfigItem |
46 | | virtual void Notify( const css::uno::Sequence< OUString > &rPropertyNames ) override; |
47 | | |
48 | | void Load(); |
49 | | using ConfigItem::SetModified; |
50 | | }; |
51 | | |
52 | | class SwLayoutViewConfig final : public utl::ConfigItem |
53 | | { |
54 | | private: |
55 | | SwMasterUsrPref& m_rParent; |
56 | | bool m_bWeb; |
57 | | |
58 | | css::uno::Sequence<OUString> GetPropertyNames() const; |
59 | | |
60 | | virtual void ImplCommit() override; |
61 | | |
62 | | public: |
63 | | SwLayoutViewConfig(bool bWeb, SwMasterUsrPref& rParent); |
64 | | virtual ~SwLayoutViewConfig() override; |
65 | | |
66 | | virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; |
67 | | void Load(); |
68 | | using ConfigItem::SetModified; |
69 | | }; |
70 | | |
71 | | class SwGridConfig final : public utl::ConfigItem |
72 | | { |
73 | | private: |
74 | | SwMasterUsrPref& m_rParent; |
75 | | |
76 | | static css::uno::Sequence<OUString> GetPropertyNames(); |
77 | | |
78 | | virtual void ImplCommit() override; |
79 | | |
80 | | public: |
81 | | SwGridConfig(bool bWeb, SwMasterUsrPref& rParent); |
82 | | virtual ~SwGridConfig() override; |
83 | | |
84 | | virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; |
85 | | void Load(); |
86 | | using ConfigItem::SetModified; |
87 | | }; |
88 | | |
89 | | class SwCursorConfig final : public utl::ConfigItem |
90 | | { |
91 | | private: |
92 | | SwMasterUsrPref& m_rParent; |
93 | | |
94 | | static css::uno::Sequence<OUString> GetPropertyNames(); |
95 | | |
96 | | virtual void ImplCommit() override; |
97 | | |
98 | | public: |
99 | | SwCursorConfig(SwMasterUsrPref& rParent); |
100 | | virtual ~SwCursorConfig() override; |
101 | | |
102 | | virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; |
103 | | void Load(); |
104 | | using ConfigItem::SetModified; |
105 | | }; |
106 | | |
107 | | class SwFmtAidsAutoComplConfig final : public utl::ConfigItem |
108 | | { |
109 | | private: |
110 | | SwMasterUsrPref& m_rParent; |
111 | | |
112 | | static css::uno::Sequence<OUString> GetPropertyNames(); |
113 | | |
114 | | virtual void ImplCommit() override; |
115 | | |
116 | | public: |
117 | | SwFmtAidsAutoComplConfig(SwMasterUsrPref& rParent); |
118 | | virtual ~SwFmtAidsAutoComplConfig() override; |
119 | | |
120 | | virtual void Notify(const css::uno::Sequence<OUString>& aPropertyNames) override; |
121 | | void Load(); |
122 | | using ConfigItem::SetModified; |
123 | | }; |
124 | | |
125 | | class SwWebColorConfig final : public utl::ConfigItem |
126 | | { |
127 | | private: |
128 | | SwMasterUsrPref& m_rParent; |
129 | | css::uno::Sequence<OUString> m_aPropNames; |
130 | | |
131 | | virtual void ImplCommit() override; |
132 | | |
133 | | public: |
134 | | SwWebColorConfig(SwMasterUsrPref& rParent); |
135 | | virtual ~SwWebColorConfig() override; |
136 | | |
137 | | virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; |
138 | | void Load(); |
139 | | using ConfigItem::SetModified; |
140 | | }; |
141 | | |
142 | | class SwMasterUsrPref : public SwViewOption |
143 | | { |
144 | | friend class SwContentViewConfig; |
145 | | friend class SwLayoutViewConfig; |
146 | | friend class SwGridConfig; |
147 | | friend class SwCursorConfig; |
148 | | friend class SwWebColorConfig; |
149 | | friend class SwFmtAidsAutoComplConfig; |
150 | | |
151 | | SwFieldUpdateFlags m_eFieldUpdateFlags; //update of fields and charts |
152 | | sal_Int32 m_nLinkUpdateMode; |
153 | | FieldUnit m_eUserMetric; |
154 | | FieldUnit m_eHScrollMetric; |
155 | | bool m_bIsHScrollMetricSet; |
156 | | FieldUnit m_eVScrollMetric; |
157 | | bool m_bIsVScrollMetricSet; |
158 | | |
159 | | sal_Int32 m_nDefTabInMm100; //default tab stop distance, in 1/100 mm |
160 | | |
161 | | bool m_bIsSquaredPageMode; //default page mode for text grid |
162 | | bool m_bIsAlignMathObjectsToBaseline; |
163 | | |
164 | | bool m_bApplyCharUnit; // apply_char_unit |
165 | | |
166 | | // Scale |
167 | | bool m_bUseDefaultZoom; |
168 | | sal_uInt16 m_nDefaultZoomValue; // percent. |
169 | | SvxZoomType m_eDefaultZoomType; |
170 | | |
171 | | // Note that these write to SwMasterUsrPref during their ctor |
172 | | // so any members initialized after their ctor's are called |
173 | | // will overwrite their loaded config settings |
174 | | SwContentViewConfig m_aContentConfig; |
175 | | SwLayoutViewConfig m_aLayoutConfig; |
176 | | SwGridConfig m_aGridConfig; |
177 | | SwCursorConfig m_aCursorConfig; |
178 | | std::unique_ptr<SwWebColorConfig> m_pWebColorConfig; |
179 | | SwFmtAidsAutoComplConfig m_aFmtAidsAutoComplConfig; |
180 | | std::unique_ptr<SwBaselineGridConfig> m_aBaselineGridConfig; // Not available in web mode |
181 | | |
182 | | public: |
183 | | SwMasterUsrPref(bool bWeb); |
184 | | ~SwMasterUsrPref(); |
185 | | |
186 | | void SetUsrPref(const SwViewOption &rCopy); |
187 | | |
188 | | void SetModified() |
189 | 0 | { |
190 | 0 | m_aContentConfig.SetModified(); |
191 | 0 | m_aLayoutConfig.SetModified(); |
192 | 0 | m_aGridConfig.SetModified(); |
193 | 0 | m_aCursorConfig.SetModified(); |
194 | 0 | if(m_pWebColorConfig) |
195 | 0 | m_pWebColorConfig->SetModified(); |
196 | 0 | m_aFmtAidsAutoComplConfig.SetModified(); |
197 | |
|
198 | 0 | if(m_aBaselineGridConfig) |
199 | 0 | { |
200 | 0 | m_aBaselineGridConfig->SetModified(); |
201 | 0 | } |
202 | 0 | } |
203 | | |
204 | | void SetUpdateLinkMode(sal_Int32 nSet, bool bNoModify = false) |
205 | 0 | { |
206 | 0 | m_nLinkUpdateMode = nSet; |
207 | 0 | if(!bNoModify) |
208 | 0 | m_aContentConfig.SetModified(); |
209 | 0 | } |
210 | 13.8k | sal_Int32 GetUpdateLinkMode() const {return m_nLinkUpdateMode; } |
211 | | |
212 | | void SetUpdateFields(bool bSet) |
213 | 0 | { |
214 | 0 | if(bSet && m_eFieldUpdateFlags == AUTOUPD_OFF) |
215 | 0 | { |
216 | 0 | m_eFieldUpdateFlags = AUTOUPD_FIELD_ONLY; |
217 | 0 | } |
218 | 0 | else if(!bSet) |
219 | 0 | { |
220 | 0 | m_eFieldUpdateFlags = AUTOUPD_OFF; |
221 | 0 | } |
222 | 0 | }; |
223 | 0 | bool IsUpdateFields()const {return m_eFieldUpdateFlags != AUTOUPD_OFF; } |
224 | | |
225 | 0 | SwFieldUpdateFlags GetFieldUpdateFlags()const {return m_eFieldUpdateFlags;} |
226 | | void SetFieldUpdateFlags(SwFieldUpdateFlags eSet) |
227 | 0 | { |
228 | 0 | m_eFieldUpdateFlags = eSet; |
229 | 0 | m_aContentConfig.SetModified(); |
230 | 0 | } |
231 | | |
232 | | void SetUpdateCharts(bool bSet) |
233 | 0 | { |
234 | 0 | if(bSet) |
235 | 0 | { |
236 | 0 | m_eFieldUpdateFlags = AUTOUPD_FIELD_AND_CHARTS; |
237 | 0 | } |
238 | 0 | else if(m_eFieldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS) |
239 | 0 | { |
240 | 0 | m_eFieldUpdateFlags = AUTOUPD_FIELD_ONLY; |
241 | 0 | } |
242 | 0 | }; |
243 | 0 | bool IsUpdateCharts()const {return m_eFieldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS; } |
244 | | |
245 | 0 | FieldUnit GetMetric() const { return m_eUserMetric;} |
246 | | void SetMetric(FieldUnit eSet, bool bNoModify = false) |
247 | 0 | { |
248 | 0 | m_eUserMetric = eSet; |
249 | 0 | if(!bNoModify) |
250 | 0 | m_aLayoutConfig.SetModified(); |
251 | 0 | } |
252 | | |
253 | 0 | bool IsHScrollMetric()const {return m_bIsHScrollMetricSet;} |
254 | 4.02k | FieldUnit GetHScrollMetric() const { return m_bIsHScrollMetricSet ? m_eHScrollMetric : m_eUserMetric;} |
255 | | void SetHScrollMetric(FieldUnit eSet) |
256 | 0 | { |
257 | 0 | m_eHScrollMetric = eSet; m_bIsHScrollMetricSet = true; |
258 | 0 | m_aLayoutConfig.SetModified(); |
259 | 0 | } |
260 | | |
261 | 0 | bool IsVScrollMetric()const {return m_bIsVScrollMetricSet;} |
262 | 4.02k | FieldUnit GetVScrollMetric() const { return m_bIsVScrollMetricSet ? m_eVScrollMetric : m_eUserMetric;} |
263 | | void SetVScrollMetric(FieldUnit eSet) |
264 | 0 | { |
265 | 0 | m_eVScrollMetric = eSet; m_bIsVScrollMetricSet = true; |
266 | 0 | m_aLayoutConfig.SetModified(); |
267 | 0 | } |
268 | | |
269 | | bool IsApplyCharUnit() const |
270 | 0 | { |
271 | 0 | return m_bApplyCharUnit; |
272 | 0 | } |
273 | | void SetApplyCharUnit(bool bSet, bool noModify = false) |
274 | 0 | { |
275 | 0 | m_bApplyCharUnit = bSet; |
276 | 0 | if (!noModify) { |
277 | 0 | m_aLayoutConfig.SetModified(); |
278 | 0 | } |
279 | 0 | } |
280 | | |
281 | 4.25k | bool IsDefaultZoom() const { return m_bUseDefaultZoom;} |
282 | | void SetDefaultZoom( bool bSet, bool bNoModify = false ) |
283 | 0 | { |
284 | 0 | m_bUseDefaultZoom = bSet; |
285 | 0 | if(!bNoModify) |
286 | 0 | m_aContentConfig.SetModified(); |
287 | 0 | } |
288 | 0 | sal_uInt16 GetDefaultZoomValue() const { return m_nDefaultZoomValue; } |
289 | | void SetDefaultZoomValue ( sal_uInt16 nValue, bool bNoModify = false ) |
290 | 0 | { |
291 | 0 | m_nDefaultZoomValue = nValue; |
292 | 0 | if(!bNoModify) |
293 | 0 | m_aContentConfig.SetModified(); |
294 | 0 | } |
295 | 0 | SvxZoomType GetDefaultZoomType() const { return m_eDefaultZoomType;} |
296 | | void SetDefaultZoomType( SvxZoomType eType, bool bNoModify = false ) |
297 | 0 | { |
298 | 0 | m_eDefaultZoomType = eType; |
299 | 0 | if(!bNoModify) |
300 | 0 | m_aContentConfig.SetModified(); |
301 | 0 | } |
302 | | |
303 | 76.8k | sal_Int32 GetDefTabInMm100() const { return m_nDefTabInMm100;} |
304 | | void SetDefTabInMm100( sal_Int32 nSet, bool bNoModify = false ) |
305 | 0 | { |
306 | 0 | m_nDefTabInMm100 = nSet; |
307 | 0 | if(!bNoModify) |
308 | 0 | m_aLayoutConfig.SetModified(); |
309 | 0 | } |
310 | | |
311 | | //default page mode for text grid |
312 | 76.8k | bool IsSquaredPageMode() const {return m_bIsSquaredPageMode;} |
313 | | void SetDefaultPageMode( bool bVal, bool bNoModify = false ) |
314 | 0 | { |
315 | 0 | m_bIsSquaredPageMode = bVal; |
316 | 0 | if(!bNoModify) |
317 | 0 | m_aLayoutConfig.SetModified(); |
318 | 0 | } |
319 | | |
320 | 76.8k | bool IsAlignMathObjectsToBaseline() const { return m_bIsAlignMathObjectsToBaseline; } |
321 | | void SetAlignMathObjectsToBaseline( bool bVal, bool noModify = false ) |
322 | 0 | { |
323 | 0 | m_bIsAlignMathObjectsToBaseline = bVal; |
324 | 0 | if (!noModify) { |
325 | 0 | m_aLayoutConfig.SetModified(); |
326 | 0 | } |
327 | 0 | } |
328 | | |
329 | | void SetEncloseWithCharactersOn(bool bVal, bool noModify = false) |
330 | 0 | { |
331 | 0 | this->SwViewOption::SetEncloseWithCharactersOn(bVal); |
332 | 0 | if (!noModify) |
333 | 0 | { |
334 | 0 | m_aFmtAidsAutoComplConfig.SetModified(); |
335 | 0 | } |
336 | 0 | } |
337 | | }; |
338 | | |
339 | | #endif |
340 | | |
341 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |