16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
106d739b60SAndrew Rist  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
196d739b60SAndrew Rist  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
226d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_OINSTANCEPROVIDER_HXX_
32cdf0e10cSrcweir #include <helper/oinstanceprovider.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <classes/servicemanager.hxx>
35cdf0e10cSrcweir #include <macros/debug.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifndef __FRAMEWORK_DEFINES_HXX_
38cdf0e10cSrcweir #include <defines.hxx>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir //	interface includes
43cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
45cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/XFrameLoader.hpp>
48cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
49cdf0e10cSrcweir #include <com/sun/star/frame/XLoadEventListener.hpp>
50cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
51cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
52cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
53cdf0e10cSrcweir #include <com/sun/star/frame/XFrames.hpp>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONNECTION_XConnection_HPP_
56cdf0e10cSrcweir #include <com/sun/star/connection/XConnection.hpp>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BRIDGE_XBridgeFactory_HPP_
60cdf0e10cSrcweir #include <com/sun/star/bridge/XBridgeFactory.hpp>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64cdf0e10cSrcweir //	other includes
65cdf0e10cSrcweir //_________________________________________________________________________________________________________________
66cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
67cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
68cdf0e10cSrcweir #include <rtl/ustring.hxx>
69cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
70cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
71cdf0e10cSrcweir #include <svtools/unoiface.hxx>
72cdf0e10cSrcweir #include <vcl/svapp.hxx>
73cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
74cdf0e10cSrcweir #include <vos/process.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //_________________________________________________________________________________________________________________
77cdf0e10cSrcweir //	namespace
78cdf0e10cSrcweir //_________________________________________________________________________________________________________________
79cdf0e10cSrcweir 
80cdf0e10cSrcweir using namespace ::rtl							;
81cdf0e10cSrcweir using namespace ::vos							;
82cdf0e10cSrcweir using namespace ::comphelper					;
83cdf0e10cSrcweir using namespace ::framework						;
84cdf0e10cSrcweir using namespace ::com::sun::star::uno			;
85cdf0e10cSrcweir using namespace ::com::sun::star::lang			;
86cdf0e10cSrcweir using namespace ::com::sun::star::frame			;
87cdf0e10cSrcweir using namespace ::com::sun::star::awt			;
88cdf0e10cSrcweir using namespace ::com::sun::star::beans			;
89cdf0e10cSrcweir using namespace ::com::sun::star::util			;
90cdf0e10cSrcweir using namespace ::com::sun::star::connection	;
91cdf0e10cSrcweir using namespace ::com::sun::star::bridge		;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir //_________________________________________________________________________________________________________________
94cdf0e10cSrcweir //	const
95cdf0e10cSrcweir //_________________________________________________________________________________________________________________
96cdf0e10cSrcweir 
97cdf0e10cSrcweir #define	APPLICATIONNAME							"FrameWork"
98cdf0e10cSrcweir #define	COMMANDARGUMENT_PLUGIN					DECLARE_ASCII("-plugin"					)
99cdf0e10cSrcweir #define	NAME_PLUGINBRIDGE						DECLARE_ASCII("mozilla plugin bridge"	)
100cdf0e10cSrcweir #define	PROTOCOL_PLUGINBRIDGE					DECLARE_ASCII("urp"						)
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //_________________________________________________________________________________________________________________
103cdf0e10cSrcweir //	declarations
104cdf0e10cSrcweir //_________________________________________________________________________________________________________________
105cdf0e10cSrcweir 
106cdf0e10cSrcweir /*-************************************************************************************************************//**
107cdf0e10cSrcweir 	@short		normal application
108cdf0e10cSrcweir 	@descr		An instance of these class can be a normal node in frame tree only. The highest level to be allowed is 3!
109cdf0e10cSrcweir 				On 1 stand the desktop himself as the only one, on 2 are all tasks present ... and then comes frames only.
110cdf0e10cSrcweir 				A frame support influencing of his subtree, find of subframes, activate- and deactivate-mechanism as well as
111cdf0e10cSrcweir 				set/get of a frame window, component or controller.
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	@implements	XInterface
114cdf0e10cSrcweir 				XTypeProvider
115cdf0e10cSrcweir 				XServiceInfo
116cdf0e10cSrcweir 				XFramesSupplier
117cdf0e10cSrcweir 				XFrame
118cdf0e10cSrcweir 				XComponent
119cdf0e10cSrcweir 				XStatusIndicatorSupplier
120cdf0e10cSrcweir 				XDispatchProvider
121cdf0e10cSrcweir 				XDispatchProviderInterception
122cdf0e10cSrcweir 				XBrowseHistoryRegistry
123cdf0e10cSrcweir 				XLoadEventListener
124cdf0e10cSrcweir 				XEventListener
125cdf0e10cSrcweir 				XWindowListener
126cdf0e10cSrcweir 				XTopWindowListener
127cdf0e10cSrcweir 				[ XDebugging, if TEST_TREE is defined! ]
128cdf0e10cSrcweir 	@base		OMutexMember
129cdf0e10cSrcweir 				OWeakObject
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	@devstatus	deprecated
132cdf0e10cSrcweir *//*-*************************************************************************************************************/
133cdf0e10cSrcweir class FrameWork : public Application
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
136cdf0e10cSrcweir 	//	public methods
137cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	public:
140cdf0e10cSrcweir 		void Main();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	private:
143cdf0e10cSrcweir 		void impl_analyzeCommandArguments();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	private:
146cdf0e10cSrcweir 		sal_Bool	m_bUsePlugIn	;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir };	//	class FrameWork
149cdf0e10cSrcweir 
150cdf0e10cSrcweir //_________________________________________________________________________________________________________________
151cdf0e10cSrcweir //	definitions
152cdf0e10cSrcweir //_________________________________________________________________________________________________________________
153cdf0e10cSrcweir 
154cdf0e10cSrcweir //_________________________________________________________________________________________________________________
155cdf0e10cSrcweir //	global variables
156cdf0e10cSrcweir //_________________________________________________________________________________________________________________
157cdf0e10cSrcweir 
158cdf0e10cSrcweir FrameWork	aFrameWork	;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir //_________________________________________________________________________________________________________________
161cdf0e10cSrcweir //	definitions
162cdf0e10cSrcweir //_________________________________________________________________________________________________________________
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //*****************************************************************************************************************
165cdf0e10cSrcweir //	private methods
166cdf0e10cSrcweir //*****************************************************************************************************************
impl_analyzeCommandArguments()167cdf0e10cSrcweir void FrameWork::impl_analyzeCommandArguments()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	// First reset all member variables which present states of incoming arguments!
170cdf0e10cSrcweir 	m_bUsePlugIn = sal_False;	// depends from "/plugin"
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	// Then step over all given arguments and search for supported one.
173cdf0e10cSrcweir 	OStartupInfo	aInfo		;
174cdf0e10cSrcweir 	OUString		sArgument	;
175cdf0e10cSrcweir 	sal_uInt32		nCount		= aInfo.getCommandArgCount();
176cdf0e10cSrcweir 	for ( sal_uInt32 nArgument=0; nArgument<nCount; ++nArgument )
177cdf0e10cSrcweir 	{
17807a3d7f1SPedro Giffuni 		// If extraction of current argument successful ...
179cdf0e10cSrcweir 		if ( aInfo.getCommandArg( nArgument, sArgument ) == osl_Process_E_None )
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir 			// ... search for matching with supported values.
182cdf0e10cSrcweir 			if ( sArgument == COMMANDARGUMENT_PLUGIN )
183cdf0e10cSrcweir 			{
184cdf0e10cSrcweir 				// We found "/plugin" => set internal equivalent.
185cdf0e10cSrcweir 				m_bUsePlugIn = sal_True;
186cdf0e10cSrcweir 			}
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir //_________________________________________________________________________________________________________________
192cdf0e10cSrcweir //	main
193cdf0e10cSrcweir //_________________________________________________________________________________________________________________
194cdf0e10cSrcweir 
Main()195cdf0e10cSrcweir void FrameWork::Main()
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
198*6b5a962bSmseidel 	// a) Initialize our application
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	// Analyze command arguments.
201cdf0e10cSrcweir 	impl_analyzeCommandArguments();
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 	// Create new global servicemanager.
204cdf0e10cSrcweir 	ServiceManager aManager;
205cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xGlobalServiceManager = aManager.getGlobalUNOServiceManager();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	if ( xGlobalServiceManager.is() == sal_True )
208cdf0e10cSrcweir 	{
209cdf0e10cSrcweir 		// If it was successful - set in as static value in UNOTOOLS!
210cdf0e10cSrcweir 		setProcessServiceFactory( xGlobalServiceManager );
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
213*6b5a962bSmseidel 		// b) Create root of our frame tree
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 		// Create top of frame hierarchy - the desktop.
216cdf0e10cSrcweir 		Reference< XDesktop > xDesktop( xGlobalServiceManager->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY );
217cdf0e10cSrcweir 		// Safe impossible cases
218cdf0e10cSrcweir 		// We need the desktop for working.
219cdf0e10cSrcweir 		LOG_ASSERT( !(xDesktop.is()==sal_False), "FrameWork::Main()\nCan't instanciate desktop!Servicename unknown?\n" )
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
222cdf0e10cSrcweir 		// c) Initialize connection to possible PlugIn dll.
223cdf0e10cSrcweir 
224cdf0e10cSrcweir // OPipeConnection removed, connection to plugin now uses acceptor service
225cdf0e10cSrcweir #if 0
226cdf0e10cSrcweir 		if ( m_bUsePlugIn == sal_True )
227cdf0e10cSrcweir 		{
228cdf0e10cSrcweir 			Reference< XConnection >	xConnection			= new OPipeConnection( xGlobalServiceManager );
229cdf0e10cSrcweir 			Reference< XBridgeFactory >	xBridgeFactory		( xGlobalServiceManager->createInstance( SERVICENAME_BRIDGEFACTORY	), UNO_QUERY );
230cdf0e10cSrcweir 			if	(
231cdf0e10cSrcweir 					( xConnection.is()			== sal_True )	&&
232cdf0e10cSrcweir 					( xBridgeFactory.is()		== sal_True )
233cdf0e10cSrcweir 				)
234cdf0e10cSrcweir 			{
235cdf0e10cSrcweir 				Reference< XBridge > xBridge = xBridgeFactory->createBridge(	NAME_PLUGINBRIDGE								,
236cdf0e10cSrcweir 																				PROTOCOL_PLUGINBRIDGE							,
237cdf0e10cSrcweir 																				xConnection										,
238cdf0e10cSrcweir 																				new OInstanceProvider( xGlobalServiceManager )	);
239cdf0e10cSrcweir 			}
240cdf0e10cSrcweir 			else
241cdf0e10cSrcweir 			{
242cdf0e10cSrcweir 				// Error handling ... !?
243cdf0e10cSrcweir 				LOG_ASSERT( sal_False, "FrameWork::Main()\nNo connection to plugin. Initialization of bridge failed.\n" )
244cdf0e10cSrcweir 			}
245cdf0e10cSrcweir 		}
246cdf0e10cSrcweir #endif
247cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
248cdf0e10cSrcweir 		// d) Initialize new task with a HTML-URL in it.
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 		// Cast desktop to right interface to do this.
251cdf0e10cSrcweir 		Reference< XDispatchProvider > xDispatchProvider( xDesktop, UNO_QUERY );
252cdf0e10cSrcweir 		// Safe impossible cases.
253cdf0e10cSrcweir 		// Desktop MUST support these interface!
254cdf0e10cSrcweir 		LOG_ASSERT( !(xDispatchProvider.is()==sal_False), "FrameWork::Main()\nDesktop don't support XDispatchProvider interface.\n" )
255cdf0e10cSrcweir 		if ( xDispatchProvider.is() == sal_True )
256cdf0e10cSrcweir 		{
257cdf0e10cSrcweir 			// Build URL ...
258cdf0e10cSrcweir 			OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "file://e|/dokumentation/Documentation/projekte/services/inimanager/inimanager/index.html" ));
259cdf0e10cSrcweir 			URL aURL;
260cdf0e10cSrcweir 			aURL.Complete = sURL;
261cdf0e10cSrcweir 			// ... and dispatch it.
262cdf0e10cSrcweir 			Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, FRAMETYPE_BLANK, 0 );
263cdf0e10cSrcweir 			xDispatch->dispatch( aURL, Sequence< PropertyValue >() );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 			// Use special feature of desktop service and log current tree state in file.
266cdf0e10cSrcweir //			LOG_TREE( xDesktop )
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 			// Build URL ...
269cdf0e10cSrcweir 			sURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "file://d|/menu.htm" ));
270cdf0e10cSrcweir 			aURL.Complete = sURL;
271cdf0e10cSrcweir 			// ... and dispatch it.
272cdf0e10cSrcweir 			xDispatch = xDispatchProvider->queryDispatch( aURL, FRAMETYPE_BLANK, 0 );
273cdf0e10cSrcweir 			xDispatch->dispatch( aURL, Sequence< PropertyValue >() );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 			// Use special feature of desktop service and log current tree state in file.
276cdf0e10cSrcweir //			LOG_TREE( xDesktop )
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 		// Set running-mode for application.
280cdf0e10cSrcweir 		Execute();
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir }
283