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