summaryrefslogtreecommitdiff
path: root/framework/source/application/framework.cxx
blob: 183bf0d59221765cd9196a0f23f9b78585169785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_framework.hxx"

//_________________________________________________________________________________________________________________
//	my own includes
//_________________________________________________________________________________________________________________

#include <helper/oinstanceprovider.hxx>
#include <classes/servicemanager.hxx>
#include <macros/debug.hxx>

#include <defines.hxx>

//_________________________________________________________________________________________________________________
//	interface includes
//_________________________________________________________________________________________________________________
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/frame/XFrameLoader.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XLoadEventListener.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/frame/XFrames.hpp>

#include <com/sun/star/connection/XConnection.hpp>

#include <com/sun/star/bridge/XBridgeFactory.hpp>

//_________________________________________________________________________________________________________________
//	other includes
//_________________________________________________________________________________________________________________
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/unoiface.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <vos/process.hxx>

//_________________________________________________________________________________________________________________
//	namespace
//_________________________________________________________________________________________________________________

using namespace ::rtl							;
using namespace ::vos							;
using namespace ::comphelper					;
using namespace ::framework						;
using namespace ::com::sun::star::uno			;
using namespace ::com::sun::star::lang			;
using namespace ::com::sun::star::frame			;
using namespace ::com::sun::star::awt			;
using namespace ::com::sun::star::beans			;
using namespace ::com::sun::star::util			;
using namespace ::com::sun::star::connection	;
using namespace ::com::sun::star::bridge		;

//_________________________________________________________________________________________________________________
//	const
//_________________________________________________________________________________________________________________

#define	APPLICATIONNAME							"FrameWork"
#define	COMMANDARGUMENT_PLUGIN					DECLARE_ASCII("-plugin"					)
#define	NAME_PLUGINBRIDGE						DECLARE_ASCII("mozilla plugin bridge"	)
#define	PROTOCOL_PLUGINBRIDGE					DECLARE_ASCII("urp"						)

//_________________________________________________________________________________________________________________
//	declarations
//_________________________________________________________________________________________________________________

/*-************************************************************************************************************//**
    @short		normal application
    @descr		An instance of these class can be a normal node in frame tree only. The highest level to be allowed is 3!
                On 1 stand the desktop himself as the only one, on 2 are all tasks present ... and then comes frames only.
                A frame support influencing of his subtree, find of subframes, activate- and deactivate-mechanism as well as
                set/get of a frame window, component or controller.

    @implements	XInterface
                XTypeProvider
                XServiceInfo
                XFramesSupplier
                XFrame
                XComponent
                XStatusIndicatorSupplier
                XDispatchProvider
                XDispatchProviderInterception
                XBrowseHistoryRegistry
                XLoadEventListener
                XEventListener
                XWindowListener
                XTopWindowListener
                [ XDebugging, if TEST_TREE is defined! ]
    @base		OMutexMember
                OWeakObject

    @devstatus	deprecated
*//*-*************************************************************************************************************/
class FrameWork : public Application
{
    //-------------------------------------------------------------------------------------------------------------
    //	public methods
    //-------------------------------------------------------------------------------------------------------------

    public:
        void Main();

    private:
        void impl_analyzeCommandArguments();

    private:
        sal_Bool	m_bUsePlugIn	;

};	//	class FrameWork

//_________________________________________________________________________________________________________________
//	definitions
//_________________________________________________________________________________________________________________

//_________________________________________________________________________________________________________________
//	global variables
//_________________________________________________________________________________________________________________

FrameWork	aFrameWork	;

//_________________________________________________________________________________________________________________
//	definitions
//_________________________________________________________________________________________________________________

//*****************************************************************************************************************
//	private methods
//*****************************************************************************************************************
void FrameWork::impl_analyzeCommandArguments()
{
    // First reset all member variables which present states of incoming arguments!
    m_bUsePlugIn = sal_False;	// depends from "/plugin"

    // Then step over all given arguments and search for supported one.
    OStartupInfo	aInfo		;
    OUString		sArgument	;
    sal_uInt32		nCount		= aInfo.getCommandArgCount();
    for ( sal_uInt32 nArgument=0; nArgument<nCount; ++nArgument )
    {
        // If extraction of current argument successfull ...
        if ( aInfo.getCommandArg( nArgument, sArgument ) == osl_Process_E_None )
        {
            // ... search for matching with supported values.
            if ( sArgument == COMMANDARGUMENT_PLUGIN )
            {
                // We found "/plugin" => set internal equivalent.
                m_bUsePlugIn = sal_True;
            }
        }
    }
}

