merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / config / misccfg.cxx
blob7101a13781424cb2ef3490624b30fcd407ae32ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: misccfg.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #ifdef SVL_DLLIMPLEMENTATION
35 #undef SVL_DLLIMPLEMENTATION
36 #endif
37 #define SVT_DLLIMPLEMENTATION
39 #include "misccfg.hxx"
40 #include <svtools/zforlist.hxx>
41 #include <tools/debug.hxx>
43 #include <rtl/logfile.hxx>
46 #define DEFAULT_TAB 2000
48 #define DEF_INCH 2540L
49 #define DEF_RELTWIP 1440L
51 using namespace rtl;
52 using namespace com::sun::star::uno;
54 #define C2U(cChar) OUString::createFromAscii(cChar)
55 /*--------------------------------------------------------------------
56 Beschreibung:
57 --------------------------------------------------------------------*/
58 SfxMiscCfg::SfxMiscCfg() :
59 ConfigItem(C2U("Office.Common") ),
60 bPaperSize(FALSE),
61 bPaperOrientation (FALSE),
62 bNotFound (FALSE),
63 nYear2000( SvNumberFormatter::GetYear2000Default() )
65 RTL_LOGFILE_CONTEXT(aLog, "svtools SfxMiscCfg::SfxMiscCfg()");
67 Load();
69 /* -----------------------------02.03.01 15:31--------------------------------
71 ---------------------------------------------------------------------------*/
72 SfxMiscCfg::~SfxMiscCfg()
75 /*--------------------------------------------------------------------
76 Beschreibung:
77 --------------------------------------------------------------------*/
79 void SfxMiscCfg::SetNotFoundWarning( BOOL bSet)
81 if(bNotFound != bSet)
82 SetModified();
83 bNotFound = bSet;
86 /*--------------------------------------------------------------------
87 Beschreibung:
88 --------------------------------------------------------------------*/
90 void SfxMiscCfg::SetPaperSizeWarning( BOOL bSet)
92 if(bPaperSize != bSet)
93 SetModified();
94 bPaperSize = bSet;
97 /*--------------------------------------------------------------------
98 Beschreibung:
99 --------------------------------------------------------------------*/
100 void SfxMiscCfg::SetPaperOrientationWarning( BOOL bSet)
102 if(bPaperOrientation != bSet)
103 SetModified();
104 bPaperOrientation = bSet;
106 /*--------------------------------------------------------------------
107 Beschreibung:
108 --------------------------------------------------------------------*/
110 void SfxMiscCfg::SetYear2000( sal_Int32 nSet )
112 if(nYear2000 != nSet)
113 SetModified();
114 nYear2000 = nSet;
116 /* -----------------------------02.03.01 15:31--------------------------------
118 ---------------------------------------------------------------------------*/
119 const Sequence<OUString>& SfxMiscCfg::GetPropertyNames()
121 static Sequence<OUString> aNames;
122 if(!aNames.getLength())
124 static const char* aPropNames[] =
126 "Print/Warning/PaperSize", // 0
127 "Print/Warning/PaperOrientation", // 1
128 "Print/Warning/NotFound", // 2
129 "DateFormat/TwoDigitYear", // 3
131 const int nCount = 4;
132 aNames.realloc(nCount);
133 OUString* pNames = aNames.getArray();
134 for(int i = 0; i < nCount; i++)
135 pNames[i] = OUString::createFromAscii(aPropNames[i]);
137 return aNames;
139 /* -----------------------------02.03.01 15:31--------------------------------
141 ---------------------------------------------------------------------------*/
142 void SfxMiscCfg::Load()
144 const Sequence<OUString>& aNames = GetPropertyNames();
145 Sequence<Any> aValues = GetProperties(aNames);
146 EnableNotification(aNames);
147 const Any* pValues = aValues.getConstArray();
148 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
149 if(aValues.getLength() == aNames.getLength())
151 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
153 if(pValues[nProp].hasValue())
155 switch(nProp)
157 case 0: bPaperSize = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperSize",
158 case 1: bPaperOrientation = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperOrientation",
159 case 2: bNotFound = *(sal_Bool*)pValues[nProp].getValue() ; break; //"Print/Warning/NotFound",
160 case 3: pValues[nProp] >>= nYear2000;break; //"DateFormat/TwoDigitYear",
166 /* -----------------------------02.03.01 15:31--------------------------------
168 ---------------------------------------------------------------------------*/
169 void SfxMiscCfg::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
171 Load();
173 /* -----------------------------02.03.01 15:31--------------------------------
175 ---------------------------------------------------------------------------*/
176 void SfxMiscCfg::Commit()
178 const Sequence<OUString>& aNames = GetPropertyNames();
179 Sequence<Any> aValues(aNames.getLength());
180 Any* pValues = aValues.getArray();
182 const Type& rType = ::getBooleanCppuType();
183 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
185 switch(nProp)
187 case 0: pValues[nProp].setValue(&bPaperSize, rType);break; //"Print/Warning/PaperSize",
188 case 1: pValues[nProp].setValue(&bPaperOrientation, rType);break; //"Print/Warning/PaperOrientation",
189 case 2: pValues[nProp].setValue(&bNotFound, rType);break; //"Print/Warning/NotFound",
190 case 3: pValues[nProp] <<= nYear2000;break; //"DateFormat/TwoDigitYear",
193 PutProperties(aNames, aValues);