fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / config / apearcfg.cxx
blobfe09f970dc7ca185385fc4e8cd4db08a192a8280
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
33 #if defined UNX
34 #define DEFAULT_AAMINHEIGHT 8
35 #endif
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 )
48 #if defined( UNX )
49 ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT )
50 #endif
51 ,bMenuMouseFollow(sal_False)
52 #if defined( UNX )
53 ,bFontAntialiasing ( sal_True )
54 #endif
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())
69 switch(nProp)
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",
76 #if defined( UNX )
77 case 5: bFontAntialiasing = *(sal_Bool*)pValues->getValue(); break; // "FontAntialising/Enabled",
78 case 6: *pValues >>= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight",
79 #endif
86 SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
90 const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames()
92 static Sequence<OUString> aNames;
93 if(!aNames.getLength())
95 static const sal_Char* aPropNames[] =
97 "FontScaling" // 0
98 ,"Window/Drag" // 1
99 ,"Menu/FollowMouse" // 2
100 ,"Dialog/MousePositioning" // 3
101 ,"Dialog/MiddleMouseButton" // 4
102 #if defined( UNX )
103 ,"FontAntiAliasing/Enabled" // 5
104 ,"FontAntiAliasing/MinPixelHeight" // 6
105 #endif
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 );
115 return aNames;
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++)
127 switch(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",
134 #if defined( UNX )
135 case 5: pValues[nProp].setValue(&bFontAntialiasing, rType); break; // "FontAntialising/Enabled",
136 case 6: pValues[nProp] <<= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight",
137 #endif
140 PutProperties(rNames, aValues);
143 void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence< OUString >& )
147 void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet )
149 nScaleFactor = nSet;
150 SetModified();
153 void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet )
155 nSnapMode = nSet;
156 SetModified();
159 void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet )
161 nMiddleMouse = nSet;
162 SetModified();
165 void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp )
167 AllSettings hAppSettings = pApp->GetSettings();
168 StyleSettings hAppStyle = hAppSettings.GetStyleSettings();
170 // Look & Feel
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();
176 // and set it here
177 hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts );
179 // Screen and ScreenFont Scaling
181 hAppStyle.SetScreenZoom( nScaleFactor );
182 hAppStyle.SetScreenFontZoom( nScaleFactor );
184 #if defined( UNX )
185 // font anti aliasing
186 hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight );
187 hAppStyle.SetDisplayOptions( bFontAntialiasing ? 0 : DISPLAY_OPTION_AA_DISABLE );
188 #endif
190 // Mouse Snap
192 MouseSettings hMouseSettings = hAppSettings.GetMouseSettings();
193 sal_uLong nMouseOptions = hMouseSettings.GetOptions();
195 nMouseOptions &= ~ (MOUSE_OPTION_AUTOCENTERPOS | MOUSE_OPTION_AUTODEFBTNPOS);
197 switch ( nSnapMode )
199 case SnapToButton:
200 nMouseOptions |= MOUSE_OPTION_AUTODEFBTNPOS;
201 break;
202 case SnapToMiddle:
203 nMouseOptions |= MOUSE_OPTION_AUTOCENTERPOS;
204 break;
205 case NoSnap:
206 default:
207 break;
209 hMouseSettings.SetOptions(nMouseOptions);
210 hMouseSettings.SetMiddleButtonAction(nMiddleMouse);
212 // Merge and Publish Settings
214 sal_uLong nFollow = hMouseSettings.GetFollow();
215 if(bMenuMouseFollow)
216 nFollow |= MOUSE_FOLLOW_MENU;
217 else
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: */