xref: /aoo41x/main/svtools/source/config/apearcfg.cxx (revision 5900e8ec)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5900e8ecSAndrew Rist  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19*5900e8ecSAndrew Rist  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svtools/apearcfg.hxx>
28cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "tools/debug.hxx"
31cdf0e10cSrcweir #include "vcl/settings.hxx"
32cdf0e10cSrcweir #include "vcl/svapp.hxx"
33cdf0e10cSrcweir #include <rtl/logfile.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define DEFAULT_LOOKNFEEL   0
36cdf0e10cSrcweir #define DEFAULT_DRAGMODE    2
37cdf0e10cSrcweir #define DEFAULT_SNAPMODE    0
38cdf0e10cSrcweir #define DEFAULT_SCALEFACTOR 100
39cdf0e10cSrcweir #define DEFAULT_AAMINHEIGHT	8
40cdf0e10cSrcweir 
41cdf0e10cSrcweir using namespace ::rtl;
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir sal_Bool SvtTabAppearanceCfg::bInitialized = sal_False;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /*--------------------------------------------------------------------
47cdf0e10cSrcweir 	 Beschreibung:
48cdf0e10cSrcweir  --------------------------------------------------------------------*/
SvtTabAppearanceCfg()49cdf0e10cSrcweir SvtTabAppearanceCfg::SvtTabAppearanceCfg()
50cdf0e10cSrcweir 	:ConfigItem(OUString::createFromAscii("Office.Common/View"))
51cdf0e10cSrcweir 	,nDragMode			( DEFAULT_DRAGMODE )
52cdf0e10cSrcweir 	,nScaleFactor       ( DEFAULT_SCALEFACTOR )
53cdf0e10cSrcweir 	,nSnapMode			( DEFAULT_SNAPMODE )
54cdf0e10cSrcweir     ,nMiddleMouse       ( MOUSE_MIDDLE_AUTOSCROLL )
55cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
56cdf0e10cSrcweir 	,nAAMinPixelHeight	( DEFAULT_AAMINHEIGHT )
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 	,bMenuMouseFollow(sal_False)
59cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
60cdf0e10cSrcweir 	,bFontAntialiasing	( sal_True )
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	RTL_LOGFILE_CONTEXT(aLog, "svtools SvtTabAppearanceCfg::SvtTabAppearanceCfg()");
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     const Sequence<OUString>& rNames = GetPropertyNames();
66cdf0e10cSrcweir     Sequence<Any> aValues = GetProperties(rNames);
67cdf0e10cSrcweir 	const Any* pValues = aValues.getConstArray();
68cdf0e10cSrcweir     DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	if(aValues.getLength() == rNames.getLength())
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir         for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues)
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			if(pValues->hasValue())
75cdf0e10cSrcweir 			{
76cdf0e10cSrcweir 				switch(nProp)
77cdf0e10cSrcweir 				{
78cdf0e10cSrcweir                     case  0: *pValues >>= nScaleFactor; break; //"FontScaling",
79cdf0e10cSrcweir                     case  1: *pValues >>= nDragMode; break;   //"Window/Drag",
80cdf0e10cSrcweir                     case  2: bMenuMouseFollow = *(sal_Bool*)pValues->getValue(); break; //"Menu/FollowMouse",
81cdf0e10cSrcweir                     case  3: *pValues >>= nSnapMode; break; //"Dialog/MousePositioning",
82cdf0e10cSrcweir                     case  4: *pValues >>= nMiddleMouse; break; //"Dialog/MiddleMouseButton",
83cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
84cdf0e10cSrcweir                     case  5: bFontAntialiasing = *(sal_Bool*)pValues->getValue(); break;    // "FontAntialising/Enabled",
85cdf0e10cSrcweir                     case  6: *pValues >>= nAAMinPixelHeight; break;                         // "FontAntialising/MinPixelHeight",
86cdf0e10cSrcweir #endif
87cdf0e10cSrcweir                 }
88cdf0e10cSrcweir 			}
89cdf0e10cSrcweir 		}
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir /* -----------------------------22.05.01 11:53--------------------------------
93cdf0e10cSrcweir 
94cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~SvtTabAppearanceCfg()95cdf0e10cSrcweir SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir }
98cdf0e10cSrcweir /* -----------------------------22.05.01 11:54--------------------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetPropertyNames()101cdf0e10cSrcweir const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames()
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     static Sequence<OUString> aNames;
104cdf0e10cSrcweir     if(!aNames.getLength())
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         static const sal_Char* aPropNames[] =
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir              "FontScaling"                       //  0
109cdf0e10cSrcweir             ,"Window/Drag"                       //  1
110cdf0e10cSrcweir             ,"Menu/FollowMouse"                  //  2
111cdf0e10cSrcweir             ,"Dialog/MousePositioning"           //  3
112cdf0e10cSrcweir             ,"Dialog/MiddleMouseButton"          //  4
113cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
114cdf0e10cSrcweir             ,"FontAntiAliasing/Enabled"         //  5
115cdf0e10cSrcweir             ,"FontAntiAliasing/MinPixelHeight"  //  6
116cdf0e10cSrcweir #endif
117cdf0e10cSrcweir         };
118cdf0e10cSrcweir         const int nCount = sizeof( aPropNames ) / sizeof( aPropNames[0] );
119cdf0e10cSrcweir         aNames.realloc(nCount);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		const sal_Char** pAsciiNames = aPropNames;
122cdf0e10cSrcweir         OUString* pNames = aNames.getArray();
123cdf0e10cSrcweir         for(int i = 0; i < nCount; ++i, ++pNames, ++pAsciiNames)
124cdf0e10cSrcweir             *pNames = OUString::createFromAscii( *pAsciiNames );
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir     return aNames;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir /* -----------------------------22.05.01 11:54--------------------------------
129cdf0e10cSrcweir 
130cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Commit()131cdf0e10cSrcweir void  SvtTabAppearanceCfg::Commit()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     const Sequence<OUString>& rNames = GetPropertyNames();
134cdf0e10cSrcweir     Sequence<Any> aValues(rNames.getLength());
135cdf0e10cSrcweir 	Any* pValues = aValues.getArray();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	const Type& rType = ::getBooleanCppuType();
138cdf0e10cSrcweir     for(int nProp = 0; nProp < rNames.getLength(); nProp++)
139cdf0e10cSrcweir 	{
140cdf0e10cSrcweir 		switch(nProp)
141cdf0e10cSrcweir 		{
142cdf0e10cSrcweir             case  0: pValues[nProp] <<= nScaleFactor; break;            // "FontScaling",
143cdf0e10cSrcweir             case  1: pValues[nProp] <<= nDragMode; break;               //"Window/Drag",
144cdf0e10cSrcweir             case  2: pValues[nProp].setValue(&bMenuMouseFollow, rType); break; //"Menu/FollowMouse",
145cdf0e10cSrcweir             case  3: pValues[nProp] <<= nSnapMode; break;               //"Dialog/MousePositioning",
146cdf0e10cSrcweir             case  4: pValues[nProp] <<= nMiddleMouse; break;               //"Dialog/MiddleMouseButton",
147cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
148cdf0e10cSrcweir             case  5: pValues[nProp].setValue(&bFontAntialiasing, rType); break; // "FontAntialising/Enabled",
149cdf0e10cSrcweir             case  6: pValues[nProp] <<= nAAMinPixelHeight; break;               // "FontAntialising/MinPixelHeight",
150cdf0e10cSrcweir #endif
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir     PutProperties(rNames, aValues);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
Notify(const com::sun::star::uno::Sequence<rtl::OUString> &)156cdf0e10cSrcweir void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir /*--------------------------------------------------------------------
161cdf0e10cSrcweir 	 Beschreibung:
162cdf0e10cSrcweir  --------------------------------------------------------------------*/
163cdf0e10cSrcweir 
SetDragMode(sal_uInt16 nSet)164cdf0e10cSrcweir void SvtTabAppearanceCfg::SetDragMode  ( sal_uInt16 nSet )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	nDragMode = nSet;
167cdf0e10cSrcweir     SetModified();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir /*--------------------------------------------------------------------
171cdf0e10cSrcweir 	 Beschreibung:
172cdf0e10cSrcweir  --------------------------------------------------------------------*/
173cdf0e10cSrcweir 
SetScaleFactor(sal_uInt16 nSet)174cdf0e10cSrcweir void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	nScaleFactor = nSet;
177cdf0e10cSrcweir     SetModified();
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir /*--------------------------------------------------------------------
181cdf0e10cSrcweir 	 Beschreibung:
182cdf0e10cSrcweir  --------------------------------------------------------------------*/
183cdf0e10cSrcweir 
SetSnapMode(sal_uInt16 nSet)184cdf0e10cSrcweir void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	nSnapMode = nSet;
187cdf0e10cSrcweir     SetModified();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir /*--------------------------------------------------------------------
190cdf0e10cSrcweir 	 Beschreibung:
191cdf0e10cSrcweir  --------------------------------------------------------------------*/
SetMiddleMouseButton(sal_uInt16 nSet)192cdf0e10cSrcweir void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     nMiddleMouse = nSet;
195cdf0e10cSrcweir     SetModified();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir /*--------------------------------------------------------------------
198cdf0e10cSrcweir 	 Beschreibung:
199cdf0e10cSrcweir  --------------------------------------------------------------------*/
200cdf0e10cSrcweir 
SetApplicationDefaults(Application * pApp)201cdf0e10cSrcweir void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	AllSettings   hAppSettings = pApp->GetSettings();
204cdf0e10cSrcweir 	StyleSettings hAppStyle    = hAppSettings.GetStyleSettings();
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	// Look & Feel
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	// SetStandard...Styles() resets the UseSystemUIFonts flag,
209cdf0e10cSrcweir 	// but we don't want to change it now, so save the flag before ...
210cdf0e10cSrcweir 	sal_Bool bUseSystemUIFonts = hAppStyle.GetUseSystemUIFonts();
211cdf0e10cSrcweir 	hAppStyle.SetStandardStyles();
212cdf0e10cSrcweir 	// and set it here
213cdf0e10cSrcweir 	hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	// Screen and ScreenFont Scaling
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	hAppStyle.SetScreenZoom( nScaleFactor );
218cdf0e10cSrcweir 	hAppStyle.SetScreenFontZoom( nScaleFactor );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
221cdf0e10cSrcweir 	// font anti aliasing
222cdf0e10cSrcweir 	hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight );
223cdf0e10cSrcweir 	hAppStyle.SetDisplayOptions( bFontAntialiasing ? 0 : DISPLAY_OPTION_AA_DISABLE );
224cdf0e10cSrcweir #endif
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	// Mouse Snap
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	MouseSettings hMouseSettings = hAppSettings.GetMouseSettings();
229cdf0e10cSrcweir 	sal_uLong         nMouseOptions  = hMouseSettings.GetOptions();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	nMouseOptions &=  ! (MOUSE_OPTION_AUTOCENTERPOS | MOUSE_OPTION_AUTODEFBTNPOS);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	switch ( nSnapMode )
234cdf0e10cSrcweir 	{
235cdf0e10cSrcweir 	case SnapToButton:
236cdf0e10cSrcweir 		nMouseOptions |= MOUSE_OPTION_AUTODEFBTNPOS;
237cdf0e10cSrcweir 		break;
238cdf0e10cSrcweir 	case SnapToMiddle:
239cdf0e10cSrcweir 		nMouseOptions |= MOUSE_OPTION_AUTOCENTERPOS;
240cdf0e10cSrcweir 		break;
241cdf0e10cSrcweir 	case NoSnap:
242cdf0e10cSrcweir 	default:
243cdf0e10cSrcweir 		break;
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir     hMouseSettings.SetOptions(nMouseOptions);
246cdf0e10cSrcweir     hMouseSettings.SetMiddleButtonAction(nMiddleMouse);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     // Merge and Publish Settings
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     sal_uLong nFollow = hMouseSettings.GetFollow();
251cdf0e10cSrcweir     if(bMenuMouseFollow)
252cdf0e10cSrcweir         nFollow |= MOUSE_FOLLOW_MENU;
253cdf0e10cSrcweir     else
254cdf0e10cSrcweir         nFollow &= ~MOUSE_FOLLOW_MENU;
255cdf0e10cSrcweir     hMouseSettings.SetFollow( nFollow );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     hAppSettings.SetMouseSettings( hMouseSettings );
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	hAppSettings.SetStyleSettings( hAppStyle );
260cdf0e10cSrcweir 	pApp->MergeSystemSettings    ( hAppSettings );      // Allow system-settings to apply
261cdf0e10cSrcweir 	pApp->SystemSettingsChanging ( hAppSettings, NULL );// Allow overruling of system-settings
262cdf0e10cSrcweir 														//is concerned with window drag
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	pApp->SetSettings ( hAppSettings );
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 
269