summaryrefslogtreecommitdiff
path: root/framework/source/accelerators
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-01-09 20:58:27 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-01-18 17:02:37 +0100
commit7dca32d575ab974e5f42f579bdeda21d2e445efe (patch)
tree420ffff2d8d6a586c666038f52fa7b2879bc2ec1 /framework/source/accelerators
parent72b5343bd16deec540d8cd148cd7aebd74e92c16 (diff)
fwk: Use constructor feature for DocumentAcceleratorConfiguration.
And avoid css::uno::XInitialization protocol. Change-Id: I14daf6409bf0d651d7b23246ba3855f647b3d1ef
Diffstat (limited to 'framework/source/accelerators')
-rw-r--r--framework/source/accelerators/documentacceleratorconfiguration.cxx140
1 files changed, 93 insertions, 47 deletions
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx
index d9e8689a7d42..be029dd46667 100644
--- a/framework/source/accelerators/documentacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx
@@ -17,74 +17,105 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <accelerators/documentacceleratorconfiguration.hxx>
+#include <accelerators/acceleratorconfiguration.hxx>
+#include <accelerators/istoragelistener.hxx>
+#include <accelerators/presethandler.hxx>
#include <xml/acceleratorconfigurationreader.hxx>
-
#include <xml/acceleratorconfigurationwriter.hxx>
-
#include <xml/saxnamespacefilter.hxx>
#include <threadhelp/readguard.hxx>
#include <threadhelp/writeguard.hxx>
-
#include <acceleratorconst.h>
-#include <services.h>
-#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
-
-#include <com/sun/star/io/XTruncate.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <rtl/ref.hxx>
-#include <com/sun/star/embed/ElementModes.hpp>
+using namespace framework;
-#include <com/sun/star/xml/sax/InputSource.hpp>
+namespace {
-#include <com/sun/star/xml/sax/XParser.hpp>
+/**
+ implements a read/write access to a document
+ based accelerator configuration.
+ */
-#include <comphelper/sequenceashashmap.hxx>
-#include <i18nlangtag/languagetag.hxx>
+typedef ::cppu::ImplInheritanceHelper1<
+ XMLBasedAcceleratorConfiguration,
+ css::lang::XServiceInfo> DocumentAcceleratorConfiguration_BASE;
-namespace framework
+class DocumentAcceleratorConfiguration : public DocumentAcceleratorConfiguration_BASE
{
+private:
-//-----------------------------------------------
-// XInterface, XTypeProvider, XServiceInfo
-
-DEFINE_XSERVICEINFO_MULTISERVICE_2(DocumentAcceleratorConfiguration ,
- ::cppu::OWeakObject ,
- "com.sun.star.ui.DocumentAcceleratorConfiguration" ,
- OUString("com.sun.star.comp.framework.DocumentAcceleratorConfiguration"))
-
-DEFINE_INIT_SERVICE(DocumentAcceleratorConfiguration,
- {
- /*Attention
- I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
- to create a new instance of this class by our own supported service factory.
- see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information!
- */
- }
- )
+ //----------------------------------
+ /** points to the root storage of the outside document,
+ where we can read/save our configuration data. */
+ css::uno::Reference< css::embed::XStorage > m_xDocumentRoot;
-//-----------------------------------------------
-DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : DocumentAcceleratorConfiguration_BASE(xContext)
-{
-}
+public:
-//-----------------------------------------------
-DocumentAcceleratorConfiguration::~DocumentAcceleratorConfiguration()
-{
- m_aPresetHandler.removeStorageListener(this);
-}
+ /** initialize this instance and fill the internal cache.
+
+ @param xSMGR
+ reference to an uno service manager, which is used internaly.
+ */
+ DocumentAcceleratorConfiguration(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Sequence< css::uno::Any >& lArguments);
+
+ virtual ~DocumentAcceleratorConfiguration();
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.framework.DocumentAcceleratorConfiguration");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.ui.DocumentAcceleratorConfiguration");
+ return aSeq;
+ }
+
+ // XUIConfigurationStorage
+ virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasStorage()
+ throw(css::uno::RuntimeException);
+
+private:
+
+ /** read all data into the cache. */
+ void impl_ts_fillCache();
+
+ /** forget all currently cached data AND(!)
+ forget all currently used storages. */
+ void impl_ts_clearCache();
+};
//-----------------------------------------------
-void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
- throw(css::uno::Exception ,
- css::uno::RuntimeException)
+DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Sequence< css::uno::Any >& lArguments)
+ : DocumentAcceleratorConfiguration_BASE(xContext)
{
- // SAFE -> ----------------------------------
WriteGuard aWriteLock(m_aLock);
css::uno::Reference<css::embed::XStorage> xRoot;
@@ -101,12 +132,17 @@ void SAL_CALL DocumentAcceleratorConfiguration::initialize(const css::uno::Seque
}
aWriteLock.unlock();
- // <- SAFE ----------------------------------
impl_ts_fillCache();
}
//-----------------------------------------------
+DocumentAcceleratorConfiguration::~DocumentAcceleratorConfiguration()
+{
+ m_aPresetHandler.removeStorageListener(this);
+}
+
+//-----------------------------------------------
void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
throw(css::uno::RuntimeException)
{
@@ -185,4 +221,14 @@ void DocumentAcceleratorConfiguration::impl_ts_clearCache()
} // namespace framework
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &arguments)
+{
+ rtl::Reference<DocumentAcceleratorConfiguration> x(new DocumentAcceleratorConfiguration(context, arguments));
+ x->acquire();
+ return static_cast<cppu::OWeakObject *>(x.get());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */