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_CREATEDISPATCHER_HXX_
25 #define __FRAMEWORK_DISPATCH_CREATEDISPATCHER_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <dispatch/basedispatcher.hxx>
32 
33 //_________________________________________________________________________________________________________________
34 //	interface includes
35 //_________________________________________________________________________________________________________________
36 
37 //_________________________________________________________________________________________________________________
38 //	other includes
39 //_________________________________________________________________________________________________________________
40 
41 //_________________________________________________________________________________________________________________
42 //	namespace
43 //_________________________________________________________________________________________________________________
44 
45 namespace framework{
46 
47 //_________________________________________________________________________________________________________________
48 //	exported const
49 //_________________________________________________________________________________________________________________
50 
51 //_________________________________________________________________________________________________________________
52 //	exported definitions
53 //_________________________________________________________________________________________________________________
54 
55 /*-************************************************************************************************************//**
56     @short          helper to create new frames by using non special target name and CREATE flag
57     @descr          If user whish to find any frame by name or will create it, if it not already exist ...
58                     these dispatch helper should be used. Because - a frame must be created at dispatch call ...
59                     not on queryDispatch()! So we hold weakreferences to the possible parent frame, safe the name
60                     of new frame. If user call dispatch at us - we check a weakreference to our last created frame
61                     (he should have same name!) ... if he exist - we do nothing ... if not - we create it again.
62                     But if possible parent for new created task doesn't exist - we couldn't do anything!
63                     Then we wait for our own dispose and do nothing.
64 
65     @attention      Use this class as member only! Never use it as baseclass.
66 					XInterface will be ambiguous and we hold a weakreference to our OWNER - not to our SUPERCLASS!
67 
68 	@implements		XInterface
69 					XDispatch
70                     XStatusListener
71                     XLoadEventListener
72 					XEventListener
73 
74     @base           BaseDispatcher
75 
76 	@devstatus		ready to use
77     @threadsafe     yes
78 *//*-*************************************************************************************************************/
79 class CreateDispatcher  :   // -interfaces  ... are supported by our BaseDispatcher!
80                             // -baseclasses ... order is necessary for right initialization!
81                             public BaseDispatcher
82 {
83 	//-------------------------------------------------------------------------------------------------------------
84 	//	public methods
85 	//-------------------------------------------------------------------------------------------------------------
86 	public:
87         //  ctor
88                               CreateDispatcher    ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory    ,
89                                                     const css::uno::Reference< css::frame::XFrame >&              xParent     ,
90                                                     const rtl::OUString&                                          sName       );
91 		//	XDispatch
92         virtual void SAL_CALL dispatch            ( const css::util::URL&                                         aURL        ,
93                                                     const css::uno::Sequence< css::beans::PropertyValue >&        lArguments  ) throw( css::uno::RuntimeException );
94 
95     //-------------------------------------------------------------------------------------------------------------
96     //  protected methods
97 	//-------------------------------------------------------------------------------------------------------------
98     protected:
99         virtual void SAL_CALL reactForLoadingState ( const css::util::URL&                                        aURL        ,
100                                                      const css::uno::Sequence< css::beans::PropertyValue >&       lDescriptor ,
101                                                      const css::uno::Reference< css::frame::XFrame >&             xTarget     ,
102                                                            sal_Bool                                               bState      ,
103                                                      const css::uno::Any&                                         aAsyncInfo  = css::uno::Any() );
104 
reactForHandlingState(const css::util::URL & aURL,const css::uno::Sequence<css::beans::PropertyValue> & lDescriptor,sal_Bool bState,const css::uno::Any & aAsyncInfo=css::uno::Any ())105         virtual void SAL_CALL reactForHandlingState( const css::util::URL&                                        aURL        ,
106                                                      const css::uno::Sequence< css::beans::PropertyValue >&       lDescriptor ,
107                                                            sal_Bool                                               bState      ,
108                                                      const css::uno::Any&                                         aAsyncInfo  = css::uno::Any() )
109         { LOG_WARNING( "CreateDispatcher::reactForHandlingState()", "Who call this function! It's a non used pure virtual function overload ..." ) }
110 
111 	//-------------------------------------------------------------------------------------------------------------
112 	//	variables
113 	//	(should be private everyway!)
114 	//-------------------------------------------------------------------------------------------------------------
115 	private:
116         css::uno::WeakReference< css::frame::XFrame >   m_xTarget       ;   /// new created frame (Don't hold hard reference ... target frame couldn't die then!)
117         ::rtl::OUString                                 m_sTargetName   ;   /// name of new created frame
118 
119 };      //  class CreateDispatcher
120 
121 }		//	namespace framework
122 
123 #endif  //  #ifndef __FRAMEWORK_DISPATCH_CREATEDISPATCHER_HXX_
124