1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svtools/apearcfg.hxx>
22 #include "com/sun/star/uno/Any.hxx"
24 #include "tools/debug.hxx"
25 #include "vcl/settings.hxx"
26 #include "vcl/svapp.hxx"
27 #include <rtl/logfile.hxx>
28 #include <sal/macros.h>
30 #define DEFAULT_DRAGMODE 2
31 #define DEFAULT_SNAPMODE 0
32 #define DEFAULT_SCALEFACTOR 100
34 #define DEFAULT_AAMINHEIGHT 8
37 using namespace ::rtl
;
38 using namespace ::com::sun::star::uno
;
40 sal_Bool
SvtTabAppearanceCfg::bInitialized
= sal_False
;
42 SvtTabAppearanceCfg::SvtTabAppearanceCfg()
43 :ConfigItem(OUString("Office.Common/View"))
44 ,nDragMode ( DEFAULT_DRAGMODE
)
45 ,nScaleFactor ( DEFAULT_SCALEFACTOR
)
46 ,nSnapMode ( DEFAULT_SNAPMODE
)
47 ,nMiddleMouse ( MOUSE_MIDDLE_AUTOSCROLL
)
49 ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT
)
51 ,bMenuMouseFollow(sal_False
)
53 ,bFontAntialiasing ( sal_True
)
56 RTL_LOGFILE_CONTEXT(aLog
, "svtools SvtTabAppearanceCfg::SvtTabAppearanceCfg()");
58 const Sequence
<OUString
>& rNames
= GetPropertyNames();
59 Sequence
<Any
> aValues
= GetProperties(rNames
);
60 const Any
* pValues
= aValues
.getConstArray();
61 DBG_ASSERT(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
63 if(aValues
.getLength() == rNames
.getLength())
65 for(int nProp
= 0; nProp
< rNames
.getLength(); ++nProp
, ++pValues
)
67 if(pValues
->hasValue())
71 case 0: *pValues
>>= nScaleFactor
; break; //"FontScaling",
72 case 1: *pValues
>>= nDragMode
; break; //"Window/Drag",
73 case 2: bMenuMouseFollow
= *(sal_Bool
*)pValues
->getValue(); break; //"Menu/FollowMouse",
74 case 3: *pValues
>>= nSnapMode
; break; //"Dialog/MousePositioning",
75 case 4: *pValues
>>= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
77 case 5: bFontAntialiasing
= *(sal_Bool
*)pValues
->getValue(); break; // "FontAntialising/Enabled",
78 case 6: *pValues
>>= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
86 SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
90 const Sequence
<OUString
>& SvtTabAppearanceCfg::GetPropertyNames()
92 static Sequence
<OUString
> aNames
;
93 if(!aNames
.getLength())
95 static const sal_Char
* aPropNames
[] =
99 ,"Menu/FollowMouse" // 2
100 ,"Dialog/MousePositioning" // 3
101 ,"Dialog/MiddleMouseButton" // 4
103 ,"FontAntiAliasing/Enabled" // 5
104 ,"FontAntiAliasing/MinPixelHeight" // 6
107 const int nCount
= SAL_N_ELEMENTS( aPropNames
);
108 aNames
.realloc(nCount
);
110 const sal_Char
** pAsciiNames
= aPropNames
;
111 OUString
* pNames
= aNames
.getArray();
112 for(int i
= 0; i
< nCount
; ++i
, ++pNames
, ++pAsciiNames
)
113 *pNames
= OUString::createFromAscii( *pAsciiNames
);
118 void SvtTabAppearanceCfg::Commit()
120 const Sequence
<OUString
>& rNames
= GetPropertyNames();
121 Sequence
<Any
> aValues(rNames
.getLength());
122 Any
* pValues
= aValues
.getArray();
124 const Type
& rType
= ::getBooleanCppuType();
125 for(int nProp
= 0; nProp
< rNames
.getLength(); nProp
++)
129 case 0: pValues
[nProp
] <<= nScaleFactor
; break; // "FontScaling",
130 case 1: pValues
[nProp
] <<= nDragMode
; break; //"Window/Drag",
131 case 2: pValues
[nProp
].setValue(&bMenuMouseFollow
, rType
); break; //"Menu/FollowMouse",
132 case 3: pValues
[nProp
] <<= nSnapMode
; break; //"Dialog/MousePositioning",
133 case 4: pValues
[nProp
] <<= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
135 case 5: pValues
[nProp
].setValue(&bFontAntialiasing
, rType
); break; // "FontAntialising/Enabled",
136 case 6: pValues
[nProp
] <<= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
140 PutProperties(rNames
, aValues
);
143 void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence
< OUString
>& )
147 void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet
)
153 void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet
)
159 void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet
)
165 void SvtTabAppearanceCfg::SetApplicationDefaults ( Application
* pApp
)
167 AllSettings hAppSettings
= pApp
->GetSettings();
168 StyleSettings hAppStyle
= hAppSettings
.GetStyleSettings();
172 // SetStandard...Styles() resets the UseSystemUIFonts flag,
173 // but we don't want to change it now, so save the flag before ...
174 sal_Bool bUseSystemUIFonts
= hAppStyle
.GetUseSystemUIFonts();
175 hAppStyle
.SetStandardStyles();
177 hAppStyle
.SetUseSystemUIFonts( bUseSystemUIFonts
);
179 // Screen and ScreenFont Scaling
181 hAppStyle
.SetScreenZoom( nScaleFactor
);
182 hAppStyle
.SetScreenFontZoom( nScaleFactor
);
185 // font anti aliasing
186 hAppStyle
.SetAntialiasingMinPixelHeight( nAAMinPixelHeight
);
187 hAppStyle
.SetDisplayOptions( bFontAntialiasing
? 0 : DISPLAY_OPTION_AA_DISABLE
);
192 MouseSettings hMouseSettings
= hAppSettings
.GetMouseSettings();
193 sal_uLong nMouseOptions
= hMouseSettings
.GetOptions();
195 nMouseOptions
&= ~ (MOUSE_OPTION_AUTOCENTERPOS
| MOUSE_OPTION_AUTODEFBTNPOS
);
200 nMouseOptions
|= MOUSE_OPTION_AUTODEFBTNPOS
;
203 nMouseOptions
|= MOUSE_OPTION_AUTOCENTERPOS
;
209 hMouseSettings
.SetOptions(nMouseOptions
);
210 hMouseSettings
.SetMiddleButtonAction(nMiddleMouse
);
212 // Merge and Publish Settings
214 sal_uLong nFollow
= hMouseSettings
.GetFollow();
216 nFollow
|= MOUSE_FOLLOW_MENU
;
218 nFollow
&= ~MOUSE_FOLLOW_MENU
;
219 hMouseSettings
.SetFollow( nFollow
);
221 hAppSettings
.SetMouseSettings( hMouseSettings
);
223 hAppSettings
.SetStyleSettings( hAppStyle
);
224 pApp
->MergeSystemSettings ( hAppSettings
); // Allow system-settings to apply
225 pApp
->SystemSettingsChanging ( hAppSettings
, NULL
);// Allow overruling of system-settings
226 //is concerned with window drag
228 pApp
->SetSettings ( hAppSettings
);
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */