merge the formfield patch from ooo-build
[ooovba.git] / framework / source / services / backingcomp.cxx
blobb769e0a89e2a3439a4c1b86cb4a960eeabdb7137
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: backingcomp.cxx,v $
11 * $Revision: 1.26 $
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 //_______________________________________________
40 // own includes
41 #include <threadhelp/readguard.hxx>
42 #include <threadhelp/writeguard.hxx>
43 #include <classes/droptargetlistener.hxx>
44 #include <helper/acceleratorinfo.hxx>
45 #include <targets.h>
46 #include <properties.h>
47 #include <services.h>
49 #ifndef _FRAMEWORK_HELPID_HRC
50 #include <helpid.hrc>
51 #endif
53 //_______________________________________________
54 // interface includes
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 //_______________________________________________
66 // other includes
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>
77 #ifndef _SOLAR_HRC
78 #include <svtools/solar.hrc>
79 #endif
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>
86 #endif
88 namespace framework
91 //_______________________________________________
93 //_______________________________________________
95 BackingComp::BackingComp( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR )
96 : ThreadHelpBase (&Application::GetSolarMutex() )
97 , m_xSMGR (xSMGR )
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 ...
117 @param aType
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(
131 aType,
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())
145 /* SAFE { */
146 ReadGuard aReadLock(m_aLock);
147 if (m_xWindow.is())
148 aResult = m_xWindow->queryInterface(aType);
149 aReadLock.unlock();
150 /* } SAFE */
153 // look for XWeak and XInterface
154 if (!aResult.hasValue())
155 aResult = OWeakObject::queryInterface(aType);
157 return aResult;
160 //_______________________________________________
162 /** increase ref count of this instance.
165 void SAL_CALL BackingComp::acquire()
166 throw()
168 OWeakObject::acquire();
171 //_______________________________________________
173 /** decrease ref count of this instance.
176 void SAL_CALL BackingComp::release()
177 throw()
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)
201 /* GLOBAL SAFE { */
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)
206 /* LOCAL SAFE { */
207 ReadGuard aReadLock(m_aLock);
208 css::uno::Reference< css::lang::XTypeProvider > xProvider(m_xWindow, css::uno::UNO_QUERY);
209 aReadLock.unlock();
210 /* } LOCAL SAFE */
212 css::uno::Sequence< css::uno::Type > lWindowTypes;
213 if (xProvider.is())
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 ),
222 lWindowTypes);
224 pTypeCollection = &aTypeCollection;
226 /* } GLOBAL SAFE */
228 return pTypeCollection->getTypes();
231 //_______________________________________________
233 /** create one unique Id for all instances of this class.
235 Optimize this method
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;
246 if (!pID)
248 /* GLOBAL SAFE { */
249 ::osl::MutexGuard aLock(::osl::Mutex::getGlobalMutex());
250 // Control these pointer again ... it can be, that another instance will be faster then this one!
251 if (!pID)
253 static ::cppu::OImplementationId aID(sal_False);
254 pID = &aID;
256 /* } GLOBAL SAFE */
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()
288 @see SERVICENAME
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)
297 return (
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()
311 @see SERVICENAME
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()
330 @see SERVICENAME
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()
348 @see SERVICENAME
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;
357 return lNames;
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.
368 @param xSMGR
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.
393 @param xSMGR
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(
403 xSMGR,
404 BackingComp::impl_getStaticImplementationName(),
405 BackingComp::impl_createInstance,
406 BackingComp::impl_getStaticSupportedServiceNames()));
407 return xReturn;
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
420 frame!
422 May he will do the following things:
424 <listing>
425 XController xBackingComp = (XController)UnoRuntime.queryInterface(
426 XController.class,
427 xSMGR.createInstance(SERVICENAME_STARTMODULE));
429 // at this time XWindow isn't present at this instance!
430 XWindow xBackingComp = (XWindow)UnoRuntime.queryInterface(
431 XWindow.class,
432 xBackingComp);
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(
440 XWindow.class,
441 xBackingComp);
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,
450 xBackingComp);
452 xBackingInit.initialize(lArgs);
453 </listing>
455 @param xFrame
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
460 successfully.
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)
468 /* SAFE */
469 WriteGuard aWriteLock(m_aLock);
471 // check some required states
472 if (m_xFrame.is())
473 throw css::uno::RuntimeException(
474 ::rtl::OUString::createFromAscii("already attached"),
475 static_cast< ::cppu::OWeakObject* >(this));
477 if (!xFrame.is())
478 throw css::uno::RuntimeException(
479 ::rtl::OUString::createFromAscii("invalid frame reference"),
480 static_cast< ::cppu::OWeakObject* >(this));
482 if (!m_xWindow.is())
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
488 m_xFrame = xFrame;
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);
495 if (xTransfer.is())
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 );
539 if( pBack )
540 pBack->setOwningFrame( m_xFrame );
542 aWriteLock.unlock();
543 /* } SAFE */
546 //_______________________________________________
548 /** not supported.
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)
559 return sal_False;
562 //_______________________________________________
564 /** not supported.
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 //_______________________________________________
580 /** not supported.
582 return An empty value.
585 css::uno::Any SAL_CALL BackingComp::getViewData()
586 throw (css::uno::RuntimeException)
588 return css::uno::Any();
591 //_______________________________________________
593 /** not supported.
595 @param aData
596 not used.
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.
608 @see attachFrame()
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)
617 /* SAFE { */
618 ReadGuard aReadLock(m_aLock);
619 return m_xFrame;
620 /* } SAFE */
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
629 UI user.
631 @param bSuspend
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 :-( */
642 return sal_True;
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.
655 @param aEvent
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.
668 /* SAFE { */
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 >();
678 aWriteLock.unlock();
679 /* } SAFE */
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)
695 /* SAFE { */
696 WriteGuard aWriteLock(m_aLock);
698 // kill the menu
699 css::util::URL aURL;
700 aURL.Complete = DECLARE_ASCII(".uno:close");
701 css::uno::Reference< css::util::XURLTransformer > xParser(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY);
702 if (xParser.is())
703 xParser->parseStrict(aURL);
705 css::uno::Reference< css::frame::XDispatchProvider > xProvider(m_xFrame, css::uno::UNO_QUERY);
706 if (xProvider.is())
708 css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, SPECIALTARGET_MENUBAR, 0);
709 if (xDispatch.is())
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);
717 if (xTransfer.is())
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
730 if (m_xWindow.is())
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 >();
747 aWriteLock.unlock();
748 /* } SAFE */
751 //_______________________________________________
753 /** not supported.
755 @param xListener
756 not used.
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 //_______________________________________________
773 /** not supported.
775 Because registration is not supported too, we must do nothing here. Nobody can call this method realy.
777 @param xListener
778 not used.
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 ...
798 @param lArgs
799 currently not used
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)
809 /* SAFE { */
810 WriteGuard aWriteLock(m_aLock);
812 if (m_xWindow.is())
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;
818 if (
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);
834 if (!m_xWindow.is())
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);
847 aWriteLock.unlock();
848 /* } SAFE */
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)
869 /* Attention
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