xref: /trunk/main/framework/source/services/backingcomp.cxx (revision 6362920db15d1fa11a859386d693abf0788d239c)
16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_framework.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "services/backingcomp.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "backingwindow.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // own includes
30cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
31cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
32cdf0e10cSrcweir #include <classes/droptargetlistener.hxx>
33cdf0e10cSrcweir #include <framework/acceleratorinfo.hxx>
34cdf0e10cSrcweir #include <targets.h>
35cdf0e10cSrcweir #include <properties.h>
36cdf0e10cSrcweir #include <services.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef _FRAMEWORK_HELPID_HRC
39cdf0e10cSrcweir #include <helpid.hrc>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // interface includes
43cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
44cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
45cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
46cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
47cdf0e10cSrcweir #include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
48cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/KeyEvent.hpp>
50cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp>
51cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // other includes
54cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
55cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
56cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
57cdf0e10cSrcweir #include <vcl/keycod.hxx>
58cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
59cdf0e10cSrcweir #include <vcl/svapp.hxx>
60cdf0e10cSrcweir #include <tools/resmgr.hxx>
61cdf0e10cSrcweir #include <tools/urlobj.hxx>
62cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #ifndef _SOLAR_HRC
65cdf0e10cSrcweir #include <svl/solar.hrc>
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir #include <svl/urihelper.hxx>
68cdf0e10cSrcweir #include <osl/file.hxx>
69cdf0e10cSrcweir #include <unotools/configmgr.hxx>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #ifndef _UTL_BOOTSTRAP_HXX_
72cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir 
75cdf0e10cSrcweir namespace framework
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 
78cdf0e10cSrcweir //_______________________________________________
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //_______________________________________________
81cdf0e10cSrcweir 
BackingComp(const css::uno::Reference<css::lang::XMultiServiceFactory> xSMGR)82cdf0e10cSrcweir BackingComp::BackingComp( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR )
83cdf0e10cSrcweir     : ThreadHelpBase    (&Application::GetSolarMutex()                  )
84cdf0e10cSrcweir     , m_xSMGR           (xSMGR                                          )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //_______________________________________________
89cdf0e10cSrcweir 
~BackingComp()90cdf0e10cSrcweir BackingComp::~BackingComp()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //_______________________________________________
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /** return information about supported interfaces.
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     Some interfaces are supported by his class directly, but some other ones are
99cdf0e10cSrcweir     used by aggregation. An instance of this class must provide some window interfaces.
100cdf0e10cSrcweir     But it must represent a VCL window behind such interfaces too! So we use an internal
10153c84c60Smseidel     saved window member to ask it for its interfaces and return it. But we must be aware then,
102cdf0e10cSrcweir     that it can be destroyed from outside too ...
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     @param  aType
105cdf0e10cSrcweir                 describe the required interface type
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     @return An Any holding the instance, which provides the queried interface.
108cdf0e10cSrcweir             Note: There exist two possible results ... this instance itself and her window member!
109cdf0e10cSrcweir  */
110cdf0e10cSrcweir 
queryInterface(const css::uno::Type & aType)111cdf0e10cSrcweir css::uno::Any SAL_CALL BackingComp::queryInterface( /*IN*/ const css::uno::Type& aType )
112cdf0e10cSrcweir     throw(css::uno::RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     css::uno::Any aResult;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     // first look for own supported interfaces
117cdf0e10cSrcweir     aResult = ::cppu::queryInterface(
118cdf0e10cSrcweir                 aType,
119cdf0e10cSrcweir                 static_cast< css::lang::XTypeProvider* >(this),
120cdf0e10cSrcweir                 static_cast< css::lang::XServiceInfo* >(this),
121cdf0e10cSrcweir                 static_cast< css::lang::XInitialization* >(this),
122cdf0e10cSrcweir                 static_cast< css::frame::XController* >(this),
123cdf0e10cSrcweir                 static_cast< css::lang::XComponent* >(this),
124cdf0e10cSrcweir                 static_cast< css::lang::XEventListener* >(this),
125cdf0e10cSrcweir                 static_cast< css::awt::XKeyListener* >(static_cast< css::lang::XEventListener* >(this)));
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     // then look for supported window interfaces
128cdf0e10cSrcweir     // Note: They exist only, if this instance was initialized
129cdf0e10cSrcweir     // with a valid window reference. It's aggregation on demand ...
130cdf0e10cSrcweir     if (!aResult.hasValue())
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         /* SAFE { */
133cdf0e10cSrcweir         ReadGuard aReadLock(m_aLock);
134cdf0e10cSrcweir         if (m_xWindow.is())
135cdf0e10cSrcweir             aResult = m_xWindow->queryInterface(aType);
136cdf0e10cSrcweir         aReadLock.unlock();
137cdf0e10cSrcweir         /* } SAFE */
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     // look for XWeak and XInterface
141cdf0e10cSrcweir     if (!aResult.hasValue())
142cdf0e10cSrcweir         aResult = OWeakObject::queryInterface(aType);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     return aResult;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir //_______________________________________________
148cdf0e10cSrcweir 
149cdf0e10cSrcweir /** increase ref count of this instance.
150cdf0e10cSrcweir  */
151cdf0e10cSrcweir 
acquire()152cdf0e10cSrcweir void SAL_CALL BackingComp::acquire()
153cdf0e10cSrcweir     throw()
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     OWeakObject::acquire();
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir //_______________________________________________
159cdf0e10cSrcweir 
160cdf0e10cSrcweir /** decrease ref count of this instance.
161cdf0e10cSrcweir  */
162cdf0e10cSrcweir 
release()163cdf0e10cSrcweir void SAL_CALL BackingComp::release()
164cdf0e10cSrcweir     throw()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     OWeakObject::release();
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir //_______________________________________________
170cdf0e10cSrcweir 
171cdf0e10cSrcweir /** return collection about all supported interfaces.
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     Optimize this method !
174cdf0e10cSrcweir     We initialize a static variable only one time.
175cdf0e10cSrcweir     And we don't must use a mutex at every call!
176cdf0e10cSrcweir     For the first call; pTypeCollection is NULL -
177cdf0e10cSrcweir     for the second call pTypeCollection is different from NULL!
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     @return A list of all supported interface types.
180cdf0e10cSrcweir */
181cdf0e10cSrcweir 
getTypes()182cdf0e10cSrcweir css::uno::Sequence< css::uno::Type > SAL_CALL BackingComp::getTypes()
183cdf0e10cSrcweir     throw(css::uno::RuntimeException)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     static ::cppu::OTypeCollection* pTypeCollection = NULL;
186cdf0e10cSrcweir     if (!pTypeCollection)
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         /* GLOBAL SAFE { */
189cdf0e10cSrcweir         ::osl::MutexGuard aGlobalLock(::osl::Mutex::getGlobalMutex());
19053c84c60Smseidel         // Control these pointer again ... it can be, that another instance will be faster than this one!
191cdf0e10cSrcweir         if (!pTypeCollection)
192cdf0e10cSrcweir         {
193cdf0e10cSrcweir             /* LOCAL SAFE { */
194cdf0e10cSrcweir             ReadGuard aReadLock(m_aLock);
195cdf0e10cSrcweir             css::uno::Reference< css::lang::XTypeProvider > xProvider(m_xWindow, css::uno::UNO_QUERY);
196cdf0e10cSrcweir             aReadLock.unlock();
197cdf0e10cSrcweir             /* } LOCAL SAFE */
198cdf0e10cSrcweir 
199cdf0e10cSrcweir             css::uno::Sequence< css::uno::Type > lWindowTypes;
200cdf0e10cSrcweir             if (xProvider.is())
201cdf0e10cSrcweir                 lWindowTypes = xProvider->getTypes();
202cdf0e10cSrcweir 
203cdf0e10cSrcweir             static ::cppu::OTypeCollection aTypeCollection(
204cdf0e10cSrcweir                     ::getCppuType((const ::com::sun::star::uno::Reference< css::lang::XInitialization >*)NULL ),
205cdf0e10cSrcweir                     ::getCppuType((const ::com::sun::star::uno::Reference< css::lang::XTypeProvider >*)NULL ),
206cdf0e10cSrcweir                     ::getCppuType((const ::com::sun::star::uno::Reference< css::lang::XServiceInfo >*)NULL ),
207cdf0e10cSrcweir                     ::getCppuType((const ::com::sun::star::uno::Reference< css::frame::XController >*)NULL ),
208cdf0e10cSrcweir                     ::getCppuType((const ::com::sun::star::uno::Reference< css::lang::XComponent >*)NULL ),
209cdf0e10cSrcweir                     lWindowTypes);
210cdf0e10cSrcweir 
211cdf0e10cSrcweir             pTypeCollection = &aTypeCollection;
212cdf0e10cSrcweir         }
213cdf0e10cSrcweir         /* } GLOBAL SAFE */
214cdf0e10cSrcweir     }
215cdf0e10cSrcweir     return pTypeCollection->getTypes();
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
218cdf0e10cSrcweir //_______________________________________________
219cdf0e10cSrcweir 
220cdf0e10cSrcweir /** create one unique Id for all instances of this class.
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     Optimize this method
223cdf0e10cSrcweir     We initialize a static variable only one time. And we don't must use a mutex at every call!
224cdf0e10cSrcweir     For the first call; pID is NULL - for the second call pID is different from NULL!
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     @return A byte array, which represent the unique id.
227cdf0e10cSrcweir */
228cdf0e10cSrcweir 
getImplementationId()229cdf0e10cSrcweir css::uno::Sequence< sal_Int8 > SAL_CALL BackingComp::getImplementationId()
230cdf0e10cSrcweir     throw(css::uno::RuntimeException)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     static ::cppu::OImplementationId* pID = NULL;
233cdf0e10cSrcweir     if (!pID)
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir         /* GLOBAL SAFE { */
236cdf0e10cSrcweir         ::osl::MutexGuard aLock(::osl::Mutex::getGlobalMutex());
23753c84c60Smseidel         // Control these pointer again ... it can be, that another instance will be faster than this one!
238cdf0e10cSrcweir         if (!pID)
239cdf0e10cSrcweir         {
240cdf0e10cSrcweir             static ::cppu::OImplementationId aID(sal_False);
241cdf0e10cSrcweir             pID = &aID;
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir         /* } GLOBAL SAFE */
244cdf0e10cSrcweir     }
245cdf0e10cSrcweir     return pID->getImplementationId();
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //_______________________________________________
249cdf0e10cSrcweir 
250cdf0e10cSrcweir /** returns a static implementation name for this UNO service.
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     Because this value is needed at different places and our class is used
253cdf0e10cSrcweir     by some generic macros too, we have to use a static impl method for that!
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     @see impl_getStaticImplementationName()
256cdf0e10cSrcweir     @see IMPLEMENTATIONNAME
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     @return The implementation name of this class.
259cdf0e10cSrcweir */
260cdf0e10cSrcweir 
getImplementationName()261cdf0e10cSrcweir ::rtl::OUString SAL_CALL BackingComp::getImplementationName()
262cdf0e10cSrcweir     throw(css::uno::RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     return impl_getStaticImplementationName();
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir //_______________________________________________
268cdf0e10cSrcweir 
269cdf0e10cSrcweir /** returns information about supported services.
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     Because this value is needed at different places and our class is used
272cdf0e10cSrcweir     by some generic macros too, we have to use a static impl method for that!
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     @see impl_getStaticSupportedServiceNames()
275cdf0e10cSrcweir     @see SERVICENAME
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     @return <TRUE/> if the queried service is supported;
278cdf0e10cSrcweir             <br><FALSE/> otherwise.
279cdf0e10cSrcweir */
280cdf0e10cSrcweir 
supportsService(const::rtl::OUString & sServiceName)281cdf0e10cSrcweir sal_Bool SAL_CALL BackingComp::supportsService( /*IN*/ const ::rtl::OUString& sServiceName )
282cdf0e10cSrcweir     throw(css::uno::RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir     return (
285cdf0e10cSrcweir             sServiceName.equals(SERVICENAME_STARTMODULE    ) ||
286cdf0e10cSrcweir             sServiceName.equals(SERVICENAME_FRAMECONTROLLER)
287cdf0e10cSrcweir            );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir //_______________________________________________
291cdf0e10cSrcweir 
292cdf0e10cSrcweir /** returns collection of supported services.
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     Because this value is needed at different places and our class is used
295cdf0e10cSrcweir     by some generic macros too, we have to use a static impl method for that!
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     @see impl_getStaticSupportedServiceNames()
298cdf0e10cSrcweir     @see SERVICENAME
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     @return A list of all supported uno service names.
301cdf0e10cSrcweir */
302cdf0e10cSrcweir 
getSupportedServiceNames()303cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL BackingComp::getSupportedServiceNames()
304cdf0e10cSrcweir     throw(css::uno::RuntimeException)
305cdf0e10cSrcweir {
306cdf0e10cSrcweir     return impl_getStaticSupportedServiceNames();
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir //_______________________________________________
310cdf0e10cSrcweir 
311cdf0e10cSrcweir /** returns static implementation name.
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     Because this value is needed at different places and our class is used
314cdf0e10cSrcweir     by some generic macros too, we have to use a static impl method for that!
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     @see impl_getStaticSupportedServiceNames()
317cdf0e10cSrcweir     @see SERVICENAME
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     @return The implementation name of this class.
320cdf0e10cSrcweir */
321cdf0e10cSrcweir 
impl_getStaticImplementationName()322cdf0e10cSrcweir ::rtl::OUString BackingComp::impl_getStaticImplementationName()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     return IMPLEMENTATIONNAME_STARTMODULE;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir //_______________________________________________
328cdf0e10cSrcweir 
329cdf0e10cSrcweir /** returns static list of supported service names.
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     Because this value is needed at different places and our class is used
332cdf0e10cSrcweir     by some generic macros too, we have to use a static impl method for that!
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     @see impl_getStaticSupportedServiceNames()
335cdf0e10cSrcweir     @see SERVICENAME
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     @return A list of all supported uno service names.
338cdf0e10cSrcweir */
339cdf0e10cSrcweir 
impl_getStaticSupportedServiceNames()340cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > BackingComp::impl_getStaticSupportedServiceNames()
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lNames(1);
343cdf0e10cSrcweir     lNames[0] = SERVICENAME_STARTMODULE;
344cdf0e10cSrcweir     return lNames;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir //_______________________________________________
348cdf0e10cSrcweir 
349cdf0e10cSrcweir /** returns a new instance of this class.
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     This factory method is registered inside the UNO runtime
352cdf0e10cSrcweir     and will be called for every createInstance() request from outside,
353cdf0e10cSrcweir     which wish to use this service.
354cdf0e10cSrcweir 
355cdf0e10cSrcweir     @param  xSMGR
356cdf0e10cSrcweir                 reference to the uno service manager, which call us
357cdf0e10cSrcweir                 We use it too, to set it at the new created instance.
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     @return A new instance as uno reference.
360cdf0e10cSrcweir */
361cdf0e10cSrcweir 
impl_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & xSMGR)362cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL BackingComp::impl_createInstance( /*IN*/ const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
363cdf0e10cSrcweir     throw(css::uno::Exception)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir     BackingComp* pObject = new BackingComp(xSMGR);
366cdf0e10cSrcweir     return css::uno::Reference< css::uno::XInterface >(static_cast< ::cppu::OWeakObject* >(pObject), css::uno::UNO_QUERY);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir //_______________________________________________
370cdf0e10cSrcweir 
371cdf0e10cSrcweir /** returns a new factory instance for instances of this class.
372cdf0e10cSrcweir 
373cdf0e10cSrcweir     It uses a helper class of the cppuhelper project as factory.
37453c84c60Smseidel     It will be initialized with all necessary information and
375cdf0e10cSrcweir     will be able afterwards to create instance of this class.
376cdf0e10cSrcweir     This factory call us back inside our method impl_createInstance().
377cdf0e10cSrcweir     So we can create and initialize ourself. Only filtering of creation
378cdf0e10cSrcweir     requests will be done by this factory.
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     @param  xSMGR
381cdf0e10cSrcweir                 reference to the uno service manager, which call us
382cdf0e10cSrcweir 
383cdf0e10cSrcweir     @return A new instance of our factory.
384cdf0e10cSrcweir */
385cdf0e10cSrcweir 
impl_createFactory(const css::uno::Reference<css::lang::XMultiServiceFactory> & xSMGR)386cdf0e10cSrcweir css::uno::Reference< css::lang::XSingleServiceFactory > BackingComp::impl_createFactory( /*IN*/ const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     css::uno::Reference< css::lang::XSingleServiceFactory > xReturn(
389cdf0e10cSrcweir         cppu::createSingleFactory(
390cdf0e10cSrcweir             xSMGR,
391cdf0e10cSrcweir             BackingComp::impl_getStaticImplementationName(),
392cdf0e10cSrcweir             BackingComp::impl_createInstance,
393cdf0e10cSrcweir             BackingComp::impl_getStaticSupportedServiceNames()));
394cdf0e10cSrcweir     return xReturn;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir //_______________________________________________
398cdf0e10cSrcweir 
399cdf0e10cSrcweir /**
400cdf0e10cSrcweir     attach this component to a target frame.
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     We has to use the container window of this frame as parent window of our own component window.
40307a3d7f1SPedro Giffuni     But it's not allowed to work with it really. May another component used it too.
40453c84c60Smseidel     Currently we need it only to create our child component window and support its
405cdf0e10cSrcweir     interfaces inside our queryInterface() method. The user of us must have e.g. the
406cdf0e10cSrcweir     XWindow interface of it to be able to call setComponent(xWindow,xController) at the
407cdf0e10cSrcweir     frame!
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     May he will do the following things:
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     <listing>
412cdf0e10cSrcweir         XController xBackingComp = (XController)UnoRuntime.queryInterface(
413cdf0e10cSrcweir             XController.class,
414cdf0e10cSrcweir             xSMGR.createInstance(SERVICENAME_STARTMODULE));
415cdf0e10cSrcweir 
416cdf0e10cSrcweir         // at this time XWindow isn't present at this instance!
417cdf0e10cSrcweir         XWindow xBackingComp = (XWindow)UnoRuntime.queryInterface(
418cdf0e10cSrcweir             XWindow.class,
419cdf0e10cSrcweir             xBackingComp);
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         // attach controller to the frame
42253c84c60Smseidel         // We will use its container window, to create
423cdf0e10cSrcweir         // the component window. From now we offer the window interfaces!
424cdf0e10cSrcweir         xBackingComp.attachFrame(xFrame);
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         XWindow xBackingComp = (XWindow)UnoRuntime.queryInterface(
427cdf0e10cSrcweir             XWindow.class,
428cdf0e10cSrcweir             xBackingComp);
429cdf0e10cSrcweir 
430cdf0e10cSrcweir         // Our user can set us at the frame as new component
431cdf0e10cSrcweir         xFrame.setComponent(xBackingWin, xBackingComp);
432cdf0e10cSrcweir 
433cdf0e10cSrcweir         // But that had no effect to our view state.
434cdf0e10cSrcweir         // We must be started to create our UI elements like e.g. menu, title, background ...
435cdf0e10cSrcweir         XInitialization xBackingInit = (XInitialization)UnoRuntime.queryInterface(
436cdf0e10cSrcweir             XInitialization.class,
437cdf0e10cSrcweir             xBackingComp);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir         xBackingInit.initialize(lArgs);
440cdf0e10cSrcweir     </listing>
441cdf0e10cSrcweir 
442cdf0e10cSrcweir     @param  xFrame
443cdf0e10cSrcweir                 reference to our new target frame
444cdf0e10cSrcweir 
445cdf0e10cSrcweir     @throw  com::sun::star::uno::RuntimeException
446cdf0e10cSrcweir                 if the given frame reference is wrong or component window couldn't be created
447cdf0e10cSrcweir                 successfully.
448cdf0e10cSrcweir                 We throw it too, if we already attached to a frame. Because we don't support
449cdf0e10cSrcweir                 reparenting of our component window on demand!
450cdf0e10cSrcweir */
451cdf0e10cSrcweir 
attachFrame(const css::uno::Reference<css::frame::XFrame> & xFrame)452cdf0e10cSrcweir void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::frame::XFrame >& xFrame )
453cdf0e10cSrcweir     throw (css::uno::RuntimeException)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir     /* SAFE */
456cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
457cdf0e10cSrcweir 
458cdf0e10cSrcweir     // check some required states
459cdf0e10cSrcweir     if (m_xFrame.is())
460cdf0e10cSrcweir         throw css::uno::RuntimeException(
461cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("already attached"),
462cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
463cdf0e10cSrcweir 
464cdf0e10cSrcweir     if (!xFrame.is())
465cdf0e10cSrcweir         throw css::uno::RuntimeException(
466cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("invalid frame reference"),
467cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     if (!m_xWindow.is())
470cdf0e10cSrcweir         throw css::uno::RuntimeException(
471cfd52e18Smseidel                 ::rtl::OUString::createFromAscii("instance seems to be not or wrong initialized"),
472cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
473cdf0e10cSrcweir 
47453c84c60Smseidel     // save the frame reference
475cdf0e10cSrcweir     m_xFrame = xFrame;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir     // establish drag&drop mode
478cdf0e10cSrcweir     ::framework::DropTargetListener* pDropListener = new ::framework::DropTargetListener(m_xSMGR, m_xFrame);
479cdf0e10cSrcweir     m_xDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >(static_cast< ::cppu::OWeakObject* >(pDropListener), css::uno::UNO_QUERY);
480cdf0e10cSrcweir 
481cdf0e10cSrcweir     css::uno::Reference< css::awt::XDataTransferProviderAccess > xTransfer(m_xSMGR->createInstance(SERVICENAME_VCLTOOLKIT), css::uno::UNO_QUERY);
482cdf0e10cSrcweir     if (xTransfer.is())
483cdf0e10cSrcweir     {
484cdf0e10cSrcweir         css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xTransfer->getDropTarget(m_xWindow);
485cdf0e10cSrcweir         if (xDropTarget.is())
486cdf0e10cSrcweir         {
487cdf0e10cSrcweir             xDropTarget->addDropTargetListener(m_xDropTargetListener);
488cdf0e10cSrcweir             xDropTarget->setActive(sal_True);
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir     }
491cdf0e10cSrcweir 
49253c84c60Smseidel     // initialize the component and its parent window
493cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow();
494cdf0e10cSrcweir     WorkWindow* pParent = (WorkWindow*)VCLUnoHelper::GetWindow(xParentWindow);
495cdf0e10cSrcweir     Window*     pWindow = VCLUnoHelper::GetWindow(m_xWindow);
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     // disable full screen mode of the frame!
498cdf0e10cSrcweir     if (pParent->IsFullScreenMode())
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         pParent->ShowFullScreenMode(sal_False);
501cdf0e10cSrcweir         pParent->SetMenuBarMode(MENUBAR_MODE_NORMAL);
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir     // create the menu bar for the backing component
505cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY_THROW);
506cdf0e10cSrcweir     css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
507cdf0e10cSrcweir     xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
508cdf0e10cSrcweir     if (xLayoutManager.is())
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir         xLayoutManager->lock();
511cdf0e10cSrcweir         xLayoutManager->createElement( DECLARE_ASCII( "private:resource/menubar/menubar"     ));
512*6362920dSJohn Bampton         /* #i85963# new backing window comes without standard bar and statusbar
513cdf0e10cSrcweir         xLayoutManager->createElement( DECLARE_ASCII( "private:resource/toolbar/standardbar" ));
514cdf0e10cSrcweir         xLayoutManager->createElement( DECLARE_ASCII( "private:resource/statusbar/statusbar" ));
515cdf0e10cSrcweir         xLayoutManager->showElement  ( DECLARE_ASCII( "private:resource/toolbar/standardbar" ));
516cdf0e10cSrcweir         xLayoutManager->showElement  ( DECLARE_ASCII( "private:resource/statusbar/statusbar" ));
517cdf0e10cSrcweir         */
518cdf0e10cSrcweir         xLayoutManager->unlock();
519cdf0e10cSrcweir     }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     // set help ID for our canvas
522cdf0e10cSrcweir     pWindow->SetHelpId(HID_BACKINGWINDOW);
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     // inform BackingWindow about frame
525cdf0e10cSrcweir     BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow );
526cdf0e10cSrcweir     if( pBack )
527cdf0e10cSrcweir         pBack->setOwningFrame( m_xFrame );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     aWriteLock.unlock();
530cdf0e10cSrcweir     /* } SAFE */
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir //_______________________________________________
534cdf0e10cSrcweir 
535cdf0e10cSrcweir /** not supported.
536cdf0e10cSrcweir 
537cdf0e10cSrcweir     This component does not know any model. It will be represented by a window and
53853c84c60Smseidel     its controller only.
539cdf0e10cSrcweir 
540cdf0e10cSrcweir     return  <FALSE/> every time.
541cdf0e10cSrcweir  */
542cdf0e10cSrcweir 
attachModel(const css::uno::Reference<css::frame::XModel> &)543cdf0e10cSrcweir sal_Bool SAL_CALL BackingComp::attachModel( /*IN*/ const css::uno::Reference< css::frame::XModel >& )
544cdf0e10cSrcweir     throw (css::uno::RuntimeException)
545cdf0e10cSrcweir {
546cdf0e10cSrcweir     return sal_False;
547cdf0e10cSrcweir }
548cdf0e10cSrcweir 
549cdf0e10cSrcweir //_______________________________________________
550cdf0e10cSrcweir 
551cdf0e10cSrcweir /** not supported.
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     This component does not know any model. It will be represented by a window and
55453c84c60Smseidel     its controller only.
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     return  An empty reference every time.
557cdf0e10cSrcweir  */
558cdf0e10cSrcweir 
getModel()559cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > SAL_CALL BackingComp::getModel()
560cdf0e10cSrcweir     throw (css::uno::RuntimeException)
561cdf0e10cSrcweir {
562cdf0e10cSrcweir     return css::uno::Reference< css::frame::XModel >();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir //_______________________________________________
566cdf0e10cSrcweir 
567cdf0e10cSrcweir /** not supported.
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     return  An empty value.
570cdf0e10cSrcweir  */
571cdf0e10cSrcweir 
getViewData()572cdf0e10cSrcweir css::uno::Any SAL_CALL BackingComp::getViewData()
573cdf0e10cSrcweir     throw (css::uno::RuntimeException)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     return css::uno::Any();
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir //_______________________________________________
579cdf0e10cSrcweir 
580cdf0e10cSrcweir /** not supported.
581cdf0e10cSrcweir 
582cdf0e10cSrcweir     @param  aData
583cdf0e10cSrcweir                 not used.
584cdf0e10cSrcweir  */
585cdf0e10cSrcweir 
restoreViewData(const css::uno::Any &)586cdf0e10cSrcweir void SAL_CALL BackingComp::restoreViewData( /*IN*/ const css::uno::Any& )
587cdf0e10cSrcweir     throw (css::uno::RuntimeException)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir //_______________________________________________
592cdf0e10cSrcweir 
593cdf0e10cSrcweir /** returns the attached frame for this component.
594cdf0e10cSrcweir 
595cdf0e10cSrcweir     @see    attachFrame()
596cdf0e10cSrcweir 
59706fea5ebSmseidel     @return The internally saved frame reference.
598cdf0e10cSrcweir             Can be null, if attachFrame() was not called before.
599cdf0e10cSrcweir  */
600cdf0e10cSrcweir 
getFrame()601cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL BackingComp::getFrame()
602cdf0e10cSrcweir     throw (css::uno::RuntimeException)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir     /* SAFE { */
605cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
606cdf0e10cSrcweir     return m_xFrame;
607cdf0e10cSrcweir     /* } SAFE */
608cdf0e10cSrcweir }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir //_______________________________________________
611cdf0e10cSrcweir 
61253c84c60Smseidel /** ask controller for its current working state.
613cdf0e10cSrcweir 
6141d625a01SJohn Bampton     If somewhere wishes to close this component, it must suspend the controller before.
615cdf0e10cSrcweir     That will be a chance for it to disagree with that AND show any UI for a possible
616cdf0e10cSrcweir     UI user.
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     @param  bSuspend
619cdf0e10cSrcweir                 If its set to sal_True this controller should be suspended.
620cdf0e10cSrcweir                 sal_False will resuspend it.
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     @return sal_True if the request could be finished successfully; sal_False otherwise.
623cdf0e10cSrcweir  */
624cdf0e10cSrcweir 
suspend(sal_Bool)625cdf0e10cSrcweir sal_Bool SAL_CALL BackingComp::suspend( /*IN*/ sal_Bool )
626cdf0e10cSrcweir     throw (css::uno::RuntimeException)
627cdf0e10cSrcweir {
628cdf0e10cSrcweir     /* FIXME ... implemented by using default :-( */
629cdf0e10cSrcweir     return sal_True;
630cdf0e10cSrcweir }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir //_______________________________________________
633cdf0e10cSrcweir 
634cdf0e10cSrcweir /** callback from our window member.
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     Our internal saved window wish to die. It will be disposed from outside (may be the frame)
637cdf0e10cSrcweir     and inform us. We must release its reference only here. Of course we check the given reference
638cdf0e10cSrcweir     here and reject callback from unknown sources.
639cdf0e10cSrcweir 
64007a3d7f1SPedro Giffuni     Note: deregistration as listener isn't necessary here. The broadcaster do it automatically.
641cdf0e10cSrcweir 
642cdf0e10cSrcweir     @param  aEvent
643cdf0e10cSrcweir                 describe the broadcaster of this callback
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     @throw ::com::sun::star::uno::RuntimeException
646cdf0e10cSrcweir                 if the broadcaster doesn't represent the expected window reference.
647cdf0e10cSrcweir */
648cdf0e10cSrcweir 
disposing(const css::lang::EventObject & aEvent)649cdf0e10cSrcweir void SAL_CALL BackingComp::disposing( /*IN*/ const css::lang::EventObject& aEvent )
650cdf0e10cSrcweir     throw(css::uno::RuntimeException)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir     // Attention: dont free m_pAccExec here! see comments inside dtor and
653cdf0e10cSrcweir     // keyPressed() for further details.
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     /* SAFE { */
656cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     if (!aEvent.Source.is() || aEvent.Source!=m_xWindow || !m_xWindow.is())
659cdf0e10cSrcweir         throw css::uno::RuntimeException(
660cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("unexpected source or called twice"),
661cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
662cdf0e10cSrcweir 
663cdf0e10cSrcweir     m_xWindow = css::uno::Reference< css::awt::XWindow >();
664cdf0e10cSrcweir 
665cdf0e10cSrcweir     aWriteLock.unlock();
666cdf0e10cSrcweir     /* } SAFE */
667cdf0e10cSrcweir }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir //_______________________________________________
670cdf0e10cSrcweir 
671cdf0e10cSrcweir /** kill this instance.
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     It can be called from our owner frame only. But there is no possibility to check the calli.
67453c84c60Smseidel     We have to release all our internal used resources and die. From this point we can throw
67553c84c60Smseidel     DisposedExceptions for every further interface request ... but current implementation doesn't do so ...
676cdf0e10cSrcweir 
677cdf0e10cSrcweir */
678cdf0e10cSrcweir 
dispose()679cdf0e10cSrcweir void SAL_CALL BackingComp::dispose()
680cdf0e10cSrcweir     throw(css::uno::RuntimeException)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     /* SAFE { */
683cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     // kill the menu
686cdf0e10cSrcweir     css::util::URL aURL;
687cdf0e10cSrcweir     aURL.Complete = DECLARE_ASCII(".uno:close");
688cdf0e10cSrcweir     css::uno::Reference< css::util::XURLTransformer > xParser(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY);
689cdf0e10cSrcweir     if (xParser.is())
690cdf0e10cSrcweir         xParser->parseStrict(aURL);
691cdf0e10cSrcweir 
692cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatchProvider > xProvider(m_xFrame, css::uno::UNO_QUERY);
693cdf0e10cSrcweir     if (xProvider.is())
694cdf0e10cSrcweir     {
695cdf0e10cSrcweir         css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, SPECIALTARGET_MENUBAR, 0);
696cdf0e10cSrcweir         if (xDispatch.is())
697cdf0e10cSrcweir             xDispatch->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue>());
698cdf0e10cSrcweir     }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     // deregister drag&drop helper
701cdf0e10cSrcweir     if (m_xDropTargetListener.is())
702cdf0e10cSrcweir     {
703cdf0e10cSrcweir         css::uno::Reference< css::awt::XDataTransferProviderAccess > xTransfer(m_xSMGR->createInstance(SERVICENAME_VCLTOOLKIT), css::uno::UNO_QUERY);
704cdf0e10cSrcweir         if (xTransfer.is())
705cdf0e10cSrcweir         {
706cdf0e10cSrcweir             css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xTransfer->getDropTarget(m_xWindow);
707cdf0e10cSrcweir             if (xDropTarget.is())
708cdf0e10cSrcweir             {
709cdf0e10cSrcweir                 xDropTarget->removeDropTargetListener(m_xDropTargetListener);
710cdf0e10cSrcweir                 xDropTarget->setActive(sal_False);
711cdf0e10cSrcweir             }
712cdf0e10cSrcweir         }
713cdf0e10cSrcweir         m_xDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
714cdf0e10cSrcweir     }
715cdf0e10cSrcweir 
716cdf0e10cSrcweir     // stop listening at the window
717cdf0e10cSrcweir     if (m_xWindow.is())
718cdf0e10cSrcweir     {
719cdf0e10cSrcweir         css::uno::Reference< css::lang::XComponent > xBroadcaster(m_xWindow, css::uno::UNO_QUERY);
720cdf0e10cSrcweir         if (xBroadcaster.is())
721cdf0e10cSrcweir         {
722cdf0e10cSrcweir             css::uno::Reference< css::lang::XEventListener > xEventThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
723cdf0e10cSrcweir             xBroadcaster->removeEventListener(xEventThis);
724cdf0e10cSrcweir         }
725cdf0e10cSrcweir         css::uno::Reference< css::awt::XKeyListener > xKeyThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
726cdf0e10cSrcweir         m_xWindow->removeKeyListener(xKeyThis);
727cdf0e10cSrcweir         m_xWindow = css::uno::Reference< css::awt::XWindow >();
728cdf0e10cSrcweir     }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     // forget all other used references
731cdf0e10cSrcweir     m_xFrame  = css::uno::Reference< css::frame::XFrame >();
732cdf0e10cSrcweir     m_xSMGR   = css::uno::Reference< css::lang::XMultiServiceFactory >();
733cdf0e10cSrcweir 
734cdf0e10cSrcweir     aWriteLock.unlock();
735cdf0e10cSrcweir     /* } SAFE */
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir //_______________________________________________
739cdf0e10cSrcweir 
740cdf0e10cSrcweir /** not supported.
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     @param  xListener
743cdf0e10cSrcweir                 not used.
744cdf0e10cSrcweir 
745cdf0e10cSrcweir     @throw  ::com::sun::star::uno::RuntimeException
74653c84c60Smseidel                 because the listener expect to be held alive by this container.
747cdf0e10cSrcweir                 We must inform it about this unsupported feature.
748cdf0e10cSrcweir  */
749cdf0e10cSrcweir 
addEventListener(const css::uno::Reference<css::lang::XEventListener> &)750cdf0e10cSrcweir void SAL_CALL BackingComp::addEventListener( /*IN*/ const css::uno::Reference< css::lang::XEventListener >& )
751cdf0e10cSrcweir     throw(css::uno::RuntimeException)
752cdf0e10cSrcweir {
753cdf0e10cSrcweir     throw css::uno::RuntimeException(
754cdf0e10cSrcweir             ::rtl::OUString::createFromAscii("not supported"),
755cdf0e10cSrcweir             static_cast< ::cppu::OWeakObject* >(this));
756cdf0e10cSrcweir }
757cdf0e10cSrcweir 
758cdf0e10cSrcweir //_______________________________________________
759cdf0e10cSrcweir 
760cdf0e10cSrcweir /** not supported.
761cdf0e10cSrcweir 
76207a3d7f1SPedro Giffuni     Because registration is not supported too, we must do nothing here. Nobody can call this method really.
763cdf0e10cSrcweir 
764cdf0e10cSrcweir     @param  xListener
765cdf0e10cSrcweir                 not used.
766cdf0e10cSrcweir  */
767cdf0e10cSrcweir 
removeEventListener(const css::uno::Reference<css::lang::XEventListener> &)768cdf0e10cSrcweir void SAL_CALL BackingComp::removeEventListener( /*IN*/ const css::uno::Reference< css::lang::XEventListener >& )
769cdf0e10cSrcweir     throw(css::uno::RuntimeException)
770cdf0e10cSrcweir {
771cdf0e10cSrcweir }
772cdf0e10cSrcweir 
773cdf0e10cSrcweir //_______________________________________________
774cdf0e10cSrcweir 
775cdf0e10cSrcweir /**
77653c84c60Smseidel     force initialization for this component.
777cdf0e10cSrcweir 
778cdf0e10cSrcweir     Inside attachFrame() we created our component window. But it was not allowed there, to
77953c84c60Smseidel     initialize it. E.g. the menu must be set at the container window of the frame, which
780cdf0e10cSrcweir     is our parent window. But may at that time another component used it.
78107a3d7f1SPedro Giffuni     That's why our creator has to inform us, when it's time to initialize us really.
78253c84c60Smseidel     Currently only calling of this method must be done. But further implementations
783cdf0e10cSrcweir     can use special in parameter to configure this initialization ...
784cdf0e10cSrcweir 
785cdf0e10cSrcweir     @param  lArgs
786cdf0e10cSrcweir                 currently not used
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     @throw  com::sun::star::uno::RuntimeException
78953c84c60Smseidel                 if some resources are missing
790cdf0e10cSrcweir                 Means if may be attachedFrame() wasn't called before.
791cdf0e10cSrcweir  */
792cdf0e10cSrcweir 
initialize(const css::uno::Sequence<css::uno::Any> & lArgs)793cdf0e10cSrcweir void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno::Any >& lArgs )
794cdf0e10cSrcweir     throw(css::uno::Exception, css::uno::RuntimeException)
795cdf0e10cSrcweir {
796cdf0e10cSrcweir     /* SAFE { */
797cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     if (m_xWindow.is())
800cdf0e10cSrcweir         throw css::uno::Exception(
801cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("already initialized"),
802cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
803cdf0e10cSrcweir 
804cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow > xParentWindow;
805cdf0e10cSrcweir     if (
806cdf0e10cSrcweir         (lArgs.getLength()!=1         ) ||
807cdf0e10cSrcweir         (!(lArgs[0] >>= xParentWindow)) ||
808cdf0e10cSrcweir         (!xParentWindow.is()          )
809cdf0e10cSrcweir        )
810cdf0e10cSrcweir     {
811cdf0e10cSrcweir         throw css::uno::Exception(
812cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("wrong or corrupt argument list"),
813cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
814cdf0e10cSrcweir     }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir     // create the component window
817cdf0e10cSrcweir     Window* pParent   = VCLUnoHelper::GetWindow(xParentWindow);
818cdf0e10cSrcweir     Window* pWindow   = new BackingWindow(pParent);
819cdf0e10cSrcweir             m_xWindow = VCLUnoHelper::GetInterface(pWindow);
820cdf0e10cSrcweir 
821cdf0e10cSrcweir     if (!m_xWindow.is())
822cdf0e10cSrcweir         throw css::uno::RuntimeException(
823cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("couldn't create component window"),
824cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this));
825cdf0e10cSrcweir 
826cdf0e10cSrcweir     // start listening for window disposing
827cdf0e10cSrcweir     // It's set at our owner frame as component window later too. So it will may be disposed there ...
828cdf0e10cSrcweir     css::uno::Reference< css::lang::XComponent > xBroadcaster(m_xWindow, css::uno::UNO_QUERY);
829cdf0e10cSrcweir     if (xBroadcaster.is())
830cdf0e10cSrcweir         xBroadcaster->addEventListener(static_cast< css::lang::XEventListener* >(this));
831cdf0e10cSrcweir 
832cdf0e10cSrcweir     m_xWindow->setVisible(sal_True);
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     aWriteLock.unlock();
835cdf0e10cSrcweir     /* } SAFE */
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir //_______________________________________________
839cdf0e10cSrcweir 
840cdf0e10cSrcweir /**
841cdf0e10cSrcweir  */
842cdf0e10cSrcweir 
keyPressed(const css::awt::KeyEvent &)843cdf0e10cSrcweir void SAL_CALL BackingComp::keyPressed( /*IN*/ const css::awt::KeyEvent&  )
844cdf0e10cSrcweir     throw(css::uno::RuntimeException)
845cdf0e10cSrcweir {
846cdf0e10cSrcweir }
847cdf0e10cSrcweir 
848cdf0e10cSrcweir //_______________________________________________
849cdf0e10cSrcweir 
850cdf0e10cSrcweir /**
851cdf0e10cSrcweir  */
852cdf0e10cSrcweir 
keyReleased(const css::awt::KeyEvent &)853cdf0e10cSrcweir void SAL_CALL BackingComp::keyReleased( /*IN*/ const css::awt::KeyEvent& )
854cdf0e10cSrcweir     throw(css::uno::RuntimeException)
855cdf0e10cSrcweir {
856cdf0e10cSrcweir     /* Attention
85715289133Smseidel         Please use keyPressed() instead of this method. Otherwise it would be possible, that
858cdf0e10cSrcweir         - a key input may be first switch to the backing mode
859cdf0e10cSrcweir         - and this component register itself as key listener too
86053c84c60Smseidel         - and its first event will be a keyReleased() for the already well known event, which switched to the backing mode!
861cdf0e10cSrcweir         So it will be handled twice! document => backing mode => exit app ...
862cdf0e10cSrcweir      */
863cdf0e10cSrcweir }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir } // namespace framework
86653c84c60Smseidel 
86753c84c60Smseidel /* vim: set noet sw=4 ts=4: */
868