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