LibreOffice Module ucb (master)  1
ucb.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_UCB_SOURCE_CORE_UCB_HXX
21 #define INCLUDED_UCB_SOURCE_CORE_UCB_HXX
22 
23 
24 #include <com/sun/star/ucb/CheckinArgument.hpp>
25 #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
26 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/util/XChangesListener.hpp>
31 #include <com/sun/star/util/XChangesNotifier.hpp>
32 
33 #include <cppuhelper/implbase.hxx>
34 #include <osl/mutex.hxx>
35 #include "providermap.hxx"
37 
38 #include <memory>
39 
40 
41 #define UCB_SERVICE_NAME "com.sun.star.ucb.UniversalContentBroker"
42 
43 
44 namespace comphelper { class OInterfaceContainerHelper2; }
45 
46 namespace com { namespace sun { namespace star { namespace ucb {
47  class XCommandInfo;
48  struct GlobalTransferCommandArgument2;
49 } } } }
50 
52  public cppu::WeakImplHelper<
53  css::ucb::XUniversalContentBroker,
54  css::lang::XServiceInfo,
55  css::lang::XInitialization,
56  css::util::XChangesListener>
57 {
58 public:
59  explicit UniversalContentBroker( const css::uno::Reference< css::uno::XComponentContext >& xContext );
60  virtual ~UniversalContentBroker() override;
61 
62  // XServiceInfo
63  virtual OUString SAL_CALL getImplementationName() override;
64  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
65  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
66 
67  static OUString getImplementationName_Static();
68  static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
69 
70  static css::uno::Reference< css::lang::XSingleServiceFactory >
71  createServiceFactory( const css::uno::Reference<
72  css::lang::XMultiServiceFactory >& rxServiceMgr );
73 
74  // XComponent
75  virtual void SAL_CALL
76  dispose() override;
77  virtual void SAL_CALL
78  addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
79  virtual void SAL_CALL
80  removeEventListener( const css::uno::Reference<
81  css::lang::XEventListener >& Listener ) override;
82 
83  // XInitialization
84  virtual void SAL_CALL
85  initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
86 
87  // XContentProviderManager
88  virtual css::uno::Reference< css::ucb::XContentProvider > SAL_CALL
89  registerContentProvider( const css::uno::Reference< css::ucb::XContentProvider >& Provider,
90  const OUString& Scheme,
91  sal_Bool ReplaceExisting ) override;
92  virtual void SAL_CALL
93  deregisterContentProvider( const css::uno::Reference< css::ucb::XContentProvider >& Provider,
94  const OUString& Scheme ) override;
95  virtual css::uno::Sequence< css::ucb::ContentProviderInfo > SAL_CALL
96  queryContentProviders() override;
97  virtual css::uno::Reference< css::ucb::XContentProvider > SAL_CALL
98  queryContentProvider( const OUString& Identifier ) override;
99 
100  // XContentProvider
101  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
102  queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
103  virtual sal_Int32 SAL_CALL
104  compareContentIds( const css::uno::Reference< css::ucb::XContentIdentifier >& Id1,
105  const css::uno::Reference< css::ucb::XContentIdentifier >& Id2 ) override;
106 
107  // XContentIdentifierFactory
108  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
109  createContentIdentifier( const OUString& ContentId ) override;
110 
111  // XCommandProcessor
112  virtual sal_Int32 SAL_CALL
113  createCommandIdentifier() override;
114  virtual css::uno::Any SAL_CALL
115  execute( const css::ucb::Command& aCommand,
116  sal_Int32 CommandId,
117  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
118  virtual void SAL_CALL
119  abort( sal_Int32 CommandId ) override;
120 
121  // XCommandProcessor2
122  virtual void SAL_CALL releaseCommandIdentifier(sal_Int32 aCommandId) override;
123 
124  // XChangesListener
125  virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& Event ) override;
126 
127  // XEventListener ( base of XChangesLisetenr )
128  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
129 
130 private:
131  css::uno::Reference< css::ucb::XContentProvider >
132  queryContentProvider( const OUString& Identifier,
133  bool bResolved );
134 
135  static css::uno::Reference< css::ucb::XCommandInfo >
136  getCommandInfo();
137 
139  void
141  const css::ucb::GlobalTransferCommandArgument2 & rArg,
142  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
143 
145  css::uno::Any checkIn( const css::ucb::CheckinArgument& rArg,
146  const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv );
147 
148 
150  void configureUcb();
151 
153  const OUString & rKey1,
154  const OUString & rKey2,
155  ucbhelper::ContentProviderDataList & rListToFill);
156 
158 
159  css::uno::Reference<
160  css::uno::XComponentContext > m_xContext;
161 
162  css::uno::Reference<
163  css::util::XChangesNotifier > m_xNotifier;
164 
165  css::uno::Sequence< css::uno::Any > m_aArguments;
167  osl::Mutex m_aMutex;
168  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners;
169  sal_Int32 m_nCommandId;
170 };
171 
172 #endif // INCLUDED_UCB_SOURCE_CORE_UCB_HXX
173 
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
Definition: ucb.hxx:168
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucb.cxx:259
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: ucb.cxx:697
css::uno::Sequence< css::uno::Any > m_aArguments
Definition: ucb.hxx:165
void globalTransfer(const css::ucb::GlobalTransferCommandArgument2 &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
Definition: ucbcmds.cxx:1544
virtual void SAL_CALL abort(sal_Int32 CommandId) override
Definition: ucb.cxx:647
virtual css::uno::Reference< css::ucb::XContentProvider > SAL_CALL queryContentProvider(const OUString &Identifier) override
Definition: ucb.cxx:451
virtual void SAL_CALL dispose() override
Definition: ucb.cxx:244
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: ucb.cxx:293
bool getContentProviderData(const OUString &rKey1, const OUString &rKey2, ucbhelper::ContentProviderDataList &rListToFill)
Definition: ucb.cxx:768
std::vector< ContentProviderData > ContentProviderDataList
void prepareAndRegister(const ucbhelper::ContentProviderDataList &rData)
Definition: ucb.cxx:745
virtual void SAL_CALL deregisterContentProvider(const css::uno::Reference< css::ucb::XContentProvider > &Provider, const OUString &Scheme) override
Definition: ucb.cxx:393
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
Definition: ucb.cxx:552
unsigned char sal_Bool
virtual sal_Int32 SAL_CALL createCommandIdentifier() override
Definition: ucb.cxx:542
virtual css::uno::Reference< css::ucb::XContentProvider > SAL_CALL registerContentProvider(const css::uno::Reference< css::ucb::XContentProvider > &Provider, const OUString &Scheme, sal_Bool ReplaceExisting) override
Definition: ucb.cxx:347
css::uno::Any checkIn(const css::ucb::CheckinArgument &rArg, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
Definition: ucbcmds.cxx:1864
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucb.cxx:270
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL createContentIdentifier(const OUString &ContentId) override
Definition: ucb.cxx:510
virtual ~UniversalContentBroker() override
Definition: ucb.cxx:235
virtual OUString SAL_CALL getImplementationName() override
static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxServiceMgr)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucb.hxx:160
osl::Mutex m_aMutex
Definition: ucb.hxx:167
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
static css::uno::Reference< css::ucb::XCommandInfo > getCommandInfo()
Definition: ucbcmds.cxx:1538
ProviderMap_Impl m_aProviders
Definition: ucb.hxx:166
static OUString getImplementationName_Static()
virtual css::uno::Sequence< css::ucb::ContentProviderInfo > SAL_CALL queryContentProviders() override
Definition: ucb.cxx:426
virtual sal_Int32 SAL_CALL compareContentIds(const css::uno::Reference< css::ucb::XContentIdentifier > &Id1, const css::uno::Reference< css::ucb::XContentIdentifier > &Id2) override
Definition: ucb.cxx:483
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: ucb.cxx:309
virtual void SAL_CALL releaseCommandIdentifier(sal_Int32 aCommandId) override
Definition: ucb.cxx:640
UniversalContentBroker(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: ucb.cxx:224
sal_Int32 m_nCommandId
Definition: ucb.hxx:169
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier) override
Definition: ucb.cxx:462
css::uno::Reference< css::util::XChangesNotifier > m_xNotifier
Definition: ucb.hxx:163
virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent &Event) override
Definition: ucb.cxx:657