1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: backingcomp.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_framework.hxx"
35 #include "services/backingcomp.hxx"
37 #include "backingwindow.hxx"
39 //_______________________________________________
41 #include <threadhelp/readguard.hxx>
42 #include <threadhelp/writeguard.hxx>
43 #include <classes/droptargetlistener.hxx>
44 #include <helper/acceleratorinfo.hxx>
46 #include <properties.h>
49 #ifndef _FRAMEWORK_HELPID_HRC
53 //_______________________________________________
55 #include <com/sun/star/beans/NamedValue.hpp>
56 #include <com/sun/star/util/XURLTransformer.hpp>
57 #include <com/sun/star/frame/XDispatchProvider.hpp>
58 #include <com/sun/star/beans/XPropertySet.hpp>
59 #include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
60 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
61 #include <com/sun/star/awt/KeyEvent.hpp>
62 #include <com/sun/star/awt/KeyModifier.hpp>
63 #include <com/sun/star/frame/XLayoutManager.hpp>
65 //_______________________________________________
67 #include <cppuhelper/typeprovider.hxx>
68 #include <cppuhelper/factory.hxx>
69 #include <toolkit/helper/vclunohelper.hxx>
70 #include <vcl/keycod.hxx>
71 #include <vcl/wrkwin.hxx>
72 #include <vcl/svapp.hxx>
73 #include <tools/resmgr.hxx>
74 #include <tools/urlobj.hxx>
75 #include <rtl/ustrbuf.hxx>
78 #include <svtools/solar.hrc>
80 #include <svtools/urihelper.hxx>
81 #include <osl/file.hxx>
82 #include <unotools/configmgr.hxx>
84 #ifndef _UTL_BOOTSTRAP_HXX_
85 #include <unotools/bootstrap.hxx>
91 //_______________________________________________
93 //_______________________________________________
95 BackingComp::BackingComp( const css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR
)
96 : ThreadHelpBase (&Application::GetSolarMutex() )
101 //_______________________________________________
103 BackingComp::~BackingComp()
107 //_______________________________________________
109 /** return information about supported interfaces.
111 Some interfaces are supported by his class directly, but some other ones are
112 used by aggregation. An instance of this class must provide some window interfaces.
113 But it must represent a VCL window behind such interfaces too! So we use an internal
114 saved window member to ask it for it's interfaces and return it. But we must be aware then,
115 that it can be destroyed from outside too ...
118 describe the required interface type
120 @return An Any holding the instance, which provides the queried interface.
121 Note: There exist two possible results ... this instance itself and her window member!
124 css::uno::Any SAL_CALL
BackingComp::queryInterface( /*IN*/ const css::uno::Type
& aType
)
125 throw(css::uno::RuntimeException
)
127 css::uno::Any aResult
;
129 // first look for own supported interfaces
130 aResult
= ::cppu::queryInterface(
132 static_cast< css::lang::XTypeProvider
* >(this),
133 static_cast< css::lang::XServiceInfo
* >(this),
134 static_cast< css::lang::XInitialization
* >(this),
135 static_cast< css::frame::XController
* >(this),
136 static_cast< css::lang::XComponent
* >(this),
137 static_cast< css::lang::XEventListener
* >(this),
138 static_cast< css::awt::XKeyListener
* >(static_cast< css::lang::XEventListener
* >(this)));
140 // then look for supported window interfaces
141 // Note: They exist only, if this instance was initialized
142 // with a valid window reference. It's aggregation on demand ...
143 if (!aResult
.hasValue())
146 ReadGuard
aReadLock(m_aLock
);
148 aResult
= m_xWindow
->queryInterface(aType
);
153 // look for XWeak and XInterface
154 if (!aResult
.hasValue())
155 aResult
= OWeakObject::queryInterface(aType
);
160 //_______________________________________________
162 /** increase ref count of this instance.
165 void SAL_CALL
BackingComp::acquire()
168 OWeakObject::acquire();
171 //_______________________________________________
173 /** decrease ref count of this instance.
176 void SAL_CALL
BackingComp::release()
179 OWeakObject::release();
182 //_______________________________________________
184 /** return collection about all supported interfaces.
186 Optimize this method !
187 We initialize a static variable only one time.
188 And we don't must use a mutex at every call!
189 For the first call; pTypeCollection is NULL -
190 for the second call pTypeCollection is different from NULL!
192 @return A list of all supported interface types.
195 css::uno::Sequence
< css::uno::Type
> SAL_CALL
BackingComp::getTypes()
196 throw(css::uno::RuntimeException
)
198 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
199 if (!pTypeCollection
)
202 ::osl::MutexGuard
aGlobalLock(::osl::Mutex::getGlobalMutex());
203 // Control these pointer again ... it can be, that another instance will be faster then this one!
204 if (!pTypeCollection
)
207 ReadGuard
aReadLock(m_aLock
);
208 css::uno::Reference
< css::lang::XTypeProvider
> xProvider(m_xWindow
, css::uno::UNO_QUERY
);
212 css::uno::Sequence
< css::uno::Type
> lWindowTypes
;
214 lWindowTypes
= xProvider
->getTypes();
216 static ::cppu::OTypeCollection
aTypeCollection(
217 ::getCppuType((const ::com::sun::star::uno::Reference
< css::lang::XInitialization
>*)NULL
),
218 ::getCppuType((const ::com::sun::star::uno::Reference
< css::lang::XTypeProvider
>*)NULL
),
219 ::getCppuType((const ::com::sun::star::uno::Reference
< css::lang::XServiceInfo
>*)NULL
),
220 ::getCppuType((const ::com::sun::star::uno::Reference
< css::frame::XController
>*)NULL
),
221 ::getCppuType((const ::com::sun::star::uno::Reference
< css::lang::XComponent
>*)NULL
),
224 pTypeCollection
= &aTypeCollection
;
228 return pTypeCollection
->getTypes();
231 //_______________________________________________
233 /** create one unique Id for all instances of this class.
236 We initialize a static variable only one time. And we don't must use a mutex at every call!
237 For the first call; pID is NULL - for the second call pID is different from NULL!
239 @return A byte array, which represent the unique id.
242 css::uno::Sequence
< sal_Int8
> SAL_CALL
BackingComp::getImplementationId()
243 throw(css::uno::RuntimeException
)
245 static ::cppu::OImplementationId
* pID
= NULL
;
249 ::osl::MutexGuard
aLock(::osl::Mutex::getGlobalMutex());
250 // Control these pointer again ... it can be, that another instance will be faster then this one!
253 static ::cppu::OImplementationId
aID(sal_False
);
258 return pID
->getImplementationId();
261 //_______________________________________________
263 /** returns a static implementation name for this UNO service.
265 Because this value is needed at different places and our class is used
266 by some generic macros too, we have to use a static impl method for that!
268 @see impl_getStaticImplementationName()
269 @see IMPLEMENTATIONNAME
271 @return The implementation name of this class.
274 ::rtl::OUString SAL_CALL
BackingComp::getImplementationName()
275 throw(css::uno::RuntimeException
)
277 return impl_getStaticImplementationName();
280 //_______________________________________________
282 /** returns information about supported services.
284 Because this value is needed at different places and our class is used
285 by some generic macros too, we have to use a static impl method for that!
287 @see impl_getStaticSupportedServiceNames()
290 @return <TRUE/> if the queried service is supported;
291 <br><FALSE/> otherwise.
294 sal_Bool SAL_CALL
BackingComp::supportsService( /*IN*/ const ::rtl::OUString
& sServiceName
)
295 throw(css::uno::RuntimeException
)
298 sServiceName
.equals(SERVICENAME_STARTMODULE
) ||
299 sServiceName
.equals(SERVICENAME_FRAMECONTROLLER
)
303 //_______________________________________________
305 /** returns collection of supported services.
307 Because this value is needed at different places and our class is used
308 by some generic macros too, we have to use a static impl method for that!
310 @see impl_getStaticSupportedServiceNames()
313 @return A list of all supported uno service names.
316 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
BackingComp::getSupportedServiceNames()
317 throw(css::uno::RuntimeException
)
319 return impl_getStaticSupportedServiceNames();
322 //_______________________________________________
324 /** returns static implementation name.
326 Because this value is needed at different places and our class is used
327 by some generic macros too, we have to use a static impl method for that!
329 @see impl_getStaticSupportedServiceNames()
332 @return The implementation name of this class.
335 ::rtl::OUString
BackingComp::impl_getStaticImplementationName()
337 return IMPLEMENTATIONNAME_STARTMODULE
;
340 //_______________________________________________
342 /** returns static list of supported service names.
344 Because this value is needed at different places and our class is used
345 by some generic macros too, we have to use a static impl method for that!
347 @see impl_getStaticSupportedServiceNames()
350 @return A list of all supported uno service names.
353 css::uno::Sequence
< ::rtl::OUString
> BackingComp::impl_getStaticSupportedServiceNames()
355 css::uno::Sequence
< ::rtl::OUString
> lNames(1);
356 lNames
[0] = SERVICENAME_STARTMODULE
;
360 //_______________________________________________
362 /** returns a new instance of this class.
364 This factory method is registered inside the UNO runtime
365 and will be called for every createInstance() request from outside,
366 which wish to use this service.
369 reference to the uno service manager, which call us
370 We use it too, to set it at the new created instance.
372 @return A new instance as uno reference.
375 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
BackingComp::impl_createInstance( /*IN*/ const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
)
376 throw(css::uno::Exception
)
378 BackingComp
* pObject
= new BackingComp(xSMGR
);
379 return css::uno::Reference
< css::uno::XInterface
>(static_cast< ::cppu::OWeakObject
* >(pObject
), css::uno::UNO_QUERY
);
382 //_______________________________________________
384 /** returns a new factory instance for instances of this class.
386 It uses a helper class of the cppuhelper project as factory.
387 It will be initialized with all neccessary informations and
388 will be able afterwards to create instance of this class.
389 This factory call us back inside our method impl_createInstance().
390 So we can create and initialize ourself. Only filtering of creation
391 requests will be done by this factory.
394 reference to the uno service manager, which call us
396 @return A new instance of our factory.
399 css::uno::Reference
< css::lang::XSingleServiceFactory
> BackingComp::impl_createFactory( /*IN*/ const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
)
401 css::uno::Reference
< css::lang::XSingleServiceFactory
> xReturn(
402 cppu::createSingleFactory(
404 BackingComp::impl_getStaticImplementationName(),
405 BackingComp::impl_createInstance
,
406 BackingComp::impl_getStaticSupportedServiceNames()));
410 //_______________________________________________
413 attach this component to a target frame.
415 We has to use the container window of this frame as parent window of our own component window.
416 But it's not allowed to work with it realy. May another component used it too.
417 Currently we need it only to create our child component window and support it's
418 interfaces inside our queryInterface() method. The user of us must have e.g. the
419 XWindow interface of it to be able to call setComponent(xWindow,xController) at the
422 May he will do the following things:
425 XController xBackingComp = (XController)UnoRuntime.queryInterface(
427 xSMGR.createInstance(SERVICENAME_STARTMODULE));
429 // at this time XWindow isn't present at this instance!
430 XWindow xBackingComp = (XWindow)UnoRuntime.queryInterface(
434 // attach controller to the frame
435 // We will use it's container window, to create
436 // the component window. From now we offer the window interfaces!
437 xBackingComp.attachFrame(xFrame);
439 XWindow xBackingComp = (XWindow)UnoRuntime.queryInterface(
443 // Our user can set us at the frame as new component
444 xFrame.setComponent(xBackingWin, xBackingComp);
446 // But that had no effect to our view state.
447 // We must be started to create our UI elements like e.g. menu, title, background ...
448 XInitialization xBackingInit = (XInitialization)UnoRuntime.queryInterface(
449 XInitialization.class,
452 xBackingInit.initialize(lArgs);
456 reference to our new target frame
458 @throw com::sun::star::uno::RuntimeException
459 if the given frame reference is wrong or component window couldn't be created
461 We throw it too, if we already attached to a frame. Because we don't support
462 reparenting of our component window on demand!
465 void SAL_CALL
BackingComp::attachFrame( /*IN*/ const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
466 throw (css::uno::RuntimeException
)
469 WriteGuard
aWriteLock(m_aLock
);
471 // check some required states
473 throw css::uno::RuntimeException(
474 ::rtl::OUString::createFromAscii("already attached"),
475 static_cast< ::cppu::OWeakObject
* >(this));
478 throw css::uno::RuntimeException(
479 ::rtl::OUString::createFromAscii("invalid frame reference"),
480 static_cast< ::cppu::OWeakObject
* >(this));
483 throw css::uno::RuntimeException(
484 ::rtl::OUString::createFromAscii("instance seams to be not or wrong initialized"),
485 static_cast< ::cppu::OWeakObject
* >(this));
487 // safe the frame reference
490 // establish drag&drop mode
491 ::framework::DropTargetListener
* pDropListener
= new ::framework::DropTargetListener(m_xSMGR
, m_xFrame
);
492 m_xDropTargetListener
= css::uno::Reference
< css::datatransfer::dnd::XDropTargetListener
>(static_cast< ::cppu::OWeakObject
* >(pDropListener
), css::uno::UNO_QUERY
);
494 css::uno::Reference
< css::awt::XDataTransferProviderAccess
> xTransfer(m_xSMGR
->createInstance(SERVICENAME_VCLTOOLKIT
), css::uno::UNO_QUERY
);
497 css::uno::Reference
< css::datatransfer::dnd::XDropTarget
> xDropTarget
= xTransfer
->getDropTarget(m_xWindow
);
498 if (xDropTarget
.is())
500 xDropTarget
->addDropTargetListener(m_xDropTargetListener
);
501 xDropTarget
->setActive(sal_True
);
505 // initialize the component and it's parent window
506 css::uno::Reference
< css::awt::XWindow
> xParentWindow
= xFrame
->getContainerWindow();
507 WorkWindow
* pParent
= (WorkWindow
*)VCLUnoHelper::GetWindow(xParentWindow
);
508 Window
* pWindow
= VCLUnoHelper::GetWindow(m_xWindow
);
510 // disable full screen mode of the frame!
511 if (pParent
->IsFullScreenMode())
513 pParent
->ShowFullScreenMode(FALSE
);
514 pParent
->SetMenuBarMode(MENUBAR_MODE_NORMAL
);
517 // create the menu bar for the backing component
518 css::uno::Reference
< css::beans::XPropertySet
> xPropSet(m_xFrame
, css::uno::UNO_QUERY_THROW
);
519 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager
;
520 xPropSet
->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER
) >>= xLayoutManager
;
521 if (xLayoutManager
.is())
523 xLayoutManager
->lock();
524 xLayoutManager
->createElement( DECLARE_ASCII( "private:resource/menubar/menubar" ));
525 /* #i85963# new backing window comes withoud standard bar and statusbar
526 xLayoutManager->createElement( DECLARE_ASCII( "private:resource/toolbar/standardbar" ));
527 xLayoutManager->createElement( DECLARE_ASCII( "private:resource/statusbar/statusbar" ));
528 xLayoutManager->showElement ( DECLARE_ASCII( "private:resource/toolbar/standardbar" ));
529 xLayoutManager->showElement ( DECLARE_ASCII( "private:resource/statusbar/statusbar" ));
531 xLayoutManager
->unlock();
534 // set help ID for our canvas
535 pWindow
->SetHelpId(HID_BACKINGWINDOW
);
537 // inform BackingWindow about frame
538 BackingWindow
* pBack
= dynamic_cast<BackingWindow
*>(pWindow
);
540 pBack
->setOwningFrame( m_xFrame
);
546 //_______________________________________________
550 This component does not know any model. It will be represented by a window and
551 it's controller only.
553 return <FALSE/> everytime.
556 sal_Bool SAL_CALL
BackingComp::attachModel( /*IN*/ const css::uno::Reference
< css::frame::XModel
>& )
557 throw (css::uno::RuntimeException
)
562 //_______________________________________________
566 This component does not know any model. It will be represented by a window and
567 it's controller only.
569 return An empty reference every time.
572 css::uno::Reference
< css::frame::XModel
> SAL_CALL
BackingComp::getModel()
573 throw (css::uno::RuntimeException
)
575 return css::uno::Reference
< css::frame::XModel
>();
578 //_______________________________________________
582 return An empty value.
585 css::uno::Any SAL_CALL
BackingComp::getViewData()
586 throw (css::uno::RuntimeException
)
588 return css::uno::Any();
591 //_______________________________________________
599 void SAL_CALL
BackingComp::restoreViewData( /*IN*/ const css::uno::Any
& )
600 throw (css::uno::RuntimeException
)
604 //_______________________________________________
606 /** returns the attached frame for this component.
610 @return The internaly saved frame reference.
611 Can be null, if attachFrame() was not called before.
614 css::uno::Reference
< css::frame::XFrame
> SAL_CALL
BackingComp::getFrame()
615 throw (css::uno::RuntimeException
)
618 ReadGuard
aReadLock(m_aLock
);
623 //_______________________________________________
625 /** ask controller for it's current working state.
627 If somehwere whish to close this component, it must suspend the controller before.
628 That will be a chance for it to disagree with that AND show any UI for a possible
632 If its set to TRUE this controller should be suspended.
633 FALSE will resuspend it.
635 @return TRUE if the request could be finished successfully; FALSE otherwise.
638 sal_Bool SAL_CALL
BackingComp::suspend( /*IN*/ sal_Bool
)
639 throw (css::uno::RuntimeException
)
641 /* FIXME ... implemented by using default :-( */
645 //_______________________________________________
647 /** callback from our window member.
649 Our internal saved window wish to die. It will be disposed from outside (may be the frame)
650 and inform us. We must release its reference only here. Of course we check the given reference
651 here and reject callback from unknown sources.
653 Note: deregistration as listener isnt neccessary here. The broadcaster do it automaticly.
656 describe the broadcaster of this callback
658 @throw ::com::sun::star::uno::RuntimeException
659 if the broadcaster doesn't represent the expected window reference.
662 void SAL_CALL
BackingComp::disposing( /*IN*/ const css::lang::EventObject
& aEvent
)
663 throw(css::uno::RuntimeException
)
665 // Attention: dont free m_pAccExec here! see comments inside dtor and
666 // keyPressed() for further details.
669 WriteGuard
aWriteLock(m_aLock
);
671 if (!aEvent
.Source
.is() || aEvent
.Source
!=m_xWindow
|| !m_xWindow
.is())
672 throw css::uno::RuntimeException(
673 ::rtl::OUString::createFromAscii("unexpected source or called twice"),
674 static_cast< ::cppu::OWeakObject
* >(this));
676 m_xWindow
= css::uno::Reference
< css::awt::XWindow
>();
682 //_______________________________________________
684 /** kill this instance.
686 It can be called from our owner frame only. But there is no possibility to check the calli.
687 We have to release all our internal used ressources and die. From this point we can throw
688 DisposedExceptions for every further interface request ... but current implementation doesn`t do so ...
692 void SAL_CALL
BackingComp::dispose()
693 throw(css::uno::RuntimeException
)
696 WriteGuard
aWriteLock(m_aLock
);
700 aURL
.Complete
= DECLARE_ASCII(".uno:close");
701 css::uno::Reference
< css::util::XURLTransformer
> xParser(m_xSMGR
->createInstance(SERVICENAME_URLTRANSFORMER
), css::uno::UNO_QUERY
);
703 xParser
->parseStrict(aURL
);
705 css::uno::Reference
< css::frame::XDispatchProvider
> xProvider(m_xFrame
, css::uno::UNO_QUERY
);
708 css::uno::Reference
< css::frame::XDispatch
> xDispatch
= xProvider
->queryDispatch(aURL
, SPECIALTARGET_MENUBAR
, 0);
710 xDispatch
->dispatch(aURL
, css::uno::Sequence
< css::beans::PropertyValue
>());
713 // deregister drag&drop helper
714 if (m_xDropTargetListener
.is())
716 css::uno::Reference
< css::awt::XDataTransferProviderAccess
> xTransfer(m_xSMGR
->createInstance(SERVICENAME_VCLTOOLKIT
), css::uno::UNO_QUERY
);
719 css::uno::Reference
< css::datatransfer::dnd::XDropTarget
> xDropTarget
= xTransfer
->getDropTarget(m_xWindow
);
720 if (xDropTarget
.is())
722 xDropTarget
->removeDropTargetListener(m_xDropTargetListener
);
723 xDropTarget
->setActive(sal_False
);
726 m_xDropTargetListener
= css::uno::Reference
< css::datatransfer::dnd::XDropTargetListener
>();
729 // stop listening at the window
732 css::uno::Reference
< css::lang::XComponent
> xBroadcaster(m_xWindow
, css::uno::UNO_QUERY
);
733 if (xBroadcaster
.is())
735 css::uno::Reference
< css::lang::XEventListener
> xEventThis(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
);
736 xBroadcaster
->removeEventListener(xEventThis
);
738 css::uno::Reference
< css::awt::XKeyListener
> xKeyThis(static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
);
739 m_xWindow
->removeKeyListener(xKeyThis
);
740 m_xWindow
= css::uno::Reference
< css::awt::XWindow
>();
743 // forget all other used references
744 m_xFrame
= css::uno::Reference
< css::frame::XFrame
>();
745 m_xSMGR
= css::uno::Reference
< css::lang::XMultiServiceFactory
>();
751 //_______________________________________________
758 @throw ::com::sun::star::uno::RuntimeException
759 because the listener expect to be holded alive by this container.
760 We must inform it about this unsupported feature.
763 void SAL_CALL
BackingComp::addEventListener( /*IN*/ const css::uno::Reference
< css::lang::XEventListener
>& )
764 throw(css::uno::RuntimeException
)
766 throw css::uno::RuntimeException(
767 ::rtl::OUString::createFromAscii("not supported"),
768 static_cast< ::cppu::OWeakObject
* >(this));
771 //_______________________________________________
775 Because registration is not supported too, we must do nothing here. Nobody can call this method realy.
781 void SAL_CALL
BackingComp::removeEventListener( /*IN*/ const css::uno::Reference
< css::lang::XEventListener
>& )
782 throw(css::uno::RuntimeException
)
786 //_______________________________________________
789 force initialiation for this component.
791 Inside attachFrame() we created our component window. But it was not allowed there, to
792 initialitze it. E.g. the menu must be set at the container window of the frame, which
793 is our parent window. But may at that time another component used it.
794 That's why our creator has to inform us, when it's time to initialize us realy.
795 Currently only calling of this method must be done. But further implementatoins
796 can use special in parameter to configure this initialization ...
801 @throw com::sun::star::uno::RuntimeException
802 if some ressources are missing
803 Means if may be attachedFrame() wasn't called before.
806 void SAL_CALL
BackingComp::initialize( /*IN*/ const css::uno::Sequence
< css::uno::Any
>& lArgs
)
807 throw(css::uno::Exception
, css::uno::RuntimeException
)
810 WriteGuard
aWriteLock(m_aLock
);
813 throw css::uno::Exception(
814 ::rtl::OUString::createFromAscii("already initialized"),
815 static_cast< ::cppu::OWeakObject
* >(this));
817 css::uno::Reference
< css::awt::XWindow
> xParentWindow
;
819 (lArgs
.getLength()!=1 ) ||
820 (!(lArgs
[0] >>= xParentWindow
)) ||
821 (!xParentWindow
.is() )
824 throw css::uno::Exception(
825 ::rtl::OUString::createFromAscii("wrong or corrupt argument list"),
826 static_cast< ::cppu::OWeakObject
* >(this));
829 // create the component window
830 Window
* pParent
= VCLUnoHelper::GetWindow(xParentWindow
);
831 Window
* pWindow
= new BackingWindow(pParent
);
832 m_xWindow
= VCLUnoHelper::GetInterface(pWindow
);
835 throw css::uno::RuntimeException(
836 ::rtl::OUString::createFromAscii("couldn't create component window"),
837 static_cast< ::cppu::OWeakObject
* >(this));
839 // start listening for window disposing
840 // It's set at our owner frame as component window later too. So it will may be disposed there ...
841 css::uno::Reference
< css::lang::XComponent
> xBroadcaster(m_xWindow
, css::uno::UNO_QUERY
);
842 if (xBroadcaster
.is())
843 xBroadcaster
->addEventListener(static_cast< css::lang::XEventListener
* >(this));
845 m_xWindow
->setVisible(sal_True
);
851 //_______________________________________________
856 void SAL_CALL
BackingComp::keyPressed( /*IN*/ const css::awt::KeyEvent
& )
857 throw(css::uno::RuntimeException
)
861 //_______________________________________________
866 void SAL_CALL
BackingComp::keyReleased( /*IN*/ const css::awt::KeyEvent
& )
867 throw(css::uno::RuntimeException
)
870 Please use keyPressed() instead of this method. Otherwhise it would be possible, that
871 - a key input may be first switch to the backing mode
872 - and this component register itself as key listener too
873 - and it's first event will be a keyRealeased() for the already well known event, which switched to the backing mode!
874 So it will be handled twice! document => backing mode => exit app ...
878 } // namespace framework