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