xref: /aoo41x/main/sw/source/ui/inc/usrpref.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _USRPREF_HXX
28 #define _USRPREF_HXX
29 
30 
31 
32 #include <unotools/configitem.hxx>
33 #include <fldupde.hxx>
34 #include "viewopt.hxx"
35 #include <tools/fldunit.hxx>
36 
37 /* -----------------------------28.09.00 09:45--------------------------------
38 
39  ---------------------------------------------------------------------------*/
40 class SwMasterUsrPref;
41 class SwContentViewConfig : public utl::ConfigItem
42 {
43 	SwMasterUsrPref& 		rParent;
44 	sal_Bool 					bWeb;
45 
46 	com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
47 	public:
48 		SwContentViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
49 		~SwContentViewConfig();
50 
51     // utl::ConfigItem
52     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
53     virtual void    Commit();
54 
55     void                    Load();
56 	void 					SetModified(){ConfigItem::SetModified();}
57 };
58 /* -----------------------------28.09.00 09:45--------------------------------
59 
60  ---------------------------------------------------------------------------*/
61 class SwLayoutViewConfig : public utl::ConfigItem
62 {
63 	SwMasterUsrPref& 	rParent;
64 	sal_Bool 				bWeb;
65 
66 	com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
67 	public:
68 		SwLayoutViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
69 		~SwLayoutViewConfig();
70 
71 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
72 	virtual void			Commit();
73 	void					Load();
74 	void 					SetModified(){ConfigItem::SetModified();}
75 };
76 /* -----------------------------19.01.01 13:06--------------------------------
77 
78  ---------------------------------------------------------------------------*/
79 class SwGridConfig : public utl::ConfigItem
80 {
81 	SwMasterUsrPref& 	rParent;
82 	sal_Bool 				bWeb;
83 
84 	com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
85 	public:
86 		SwGridConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
87 		~SwGridConfig();
88 
89 	virtual void Commit();
90 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
91 	void					Load();
92 	void 					SetModified(){ConfigItem::SetModified();}
93 };
94 /* -----------------------------19.01.01 13:06--------------------------------
95 
96  ---------------------------------------------------------------------------*/
97 class SwCursorConfig : public utl::ConfigItem
98 {
99 	SwMasterUsrPref& 	rParent;
100 
101 	com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
102 	public:
103 		SwCursorConfig(SwMasterUsrPref& rParent);
104 		~SwCursorConfig();
105 
106 	virtual void Commit();
107 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
108 	void					Load();
109 	void 					SetModified(){ConfigItem::SetModified();}
110 };
111 /* -----------------------------28.09.00 09:45--------------------------------
112 
113  ---------------------------------------------------------------------------*/
114 class SwWebColorConfig : public utl::ConfigItem
115 {
116 	SwMasterUsrPref& 		rParent;
117 	com::sun::star::uno::Sequence<rtl::OUString> aPropNames;
118 
119 	public:
120 		SwWebColorConfig(SwMasterUsrPref& rParent);
121 		~SwWebColorConfig();
122 
123 	virtual void Commit();
124 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
125 	void					Load();
126 	void 					SetModified(){ConfigItem::SetModified();}
127 };
128 /* -----------------------------28.09.00 09:45--------------------------------
129 
130  ---------------------------------------------------------------------------*/
131 class SwMasterUsrPref : public SwViewOption
132 {
133 	friend class SwContentViewConfig;
134 	friend class SwLayoutViewConfig;
135 	friend class SwGridConfig;
136 	friend class SwCursorConfig;
137 	friend class SwWebColorConfig;
138 
139     SwFldUpdateFlags eFldUpdateFlags;    //udpate of fields and charts
140 	sal_Int32	nLinkUpdateMode;
141 	FieldUnit	eUserMetric;
142     FieldUnit   eHScrollMetric;
143     sal_Bool    bIsHScrollMetricSet;
144     FieldUnit   eVScrollMetric;
145     sal_Bool    bIsVScrollMetricSet;
146 
147 	sal_Int32	nDefTab;			//default tab stop distance
148 
149     sal_Bool    bIsSquaredPageMode; //default page mode for text grid
150     sal_Bool    bIsAlignMathObjectsToBaseline;
151 
152     SwContentViewConfig aContentConfig;
153     SwLayoutViewConfig  aLayoutConfig;
154     SwGridConfig        aGridConfig;
155     SwCursorConfig      aCursorConfig;
156     SwWebColorConfig*   pWebColorConfig;
157 
158 public:
159 	SwMasterUsrPref(sal_Bool bWeb);
160 	~SwMasterUsrPref();
161 
162 	void SetUsrPref(const SwViewOption &rCopy);
163 
164 	void Commit()
165 		{
166 			aContentConfig.Commit();
167 			aLayoutConfig.Commit();
168 			aGridConfig.Commit();
169 			aCursorConfig.Commit();
170 			if(pWebColorConfig)
171 				pWebColorConfig->Commit();
172 		}
173     void SetModified()
174 		{
175 			aContentConfig.SetModified();
176 			aLayoutConfig.SetModified();
177 			aGridConfig.SetModified();
178 			aCursorConfig.SetModified();
179 			if(pWebColorConfig)
180 				pWebColorConfig->SetModified();
181 		}
182 
183     void SetUpdateLinkMode(sal_Int32 nSet, sal_Bool bNoModify = sal_False)
184         {
185             nLinkUpdateMode = nSet;
186             if(!bNoModify)
187                 aContentConfig.SetModified();
188         }
189 	sal_Int32 GetUpdateLinkMode() const {return nLinkUpdateMode; }
190 
191     void SetUpdateFields(sal_Bool bSet, sal_Bool bNoModify = sal_False)
192 		{
193             if(bSet && eFldUpdateFlags == AUTOUPD_OFF)
194 			{
195                 eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
196                 if(!bNoModify)
197                     aContentConfig.SetModified();
198 		 	}
199 			else if(!bSet)
200 			{
201                 eFldUpdateFlags = AUTOUPD_OFF;
202                 if(!bNoModify)
203                     aContentConfig.SetModified();
204 			}
205 		};
206     sal_Bool IsUpdateFields()const {return eFldUpdateFlags != AUTOUPD_OFF; }
207 
208     SwFldUpdateFlags   GetFldUpdateFlags()const {return eFldUpdateFlags;}
209     void        SetFldUpdateFlags(SwFldUpdateFlags eSet, sal_Bool bNoModify = sal_False)
210         {
211             eFldUpdateFlags = eSet;
212             if(!bNoModify)
213                 aContentConfig.SetModified();
214         }
215 
216     void SetUpdateCharts(sal_Bool bSet, sal_Bool bNoModify = sal_False)
217 		{
218 			if(bSet)
219 			{
220                 eFldUpdateFlags = AUTOUPD_FIELD_AND_CHARTS;
221                 if(!bNoModify)
222                     aContentConfig.SetModified();
223 			 }
224              else if(eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS)
225 			 {
226                 eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
227                 if(!bNoModify)
228                     aContentConfig.SetModified();
229 			 }
230 		};
231     sal_Bool IsUpdateCharts()const {return eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS; }
232 
233 	FieldUnit	GetMetric() const { return eUserMetric;}
234     void        SetMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
235                 {
236                     eUserMetric = eSet;
237                     if(!bNoModify)
238                         aLayoutConfig.SetModified();
239                 }
240 
241     sal_Bool    IsHScrollMetric()const {return bIsHScrollMetricSet;}
242     FieldUnit   GetHScrollMetric() const { return bIsHScrollMetricSet ? eHScrollMetric : eUserMetric;}
243     void        SetHScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
244                 {
245                     eHScrollMetric = eSet; bIsHScrollMetricSet = sal_True;
246                     if(!bNoModify)
247                         aLayoutConfig.SetModified();
248                 }
249 
250     sal_Bool    IsVScrollMetric()const {return bIsVScrollMetricSet;}
251     FieldUnit   GetVScrollMetric() const { return bIsVScrollMetricSet ? eVScrollMetric : eUserMetric;}
252     void        SetVScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
253                 {
254                     eVScrollMetric = eSet; bIsVScrollMetricSet = sal_True;
255                     if(!bNoModify)
256                         aLayoutConfig.SetModified();
257                 }
258 
259     sal_Int32   GetDefTab() const { return nDefTab;}
260     void        SetDefTab( sal_Int32  nSet, sal_Bool bNoModify = sal_False )
261                 {
262                     nDefTab = nSet;
263                     if(!bNoModify)
264                         aLayoutConfig.SetModified();
265                 }
266 
267     //default page mode for text grid
268     sal_Bool    IsSquaredPageMode() const {return bIsSquaredPageMode;}
269     void        SetDefaultPageMode( sal_Bool bVal, sal_Bool bNoModify = sal_False )
270                 {
271                     bIsSquaredPageMode = bVal;
272                     if(!bNoModify)
273                         aLayoutConfig.SetModified();
274                 }
275 
276     sal_Bool    IsAlignMathObjectsToBaseline() const { return bIsAlignMathObjectsToBaseline; }
277     void        SetAlignMathObjectsToBaseline( sal_Bool bVal, sal_Bool bNoModify = sal_False )
278                 {
279                     bIsAlignMathObjectsToBaseline = bVal;
280                     if(!bNoModify)
281                         aLayoutConfig.SetModified();
282                 }
283 };
284 
285 #endif
286 
287