xref: /aoo4110/main/starmath/source/config.cxx (revision b1cdbd2c)
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 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_starmath.hxx"
26 
27 
28 #include <svl/itemset.hxx>
29 #include <svl/hint.hxx>
30 #include <svl/smplhint.hxx>
31 #include <unotools/pathoptions.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <svl/eitem.hxx>
34 #include <svl/itempool.hxx>
35 #include <svl/stritem.hxx>
36 #include <svl/intitem.hxx>
37 #include <tools/stream.hxx>
38 
39 
40 #include "config.hxx"
41 #include "format.hxx"
42 #include "smmod.hxx"
43 #ifndef _STARMATH_HRC
44 #include "starmath.hrc"
45 #endif
46 
47 /////////////////////////////////////////////////////////////////
48 
SmConfig()49 SmConfig::SmConfig()
50 {
51 }
52 
53 
~SmConfig()54 SmConfig::~SmConfig()
55 {
56 }
57 
58 
ItemSetToConfig(const SfxItemSet & rSet)59 void SmConfig::ItemSetToConfig(const SfxItemSet &rSet)
60 {
61 	const SfxPoolItem *pItem	 = NULL;
62 
63 	sal_uInt16 nU16;
64 	sal_Bool bVal;
65 	if (rSet.GetItemState(SID_PRINTSIZE, sal_True, &pItem) == SFX_ITEM_SET)
66 	{	nU16 = ((const SfxUInt16Item *) pItem)->GetValue();
67         SetPrintSize( (SmPrintSize) nU16 );
68 	}
69     if (rSet.GetItemState(SID_PRINTZOOM, sal_True, &pItem) == SFX_ITEM_SET)
70 	{	nU16 = ((const SfxUInt16Item *) pItem)->GetValue();
71         SetPrintZoomFactor( nU16 );
72 	}
73 	if (rSet.GetItemState(SID_PRINTTITLE, sal_True, &pItem) == SFX_ITEM_SET)
74 	{	bVal = ((const SfxBoolItem *) pItem)->GetValue();
75         SetPrintTitle( bVal );
76 	}
77 	if (rSet.GetItemState(SID_PRINTTEXT, sal_True, &pItem) == SFX_ITEM_SET)
78 	{	bVal = ((const SfxBoolItem *) pItem)->GetValue();
79         SetPrintFormulaText( bVal );
80 	}
81 	if (rSet.GetItemState(SID_PRINTFRAME, sal_True, &pItem) == SFX_ITEM_SET)
82 	{	bVal = ((const SfxBoolItem *) pItem)->GetValue();
83         SetPrintFrame( bVal );
84 	}
85 	if (rSet.GetItemState(SID_AUTOREDRAW, sal_True, &pItem) == SFX_ITEM_SET)
86 	{	bVal = ((const SfxBoolItem *) pItem)->GetValue();
87         SetAutoRedraw( bVal );
88 	}
89 	if (rSet.GetItemState(SID_NO_RIGHT_SPACES, sal_True, &pItem) == SFX_ITEM_SET)
90 	{	bVal = ((const SfxBoolItem *) pItem)->GetValue();
91         if (IsIgnoreSpacesRight() != bVal)
92         {
93             SetIgnoreSpacesRight( bVal );
94 
95             // (angezeigte) Formeln muessen entsprechen neu formatiert werden.
96 			// Das erreichen wir mit:
97 			Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
98 		}
99 	}
100     if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, sal_True, &pItem) == SFX_ITEM_SET)
101     {   bVal = ((const SfxBoolItem *) pItem)->GetValue();
102         SetSaveOnlyUsedSymbols( bVal );
103     }
104 
105 	SaveOther();
106 }
107 
108 
ConfigToItemSet(SfxItemSet & rSet) const109 void SmConfig::ConfigToItemSet(SfxItemSet &rSet) const
110 {
111 	const SfxItemPool *pPool = rSet.GetPool();
112 
113 	rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE),
114                            (sal_uInt16) GetPrintSize()));
115 	rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM),
116                            (sal_uInt16) GetPrintZoomFactor()));
117 
118     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle()));
119     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT),  IsPrintFormulaText()));
120     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame()));
121     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw()));
122     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight()));
123     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols()));
124 }
125 
126 
127 /////////////////////////////////////////////////////////////////
128 
129 
130