1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
25 #define __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
26 
27 //__________________________________________
28 // own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <general.h>
32 #include <stdtypes.h>
33 
34 //__________________________________________
35 // interface includes
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/awt/XKeyListener.hpp>
43 
44 #ifndef _COM_SUN_STAR_FAME_XFRAME_HPP_
45 #include <com/sun/star/frame/XFrame.hpp>
46 #endif
47 
48 #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETELISTENER_HPP_
49 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
50 #endif
51 #include <com/sun/star/lang/XEventListener.hpp>
52 #include <com/sun/star/lang/XComponent.hpp>
53 
54 //__________________________________________
55 // other includes
56 #include <cppuhelper/weak.hxx>
57 
58 //__________________________________________
59 // definition
60 
61 namespace framework
62 {
63 
64 //__________________________________________
65 /**
66     implements the backing component.
67 
68     This component is a special one, which doesn't provide a controller
69     nor a model. It supports the following features:
70         - Drag & Drop
71         - Key Accelerators
72         - Simple Menu
73         - Progress Bar
74         - Background
75  */
76 class BackingComp : public  css::lang::XTypeProvider
77                   , public  css::lang::XServiceInfo
78                   , public  css::lang::XInitialization
79                   , public  css::frame::XController  // => XComponent
80                   , public  css::awt::XKeyListener // => XEventListener
81                   // attention! Must be the first base class to guarentee right initialize lock ...
82                   , private ThreadHelpBase
83                   , public  ::cppu::OWeakObject
84 {
85     //______________________________________
86     // member
87 
88     private:
89 
90         /** the global uno service manager.
91             Must be used to create own needed services. */
92         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
93 
94         /** reference to the component window. */
95         css::uno::Reference< css::awt::XWindow > m_xWindow;
96 
97         /** the owner frame of this component. */
98         css::uno::Reference< css::frame::XFrame > m_xFrame;
99 
100         /** helper for drag&drop. */
101         css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > m_xDropTargetListener;
102 
103     //______________________________________
104     // interface
105 
106     public:
107 
108                  BackingComp( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR );
109         virtual ~BackingComp(                                                                    );
110 
111         // XInterface
112         virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException);
113         virtual void          SAL_CALL acquire       (                             ) throw(                          );
114         virtual void          SAL_CALL release       (                             ) throw(                          );
115 
116         // XTypeProvide
117         virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes           () throw(css::uno::RuntimeException);
118         virtual css::uno::Sequence< sal_Int8 >       SAL_CALL getImplementationId() throw(css::uno::RuntimeException);
119 
120         // XServiceInfo
121         virtual ::rtl::OUString                       SAL_CALL getImplementationName   (                                     ) throw(css::uno::RuntimeException);
122         virtual sal_Bool                              SAL_CALL supportsService         ( const ::rtl::OUString& sServiceName ) throw(css::uno::RuntimeException);
123         virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(                                     ) throw(css::uno::RuntimeException);
124 
125         // XInitialization
126         virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArgs ) throw(css::uno::Exception, css::uno::RuntimeException);
127 
128         // XController
129         virtual void                                      SAL_CALL attachFrame    ( const css::uno::Reference< css::frame::XFrame >& xFrame   ) throw(css::uno::RuntimeException);
130         virtual sal_Bool                                  SAL_CALL attachModel    ( const css::uno::Reference< css::frame::XModel >& xModel   ) throw(css::uno::RuntimeException);
131         virtual sal_Bool                                  SAL_CALL suspend        (       sal_Bool                                   bSuspend ) throw(css::uno::RuntimeException);
132         virtual css::uno::Any                             SAL_CALL getViewData    (                                                           ) throw(css::uno::RuntimeException);
133         virtual void                                      SAL_CALL restoreViewData( const css::uno::Any&                             aData    ) throw(css::uno::RuntimeException);
134         virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel       (                                                           ) throw(css::uno::RuntimeException);
135         virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame       (                                                           ) throw(css::uno::RuntimeException);
136 
137         // XKeyListener
138         virtual void SAL_CALL keyPressed ( const css::awt::KeyEvent& aEvent ) throw(css::uno::RuntimeException);
139         virtual void SAL_CALL keyReleased( const css::awt::KeyEvent& aEvent ) throw(css::uno::RuntimeException);
140 
141         // XEventListener
142         virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
143 
144         // XComponent
145         virtual void SAL_CALL dispose            (                                                                   ) throw(css::uno::RuntimeException);
146         virtual void SAL_CALL addEventListener   ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw(css::uno::RuntimeException);
147         virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw(css::uno::RuntimeException);
148 
149     //______________________________________
150     // helper
151 
152     public:
153 
154         static css::uno::Sequence< ::rtl::OUString >                   SAL_CALL impl_getStaticSupportedServiceNames(                                                                     );
155         static ::rtl::OUString                                         SAL_CALL impl_getStaticImplementationName   (                                                                     );
156         static css::uno::Reference< css::uno::XInterface >             SAL_CALL impl_createInstance                ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ) throw( css::uno::Exception );
157         static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory                 ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
158 };
159 
160 } // namespace framework
161 
162 #endif // __FRAMEWORK_SERVICES_BACKINGCOMP_HXX_
163