1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
29 #define __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
30 
31 //__________________________________________
32 // own includes
33 
34 #include <threadhelp/threadhelpbase.hxx>
35 #include <general.h>
36 #include <stdtypes.h>
37 
38 //__________________________________________
39 // interface includes
40 #include <com/sun/star/lang/XTypeProvider.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/XInitialization.hpp>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #include <com/sun/star/awt/XWindow.hpp>
46 #include <com/sun/star/awt/XKeyListener.hpp>
47 
48 #ifndef _COM_SUN_STAR_FAME_XFRAME_HPP_
49 #include <com/sun/star/frame/XFrame.hpp>
50 #endif
51 
52 #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETELISTENER_HPP_
53 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
54 #endif
55 #include <com/sun/star/lang/XEventListener.hpp>
56 #include <com/sun/star/lang/XComponent.hpp>
57 
58 //__________________________________________
59 // other includes
60 #include <cppuhelper/weak.hxx>
61 
62 //__________________________________________
63 // definition
64 
65 namespace framework
66 {
67 
68 //__________________________________________
69 /**
70     implements the backing component.
71 
72     This component is a special one, which doesn't provide a controller
73     nor a model. It supports the following features:
74         - Drag & Drop
75         - Key Accelerators
76         - Simple Menu
77         - Progress Bar
78         - Background
79  */
80 class BackingComp : public  css::lang::XTypeProvider
81                   , public  css::lang::XServiceInfo
82                   , public  css::lang::XInitialization
83                   , public  css::frame::XController  // => XComponent
84                   , public  css::awt::XKeyListener // => XEventListener
85                   // attention! Must be the first base class to guarentee right initialize lock ...
86                   , private ThreadHelpBase
87                   , public  ::cppu::OWeakObject
88 {
89     //______________________________________
90     // member
91 
92     private:
93 
94         /** the global uno service manager.
95             Must be used to create own needed services. */
96         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
97 
98         /** reference to the component window. */
99         css::uno::Reference< css::awt::XWindow > m_xWindow;
100 
101         /** the owner frame of this component. */
102         css::uno::Reference< css::frame::XFrame > m_xFrame;
103 
104         /** helper for drag&drop. */
105         css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > m_xDropTargetListener;
106 
107     //______________________________________
108     // interface
109 
110     public:
111 
112                  BackingComp( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR );
113         virtual ~BackingComp(                                                                    );
114 
115         // XInterface
116         virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException);
117         virtual void          SAL_CALL acquire       (                             ) throw(                          );
118         virtual void          SAL_CALL release       (                             ) throw(                          );
119 
120         // XTypeProvide
121         virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes           () throw(css::uno::RuntimeException);
122         virtual css::uno::Sequence< sal_Int8 >       SAL_CALL getImplementationId() throw(css::uno::RuntimeException);
123 
124         // XServiceInfo
125         virtual ::rtl::OUString                       SAL_CALL getImplementationName   (                                     ) throw(css::uno::RuntimeException);
126         virtual sal_Bool                              SAL_CALL supportsService         ( const ::rtl::OUString& sServiceName ) throw(css::uno::RuntimeException);
127         virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(                                     ) throw(css::uno::RuntimeException);
128 
129         // XInitialization
130         virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArgs ) throw(css::uno::Exception, css::uno::RuntimeException);
131 
132         // XController
133         virtual void                                      SAL_CALL attachFrame    ( const css::uno::Reference< css::frame::XFrame >& xFrame   ) throw(css::uno::RuntimeException);
134         virtual sal_Bool                                  SAL_CALL attachModel    ( const css::uno::Reference< css::frame::XModel >& xModel   ) throw(css::uno::RuntimeException);
135         virtual sal_Bool                                  SAL_CALL suspend        (       sal_Bool                                   bSuspend ) throw(css::uno::RuntimeException);
136         virtual css::uno::Any                             SAL_CALL getViewData    (                                                           ) throw(css::uno::RuntimeException);
137         virtual void                                      SAL_CALL restoreViewData( const css::uno::Any&                             aData    ) throw(css::uno::RuntimeException);
138         virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel       (                                                           ) throw(css::uno::RuntimeException);
139         virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame       (                                                           ) throw(css::uno::RuntimeException);
140 
141         // XKeyListener
142         virtual void SAL_CALL keyPressed ( const css::awt::KeyEvent& aEvent ) throw(css::uno::RuntimeException);
143         virtual void SAL_CALL keyReleased( const css::awt::KeyEvent& aEvent ) throw(css::uno::RuntimeException);
144 
145         // XEventListener
146         virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
147 
148         // XComponent
149         virtual void SAL_CALL dispose            (                                                                   ) throw(css::uno::RuntimeException);
150         virtual void SAL_CALL addEventListener   ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw(css::uno::RuntimeException);
151         virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw(css::uno::RuntimeException);
152 
153     //______________________________________
154     // helper
155 
156     public:
157 
158         static css::uno::Sequence< ::rtl::OUString >                   SAL_CALL impl_getStaticSupportedServiceNames(                                                                     );
159         static ::rtl::OUString                                         SAL_CALL impl_getStaticImplementationName   (                                                                     );
160         static css::uno::Reference< css::uno::XInterface >             SAL_CALL impl_createInstance                ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ) throw( css::uno::Exception );
161         static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory                 ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
162 };
163 
164 } // namespace framework
165 
166 #endif // __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
167