fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / accelerators / globalacceleratorconfiguration.cxx
bloba20b20a4f511c4cc3f4fbd556d084def839c8b26
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 .
20 #include <accelerators/acceleratorconfiguration.hxx>
21 #include <accelerators/presethandler.hxx>
22 #include <helper/mischelper.hxx>
24 #include <acceleratorconst.h>
26 #include <com/sun/star/util/XChangesNotifier.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <rtl/ref.hxx>
31 #include <vcl/svapp.hxx>
32 #include <i18nlangtag/languagetag.hxx>
34 using namespace framework;
36 namespace {
38 /**
39 implements a read/write access to the global
40 accelerator configuration.
42 typedef ::cppu::ImplInheritanceHelper1<
43 XCUBasedAcceleratorConfiguration,
44 css::lang::XServiceInfo > GlobalAcceleratorConfiguration_BASE;
45 class GlobalAcceleratorConfiguration : public GlobalAcceleratorConfiguration_BASE
47 public:
49 /** initialize this instance and fill the internal cache.
51 @param xSMGR
52 reference to an uno service manager, which is used internally.
54 GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext);
56 /** TODO */
57 virtual ~GlobalAcceleratorConfiguration() {}
59 virtual OUString SAL_CALL getImplementationName()
60 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
62 return OUString("com.sun.star.comp.framework.GlobalAcceleratorConfiguration");
65 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
66 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
68 return cppu::supportsService(this, ServiceName);
71 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
72 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
74 css::uno::Sequence< OUString > aSeq(1);
75 aSeq[0] = "com.sun.star.ui.GlobalAcceleratorConfiguration";
76 return aSeq;
79 // XComponent
80 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 /// This has to be called after when the instance is acquire()'d.
83 void fillCache();
85 private:
87 /** helper to listen for configuration changes without ownership cycle problems */
88 css::uno::Reference< css::util::XChangesListener > m_xCfgListener;
91 GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
92 : GlobalAcceleratorConfiguration_BASE(xContext)
96 void GlobalAcceleratorConfiguration::fillCache()
98 /** read all data into the cache. */
100 #if 0
101 // get current office locale ... but dont cache it.
102 // Otherwise we must be listener on the configuration layer
103 // which seems to superflous for this small implementation .-)
104 // XXX: what is this good for? it was a comphelper::Locale but unused
105 LanguageTag aLanguageTag(m_sLocale);
106 #endif
108 // May be there exists no accelerator config? Handle it gracefully :-)
111 m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
112 XCUBasedAcceleratorConfiguration::reload();
114 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
115 m_xCfgListener = new WeakChangesListener(this);
116 xBroadcaster->addChangesListener(m_xCfgListener);
118 catch(const css::uno::RuntimeException&)
119 { throw; }
120 catch(const css::uno::Exception&)
124 // XComponent.dispose(), #i120029#, to release the cyclic reference
126 void SAL_CALL GlobalAcceleratorConfiguration::dispose()
127 throw(css::uno::RuntimeException, std::exception)
131 css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
132 if ( xBroadcaster.is() )
133 xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
135 catch(const css::uno::RuntimeException&)
136 { throw; }
137 catch(const css::uno::Exception&)
143 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
144 com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(
145 css::uno::XComponentContext *context,
146 css::uno::Sequence<css::uno::Any> const &)
148 GlobalAcceleratorConfiguration *inst = new GlobalAcceleratorConfiguration(context);
149 css::uno::XInterface *acquired_inst = cppu::acquire(inst);
151 inst->fillCache();
153 return acquired_inst;
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */