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_DISPATCH_LOADDISPATCHER_HXX_
25 #define __FRAMEWORK_DISPATCH_LOADDISPATCHER_HXX_
26 
27 //_______________________________________________
28 // my own includes
29 
30 #include <loadenv/loadenv.hxx>
31 
32 //_______________________________________________
33 // interface includes
34 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
35 #include <com/sun/star/frame/XSynchronousDispatch.hpp>
36 
37 //_______________________________________________
38 // other includes
39 
40 #include <cppuhelper/implbase2.hxx>
41 
42 //_______________________________________________
43 // namespace
44 
45 namespace framework{
46 
47 namespace css = ::com::sun::star;
48 
49 //_______________________________________________
50 // exported const
51 
52 //_______________________________________________
53 // exported definitions
54 
55 /** @short      implements a dispatch object which can be used to load
56                 non-visible components (by using the mechanism of ContentHandler)
57                 or visible-components (by using the mechanism of FrameLoader).
58 
59     @author     as96863
60  */
61 class LoadDispatcher : private ThreadHelpBase
62                      , public  ::cppu::WeakImplHelper2< css::frame::XNotifyingDispatch,          // => XDispatch => XInterface
63                                                         css::frame::XSynchronousDispatch >
64 {
65     //___________________________________________
66     // member
67 
68     private:
69 
70         /** @short  can be used to create own needed services on demand. */
71         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
72 
73         /** @short  TODO document me */
74         css::uno::WeakReference< css::frame::XFrame > m_xOwnerFrame;
75 
76         /** @short  TODO document me */
77         ::rtl::OUString m_sTarget;
78 
79         /** @short  TODO document me */
80         sal_Int32 m_nSearchFlags;
81 
82         /** @short  TODO document me */
83         LoadEnv m_aLoader;
84 
85     //___________________________________________
86     // native interface
87 
88     public:
89 
90         /** @short  creates a new instance and initialize it with all neccessary parameters.
91 
92             @descr  Every instance of such LoadDispatcher can be used for the specified context only.
93                     That means: It can be used to load any further requested content into tzhe here(!)
94                     specified target frame.
95 
96             @param  xSMGR
97                     will be used to create own needed services on demand.
98 
99             @param  xOwnerFrame
100                     used as startpoit to locate the right target frame.
101 
102             @param  sTargetName
103                     the name or the target frame for loading or a special qualifier
104                     which define such target.
105 
106             @param  nSearchFlags
107                     used in case sTargetFrame isnt a special one.
108          */
109         LoadDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR       ,
110                        const css::uno::Reference< css::frame::XFrame >&              xOwnerFrame ,
111                        const ::rtl::OUString                                         sTargetName ,
112                              sal_Int32                                               nSearchFlags);
113 
114         //_______________________________________
115 
116         /** @short  used to free internal resources.
117          */
118         virtual ~LoadDispatcher();
119 
120     //___________________________________________
121     // uno interface
122 
123     public:
124 
125         // XNotifyingDispatch
126         virtual void SAL_CALL dispatchWithNotification(const css::util::URL&                                             aURL      ,
127                                                        const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
128                                                        const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
129             throw(css::uno::RuntimeException);
130 
131         // XDispatch
132         virtual void SAL_CALL dispatch(const css::util::URL&                                  aURL      ,
133                                        const css::uno::Sequence< css::beans::PropertyValue >& lArguments)
134             throw(css::uno::RuntimeException);
135 
136         virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
137                                                 const css::util::URL&                                     aURL     )
138             throw(css::uno::RuntimeException);
139 
140         virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
141                                                    const css::util::URL&                                     aURL     )
142             throw(css::uno::RuntimeException);
143 
144         // XSynchronousDispatch
145         virtual css::uno::Any SAL_CALL dispatchWithReturnValue( const css::util::URL&                                  aURL      ,
146                                                                 const css::uno::Sequence< css::beans::PropertyValue >& lArguments )
147             throw( css::uno::RuntimeException );
148 
149     private:
150         css::uno::Any impl_dispatch( const css::util::URL& rURL,
151                                      const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
152                                      const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
153 }; // class LoadDispatcher
154 
155 } // namespace framework
156 
157 #endif // #ifndef __FRAMEWORK_DISPATCH_LOADDISPATCHER_HXX_
158