//_________________________________________________________________________________________________________________
//	main
//_________________________________________________________________________________________________________________

void FrameWork::Main()
{
    //-------------------------------------------------------------------------------------------------------------
    // a) Initialize ouer application

    // Analyze command arguments.
    impl_analyzeCommandArguments();

    // Create new global servicemanager.
    ServiceManager aManager;
    Reference< XMultiServiceFactory > xGlobalServiceManager = aManager.getGlobalUNOServiceManager();

    if ( xGlobalServiceManager.is() == sal_True )
    {
        // If it was successful - set in as static value in UNOTOOLS!
        setProcessServiceFactory( xGlobalServiceManager );

        //---------------------------------------------------------------------------------------------------------
        // b) Create root of ouer frame tree

        // Create top of frame hierarchy - the desktop.
        Reference< XDesktop > xDesktop( xGlobalServiceManager->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY );
        // Safe impossible cases
        // We need the desktop for working.
        LOG_ASSERT( !(xDesktop.is()==sal_False), "FrameWork::Main()\nCan't instanciate desktop!Servicename unknown?\n" )

        //---------------------------------------------------------------------------------------------------------
        // c) Initialize connection to possible PlugIn dll.

// OPipeConnection removed, connection to plugin now uses acceptor service
#if 0
        if ( m_bUsePlugIn == sal_True )
        {
            Reference< XConnection >	xConnection			= new OPipeConnection( xGlobalServiceManager );
            Reference< XBridgeFactory >	xBridgeFactory		( xGlobalServiceManager->createInstance( SERVICENAME_BRIDGEFACTORY	), UNO_QUERY );
            if	(
                    ( xConnection.is()			== sal_True )	&&
                    ( xBridgeFactory.is()		== sal_True )
                )
            {
                Reference< XBridge > xBridge = xBridgeFactory->createBridge(	NAME_PLUGINBRIDGE								,
                                                                                PROTOCOL_PLUGINBRIDGE							,
                                                                                xConnection										,
                                                                                new OInstanceProvider( xGlobalServiceManager )	);
            }
            else
            {
                // Error handling ... !?
                LOG_ASSERT( sal_False, "FrameWork::Main()\nNo connection to plugin. Initialization of bridge failed.\n" )
            }
        }
#endif
        //---------------------------------------------------------------------------------------------------------
        // d) Initialize new task with a HTML-URL in it.

        // Cast desktop to right interface to do this.
        Reference< XDispatchProvider > xDispatchProvider( xDesktop, UNO_QUERY );
        // Safe impossible cases.
        // Desktop MUST support these interface!
        LOG_ASSERT( !(xDispatchProvider.is()==sal_False), "FrameWork::Main()\nDesktop don't support XDispatchProvider interface.\n" )
        if ( xDispatchProvider.is() == sal_True )
        {
            // Build URL ...
            OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "file://e|/dokumentation/Documentation/projekte/services/inimanager/inimanager/index.html" ));
            URL aURL;
            aURL.Complete = sURL;
            // ... and dispatch it.
            Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, FRAMETYPE_BLANK, 0 );
            xDispatch->dispatch( aURL, Sequence< PropertyValue >() );

            // Use special feature of desktop service and log current tree state in file.
//			LOG_TREE( xDesktop )

            // Build URL ...
            sURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "file://d|/menu.htm" ));
            aURL.Complete = sURL;
            // ... and dispatch it.
            xDispatch = xDispatchProvider->queryDispatch( aURL, FRAMETYPE_BLANK, 0 );
            xDispatch->dispatch( aURL, Sequence< PropertyValue >() );

            // Use special feature of desktop service and log current tree state in file.
//			LOG_TREE( xDesktop )
        }

        // Set running-mode for application.
        Execute();
    }
}