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 <sal/macros.h>
29 #define DEFAULT_DRAGMODE 2
30 #define DEFAULT_SNAPMODE 0
31 #define DEFAULT_SCALEFACTOR 100
33 #define DEFAULT_AAMINHEIGHT 8
36 using namespace ::rtl
;
37 using namespace ::com::sun::star::uno
;
39 sal_Bool
SvtTabAppearanceCfg::bInitialized
= sal_False
;
41 SvtTabAppearanceCfg::SvtTabAppearanceCfg()
42 :ConfigItem(OUString("Office.Common/View"))
43 ,nDragMode ( DEFAULT_DRAGMODE
)
44 ,nScaleFactor ( DEFAULT_SCALEFACTOR
)
45 ,nSnapMode ( DEFAULT_SNAPMODE
)
46 ,nMiddleMouse ( MOUSE_MIDDLE_AUTOSCROLL
)
48 ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT
)
50 ,bMenuMouseFollow(sal_False
)
52 ,bFontAntialiasing ( sal_True
)
55 const Sequence
<OUString
>& rNames
= GetPropertyNames();
56 Sequence
<Any
> aValues
= GetProperties(rNames
);
57 const Any
* pValues
= aValues
.getConstArray();
58 DBG_ASSERT(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
60 if(aValues
.getLength() == rNames
.getLength())
62 for(int nProp
= 0; nProp
< rNames
.getLength(); ++nProp
, ++pValues
)
64 if(pValues
->hasValue())
68 case 0: *pValues
>>= nScaleFactor
; break; //"FontScaling",
69 case 1: *pValues
>>= nDragMode
; break; //"Window/Drag",
70 case 2: bMenuMouseFollow
= *(sal_Bool
*)pValues
->getValue(); break; //"Menu/FollowMouse",
71 case 3: *pValues
>>= nSnapMode
; break; //"Dialog/MousePositioning",
72 case 4: *pValues
>>= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
74 case 5: bFontAntialiasing
= *(sal_Bool
*)pValues
->getValue(); break; // "FontAntialising/Enabled",
75 case 6: *pValues
>>= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
83 SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
87 const Sequence
<OUString
>& SvtTabAppearanceCfg::GetPropertyNames()
89 static Sequence
<OUString
> aNames
;
90 if(!aNames
.getLength())
92 static const sal_Char
* aPropNames
[] =
96 ,"Menu/FollowMouse" // 2
97 ,"Dialog/MousePositioning" // 3
98 ,"Dialog/MiddleMouseButton" // 4
100 ,"FontAntiAliasing/Enabled" // 5
101 ,"FontAntiAliasing/MinPixelHeight" // 6
104 const int nCount
= SAL_N_ELEMENTS( aPropNames
);
105 aNames
.realloc(nCount
);
107 const sal_Char
** pAsciiNames
= aPropNames
;
108 OUString
* pNames
= aNames
.getArray();
109 for(int i
= 0; i
< nCount
; ++i
, ++pNames
, ++pAsciiNames
)
110 *pNames
= OUString::createFromAscii( *pAsciiNames
);
115 void SvtTabAppearanceCfg::Commit()
117 const Sequence
<OUString
>& rNames
= GetPropertyNames();
118 Sequence
<Any
> aValues(rNames
.getLength());
119 Any
* pValues
= aValues
.getArray();
121 const Type
& rType
= ::getBooleanCppuType();
122 for(int nProp
= 0; nProp
< rNames
.getLength(); nProp
++)
126 case 0: pValues
[nProp
] <<= nScaleFactor
; break; // "FontScaling",
127 case 1: pValues
[nProp
] <<= nDragMode
; break; //"Window/Drag",
128 case 2: pValues
[nProp
].setValue(&bMenuMouseFollow
, rType
); break; //"Menu/FollowMouse",
129 case 3: pValues
[nProp
] <<= nSnapMode
; break; //"Dialog/MousePositioning",
130 case 4: pValues
[nProp
] <<= nMiddleMouse
; break; //"Dialog/MiddleMouseButton",
132 case 5: pValues
[nProp
].setValue(&bFontAntialiasing
, rType
); break; // "FontAntialising/Enabled",
133 case 6: pValues
[nProp
] <<= nAAMinPixelHeight
; break; // "FontAntialising/MinPixelHeight",
137 PutProperties(rNames
, aValues
);
140 void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence
< OUString
>& )
144 void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet
)
150 void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet
)
156 void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet
)
162 void SvtTabAppearanceCfg::SetApplicationDefaults ( Application
* pApp
)
164 AllSettings hAppSettings
= pApp
->GetSettings();
165 StyleSettings hAppStyle
= hAppSettings
.GetStyleSettings();
169 // SetStandard...Styles() resets the UseSystemUIFonts flag,
170 // but we don't want to change it now, so save the flag before ...
171 sal_Bool bUseSystemUIFonts
= hAppStyle
.GetUseSystemUIFonts();
172 hAppStyle
.SetStandardStyles();
174 hAppStyle
.SetUseSystemUIFonts( bUseSystemUIFonts
);
176 // Screen and ScreenFont Scaling
178 hAppStyle
.SetScreenZoom( nScaleFactor
);
179 hAppStyle
.SetScreenFontZoom( nScaleFactor
);
182 // font anti aliasing
183 hAppStyle
.SetAntialiasingMinPixelHeight( nAAMinPixelHeight
);
184 hAppStyle
.SetDisplayOptions( bFontAntialiasing
? 0 : DISPLAY_OPTION_AA_DISABLE
);
189 MouseSettings hMouseSettings
= hAppSettings
.GetMouseSettings();
190 sal_uLong nMouseOptions
= hMouseSettings
.GetOptions();
192 nMouseOptions
&= ~ (MOUSE_OPTION_AUTOCENTERPOS
| MOUSE_OPTION_AUTODEFBTNPOS
);
197 nMouseOptions
|= MOUSE_OPTION_AUTODEFBTNPOS
;
200 nMouseOptions
|= MOUSE_OPTION_AUTOCENTERPOS
;
206 hMouseSettings
.SetOptions(nMouseOptions
);
207 hMouseSettings
.SetMiddleButtonAction(nMiddleMouse
);
209 // Merge and Publish Settings
211 sal_uLong nFollow
= hMouseSettings
.GetFollow();
213 nFollow
|= MOUSE_FOLLOW_MENU
;
215 nFollow
&= ~MOUSE_FOLLOW_MENU
;
216 hMouseSettings
.SetFollow( nFollow
);
218 hAppSettings
.SetMouseSettings( hMouseSettings
);
220 hAppSettings
.SetStyleSettings( hAppStyle
);
221 pApp
->MergeSystemSettings ( hAppSettings
); // Allow system-settings to apply
222 pApp
->SystemSettingsChanging ( hAppSettings
, NULL
);// Allow overruling of system-settings
223 //is concerned with window drag
225 pApp
->SetSettings ( hAppSettings
);
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */