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