xref: /trunk/main/sw/source/ui/inc/usrpref.hxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _USRPREF_HXX
23 #define _USRPREF_HXX
24 
25 #include <unotools/configitem.hxx>
26 #include <fldupde.hxx>
27 #include "viewopt.hxx"
28 #include <tools/fldunit.hxx>
29 
30 /* -----------------------------28.09.00 09:45--------------------------------
31 
32  ---------------------------------------------------------------------------*/
33 class SwMasterUsrPref;
34 class SwContentViewConfig : public utl::ConfigItem
35 {
36     SwMasterUsrPref&        rParent;
37     sal_Bool                    bWeb;
38 
39     com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
40     public:
41         SwContentViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
42         ~SwContentViewConfig();
43 
44     // utl::ConfigItem
45     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
46     virtual void    Commit();
47 
48     void                    Load();
49     void                    SetModified(){ConfigItem::SetModified();}
50 };
51 /* -----------------------------28.09.00 09:45--------------------------------
52 
53  ---------------------------------------------------------------------------*/
54 class SwLayoutViewConfig : public utl::ConfigItem
55 {
56     SwMasterUsrPref&    rParent;
57     sal_Bool                bWeb;
58 
59     com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
60     public:
61         SwLayoutViewConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
62         ~SwLayoutViewConfig();
63 
64     virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
65     virtual void            Commit();
66     void                    Load();
67     void                    SetModified(){ConfigItem::SetModified();}
68 };
69 /* -----------------------------19.01.01 13:06--------------------------------
70 
71  ---------------------------------------------------------------------------*/
72 class SwGridConfig : public utl::ConfigItem
73 {
74     SwMasterUsrPref&    rParent;
75     sal_Bool                bWeb;
76 
77     com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
78     public:
79         SwGridConfig(sal_Bool bWeb, SwMasterUsrPref& rParent);
80         ~SwGridConfig();
81 
82     virtual void Commit();
83     virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
84     void                    Load();
85     void                    SetModified(){ConfigItem::SetModified();}
86 };
87 /* -----------------------------19.01.01 13:06--------------------------------
88 
89  ---------------------------------------------------------------------------*/
90 class SwCursorConfig : public utl::ConfigItem
91 {
92     SwMasterUsrPref&    rParent;
93 
94     com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
95     public:
96         SwCursorConfig(SwMasterUsrPref& rParent);
97         ~SwCursorConfig();
98 
99     virtual void Commit();
100     virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
101     void                    Load();
102     void                    SetModified(){ConfigItem::SetModified();}
103 };
104 /* -----------------------------28.09.00 09:45--------------------------------
105 
106  ---------------------------------------------------------------------------*/
107 class SwWebColorConfig : public utl::ConfigItem
108 {
109     SwMasterUsrPref&        rParent;
110     com::sun::star::uno::Sequence<rtl::OUString> aPropNames;
111 
112     public:
113         SwWebColorConfig(SwMasterUsrPref& rParent);
114         ~SwWebColorConfig();
115 
116     virtual void Commit();
117     virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
118     void                    Load();
119     void                    SetModified(){ConfigItem::SetModified();}
120 };
121 /* -----------------------------28.09.00 09:45--------------------------------
122 
123  ---------------------------------------------------------------------------*/
124 class SwMasterUsrPref : public SwViewOption
125 {
126     friend class SwContentViewConfig;
127     friend class SwLayoutViewConfig;
128     friend class SwGridConfig;
129     friend class SwCursorConfig;
130     friend class SwWebColorConfig;
131 
132     SwFldUpdateFlags eFldUpdateFlags; // update of fields and charts
133     sal_Int32   nLinkUpdateMode;
134     FieldUnit   eUserMetric;
135     FieldUnit   eHScrollMetric;
136     sal_Bool    bIsHScrollMetricSet;
137     FieldUnit   eVScrollMetric;
138     sal_Bool    bIsVScrollMetricSet;
139 
140     sal_Int32   nDefTab;            // default tab stop distance
141 
142     sal_Bool    bIsSquaredPageMode; // default page mode for text grid
143     sal_Bool    bIsAlignMathObjectsToBaseline;
144 
145     SwContentViewConfig aContentConfig;
146     SwLayoutViewConfig  aLayoutConfig;
147     SwGridConfig        aGridConfig;
148     SwCursorConfig      aCursorConfig;
149     SwWebColorConfig*   pWebColorConfig;
150 
151 public:
152     SwMasterUsrPref(sal_Bool bWeb);
153     ~SwMasterUsrPref();
154 
155     void SetUsrPref(const SwViewOption &rCopy);
156 
157     void Commit()
158         {
159             aContentConfig.Commit();
160             aLayoutConfig.Commit();
161             aGridConfig.Commit();
162             aCursorConfig.Commit();
163             if(pWebColorConfig)
164                 pWebColorConfig->Commit();
165         }
166     void SetModified()
167         {
168             aContentConfig.SetModified();
169             aLayoutConfig.SetModified();
170             aGridConfig.SetModified();
171             aCursorConfig.SetModified();
172             if(pWebColorConfig)
173                 pWebColorConfig->SetModified();
174         }
175 
176     void SetUpdateLinkMode(sal_Int32 nSet, sal_Bool bNoModify = sal_False)
177         {
178             nLinkUpdateMode = nSet;
179             if(!bNoModify)
180                 aContentConfig.SetModified();
181         }
182     sal_Int32 GetUpdateLinkMode() const {return nLinkUpdateMode; }
183 
184     void SetUpdateFields(sal_Bool bSet, sal_Bool bNoModify = sal_False)
185         {
186             if(bSet && eFldUpdateFlags == AUTOUPD_OFF)
187             {
188                 eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
189                 if(!bNoModify)
190                     aContentConfig.SetModified();
191             }
192             else if(!bSet)
193             {
194                 eFldUpdateFlags = AUTOUPD_OFF;
195                 if(!bNoModify)
196                     aContentConfig.SetModified();
197             }
198         };
199     sal_Bool IsUpdateFields()const {return eFldUpdateFlags != AUTOUPD_OFF; }
200 
201     SwFldUpdateFlags   GetFldUpdateFlags()const {return eFldUpdateFlags;}
202     void        SetFldUpdateFlags(SwFldUpdateFlags eSet, sal_Bool bNoModify = sal_False)
203         {
204             eFldUpdateFlags = eSet;
205             if(!bNoModify)
206                 aContentConfig.SetModified();
207         }
208 
209     void SetUpdateCharts(sal_Bool bSet, sal_Bool bNoModify = sal_False)
210         {
211             if(bSet)
212             {
213                 eFldUpdateFlags = AUTOUPD_FIELD_AND_CHARTS;
214                 if(!bNoModify)
215                     aContentConfig.SetModified();
216              }
217              else if(eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS)
218              {
219                 eFldUpdateFlags = AUTOUPD_FIELD_ONLY;
220                 if(!bNoModify)
221                     aContentConfig.SetModified();
222              }
223         };
224     sal_Bool IsUpdateCharts()const {return eFldUpdateFlags == AUTOUPD_FIELD_AND_CHARTS; }
225 
226     FieldUnit   GetMetric() const { return eUserMetric;}
227     void        SetMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
228                 {
229                     eUserMetric = eSet;
230                     if(!bNoModify)
231                         aLayoutConfig.SetModified();
232                 }
233 
234     sal_Bool    IsHScrollMetric()const {return bIsHScrollMetricSet;}
235     FieldUnit   GetHScrollMetric() const { return bIsHScrollMetricSet ? eHScrollMetric : eUserMetric;}
236     void        SetHScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
237                 {
238                     eHScrollMetric = eSet; bIsHScrollMetricSet = sal_True;
239                     if(!bNoModify)
240                         aLayoutConfig.SetModified();
241                 }
242 
243     sal_Bool    IsVScrollMetric()const {return bIsVScrollMetricSet;}
244     FieldUnit   GetVScrollMetric() const { return bIsVScrollMetricSet ? eVScrollMetric : eUserMetric;}
245     void        SetVScrollMetric(FieldUnit eSet, sal_Bool bNoModify = sal_False)
246                 {
247                     eVScrollMetric = eSet; bIsVScrollMetricSet = sal_True;
248                     if(!bNoModify)
249                         aLayoutConfig.SetModified();
250                 }
251 
252     sal_Int32   GetDefTab() const { return nDefTab;}
253     void        SetDefTab( sal_Int32  nSet, sal_Bool bNoModify = sal_False )
254                 {
255                     nDefTab = nSet;
256                     if(!bNoModify)
257                         aLayoutConfig.SetModified();
258                 }
259 
260     // default page mode for text grid
261     sal_Bool    IsSquaredPageMode() const {return bIsSquaredPageMode;}
262     void        SetDefaultPageMode( sal_Bool bVal, sal_Bool bNoModify = sal_False )
263                 {
264                     bIsSquaredPageMode = bVal;
265                     if(!bNoModify)
266                         aLayoutConfig.SetModified();
267                 }
268 
269     sal_Bool    IsAlignMathObjectsToBaseline() const { return bIsAlignMathObjectsToBaseline; }
270     void        SetAlignMathObjectsToBaseline( sal_Bool bVal, sal_Bool bNoModify = sal_False )
271                 {
272                     bIsAlignMathObjectsToBaseline = bVal;
273                     if(!bNoModify)
274                         aLayoutConfig.SetModified();
275                 }
276 };
277 
278 #endif
279 
280 /* vim: set noet sw=4 ts=4: */
281