1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: apearcfg.cxx,v $
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
37 #define SVT_DLLIMPLEMENTATION
39 #include "apearcfg.hxx"
40 #include "com/sun/star/uno/Any.hxx"
42 #include "tools/debug.hxx"
43 #include "vcl/settings.hxx"
44 #include "vcl/svapp.hxx"
45 #include <rtl/logfile.hxx>
47 #define DEFAULT_LOOKNFEEL 0
48 #define DEFAULT_DRAGMODE 2
49 #define DEFAULT_SNAPMODE 0
50 #define DEFAULT_SCALEFACTOR 100
51 #define DEFAULT_AAMINHEIGHT 8
53 using namespace ::rtl
;
54 using namespace ::com::sun::star::uno
;
56 sal_Bool
SvtTabAppearanceCfg::bInitialized
= sal_False
;
58 /*--------------------------------------------------------------------
60 --------------------------------------------------------------------*/
61 SvtTabAppearanceCfg::SvtTabAppearanceCfg()
62 :ConfigItem(OUString::createFromAscii("Office.Common/View"))
63 ,nLookNFeel ( DEFAULT_LOOKNFEEL
)
64 ,nDragMode ( DEFAULT_DRAGMODE
)
65 ,nScaleFactor ( DEFAULT_SCALEFACTOR
)
66 ,nSnapMode ( DEFAULT_SNAPMODE
)
67 ,nMiddleMouse ( MOUSE_MIDDLE_AUTOSCROLL
)
68 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
69 ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT
)
71 ,bMenuMouseFollow(FALSE
)
72 ,bSingleLineTabCtrl(FALSE
)
73 ,bColoredTabCtrl(FALSE
)
74 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
75 ,bFontAntialiasing ( TRUE
)
78 RTL_LOGFILE_CONTEXT(aLog
, "svtools SvtTabAppearanceCfg::SvtTabAppearanceCfg()");
80 const Sequence
<OUString
>& rNames
= GetPropertyNames();
81 Sequence
<Any
> aValues
= GetProperties(rNames
);
82 const Any
* pValues
= aValues
.getConstArray();
83 DBG_ASSERT(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
85 if(aValues
.getLength() == rNames
.getLength())
87 for(int nProp
= 0; nProp
< rNames
.getLength(); ++nProp
, ++pValues
)
89 if(pValues
->hasValue())
93 case 0: *pValues
>>= nScaleFactor
; break; //"FontScaling",
94 case 1: *pValues
>>= nLookNFeel
; break; //"LookAndFeel",
95 case 2: *pValues
>>= nDragMode
; break; //"Window/Drag",
96 case 3: bMenuMouseFollow
= *(sal_Bool
*)pValues
->getValue(); break; //"Menu/FollowMouse",
97 case 4: bSingleLineTabCtrl
= *(sal_Bool
*)pValues
->getValue(); break; //"Dialog/SingleLineTab",
98 case 5: bColoredTabCtrl
= *(sal_Bool
*)pValues
->getValue(); break; //"Dialog/ColoredTab",
99 case 6: *pValues
>>= nSnapMode
; break; //"Dialog/MousePositioning",
100 case 7: *pValues
>>= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
101 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
102 case 8: bFontAntialiasing
= *(sal_Bool
*)pValues
->getValue(); break; // "FontAntialising/Enabled",
103 case 9: *pValues
>>= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
110 /* -----------------------------22.05.01 11:53--------------------------------
112 ---------------------------------------------------------------------------*/
113 SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
116 /* -----------------------------22.05.01 11:54--------------------------------
118 ---------------------------------------------------------------------------*/
119 const Sequence
<OUString
>& SvtTabAppearanceCfg::GetPropertyNames()
121 static Sequence
<OUString
> aNames
;
122 if(!aNames
.getLength())
124 static const sal_Char
* aPropNames
[] =
129 ,"Menu/FollowMouse" // 3
130 ,"Dialog/SingleLineTab" // 4
131 ,"Dialog/ColoredTab" // 5
132 ,"Dialog/MousePositioning" // 6
133 ,"Dialog/MiddleMouseButton" // 7
134 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
135 ,"FontAntiAliasing/Enabled" // 8
136 ,"FontAntiAliasing/MinPixelHeight" // 9
139 const int nCount
= sizeof( aPropNames
) / sizeof( aPropNames
[0] );
140 aNames
.realloc(nCount
);
142 const sal_Char
** pAsciiNames
= aPropNames
;
143 OUString
* pNames
= aNames
.getArray();
144 for(int i
= 0; i
< nCount
; ++i
, ++pNames
, ++pAsciiNames
)
145 *pNames
= OUString::createFromAscii( *pAsciiNames
);
149 /* -----------------------------22.05.01 11:54--------------------------------
151 ---------------------------------------------------------------------------*/
152 void SvtTabAppearanceCfg::Commit()
154 const Sequence
<OUString
>& rNames
= GetPropertyNames();
155 Sequence
<Any
> aValues(rNames
.getLength());
156 Any
* pValues
= aValues
.getArray();
158 const Type
& rType
= ::getBooleanCppuType();
159 for(int nProp
= 0; nProp
< rNames
.getLength(); nProp
++)
163 case 0: pValues
[nProp
] <<= nScaleFactor
; break; // "FontScaling",
164 case 1: pValues
[nProp
] <<= nLookNFeel
; break; //"LookAndFeel",
165 case 2: pValues
[nProp
] <<= nDragMode
; break; //"Window/Drag",
166 case 3: pValues
[nProp
].setValue(&bMenuMouseFollow
, rType
); break; //"Menu/FollowMouse",
167 case 4: pValues
[nProp
].setValue(&bSingleLineTabCtrl
, rType
); break; //"Dialog/SingleLineTab",
168 case 5: pValues
[nProp
].setValue(&bColoredTabCtrl
, rType
); break; //"Dialog/ColoredTab",
169 case 6: pValues
[nProp
] <<= nSnapMode
; break; //"Dialog/MousePositioning",
170 case 7: pValues
[nProp
] <<= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
171 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
172 case 8: pValues
[nProp
].setValue(&bFontAntialiasing
, rType
); break; // "FontAntialising/Enabled",
173 case 9: pValues
[nProp
] <<= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
177 PutProperties(rNames
, aValues
);
179 /*--------------------------------------------------------------------
181 --------------------------------------------------------------------*/
183 void SvtTabAppearanceCfg::SetLookNFeel ( USHORT nSet
)
189 /*--------------------------------------------------------------------
191 --------------------------------------------------------------------*/
193 void SvtTabAppearanceCfg::SetDragMode ( USHORT nSet
)
199 /*--------------------------------------------------------------------
201 --------------------------------------------------------------------*/
203 void SvtTabAppearanceCfg::SetScaleFactor ( USHORT nSet
)
209 /*--------------------------------------------------------------------
211 --------------------------------------------------------------------*/
213 void SvtTabAppearanceCfg::SetSnapMode ( USHORT nSet
)
218 /*--------------------------------------------------------------------
220 --------------------------------------------------------------------*/
221 void SvtTabAppearanceCfg::SetMiddleMouseButton ( USHORT nSet
)
226 /*--------------------------------------------------------------------
228 --------------------------------------------------------------------*/
230 void SvtTabAppearanceCfg::SetApplicationDefaults ( Application
* pApp
)
232 AllSettings hAppSettings
= pApp
->GetSettings();
233 StyleSettings hAppStyle
= hAppSettings
.GetStyleSettings();
237 // SetStandard...Styles() resets the UseSystemUIFonts flag,
238 // but we don't want to change it now, so save the flag before ...
239 BOOL bUseSystemUIFonts
= hAppStyle
.GetUseSystemUIFonts();
241 switch ( nLookNFeel
)
244 hAppStyle
.SetStandardUnixStyles(); break;
247 hAppStyle
.SetStandardOS2Styles(); break;
250 hAppStyle
.SetStandardMacStyles(); break;
253 hAppStyle
.SetStandardWinStyles(); break;
255 case LookStardivision
:
257 hAppStyle
.SetStandardStyles(); break;
261 hAppStyle
.SetUseSystemUIFonts( bUseSystemUIFonts
);
263 // Screen and ScreenFont Scaling
265 hAppStyle
.SetScreenZoom( nScaleFactor
);
266 hAppStyle
.SetScreenFontZoom( nScaleFactor
);
268 #if defined( UNX ) || defined ( FS_PRIV_DEBUG )
269 // font anti aliasing
270 hAppStyle
.SetAntialiasingMinPixelHeight( nAAMinPixelHeight
);
271 hAppStyle
.SetDisplayOptions( bFontAntialiasing
? 0 : DISPLAY_OPTION_AA_DISABLE
);
276 MouseSettings hMouseSettings
= hAppSettings
.GetMouseSettings();
277 ULONG nMouseOptions
= hMouseSettings
.GetOptions();
279 nMouseOptions
&= ! (MOUSE_OPTION_AUTOCENTERPOS
| MOUSE_OPTION_AUTODEFBTNPOS
);
284 nMouseOptions
|= MOUSE_OPTION_AUTODEFBTNPOS
;
287 nMouseOptions
|= MOUSE_OPTION_AUTOCENTERPOS
;
293 hMouseSettings
.SetOptions(nMouseOptions
);
294 hMouseSettings
.SetMiddleButtonAction(nMiddleMouse
);
296 // Merge and Publish Settings
298 ULONG nFollow
= hMouseSettings
.GetFollow();
300 nFollow
|= MOUSE_FOLLOW_MENU
;
302 nFollow
&= ~MOUSE_FOLLOW_MENU
;
303 hMouseSettings
.SetFollow( nFollow
);
304 sal_uInt16 nTabStyle
= 0;
305 if(bSingleLineTabCtrl
)
306 nTabStyle
|= STYLE_TABCONTROL_SINGLELINE
;
309 nTabStyle
|= STYLE_TABCONTROL_COLOR
;
310 hAppStyle
.SetTabControlStyle(nTabStyle
);
313 hAppSettings
.SetMouseSettings( hMouseSettings
);
315 hAppSettings
.SetStyleSettings( hAppStyle
);
316 pApp
->MergeSystemSettings ( hAppSettings
); // Allow system-settings to apply
317 pApp
->SystemSettingsChanging ( hAppSettings
, NULL
);// Allow overruling of system-settings
318 //is concerned with window drag
320 pApp
->SetSettings ( hAppSettings
);