1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_GENERICCONTROLLER_HXX
27cdf0e10cSrcweir #include "genericcontroller.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_
30cdf0e10cSrcweir #include <comphelper/uno3.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
33cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX
36cdf0e10cSrcweir #include "browserids.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX //autogen
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
42cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef DBAUI_DATAVIEW_HXX
45cdf0e10cSrcweir #include "dataview.hxx"
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
48cdf0e10cSrcweir #include <tools/debug.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
51cdf0e10cSrcweir #include <tools/diagnose_ex.h>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
54cdf0e10cSrcweir #include "dbustrings.hrc"
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _VCL_STDTEXT_HXX
57cdf0e10cSrcweir #include <vcl/stdtext.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
60cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #include <framework/titlehelper.hxx>
63cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
64cdf0e10cSrcweir #include <comphelper/sequence.hxx>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
67cdf0e10cSrcweir #include <comphelper/extract.hxx>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
70cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
73cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
76cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp>
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
79cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
80cdf0e10cSrcweir #endif
81cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
82cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
85cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
86cdf0e10cSrcweir #endif
87cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
88cdf0e10cSrcweir #include "UITools.hxx"
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir #ifndef _DBAUI_COMMON_TYPES_HXX_
91cdf0e10cSrcweir #include "commontypes.hxx"
92cdf0e10cSrcweir #endif
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #ifndef _SV_WAITOBJ_HXX
95cdf0e10cSrcweir #include <vcl/waitobj.hxx>
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir #ifndef _URLOBJ_HXX
98cdf0e10cSrcweir #include <tools/urlobj.hxx>
99cdf0e10cSrcweir #endif
100cdf0e10cSrcweir #ifndef SVTOOLS_URIHELPER_HXX
101cdf0e10cSrcweir #include <svl/urihelper.hxx>
102cdf0e10cSrcweir #endif
103cdf0e10cSrcweir #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
104cdf0e10cSrcweir #include "datasourceconnector.hxx"
105cdf0e10cSrcweir #endif
106cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
107cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
108cdf0e10cSrcweir #endif
109cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
110cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
111cdf0e10cSrcweir #endif
112cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_STATUS_VISIBILITY_HPP_
113cdf0e10cSrcweir #include <com/sun/star/frame/status/Visibility.hpp>
114cdf0e10cSrcweir #endif
115cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
116cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
117cdf0e10cSrcweir #endif
118cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX_
119cdf0e10cSrcweir #include <rtl/ustring.hxx>
120cdf0e10cSrcweir #endif
121cdf0e10cSrcweir #ifndef _RTL_LOGFILE_HXX_
122cdf0e10cSrcweir #include <rtl/logfile.hxx>
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir #include <algorithm>
125cdf0e10cSrcweir #include <hash_map>
126cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
127cdf0e10cSrcweir #include <limits>
128cdf0e10cSrcweir 
129cdf0e10cSrcweir using namespace ::com::sun::star;
130cdf0e10cSrcweir using namespace ::com::sun::star::uno;
131cdf0e10cSrcweir using namespace ::com::sun::star::beans;
132cdf0e10cSrcweir using namespace ::com::sun::star::frame;
133cdf0e10cSrcweir using namespace ::com::sun::star::frame::status;
134cdf0e10cSrcweir using namespace ::com::sun::star::util;
135cdf0e10cSrcweir using namespace ::com::sun::star::lang;
136cdf0e10cSrcweir using namespace ::com::sun::star::container;
137cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
138cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
139cdf0e10cSrcweir using namespace ::com::sun::star::task;
140cdf0e10cSrcweir using namespace ::com::sun::star::awt;
141cdf0e10cSrcweir using namespace ::com::sun::star;
142cdf0e10cSrcweir using namespace ::dbtools;
143cdf0e10cSrcweir using namespace ::comphelper;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // -------------------------------------------------------------------------
146cdf0e10cSrcweir #define ALL_FEATURES	            -1
147cdf0e10cSrcweir #define FIRST_USER_DEFINED_FEATURE  ( ::std::numeric_limits< sal_uInt16 >::max() - 1000 )
148cdf0e10cSrcweir #define LAST_USER_DEFINED_FEATURE   ( ::std::numeric_limits< sal_uInt16 >::max()        )
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -------------------------------------------------------------------------
151cdf0e10cSrcweir typedef ::std::hash_map< sal_Int16, sal_Int16 > CommandHashMap;
152cdf0e10cSrcweir typedef ::std::list< DispatchInformation > DispatchInfoList;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // -------------------------------------------------------------------------
getConfirmDeletionURL()156cdf0e10cSrcweir const ::rtl::OUString& getConfirmDeletionURL()
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 	static const ::rtl::OUString sConfirmDeletionURL( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/ConfirmDeletion" ) );
159cdf0e10cSrcweir 	return sConfirmDeletionURL;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir namespace dbaui
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 
165cdf0e10cSrcweir //==========================================================================
166cdf0e10cSrcweir //= UserDefinedFeatures
167cdf0e10cSrcweir //==========================================================================
168cdf0e10cSrcweir class UserDefinedFeatures
169cdf0e10cSrcweir {
170cdf0e10cSrcweir public:
171cdf0e10cSrcweir     UserDefinedFeatures( const Reference< XController >& _rxController );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     FeatureState    getState( const URL& _rFeatureURL );
174cdf0e10cSrcweir     void            execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir private:
177cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference< XController > m_aController;
178cdf0e10cSrcweir };
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //--------------------------------------------------------------------------
UserDefinedFeatures(const Reference<XController> & _rxController)181cdf0e10cSrcweir UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController )
182cdf0e10cSrcweir     :m_aController( _rxController )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir //--------------------------------------------------------------------------
getState(const URL &)187cdf0e10cSrcweir FeatureState UserDefinedFeatures::getState( const URL& /*_rFeatureURL*/ )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     // for now, enable all the time
190cdf0e10cSrcweir     // TODO: we should ask the dispatcher. However, this is laborious, since you cannot ask a dispatcher
191cdf0e10cSrcweir     // directly, but need to add a status listener.
192cdf0e10cSrcweir     FeatureState aState;
193cdf0e10cSrcweir     aState.bEnabled = sal_True;
194cdf0e10cSrcweir     return aState;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir //--------------------------------------------------------------------------
execute(const URL & _rFeatureURL,const Sequence<PropertyValue> & _rArgs)198cdf0e10cSrcweir void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     try
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         Reference< XController > xController( (Reference< XController >)m_aController, UNO_SET_THROW );
203cdf0e10cSrcweir         Reference< XDispatchProvider > xDispatchProvider( xController->getFrame(), UNO_QUERY_THROW );
204cdf0e10cSrcweir         Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch(
205cdf0e10cSrcweir             _rFeatureURL,
206cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
207cdf0e10cSrcweir             FrameSearchFlag::AUTO
208cdf0e10cSrcweir         ) );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         if ( xDispatch == xController )
211cdf0e10cSrcweir         {
212cdf0e10cSrcweir             OSL_ENSURE( false, "UserDefinedFeatures::execute: the controller shouldn't be the dispatcher here!" );
213cdf0e10cSrcweir             xDispatch.clear();
214cdf0e10cSrcweir         }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir         if ( xDispatch.is() )
217cdf0e10cSrcweir             xDispatch->dispatch( _rFeatureURL, _rArgs );
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir     catch( const Exception& )
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir //==========================================================================
226cdf0e10cSrcweir //= OGenericUnoController_Data
227cdf0e10cSrcweir //==========================================================================
228cdf0e10cSrcweir struct OGenericUnoController_Data
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     ::sfx2::UserInputInterception   m_aUserInputInterception;
231cdf0e10cSrcweir     UserDefinedFeatures             m_aUserDefinedFeatures;
232cdf0e10cSrcweir 
OGenericUnoController_Datadbaui::OGenericUnoController_Data233cdf0e10cSrcweir     OGenericUnoController_Data( OGenericUnoController& _rController, ::osl::Mutex& _rMutex )
234cdf0e10cSrcweir         :m_aUserInputInterception( _rController, _rMutex )
235cdf0e10cSrcweir         ,m_aUserDefinedFeatures( _rController.getXController() )
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir     }
238cdf0e10cSrcweir };
239cdf0e10cSrcweir 
240cdf0e10cSrcweir //==========================================================================
241cdf0e10cSrcweir //= OGenericUnoController
242cdf0e10cSrcweir //==========================================================================
DBG_NAME(OGenericUnoController)243cdf0e10cSrcweir DBG_NAME(OGenericUnoController)
244cdf0e10cSrcweir // -------------------------------------------------------------------------
245cdf0e10cSrcweir OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFactory >& _rM)
246cdf0e10cSrcweir 	:OGenericUnoController_Base( getMutex() )
247cdf0e10cSrcweir 	,m_pView(NULL)
248cdf0e10cSrcweir #ifdef DBG_UTIL
249cdf0e10cSrcweir     ,m_bDescribingSupportedFeatures( false )
250cdf0e10cSrcweir #endif
251cdf0e10cSrcweir 	,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
252cdf0e10cSrcweir 	,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
253cdf0e10cSrcweir 	,m_xServiceFactory(_rM)
254cdf0e10cSrcweir     ,m_aCurrentFrame( *this )
255cdf0e10cSrcweir 	,m_bPreview(sal_False)
256cdf0e10cSrcweir 	,m_bReadOnly(sal_False)
257cdf0e10cSrcweir 	,m_bCurrentlyModified(sal_False)
258cdf0e10cSrcweir     ,m_bExternalTitle(sal_False)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir     osl_incrementInterlockedCount( &m_refCount );
261cdf0e10cSrcweir     {
262cdf0e10cSrcweir         m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) );
263cdf0e10cSrcweir     }
264cdf0e10cSrcweir     osl_decrementInterlockedCount( &m_refCount );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     DBG_CTOR(OGenericUnoController,NULL);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	try
269cdf0e10cSrcweir 	{
270cdf0e10cSrcweir 		m_xUrlTransformer = Reference< XURLTransformer > (_rM->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), UNO_QUERY);
271cdf0e10cSrcweir 	}
272cdf0e10cSrcweir 	catch(Exception&)
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
275cdf0e10cSrcweir 	}
276cdf0e10cSrcweir }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir #ifdef WNT
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
OGenericUnoController()280cdf0e10cSrcweir OGenericUnoController::OGenericUnoController()
281cdf0e10cSrcweir 	:OGenericUnoController_Base( getMutex() )
282cdf0e10cSrcweir 	,m_pView(NULL)
283cdf0e10cSrcweir #ifdef DBG_UTIL
284cdf0e10cSrcweir     ,m_bDescribingSupportedFeatures( false )
285cdf0e10cSrcweir #endif
286cdf0e10cSrcweir 	,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
287cdf0e10cSrcweir 	,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
288cdf0e10cSrcweir     ,m_aCurrentFrame( *this )
289cdf0e10cSrcweir 	,m_bPreview(sal_False)
290cdf0e10cSrcweir 	,m_bReadOnly(sal_False)
291cdf0e10cSrcweir 	,m_bCurrentlyModified(sal_False)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     OSL_ENSURE( false, "OGenericUnoController::OGenericUnoController: illegal call!" );
294cdf0e10cSrcweir     // This ctor only exists because the MSVC compiler complained about an unresolved external
295cdf0e10cSrcweir     // symbol. It should not be used at all. Since using it yields strange runtime problems,
296cdf0e10cSrcweir     // we simply abort here.
297cdf0e10cSrcweir     abort();
298cdf0e10cSrcweir }
299cdf0e10cSrcweir #endif
300cdf0e10cSrcweir 
301cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OGenericUnoController()302cdf0e10cSrcweir OGenericUnoController::~OGenericUnoController()
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 
305cdf0e10cSrcweir     DBG_DTOR(OGenericUnoController,NULL);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir // -----------------------------------------------------------------------------
Construct(Window *)309cdf0e10cSrcweir sal_Bool OGenericUnoController::Construct(Window* /*pParent*/)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	OSL_ENSURE( getView(), "the view is NULL!" );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	if ( getView() )
314cdf0e10cSrcweir 	{
315cdf0e10cSrcweir 		getView()->Construct();
316cdf0e10cSrcweir 		getView()->Show();
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     m_aSupportedFeatures.clear();
320cdf0e10cSrcweir 	fillSupportedFeatures();
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	// create the database context
323cdf0e10cSrcweir 	DBG_ASSERT(getORB().is(), "OGenericUnoController::Construct need a service factory!");
324cdf0e10cSrcweir 	try
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		m_xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
327cdf0e10cSrcweir 	}
328cdf0e10cSrcweir 	catch(Exception&)
329cdf0e10cSrcweir 	{
330cdf0e10cSrcweir 		DBG_ERROR("OGenericUnoController::Construct: could not create (or start listening at) the database context!");
331cdf0e10cSrcweir 	}
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	if (!m_xDatabaseContext.is())
334cdf0e10cSrcweir 	{		// at least notify the user. Though the whole component does not make any sense without the database context ...
335cdf0e10cSrcweir 		ShowServiceNotAvailableError(getView(), String(SERVICE_SDB_DATABASECONTEXT), sal_True);
336cdf0e10cSrcweir 	}
337cdf0e10cSrcweir 	return sal_True;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OGenericUnoController,OnAsyncInvalidateAll,void *,EMPTYARG)340cdf0e10cSrcweir IMPL_LINK(OGenericUnoController, OnAsyncInvalidateAll, void*, EMPTYARG)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	if ( !OGenericUnoController_Base::rBHelper.bInDispose && !OGenericUnoController_Base::rBHelper.bDisposed )
343cdf0e10cSrcweir 		InvalidateFeature_Impl();
344cdf0e10cSrcweir 	return 0L;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_initialize()347cdf0e10cSrcweir void OGenericUnoController::impl_initialize()
348cdf0e10cSrcweir {
349cdf0e10cSrcweir }
350cdf0e10cSrcweir // -------------------------------------------------------------------------
initialize(const Sequence<Any> & aArguments)351cdf0e10cSrcweir void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
352cdf0e10cSrcweir {
353cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
354cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	Reference< XWindow >		xParent;
357cdf0e10cSrcweir 	Reference< XFrame > xFrame;
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	PropertyValue aValue;
360cdf0e10cSrcweir 	const Any* pIter	= aArguments.getConstArray();
361cdf0e10cSrcweir 	const Any* pEnd 	= pIter + aArguments.getLength();
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	for ( ; pIter != pEnd; ++pIter )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Frame" ) ) )
366cdf0e10cSrcweir 		{
367cdf0e10cSrcweir             xFrame.set(aValue.Value,UNO_QUERY_THROW);
368cdf0e10cSrcweir 		}
369cdf0e10cSrcweir         /* #i42316#
370cdf0e10cSrcweir 		else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "ReadOnly" ) ) )
371cdf0e10cSrcweir 		{
372cdf0e10cSrcweir 			aValue.Value >>= m_bReadOnly;
373cdf0e10cSrcweir 		}
374cdf0e10cSrcweir         */
375cdf0e10cSrcweir 		else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Preview" ) ) )
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			aValue.Value >>= m_bPreview;
378cdf0e10cSrcweir             m_bReadOnly = sal_True;
379cdf0e10cSrcweir 		}
380cdf0e10cSrcweir 	}
381cdf0e10cSrcweir 	try
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		if ( !xFrame.is() )
384cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "need a frame" ) ), *this, 1 );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir         xParent = xFrame->getContainerWindow();
387cdf0e10cSrcweir 		VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent);
388cdf0e10cSrcweir 		Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL;
389cdf0e10cSrcweir 		if (!pParentWin)
390cdf0e10cSrcweir 		{
391cdf0e10cSrcweir 			throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "Parent window is null" ), *this, 1 );
392cdf0e10cSrcweir 		}
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         m_aInitParameters.assign( aArguments );
395cdf0e10cSrcweir 		Construct( pParentWin );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir         ODataView* pView = getView();
398cdf0e10cSrcweir         if ( !pView )
399cdf0e10cSrcweir             throw RuntimeException( ::rtl::OUString::createFromAscii( "unable to create a view" ), *this );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 		if ( m_bReadOnly || m_bPreview )
402cdf0e10cSrcweir 			pView->EnableInput( sal_False );
403cdf0e10cSrcweir 
404cdf0e10cSrcweir         impl_initialize();
405cdf0e10cSrcweir 	}
406cdf0e10cSrcweir 	catch(Exception& e)
407cdf0e10cSrcweir 	{
408cdf0e10cSrcweir 		// no one clears my view if I won't
409cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pView);
410cdf0e10cSrcweir 		m_pView = NULL;
411cdf0e10cSrcweir 		throw;
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir //------------------------------------------------------------------------------
acquire()416cdf0e10cSrcweir void SAL_CALL OGenericUnoController::acquire(  ) throw ()
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	OGenericUnoController_Base::acquire();
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir //------------------------------------------------------------------------------
release()422cdf0e10cSrcweir void SAL_CALL OGenericUnoController::release(  ) throw ()
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	OGenericUnoController_Base::release();
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir // -------------------------------------------------------------------------
startFrameListening(const Reference<XFrame> & _rxFrame)428cdf0e10cSrcweir void OGenericUnoController::startFrameListening( const Reference< XFrame >& _rxFrame )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir     if ( _rxFrame.is() )
431cdf0e10cSrcweir 	    _rxFrame->addFrameActionListener( this );
432cdf0e10cSrcweir }
433cdf0e10cSrcweir 
434cdf0e10cSrcweir // -------------------------------------------------------------------------
stopFrameListening(const Reference<XFrame> & _rxFrame)435cdf0e10cSrcweir void OGenericUnoController::stopFrameListening( const Reference< XFrame >& _rxFrame )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir 	if ( _rxFrame.is() )
438cdf0e10cSrcweir 		_rxFrame->removeFrameActionListener( this );
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(const EventObject & Source)442cdf0e10cSrcweir void OGenericUnoController::disposing(const EventObject& Source) throw( RuntimeException )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	// our frame ?
445cdf0e10cSrcweir 	if ( Source.Source == getFrame() )
446cdf0e10cSrcweir 		stopFrameListening( getFrame() );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir //------------------------------------------------------------------------
modified(const EventObject & aEvent)449cdf0e10cSrcweir void OGenericUnoController::modified(const EventObject& aEvent) throw( RuntimeException )
450cdf0e10cSrcweir {
451cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
452cdf0e10cSrcweir 	if ( !isDataSourceReadOnly() )
453cdf0e10cSrcweir 	{
454cdf0e10cSrcweir 		Reference<XModifiable> xModi(aEvent.Source,UNO_QUERY);
455cdf0e10cSrcweir 		if ( xModi.is() )
456cdf0e10cSrcweir 			m_bCurrentlyModified = xModi->isModified(); // can only be reset by save
457cdf0e10cSrcweir 		else
458cdf0e10cSrcweir 			m_bCurrentlyModified = sal_True;
459cdf0e10cSrcweir 	}
460cdf0e10cSrcweir 	InvalidateFeature(ID_BROWSER_SAVEDOC);
461cdf0e10cSrcweir 	InvalidateFeature(ID_BROWSER_UNDO);
462cdf0e10cSrcweir }
463cdf0e10cSrcweir // -----------------------------------------------------------------------
getComponentWindow()464cdf0e10cSrcweir Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw (RuntimeException)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir 	return VCLUnoHelper::GetInterface( getView() );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir // -----------------------------------------------------------------------
getViewControllerName()470cdf0e10cSrcweir ::rtl::OUString SAL_CALL OGenericUnoController::getViewControllerName() throw (::com::sun::star::uno::RuntimeException)
471cdf0e10cSrcweir {
472cdf0e10cSrcweir     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir // -----------------------------------------------------------------------
getCreationArguments()476cdf0e10cSrcweir Sequence< PropertyValue > SAL_CALL OGenericUnoController::getCreationArguments() throw (RuntimeException)
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     // currently we do not support any creation args, so anything passed to XModel2::createViewController would be
479cdf0e10cSrcweir     // lost, so we can equally return an empty sequence here
480cdf0e10cSrcweir     return Sequence< PropertyValue >();
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir // -----------------------------------------------------------------------
attachFrame(const Reference<XFrame> & _rxFrame)484cdf0e10cSrcweir void OGenericUnoController::attachFrame( const Reference< XFrame >& _rxFrame ) throw( RuntimeException )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
487cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     stopFrameListening( m_aCurrentFrame.getFrame() );
490cdf0e10cSrcweir 	Reference< XFrame > xFrame = m_aCurrentFrame.attachFrame( _rxFrame );
491cdf0e10cSrcweir 	startFrameListening( xFrame );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	loadMenu( xFrame );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	if ( getView() )
496cdf0e10cSrcweir 		getView()->attachFrame( xFrame );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir // -----------------------------------------------------------------------------
500cdf0e10cSrcweir struct CommandCollector : public ::std::unary_function< SupportedFeatures::value_type, void>
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	sal_uInt16  m_nFeature;
503cdf0e10cSrcweir 	StringBag&  m_rFeatureCommands;
CommandCollectordbaui::CommandCollector504cdf0e10cSrcweir 	CommandCollector( sal_uInt16 _nFeature, StringBag& _rFeatureCommands )
505cdf0e10cSrcweir         :m_nFeature        ( _nFeature         )
506cdf0e10cSrcweir         ,m_rFeatureCommands( _rFeatureCommands )
507cdf0e10cSrcweir     {
508cdf0e10cSrcweir     }
509cdf0e10cSrcweir 
operator ()dbaui::CommandCollector510cdf0e10cSrcweir 	void operator() ( const SupportedFeatures::value_type& lhs )
511cdf0e10cSrcweir 	{
512cdf0e10cSrcweir 		if ( lhs.second.nFeatureId == m_nFeature )
513cdf0e10cSrcweir 			m_rFeatureCommands.insert( lhs.first );
514cdf0e10cSrcweir 	}
515cdf0e10cSrcweir };
516cdf0e10cSrcweir 
517cdf0e10cSrcweir // -----------------------------------------------------------------------
518cdf0e10cSrcweir namespace
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     typedef ::std::vector< Any >    States;
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     // ...................................................................
lcl_notifyMultipleStates(XStatusListener & _rListener,FeatureStateEvent & _rEvent,const States & _rStates)523cdf0e10cSrcweir     void    lcl_notifyMultipleStates( XStatusListener& _rListener, FeatureStateEvent& _rEvent, const States& _rStates )
524cdf0e10cSrcweir     {
525cdf0e10cSrcweir         for (   States::const_iterator state = _rStates.begin();
526cdf0e10cSrcweir                 state != _rStates.end();
527cdf0e10cSrcweir                 ++state
528cdf0e10cSrcweir             )
529cdf0e10cSrcweir         {
530cdf0e10cSrcweir             _rEvent.State = *state;
531cdf0e10cSrcweir             _rListener.statusChanged( _rEvent );
532cdf0e10cSrcweir         }
533cdf0e10cSrcweir     }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     // ...................................................................
lcl_collectStates(const FeatureState & _rFeatureState,States & _out_rStates)536cdf0e10cSrcweir     void    lcl_collectStates( const FeatureState& _rFeatureState, States& _out_rStates )
537cdf0e10cSrcweir     {
538cdf0e10cSrcweir         // order matters, due to a bug in framework which resets the check state when any non-boolean event
539cdf0e10cSrcweir         // arrives
540cdf0e10cSrcweir         // #i68215# is the bug to (re-)introduce this "ordered" notification here
541cdf0e10cSrcweir         // #i67882# is the bug which was caused by the real fix which we did in framework
542cdf0e10cSrcweir         // #i68216# is the bug which requests to fix the code in Draw which relies on
543cdf0e10cSrcweir         //          framework's implementation details
544cdf0e10cSrcweir         // 2006-08-07 / frank.schoenheit@sun.com
545cdf0e10cSrcweir         if ( !!_rFeatureState.sTitle )
546cdf0e10cSrcweir             _out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) );
547cdf0e10cSrcweir         if ( !!_rFeatureState.bChecked )
548cdf0e10cSrcweir             _out_rStates.push_back( makeAny( (sal_Bool)*_rFeatureState.bChecked ) );
549cdf0e10cSrcweir         if ( !!_rFeatureState.bInvisible )
550cdf0e10cSrcweir             _out_rStates.push_back( makeAny( Visibility( !*_rFeatureState.bInvisible ) ) );
551cdf0e10cSrcweir         if ( _rFeatureState.aValue.hasValue() )
552cdf0e10cSrcweir             _out_rStates.push_back( _rFeatureState.aValue );
553cdf0e10cSrcweir         if ( _out_rStates.empty() )
554cdf0e10cSrcweir             _out_rStates.push_back( Any() );
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir }
557cdf0e10cSrcweir 
558cdf0e10cSrcweir // -----------------------------------------------------------------------
ImplBroadcastFeatureState(const::rtl::OUString & _rFeature,const Reference<XStatusListener> & xListener,sal_Bool _bIgnoreCache)559cdf0e10cSrcweir void OGenericUnoController::ImplBroadcastFeatureState(const ::rtl::OUString& _rFeature, const Reference< XStatusListener > & xListener, sal_Bool _bIgnoreCache)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir 	sal_uInt16 nFeat = m_aSupportedFeatures[ _rFeature ].nFeatureId;
562cdf0e10cSrcweir 	FeatureState aFeatState( GetState( nFeat ) );
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	FeatureState& rCachedState = m_aStateCache[nFeat];	// creates if neccessary
565cdf0e10cSrcweir 	if ( !_bIgnoreCache )
566cdf0e10cSrcweir 	{
567cdf0e10cSrcweir 		// check if we really need to notify the listeners : this method may be called much more often than needed, so check
568cdf0e10cSrcweir 		// the cached state of the feature
569cdf0e10cSrcweir 		sal_Bool bAlreadyCached = ( m_aStateCache.find(nFeat) != m_aStateCache.end() );
570cdf0e10cSrcweir 		if ( bAlreadyCached )
571cdf0e10cSrcweir             if  (   ( rCachedState.bEnabled == aFeatState.bEnabled )
572cdf0e10cSrcweir                 &&  ( rCachedState.bChecked == aFeatState.bChecked )
573cdf0e10cSrcweir                 &&  ( rCachedState.bInvisible == aFeatState.bInvisible )
574cdf0e10cSrcweir                 &&  ( rCachedState.sTitle == aFeatState.sTitle )
575cdf0e10cSrcweir                 )
576cdf0e10cSrcweir             return;
577cdf0e10cSrcweir 	}
578cdf0e10cSrcweir 	rCachedState = aFeatState;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	FeatureStateEvent aEvent;
581cdf0e10cSrcweir 	aEvent.FeatureURL.Complete = _rFeature;
582cdf0e10cSrcweir 	if (m_xUrlTransformer.is())
583cdf0e10cSrcweir 		m_xUrlTransformer->parseStrict(aEvent.FeatureURL);
584cdf0e10cSrcweir 	aEvent.Source		= (XDispatch*)this;
585cdf0e10cSrcweir 	aEvent.IsEnabled	= aFeatState.bEnabled;
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     // collect all states to be notified
588cdf0e10cSrcweir     States aStates;
589cdf0e10cSrcweir     lcl_collectStates( aFeatState, aStates );
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 	// a special listener ?
592cdf0e10cSrcweir 	if ( xListener.is() )
593cdf0e10cSrcweir         lcl_notifyMultipleStates( *xListener.get(), aEvent, aStates );
594cdf0e10cSrcweir 	else
595cdf0e10cSrcweir 	{	// no -> iterate through all listeners responsible for the URL
596cdf0e10cSrcweir         StringBag aFeatureCommands;
597cdf0e10cSrcweir 		::std::for_each(
598cdf0e10cSrcweir             m_aSupportedFeatures.begin(),
599cdf0e10cSrcweir             m_aSupportedFeatures.end(),
600cdf0e10cSrcweir             CommandCollector( nFeat, aFeatureCommands )
601cdf0e10cSrcweir         );
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 		// it is possible that listeners are registered or revoked while
604cdf0e10cSrcweir 		// we are notifying them, so we must use a copy of m_arrStatusListener, not
605cdf0e10cSrcweir 		// m_arrStatusListener itself
606cdf0e10cSrcweir 		// #121276# / 2005-05-19 / frank.schoenheit@sun.com
607cdf0e10cSrcweir 		Dispatch aNotifyLoop( m_arrStatusListener );
608cdf0e10cSrcweir 		DispatchIterator iterSearch = aNotifyLoop.begin();
609cdf0e10cSrcweir 		DispatchIterator iterEnd = aNotifyLoop.end();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 		while (iterSearch != iterEnd)
612cdf0e10cSrcweir 		{
613cdf0e10cSrcweir 			DispatchTarget& rCurrent = *iterSearch;
614cdf0e10cSrcweir 			if ( aFeatureCommands.find( rCurrent.aURL.Complete ) != aFeatureCommands.end() )
615cdf0e10cSrcweir 			{
616cdf0e10cSrcweir 				aEvent.FeatureURL = rCurrent.aURL;
617cdf0e10cSrcweir                 lcl_notifyMultipleStates( *rCurrent.xListener.get(), aEvent, aStates );
618cdf0e10cSrcweir 			}
619cdf0e10cSrcweir 			++iterSearch;
620cdf0e10cSrcweir 		}
621cdf0e10cSrcweir 	}
622cdf0e10cSrcweir 
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir //------------------------------------------------------------------------------
isFeatureSupported(sal_Int32 _nId)626cdf0e10cSrcweir sal_Bool OGenericUnoController::isFeatureSupported( sal_Int32 _nId )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir 	SupportedFeatures::iterator aFeaturePos = ::std::find_if(
629cdf0e10cSrcweir 		m_aSupportedFeatures.begin(),
630cdf0e10cSrcweir 		m_aSupportedFeatures.end(),
631cdf0e10cSrcweir 		::std::bind2nd( CompareFeatureById(), _nId )
632cdf0e10cSrcweir 	);
633cdf0e10cSrcweir 
634cdf0e10cSrcweir     return ( m_aSupportedFeatures.end() != aFeaturePos && aFeaturePos->first.getLength());
635cdf0e10cSrcweir }
636cdf0e10cSrcweir 
637cdf0e10cSrcweir // -----------------------------------------------------------------------
InvalidateFeature(const::rtl::OUString & _rURLPath,const Reference<XStatusListener> & _xListener,sal_Bool _bForceBroadcast)638cdf0e10cSrcweir void OGenericUnoController::InvalidateFeature(const ::rtl::OUString& _rURLPath, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir 	ImplInvalidateFeature( m_aSupportedFeatures[ _rURLPath ].nFeatureId, _xListener, _bForceBroadcast );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir // -----------------------------------------------------------------------------
InvalidateFeature_Impl()644cdf0e10cSrcweir void OGenericUnoController::InvalidateFeature_Impl()
645cdf0e10cSrcweir {
646cdf0e10cSrcweir #ifdef DBG_UTIL
647cdf0e10cSrcweir 	static sal_Int32 s_nRecursions = 0;
648cdf0e10cSrcweir 	++s_nRecursions;
649cdf0e10cSrcweir #endif
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 	sal_Bool bEmpty = sal_True;
652cdf0e10cSrcweir 	FeatureListener aNextFeature;
653cdf0e10cSrcweir 	{
654cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aFeatureMutex);
655cdf0e10cSrcweir 		bEmpty = m_aFeaturesToInvalidate.empty();
656cdf0e10cSrcweir 		if (!bEmpty)
657cdf0e10cSrcweir 			aNextFeature = m_aFeaturesToInvalidate.front();
658cdf0e10cSrcweir 	}
659cdf0e10cSrcweir 	while(!bEmpty)
660cdf0e10cSrcweir 	{
661cdf0e10cSrcweir 		if ( ALL_FEATURES == aNextFeature.nId )
662cdf0e10cSrcweir 		{
663cdf0e10cSrcweir 			InvalidateAll_Impl();
664cdf0e10cSrcweir 			break;
665cdf0e10cSrcweir 		}
666cdf0e10cSrcweir 		else
667cdf0e10cSrcweir 		{
668cdf0e10cSrcweir 			SupportedFeatures::iterator aFeaturePos = ::std::find_if(
669cdf0e10cSrcweir 				m_aSupportedFeatures.begin(),
670cdf0e10cSrcweir 				m_aSupportedFeatures.end(),
671cdf0e10cSrcweir 				::std::bind2nd( CompareFeatureById(), aNextFeature.nId )
672cdf0e10cSrcweir 			);
673cdf0e10cSrcweir 
674cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
675cdf0e10cSrcweir             if ( m_aSupportedFeatures.end() == aFeaturePos )
676cdf0e10cSrcweir             {
677cdf0e10cSrcweir                 ::rtl::OString sMessage( "OGenericUnoController::InvalidateFeature_Impl: feature id " );
678cdf0e10cSrcweir                 sMessage += ::rtl::OString::valueOf( aNextFeature.nId );
679cdf0e10cSrcweir                 sMessage += ::rtl::OString( " has been invalidated, but is not supported!" );
680cdf0e10cSrcweir                 OSL_ENSURE( false, sMessage.getStr() );
681cdf0e10cSrcweir             }
682cdf0e10cSrcweir #endif
683cdf0e10cSrcweir 			if ( m_aSupportedFeatures.end() != aFeaturePos )
684cdf0e10cSrcweir 				// we really know this feature
685cdf0e10cSrcweir 				ImplBroadcastFeatureState( aFeaturePos->first, aNextFeature.xListener, aNextFeature.bForceBroadcast );
686cdf0e10cSrcweir 		}
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aFeatureMutex);
689cdf0e10cSrcweir 		m_aFeaturesToInvalidate.pop_front();
690cdf0e10cSrcweir 		bEmpty = m_aFeaturesToInvalidate.empty();
691cdf0e10cSrcweir 		if (!bEmpty)
692cdf0e10cSrcweir 			aNextFeature = m_aFeaturesToInvalidate.front();
693cdf0e10cSrcweir 	}
694cdf0e10cSrcweir 
695cdf0e10cSrcweir #ifdef DBG_UTIL
696cdf0e10cSrcweir 	--s_nRecursions;
697cdf0e10cSrcweir #endif
698cdf0e10cSrcweir }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir // -----------------------------------------------------------------------
ImplInvalidateFeature(sal_Int32 _nId,const Reference<XStatusListener> & _xListener,sal_Bool _bForceBroadcast)701cdf0e10cSrcweir void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Reference< XStatusListener >& _xListener, sal_Bool _bForceBroadcast )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
704cdf0e10cSrcweir     if ( _nId != -1 )
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir 	    SupportedFeatures::iterator aFeaturePos = ::std::find_if(
707cdf0e10cSrcweir 		    m_aSupportedFeatures.begin(),
708cdf0e10cSrcweir 		    m_aSupportedFeatures.end(),
709cdf0e10cSrcweir 		    ::std::bind2nd( CompareFeatureById(), _nId )
710cdf0e10cSrcweir 	    );
711cdf0e10cSrcweir         OSL_ENSURE( aFeaturePos != m_aSupportedFeatures.end(), "OGenericUnoController::ImplInvalidateFeature: invalidating an unsupported feature is suspicious, at least!" );
712cdf0e10cSrcweir     }
713cdf0e10cSrcweir #endif
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 	FeatureListener aListener;
716cdf0e10cSrcweir 	aListener.nId               = _nId;
717cdf0e10cSrcweir 	aListener.xListener         = _xListener;
718cdf0e10cSrcweir 	aListener.bForceBroadcast   = _bForceBroadcast;
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 	sal_Bool bWasEmpty;
721cdf0e10cSrcweir 	{
722cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aFeatureMutex );
723cdf0e10cSrcweir 		bWasEmpty = m_aFeaturesToInvalidate.empty();
724cdf0e10cSrcweir 		m_aFeaturesToInvalidate.push_back( aListener );
725cdf0e10cSrcweir 	}
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	if ( bWasEmpty )
728cdf0e10cSrcweir 		m_aAsyncInvalidateAll.Call();
729cdf0e10cSrcweir }
730cdf0e10cSrcweir 
731cdf0e10cSrcweir // -----------------------------------------------------------------------
InvalidateFeature(sal_uInt16 _nId,const Reference<XStatusListener> & _xListener,sal_Bool _bForceBroadcast)732cdf0e10cSrcweir void OGenericUnoController::InvalidateFeature(sal_uInt16 _nId, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
733cdf0e10cSrcweir {
734cdf0e10cSrcweir 	ImplInvalidateFeature( _nId, _xListener, _bForceBroadcast );
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
737cdf0e10cSrcweir // -----------------------------------------------------------------------
InvalidateAll()738cdf0e10cSrcweir void OGenericUnoController::InvalidateAll()
739cdf0e10cSrcweir {
740cdf0e10cSrcweir 	ImplInvalidateFeature( ALL_FEATURES, NULL, sal_True );
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir // -----------------------------------------------------------------------------
InvalidateAll_Impl()744cdf0e10cSrcweir void OGenericUnoController::InvalidateAll_Impl()
745cdf0e10cSrcweir {
746cdf0e10cSrcweir 	// ---------------------------------
747cdf0e10cSrcweir 	// invalidate all aupported features
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	for (   SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
750cdf0e10cSrcweir             aIter != m_aSupportedFeatures.end();
751cdf0e10cSrcweir             ++aIter
752cdf0e10cSrcweir         )
753cdf0e10cSrcweir 		ImplBroadcastFeatureState( aIter->first, NULL, sal_True );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aFeatureMutex);
757cdf0e10cSrcweir 		DBG_ASSERT(m_aFeaturesToInvalidate.size(), "OGenericUnoController::InvalidateAll_Impl: to be called from within InvalidateFeature_Impl only!");
758cdf0e10cSrcweir 		m_aFeaturesToInvalidate.pop_front();
759cdf0e10cSrcweir 		if(!m_aFeaturesToInvalidate.empty())
760cdf0e10cSrcweir 			m_aAsyncInvalidateAll.Call();
761cdf0e10cSrcweir 	}
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
764cdf0e10cSrcweir // -----------------------------------------------------------------------
queryDispatch(const URL & aURL,const::rtl::OUString & aTargetFrameName,sal_Int32 nSearchFlags)765cdf0e10cSrcweir Reference< XDispatch >	OGenericUnoController::queryDispatch(const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir 	Reference< XDispatch > xReturn;
768cdf0e10cSrcweir 
769cdf0e10cSrcweir     OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::queryDispatch: shouldn't this be filled at construction time?" );
770cdf0e10cSrcweir     if ( m_aSupportedFeatures.empty() )
771cdf0e10cSrcweir         fillSupportedFeatures();
772cdf0e10cSrcweir 
773cdf0e10cSrcweir 	// URL's we can handle ourself?
774cdf0e10cSrcweir 	if  (   aURL.Complete.equals( getConfirmDeletionURL() )
775cdf0e10cSrcweir         ||  (   ( m_aSupportedFeatures.find( aURL.Complete ) != m_aSupportedFeatures.end() )
776cdf0e10cSrcweir             &&  !isUserDefinedFeature( aURL.Complete )
777cdf0e10cSrcweir             )
778cdf0e10cSrcweir         )
779cdf0e10cSrcweir 	{
780cdf0e10cSrcweir 		xReturn = this;
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir 	// no? -> ask the slave dispatcher
783cdf0e10cSrcweir 	else if ( m_xSlaveDispatcher.is() )
784cdf0e10cSrcweir 	{
785cdf0e10cSrcweir 		xReturn = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
786cdf0e10cSrcweir 	}
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 	// outta here
789cdf0e10cSrcweir 	return xReturn;
790cdf0e10cSrcweir }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir // -----------------------------------------------------------------------
queryDispatches(const Sequence<DispatchDescriptor> & aDescripts)793cdf0e10cSrcweir Sequence< Reference< XDispatch > > OGenericUnoController::queryDispatches(const Sequence< DispatchDescriptor >& aDescripts) throw( RuntimeException )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir 	Sequence< Reference< XDispatch > > aReturn;
796cdf0e10cSrcweir 	sal_Int32 nLen = aDescripts.getLength();
797cdf0e10cSrcweir 	if ( nLen )
798cdf0e10cSrcweir 	{
799cdf0e10cSrcweir 		aReturn.realloc( nLen );
800cdf0e10cSrcweir 				Reference< XDispatch >* pReturn 	= aReturn.getArray();
801cdf0e10cSrcweir 		const	Reference< XDispatch >* pReturnEnd	= aReturn.getArray() + nLen;
802cdf0e10cSrcweir 		const	DispatchDescriptor* 	pDescripts	= aDescripts.getConstArray();
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 		for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
805cdf0e10cSrcweir 		{
806cdf0e10cSrcweir 			*pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
807cdf0e10cSrcweir 		}
808cdf0e10cSrcweir 	}
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 	return aReturn;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir // -----------------------------------------------------------------------
getSlaveDispatchProvider(void)814cdf0e10cSrcweir Reference< XDispatchProvider >	OGenericUnoController::getSlaveDispatchProvider(void) throw( RuntimeException )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	return m_xSlaveDispatcher;
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819cdf0e10cSrcweir // -----------------------------------------------------------------------
setSlaveDispatchProvider(const Reference<XDispatchProvider> & _xNewProvider)820cdf0e10cSrcweir void OGenericUnoController::setSlaveDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	m_xSlaveDispatcher = _xNewProvider;
823cdf0e10cSrcweir }
824cdf0e10cSrcweir 
825cdf0e10cSrcweir // -----------------------------------------------------------------------
getMasterDispatchProvider(void)826cdf0e10cSrcweir Reference< XDispatchProvider >	OGenericUnoController::getMasterDispatchProvider(void) throw( RuntimeException )
827cdf0e10cSrcweir {
828cdf0e10cSrcweir 	return m_xMasterDispatcher;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir // -----------------------------------------------------------------------
setMasterDispatchProvider(const Reference<XDispatchProvider> & _xNewProvider)832cdf0e10cSrcweir void OGenericUnoController::setMasterDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir 	m_xMasterDispatcher = _xNewProvider;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir 
837cdf0e10cSrcweir // -----------------------------------------------------------------------
dispatch(const URL & _aURL,const Sequence<PropertyValue> & aArgs)838cdf0e10cSrcweir void OGenericUnoController::dispatch(const URL& _aURL, const Sequence< PropertyValue >& aArgs) throw(RuntimeException)
839cdf0e10cSrcweir {
840cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
841cdf0e10cSrcweir     // Since the fix for #123967#, the SolarMutex is not locked anymore when the framework calls into
842cdf0e10cSrcweir     // here. So, lock it ourself. The real solution would be to lock it only in the places
843cdf0e10cSrcweir     // where it's needed, but a) this might turn out difficult, since we then also need to care
844cdf0e10cSrcweir     // for locking in the proper order (SolarMutex and m_aMutex), and b) this would be too many places
845cdf0e10cSrcweir     // for the time frame of the fix.
846cdf0e10cSrcweir     // #i52602# / frank.schoenheit@sun.com / 2005-07-29
847cdf0e10cSrcweir 
848cdf0e10cSrcweir #ifdef TIMELOG
849cdf0e10cSrcweir     ::rtl::OString sLog( "OGenericUnoController::dispatch( '" );
850cdf0e10cSrcweir     sLog += ::rtl::OString( _aURL.Main.getStr(), _aURL.Main.getLength(), osl_getThreadTextEncoding() );
851cdf0e10cSrcweir     sLog += ::rtl::OString( "' )" );
852cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", sLog.getStr() );
853cdf0e10cSrcweir #endif
854cdf0e10cSrcweir 
855cdf0e10cSrcweir     executeChecked(_aURL,aArgs);
856cdf0e10cSrcweir }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir // -----------------------------------------------------------------------
addStatusListener(const Reference<XStatusListener> & aListener,const URL & _rURL)859cdf0e10cSrcweir void OGenericUnoController::addStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
860cdf0e10cSrcweir {
861cdf0e10cSrcweir     // parse the ULR now and here, this saves later parsing in each notification round
862cdf0e10cSrcweir     URL aParsedURL( _rURL );
863cdf0e10cSrcweir 	if ( m_xUrlTransformer.is() )
864cdf0e10cSrcweir 		m_xUrlTransformer->parseStrict( aParsedURL );
865cdf0e10cSrcweir 
866cdf0e10cSrcweir     // remeber the listener together with the URL
867cdf0e10cSrcweir 	m_arrStatusListener.insert( m_arrStatusListener.end(), DispatchTarget( aParsedURL, aListener ) );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     // initially broadcast the state
870cdf0e10cSrcweir 	ImplBroadcastFeatureState( aParsedURL.Complete, aListener, sal_True );
871cdf0e10cSrcweir 		// force the new state to be broadcasted to the new listener
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir // -----------------------------------------------------------------------
removeStatusListener(const Reference<XStatusListener> & aListener,const URL & _rURL)875cdf0e10cSrcweir void OGenericUnoController::removeStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
876cdf0e10cSrcweir {
877cdf0e10cSrcweir 	DispatchIterator iterSearch = m_arrStatusListener.begin();
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	sal_Bool bRemoveForAll = (_rURL.Complete.getLength() == 0);
880cdf0e10cSrcweir 	while ( iterSearch != m_arrStatusListener.end() )
881cdf0e10cSrcweir 	{
882cdf0e10cSrcweir 		DispatchTarget& rCurrent = *iterSearch;
883cdf0e10cSrcweir 		if	(	(rCurrent.xListener == aListener)
884cdf0e10cSrcweir 			&&	(	bRemoveForAll
885cdf0e10cSrcweir 				||	(rCurrent.aURL.Complete.equals(_rURL.Complete))
886cdf0e10cSrcweir 				)
887cdf0e10cSrcweir 			)
888cdf0e10cSrcweir 		{
889cdf0e10cSrcweir 			m_arrStatusListener.erase( iterSearch );
890cdf0e10cSrcweir 			if (!bRemoveForAll)
891cdf0e10cSrcweir 				// remove the listener only for the given URL, so we can exit the loop after deletion
892cdf0e10cSrcweir 				break;
893cdf0e10cSrcweir 		}
894cdf0e10cSrcweir 		else
895cdf0e10cSrcweir 			++iterSearch;
896cdf0e10cSrcweir 	}
897cdf0e10cSrcweir 
898cdf0e10cSrcweir     OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::removeStatusListener: shouldn't this be filled at construction time?" );
899cdf0e10cSrcweir     if ( m_aSupportedFeatures.empty() )
900cdf0e10cSrcweir         fillSupportedFeatures();
901cdf0e10cSrcweir 
902cdf0e10cSrcweir 	SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(_rURL.Complete);
903cdf0e10cSrcweir 	if (aIter != m_aSupportedFeatures.end())
904cdf0e10cSrcweir 	{	// clear the cache for that feature
905cdf0e10cSrcweir 		StateCacheIterator aCachePos = m_aStateCache.find( aIter->second.nFeatureId );
906cdf0e10cSrcweir 		if ( aCachePos != m_aStateCache.end() )
907cdf0e10cSrcweir 			m_aStateCache.erase( aCachePos );
908cdf0e10cSrcweir 	}
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 	// now remove the listener from the deque
911cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aFeatureMutex );
912cdf0e10cSrcweir 	m_aFeaturesToInvalidate.erase(
913cdf0e10cSrcweir 		::std::remove_if(	m_aFeaturesToInvalidate.begin(),
914cdf0e10cSrcweir 							m_aFeaturesToInvalidate.end(),
915cdf0e10cSrcweir 							::std::bind2nd(FindFeatureListener(),aListener))
916cdf0e10cSrcweir 		,m_aFeaturesToInvalidate.end());
917cdf0e10cSrcweir }
918cdf0e10cSrcweir // -----------------------------------------------------------------------------
releaseNumberForComponent()919cdf0e10cSrcweir void OGenericUnoController::releaseNumberForComponent()
920cdf0e10cSrcweir {
921cdf0e10cSrcweir     try
922cdf0e10cSrcweir     {
923cdf0e10cSrcweir         Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY      );
924cdf0e10cSrcweir         if ( xUntitledProvider.is() )
925cdf0e10cSrcweir             xUntitledProvider->releaseNumberForComponent(static_cast<XWeak*>(this));
926cdf0e10cSrcweir     }
927cdf0e10cSrcweir     catch( const Exception& )
928cdf0e10cSrcweir 	{
929cdf0e10cSrcweir         // NII
930cdf0e10cSrcweir 	}
931cdf0e10cSrcweir }
932cdf0e10cSrcweir // -----------------------------------------------------------------------
disposing()933cdf0e10cSrcweir void OGenericUnoController::disposing()
934cdf0e10cSrcweir {
935cdf0e10cSrcweir 	{
936cdf0e10cSrcweir 		EventObject aDisposeEvent;
937cdf0e10cSrcweir 		aDisposeEvent.Source = static_cast<XWeak*>(this);
938cdf0e10cSrcweir 		Dispatch aStatusListener = m_arrStatusListener;
939cdf0e10cSrcweir 		Dispatch::iterator aEnd = aStatusListener.end();
940cdf0e10cSrcweir 		for (Dispatch::iterator aIter = aStatusListener.begin(); aIter != aEnd; ++aIter)
941cdf0e10cSrcweir 		{
942cdf0e10cSrcweir 			aIter->xListener->disposing(aDisposeEvent);
943cdf0e10cSrcweir 		}
944cdf0e10cSrcweir 		m_arrStatusListener.clear();
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 	m_xDatabaseContext = NULL;
948cdf0e10cSrcweir 	{
949cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aFeatureMutex);
950cdf0e10cSrcweir 		m_aAsyncInvalidateAll.CancelCall();
951cdf0e10cSrcweir 		m_aFeaturesToInvalidate.clear();
952cdf0e10cSrcweir 	}
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     releaseNumberForComponent();
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 	// check out from all the objects we are listening
957cdf0e10cSrcweir 	// the frame
958cdf0e10cSrcweir 	stopFrameListening( m_aCurrentFrame.getFrame() );
959cdf0e10cSrcweir     m_aCurrentFrame.attachFrame( NULL );
960cdf0e10cSrcweir 
961cdf0e10cSrcweir     m_xMasterDispatcher = NULL;
962cdf0e10cSrcweir     m_xSlaveDispatcher = NULL;
963cdf0e10cSrcweir     m_xServiceFactory = NULL;
964cdf0e10cSrcweir 	m_xTitleHelper.clear();
965cdf0e10cSrcweir     m_xUrlTransformer.clear();
966cdf0e10cSrcweir     m_aInitParameters.clear();
967cdf0e10cSrcweir }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir // -----------------------------------------------------------------------------
addEventListener(const Reference<XEventListener> & xListener)970cdf0e10cSrcweir void SAL_CALL OGenericUnoController::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
971cdf0e10cSrcweir {
972cdf0e10cSrcweir     // disambiguate
973cdf0e10cSrcweir     OGenericUnoController_Base::WeakComponentImplHelperBase::addEventListener( xListener );
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeEventListener(const Reference<XEventListener> & xListener)977cdf0e10cSrcweir void SAL_CALL OGenericUnoController::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
978cdf0e10cSrcweir {
979cdf0e10cSrcweir     // disambiguate
980cdf0e10cSrcweir     OGenericUnoController_Base::WeakComponentImplHelperBase::removeEventListener( xListener );
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir //------------------------------------------------------------------------------
frameAction(const FrameActionEvent & aEvent)984cdf0e10cSrcweir void OGenericUnoController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
987cdf0e10cSrcweir     if ( aEvent.Frame == m_aCurrentFrame.getFrame() )
988cdf0e10cSrcweir         m_aCurrentFrame.frameAction( aEvent.Action );
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir //------------------------------------------------------------------------------
implDescribeSupportedFeature(const sal_Char * _pAsciiCommandURL,sal_uInt16 _nFeatureId,sal_Int16 _nCommandGroup)992cdf0e10cSrcweir void OGenericUnoController::implDescribeSupportedFeature( const sal_Char* _pAsciiCommandURL,
993cdf0e10cSrcweir         sal_uInt16 _nFeatureId, sal_Int16 _nCommandGroup )
994cdf0e10cSrcweir {
995cdf0e10cSrcweir #ifdef DBG_UTIL
996cdf0e10cSrcweir     DBG_ASSERT( m_bDescribingSupportedFeatures, "OGenericUnoController::implDescribeSupportedFeature: bad timing for this call!" );
997cdf0e10cSrcweir #endif
998cdf0e10cSrcweir     OSL_PRECOND( _nFeatureId < FIRST_USER_DEFINED_FEATURE, "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" );
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     ControllerFeature aFeature;
1001cdf0e10cSrcweir     aFeature.Command = ::rtl::OUString::createFromAscii( _pAsciiCommandURL );
1002cdf0e10cSrcweir     aFeature.nFeatureId = _nFeatureId;
1003cdf0e10cSrcweir     aFeature.GroupId = _nCommandGroup;
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1006cdf0e10cSrcweir     OSL_ENSURE( m_aSupportedFeatures.find( aFeature.Command ) == m_aSupportedFeatures.end(),
1007cdf0e10cSrcweir         "OGenericUnoController::implDescribeSupportedFeature: this feature is already there!" );
1008cdf0e10cSrcweir #endif
1009cdf0e10cSrcweir     m_aSupportedFeatures[ aFeature.Command ] = aFeature;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir //------------------------------------------------------------------------------
describeSupportedFeatures()1013cdf0e10cSrcweir void OGenericUnoController::describeSupportedFeatures()
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir     // add all supported features
1016cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Copy", ID_BROWSER_COPY, CommandGroup::EDIT );
1017cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Cut", ID_BROWSER_CUT, CommandGroup::EDIT );
1018cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Paste", ID_BROWSER_PASTE, CommandGroup::EDIT );
1019cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ClipboardFormatItems", ID_BROWSER_CLIPBOARD_FORMAT_ITEMS );
1020cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:DSBEditDoc", ID_BROWSER_EDITDOC, CommandGroup::DOCUMENT );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir //------------------------------------------------------------------------------
GetState(sal_uInt16 _nId) const1024cdf0e10cSrcweir FeatureState OGenericUnoController::GetState( sal_uInt16 _nId ) const
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir 	FeatureState aReturn;
1027cdf0e10cSrcweir 		// (disabled automatically)
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 	switch ( _nId )
1030cdf0e10cSrcweir 	{
1031cdf0e10cSrcweir 		case ID_BROWSER_UNDO:
1032cdf0e10cSrcweir 		case ID_BROWSER_SAVEDOC:
1033cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
1034cdf0e10cSrcweir 			break;
1035cdf0e10cSrcweir         default:
1036cdf0e10cSrcweir             aReturn = m_pData->m_aUserDefinedFeatures.getState( getURLForId( _nId ) );
1037cdf0e10cSrcweir             break;
1038cdf0e10cSrcweir 	}
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir 	return aReturn;
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir //------------------------------------------------------------------------------
Execute(sal_uInt16 _nId,const Sequence<PropertyValue> & _rArgs)1044cdf0e10cSrcweir void OGenericUnoController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue>& _rArgs )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir     OSL_ENSURE( isUserDefinedFeature( _nId ),
1047cdf0e10cSrcweir         "OGenericUnoController::Execute: responsible for user defined features only!" );
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir     // user defined features can be handled by dispatch interceptors resp. protocol handlers only.
1050cdf0e10cSrcweir     // So, we need to do a queryDispatch, and dispatch the URL
1051cdf0e10cSrcweir     m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs );
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir //------------------------------------------------------------------------------
getURLForId(sal_Int32 _nId) const1055cdf0e10cSrcweir URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir 	URL aReturn;
1058cdf0e10cSrcweir 	if ( m_xUrlTransformer.is() )
1059cdf0e10cSrcweir 	{
1060cdf0e10cSrcweir 		SupportedFeatures::const_iterator aIter = ::std::find_if(
1061cdf0e10cSrcweir 			m_aSupportedFeatures.begin(),
1062cdf0e10cSrcweir 			m_aSupportedFeatures.end(),
1063cdf0e10cSrcweir 			::std::bind2nd( CompareFeatureById(), _nId )
1064cdf0e10cSrcweir 		);
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 		if ( m_aSupportedFeatures.end() != aIter && aIter->first.getLength() )
1067cdf0e10cSrcweir 		{
1068cdf0e10cSrcweir 			aReturn.Complete = aIter->first;
1069cdf0e10cSrcweir 			m_xUrlTransformer->parseStrict( aReturn );
1070cdf0e10cSrcweir 		}
1071cdf0e10cSrcweir 	}
1072cdf0e10cSrcweir 	return aReturn;
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir //-------------------------------------------------------------------------
isUserDefinedFeature(const sal_uInt16 _nFeatureId) const1076cdf0e10cSrcweir bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId ) const
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir     return ( _nFeatureId >= FIRST_USER_DEFINED_FEATURE ) && ( _nFeatureId < LAST_USER_DEFINED_FEATURE );
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir //-------------------------------------------------------------------------
isUserDefinedFeature(const::rtl::OUString & _rFeatureURL) const1082cdf0e10cSrcweir bool OGenericUnoController::isUserDefinedFeature( const ::rtl::OUString& _rFeatureURL ) const
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir     SupportedFeatures::const_iterator pos = m_aSupportedFeatures.find( _rFeatureURL );
1085cdf0e10cSrcweir     OSL_PRECOND( pos != m_aSupportedFeatures.end(),
1086cdf0e10cSrcweir         "OGenericUnoController::isUserDefinedFeature: this is no supported feature at all!" );
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir     return ( pos != m_aSupportedFeatures.end() ) ? isUserDefinedFeature( pos->second.nFeatureId ) : false;
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir //-------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)1092cdf0e10cSrcweir sal_Bool SAL_CALL OGenericUnoController::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException)
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 	const ::rtl::OUString* pArray = aSupported.getConstArray();
1097cdf0e10cSrcweir 	const ::rtl::OUString* pArrayEnd = aSupported.getConstArray() + aSupported.getLength();
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 	for ( ;( pArray != pArrayEnd ) && !pArray->equals( ServiceName ); ++pArray )
1100cdf0e10cSrcweir 		;
1101cdf0e10cSrcweir 	return pArray != pArrayEnd;
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir // -----------------------------------------------------------------------------
startConnectionListening(const Reference<XConnection> & _rxConnection)1105cdf0e10cSrcweir void OGenericUnoController::startConnectionListening(const Reference< XConnection >& _rxConnection)
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir 	// we have to remove ourself before dispoing the connection
1108cdf0e10cSrcweir 	Reference< XComponent >  xComponent(_rxConnection, UNO_QUERY);
1109cdf0e10cSrcweir 	if (xComponent.is())
1110cdf0e10cSrcweir 		xComponent->addEventListener(static_cast<XFrameActionListener*>(this));
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir // -----------------------------------------------------------------------------
stopConnectionListening(const Reference<XConnection> & _rxConnection)1114cdf0e10cSrcweir void OGenericUnoController::stopConnectionListening(const Reference< XConnection >& _rxConnection)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir 	// we have to remove ourself before dispoing the connection
1117cdf0e10cSrcweir 	Reference< XComponent >  xComponent(_rxConnection, UNO_QUERY);
1118cdf0e10cSrcweir 	if (xComponent.is())
1119cdf0e10cSrcweir 		xComponent->removeEventListener(static_cast<XFrameActionListener*>(this));
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir // -----------------------------------------------------------------------------
connect(const Reference<XDataSource> & _xDataSource,::dbtools::SQLExceptionInfo * _pErrorInfo)1122cdf0e10cSrcweir Reference< XConnection > OGenericUnoController::connect( const Reference< XDataSource>& _xDataSource,
1123cdf0e10cSrcweir     ::dbtools::SQLExceptionInfo* _pErrorInfo )
1124cdf0e10cSrcweir {
1125cdf0e10cSrcweir 	WaitObject aWaitCursor( getView() );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir 	ODatasourceConnector aConnector( getORB(), getView(), ::rtl::OUString() );
1128cdf0e10cSrcweir 	Reference< XConnection > xConnection = aConnector.connect( _xDataSource, _pErrorInfo );
1129cdf0e10cSrcweir 	startConnectionListening( xConnection );
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 	return xConnection;
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir // -----------------------------------------------------------------------------
connect(const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rContextInformation,::dbtools::SQLExceptionInfo * _pErrorInfo)1134cdf0e10cSrcweir Reference< XConnection > OGenericUnoController::connect( const ::rtl::OUString& _rDataSourceName,
1135cdf0e10cSrcweir     const ::rtl::OUString& _rContextInformation, ::dbtools::SQLExceptionInfo* _pErrorInfo )
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir 	WaitObject aWaitCursor( getView() );
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 	ODatasourceConnector aConnector( getORB(), getView(), _rContextInformation );
1140cdf0e10cSrcweir 	Reference<XConnection> xConnection = aConnector.connect( _rDataSourceName, _pErrorInfo );
1141cdf0e10cSrcweir 	startConnectionListening( xConnection );
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	return xConnection;
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir // -----------------------------------------------------------------------------
showError(const SQLExceptionInfo & _rInfo)1147cdf0e10cSrcweir void OGenericUnoController::showError(const SQLExceptionInfo& _rInfo)
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir 	::dbaui::showError(_rInfo,getView(),getORB());
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir // -----------------------------------------------------------------------------
getLayoutManager(const Reference<XFrame> & _xFrame) const1152cdf0e10cSrcweir Reference< XLayoutManager > OGenericUnoController::getLayoutManager(const Reference< XFrame >& _xFrame) const
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir 	Reference< XPropertySet > xPropSet( _xFrame, UNO_QUERY );
1155cdf0e10cSrcweir     Reference< XLayoutManager > xLayoutManager;
1156cdf0e10cSrcweir 	if ( xPropSet.is() )
1157cdf0e10cSrcweir     {
1158cdf0e10cSrcweir         try
1159cdf0e10cSrcweir         {
1160cdf0e10cSrcweir 			xLayoutManager.set(xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))),UNO_QUERY);
1161cdf0e10cSrcweir         }
1162cdf0e10cSrcweir         catch ( Exception& )
1163cdf0e10cSrcweir         {
1164cdf0e10cSrcweir         }
1165cdf0e10cSrcweir     }
1166cdf0e10cSrcweir 	return xLayoutManager;
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir // -----------------------------------------------------------------------------
loadMenu(const Reference<XFrame> & _xFrame)1169cdf0e10cSrcweir void OGenericUnoController::loadMenu(const Reference< XFrame >& _xFrame)
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir     Reference< XLayoutManager > xLayoutManager = getLayoutManager(_xFrame);
1172cdf0e10cSrcweir     if ( xLayoutManager.is() )
1173cdf0e10cSrcweir 	{
1174cdf0e10cSrcweir 		xLayoutManager->lock();
1175cdf0e10cSrcweir         xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
1176cdf0e10cSrcweir 		xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/toolbar" )));
1177cdf0e10cSrcweir 		xLayoutManager->unlock();
1178cdf0e10cSrcweir 		xLayoutManager->doLayout();
1179cdf0e10cSrcweir 	}
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir     onLoadedMenu( xLayoutManager );
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir // -----------------------------------------------------------------------------
onLoadedMenu(const Reference<XLayoutManager> &)1185cdf0e10cSrcweir void OGenericUnoController::onLoadedMenu(const Reference< XLayoutManager >& /*_xLayoutManager*/)
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir     // not interested in
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir // -----------------------------------------------------------------------------
closeTask()1191cdf0e10cSrcweir void OGenericUnoController::closeTask()
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir 	m_aAsyncCloseTask.Call();
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OGenericUnoController,OnAsyncCloseTask,void *,EMPTYARG)1196cdf0e10cSrcweir IMPL_LINK(OGenericUnoController, OnAsyncCloseTask, void*, EMPTYARG)
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir 	if ( !OGenericUnoController_Base::rBHelper.bInDispose )
1199cdf0e10cSrcweir 	{
1200cdf0e10cSrcweir         try
1201cdf0e10cSrcweir         {
1202cdf0e10cSrcweir             Reference< util::XCloseable > xCloseable( m_aCurrentFrame.getFrame(), UNO_QUERY_THROW );
1203cdf0e10cSrcweir             xCloseable->close( sal_False ); // false - holds the owner ship for this frame inside this object!
1204cdf0e10cSrcweir         }
1205cdf0e10cSrcweir         catch( const Exception& )
1206cdf0e10cSrcweir         {
1207cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1208cdf0e10cSrcweir         }
1209cdf0e10cSrcweir 	}
1210cdf0e10cSrcweir 	return 0L;
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir // -----------------------------------------------------------------------------
getViewData(void)1213cdf0e10cSrcweir Any SAL_CALL OGenericUnoController::getViewData(void) throw( RuntimeException )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir 	return Any();
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir // -----------------------------------------------------------------------------
restoreViewData(const Any &)1218cdf0e10cSrcweir void SAL_CALL OGenericUnoController::restoreViewData(const Any& /*Data*/) throw( RuntimeException )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir // -----------------------------------------------------------------------------
getModel(void)1223cdf0e10cSrcweir Reference< XModel > SAL_CALL OGenericUnoController::getModel(void) throw( RuntimeException )
1224cdf0e10cSrcweir {
1225cdf0e10cSrcweir     return Reference< XModel >();
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir // -----------------------------------------------------------------------------
getFrame(void)1229cdf0e10cSrcweir Reference< XFrame > SAL_CALL OGenericUnoController::getFrame(void) throw( RuntimeException )
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
1232cdf0e10cSrcweir     return m_aCurrentFrame.getFrame();
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir // -----------------------------------------------------------------------------
attachModel(const Reference<XModel> &)1236cdf0e10cSrcweir sal_Bool SAL_CALL OGenericUnoController::attachModel(const Reference< XModel > & /*xModel*/) throw( RuntimeException )
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir     OSL_ENSURE( false, "OGenericUnoController::attachModel: not supported!" );
1239cdf0e10cSrcweir     return sal_False;
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeUnChecked(sal_uInt16 _nCommandId,const Sequence<PropertyValue> & aArgs)1243cdf0e10cSrcweir void OGenericUnoController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir 	Execute(_nCommandId, aArgs);
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeUnChecked(const util::URL & _rCommand,const Sequence<PropertyValue> & aArgs)1248cdf0e10cSrcweir void OGenericUnoController::executeUnChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir     OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::executeUnChecked: shouldn't this be filled at construction time?" );
1251cdf0e10cSrcweir     if ( m_aSupportedFeatures.empty() )
1252cdf0e10cSrcweir         fillSupportedFeatures();
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
1255cdf0e10cSrcweir 	if (aIter != m_aSupportedFeatures.end())
1256cdf0e10cSrcweir 		Execute( aIter->second.nFeatureId, aArgs );
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeChecked(const util::URL & _rCommand,const Sequence<PropertyValue> & aArgs)1259cdf0e10cSrcweir void OGenericUnoController::executeChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir     OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::executeChecked: shouldn't this be filled at construction time?" );
1262cdf0e10cSrcweir     if ( m_aSupportedFeatures.empty() )
1263cdf0e10cSrcweir         fillSupportedFeatures();
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
1266cdf0e10cSrcweir 	if ( aIter != m_aSupportedFeatures.end() )
1267cdf0e10cSrcweir 	{
1268cdf0e10cSrcweir 		sal_uInt16 nFeatureId = aIter->second.nFeatureId;
1269cdf0e10cSrcweir 		if ( GetState( nFeatureId ).bEnabled )
1270cdf0e10cSrcweir 			Execute( nFeatureId, aArgs );
1271cdf0e10cSrcweir 	}
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir // -----------------------------------------------------------------------------
1274cdf0e10cSrcweir //------------------------------------------------------------------------------
1275cdf0e10cSrcweir namespace
1276cdf0e10cSrcweir {
lcl_getModuleHelpModuleName(const Reference<XFrame> & _rxFrame)1277cdf0e10cSrcweir 	::rtl::OUString lcl_getModuleHelpModuleName( const Reference< XFrame >& _rxFrame )
1278cdf0e10cSrcweir 	{
1279cdf0e10cSrcweir 		const sal_Char* pReturn = NULL;
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 		try
1282cdf0e10cSrcweir 		{
1283cdf0e10cSrcweir 			// get the model of the document in the given frame
1284cdf0e10cSrcweir 			Reference< XController > xController;
1285cdf0e10cSrcweir 			if ( _rxFrame.is() )
1286cdf0e10cSrcweir 				xController = _rxFrame->getController();
1287cdf0e10cSrcweir 			Reference< XModel > xModel;
1288cdf0e10cSrcweir 			if ( xController.is() )
1289cdf0e10cSrcweir 				xModel = xController->getModel();
1290cdf0e10cSrcweir 			Reference< XServiceInfo > xSI( xModel, UNO_QUERY );
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 			if ( !xSI.is() )
1293cdf0e10cSrcweir 			{	// try to go up the frame hierarchy
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 				Reference< XFrame > xParentFrame;
1296cdf0e10cSrcweir 				if ( _rxFrame.is() )
1297cdf0e10cSrcweir 					xParentFrame = xParentFrame.query( _rxFrame->getCreator() );
1298cdf0e10cSrcweir 				// did we find a parent frame? Which is no top-level frame?
1299cdf0e10cSrcweir 				if ( xParentFrame.is() && !_rxFrame->isTop() )
1300cdf0e10cSrcweir 					// TODO: to prevent framework assertions, re-insert this "isTop" once 98303 is fixed
1301cdf0e10cSrcweir 					return lcl_getModuleHelpModuleName( xParentFrame );
1302cdf0e10cSrcweir 			}
1303cdf0e10cSrcweir 			else
1304cdf0e10cSrcweir 			{
1305cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1306cdf0e10cSrcweir 				Sequence< ::rtl::OUString > sServiceNames = xSI->getSupportedServiceNames();
1307cdf0e10cSrcweir 				const ::rtl::OUString* pLoop = sServiceNames.getConstArray();
1308cdf0e10cSrcweir 				for ( sal_Int32 i=0; i<sServiceNames.getLength(); ++i, ++pLoop )
1309cdf0e10cSrcweir 				{
1310cdf0e10cSrcweir 					sal_Int32 nDummy = 0;
1311cdf0e10cSrcweir                     (void)nDummy;
1312cdf0e10cSrcweir 				}
1313cdf0e10cSrcweir #endif
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 				// check which service we know ....
1316cdf0e10cSrcweir 				static const sal_Char* pTransTable[] = {
1317cdf0e10cSrcweir 					"com.sun.star.sdb.OfficeDatabaseDocument","sdatabase",
1318cdf0e10cSrcweir                     "com.sun.star.report.ReportDefinition","sdatabase",
1319cdf0e10cSrcweir 					"com.sun.star.text.TextDocument",	"swriter",
1320cdf0e10cSrcweir 					"com.sun.star.sheet.SpreadsheetDocument", "scalc",
1321cdf0e10cSrcweir 					"com.sun.star.presentation.PresentationDocument", "simpress",
1322cdf0e10cSrcweir 					"com.sun.star.drawing.DrawingDocument", "sdraw",
1323cdf0e10cSrcweir 					"com.sun.star.formula.FormularProperties", "smath",
1324cdf0e10cSrcweir 					"com.sun.star.chart.ChartDocument", "schart"
1325cdf0e10cSrcweir 				};
1326cdf0e10cSrcweir 				OSL_ENSURE( ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) % 2 == 0,
1327cdf0e10cSrcweir 					"lcl_getModuleHelpModuleName: odd size of translation table!" );
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 				// loop through the table
1330cdf0e10cSrcweir 				sal_Int32 nTableEntries = ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) / 2;
1331cdf0e10cSrcweir 				const sal_Char** pDocumentService = pTransTable;
1332cdf0e10cSrcweir 				const sal_Char** pHelpModuleName = pTransTable + 1;
1333cdf0e10cSrcweir 				for ( sal_Int32 j=0; j<nTableEntries; ++j )
1334cdf0e10cSrcweir 				{
1335cdf0e10cSrcweir 					if ( xSI->supportsService( ::rtl::OUString::createFromAscii( *pDocumentService ) ) )
1336cdf0e10cSrcweir 					{	// found a table entry which matches the model's services
1337cdf0e10cSrcweir 						pReturn = *pHelpModuleName;
1338cdf0e10cSrcweir 						break;
1339cdf0e10cSrcweir 					}
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir 					++pDocumentService; ++pDocumentService;
1342cdf0e10cSrcweir 					++pHelpModuleName; ++pHelpModuleName;
1343cdf0e10cSrcweir 				}
1344cdf0e10cSrcweir 			}
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 			if ( !pReturn )
1347cdf0e10cSrcweir 			{
1348cdf0e10cSrcweir 				// could not determine the document type we're living in
1349cdf0e10cSrcweir 				// ->fallback
1350cdf0e10cSrcweir 				SvtModuleOptions aModOpt;
1351cdf0e10cSrcweir 				if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
1352cdf0e10cSrcweir 					pReturn = "swriter";
1353cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
1354cdf0e10cSrcweir 					pReturn = "sdatabase";
1355cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
1356cdf0e10cSrcweir 					pReturn = "scalc";
1357cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
1358cdf0e10cSrcweir 					pReturn = "simpress";
1359cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
1360cdf0e10cSrcweir 					pReturn = "sdraw";
1361cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
1362cdf0e10cSrcweir 					pReturn = "smath";
1363cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCHART ) )
1364cdf0e10cSrcweir 					pReturn = "schart";
1365cdf0e10cSrcweir 				else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SBASIC ) )
1366cdf0e10cSrcweir 					pReturn = "sbasic";
1367cdf0e10cSrcweir 				else
1368cdf0e10cSrcweir 				{
1369cdf0e10cSrcweir 					OSL_ENSURE( sal_False, "lcl_getModuleHelpModuleName: no installed module found" );
1370cdf0e10cSrcweir 				}
1371cdf0e10cSrcweir 			}
1372cdf0e10cSrcweir 		}
1373cdf0e10cSrcweir         catch( const Exception& )
1374cdf0e10cSrcweir         {
1375cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1376cdf0e10cSrcweir         }
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir 		if ( !pReturn )
1379cdf0e10cSrcweir 			pReturn = "swriter";
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 		return ::rtl::OUString::createFromAscii( pReturn );
1382cdf0e10cSrcweir 	}
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir // -----------------------------------------------------------------------------
1386cdf0e10cSrcweir 
openHelpAgent(rtl::OUString const & _suHelpStringURL)1387cdf0e10cSrcweir void OGenericUnoController::openHelpAgent(rtl::OUString const& _suHelpStringURL )
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir     rtl::OUString suURL(_suHelpStringURL);
1390cdf0e10cSrcweir     rtl::OUString sLanguage = rtl::OUString::createFromAscii("Language=");
1391cdf0e10cSrcweir     if (suURL.indexOf(sLanguage) == -1)
1392cdf0e10cSrcweir     {
1393cdf0e10cSrcweir         AppendConfigToken(suURL, sal_False /* sal_False := add '&' */ );
1394cdf0e10cSrcweir     }
1395cdf0e10cSrcweir     URL aURL;
1396cdf0e10cSrcweir     aURL.Complete = suURL;
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir     openHelpAgent( aURL );
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir 
openHelpAgent(const rtl::OString & _sHelpId)1401cdf0e10cSrcweir void OGenericUnoController::openHelpAgent(const rtl::OString& _sHelpId)
1402cdf0e10cSrcweir {
1403cdf0e10cSrcweir 	openHelpAgent( createHelpAgentURL( lcl_getModuleHelpModuleName( getFrame() ), _sHelpId ) );
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir 
openHelpAgent(const URL & _rURL)1406cdf0e10cSrcweir void OGenericUnoController::openHelpAgent( const URL& _rURL )
1407cdf0e10cSrcweir {
1408cdf0e10cSrcweir 	try
1409cdf0e10cSrcweir 	{
1410cdf0e10cSrcweir         URL aURL( _rURL );
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir         if ( m_xUrlTransformer.is() )
1413cdf0e10cSrcweir             m_xUrlTransformer->parseStrict(aURL);
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 		Reference< XDispatchProvider > xDispProv( m_aCurrentFrame.getFrame(), UNO_QUERY );
1416cdf0e10cSrcweir 		Reference< XDispatch > xHelpDispatch;
1417cdf0e10cSrcweir 		if ( xDispProv.is() )
1418cdf0e10cSrcweir 			xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_helpagent")), FrameSearchFlag::PARENT | FrameSearchFlag::SELF);
1419cdf0e10cSrcweir 		OSL_ENSURE(xHelpDispatch.is(), "SbaTableQueryBrowser::openHelpAgent: could not get a dispatcher!");
1420cdf0e10cSrcweir 		if (xHelpDispatch.is())
1421cdf0e10cSrcweir 		{
1422cdf0e10cSrcweir 			xHelpDispatch->dispatch(aURL, Sequence< PropertyValue >());
1423cdf0e10cSrcweir 		}
1424cdf0e10cSrcweir 	}
1425cdf0e10cSrcweir     catch( const Exception& )
1426cdf0e10cSrcweir     {
1427cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
1428cdf0e10cSrcweir     }
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTopMostContainerWindow() const1431cdf0e10cSrcweir Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() const
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir 	Reference< ::com::sun::star::awt::XWindow> xWindow;
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir     // get the top most window
1436cdf0e10cSrcweir     Reference< XFrame > xFrame( m_aCurrentFrame.getFrame() );
1437cdf0e10cSrcweir 	if ( xFrame.is() )
1438cdf0e10cSrcweir 	{
1439cdf0e10cSrcweir 		xWindow = xFrame->getContainerWindow();
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir         while ( xFrame.is() && !xFrame->isTop() )
1442cdf0e10cSrcweir 		{
1443cdf0e10cSrcweir 			xFrame.set( xFrame->getCreator(), UNO_QUERY );
1444cdf0e10cSrcweir 		}
1445cdf0e10cSrcweir 		if ( xFrame.is() )
1446cdf0e10cSrcweir 			xWindow = xFrame->getContainerWindow();
1447cdf0e10cSrcweir 	}
1448cdf0e10cSrcweir 	return xWindow;
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_getTitleHelper_throw()1451cdf0e10cSrcweir Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1454cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir     if ( ! m_xTitleHelper.is ())
1457cdf0e10cSrcweir     {
1458cdf0e10cSrcweir         Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY      );
1459cdf0e10cSrcweir         Reference< XController >      xThis(static_cast< XController* >(this), UNO_QUERY_THROW);
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir         ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_xServiceFactory);
1462cdf0e10cSrcweir         m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), UNO_QUERY_THROW);
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir         pHelper->setOwner                   (xThis            );
1465cdf0e10cSrcweir         pHelper->connectWithUntitledNumbers (xUntitledProvider);
1466cdf0e10cSrcweir     }
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir     return m_xTitleHelper;
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir //=============================================================================
1472cdf0e10cSrcweir // XTitle
getTitle()1473cdf0e10cSrcweir ::rtl::OUString SAL_CALL OGenericUnoController::getTitle()
1474cdf0e10cSrcweir     throw (RuntimeException)
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
1477cdf0e10cSrcweir     if ( m_bExternalTitle )
1478cdf0e10cSrcweir         return impl_getTitleHelper_throw()->getTitle ();
1479cdf0e10cSrcweir     return getPrivateTitle() + impl_getTitleHelper_throw()->getTitle ();
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir //=============================================================================
1483cdf0e10cSrcweir // XTitle
setTitle(const::rtl::OUString & sTitle)1484cdf0e10cSrcweir void SAL_CALL OGenericUnoController::setTitle(const ::rtl::OUString& sTitle)
1485cdf0e10cSrcweir     throw (RuntimeException)
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1488cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
1489cdf0e10cSrcweir     m_bExternalTitle = sal_True;
1490cdf0e10cSrcweir     impl_getTitleHelper_throw()->setTitle (sTitle);
1491cdf0e10cSrcweir }
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir //=============================================================================
1494cdf0e10cSrcweir // XTitleChangeBroadcaster
addTitleChangeListener(const Reference<XTitleChangeListener> & xListener)1495cdf0e10cSrcweir void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
1496cdf0e10cSrcweir     throw (RuntimeException)
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir     Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
1499cdf0e10cSrcweir     if (xBroadcaster.is ())
1500cdf0e10cSrcweir         xBroadcaster->addTitleChangeListener (xListener);
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeTitleChangeListener(const Reference<XTitleChangeListener> & xListener)1504cdf0e10cSrcweir void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
1505cdf0e10cSrcweir     throw (RuntimeException)
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir     Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
1508cdf0e10cSrcweir     if (xBroadcaster.is ())
1509cdf0e10cSrcweir         xBroadcaster->removeTitleChangeListener (xListener);
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir // =============================================================================
1513cdf0e10cSrcweir // XUserInputInterception
1514cdf0e10cSrcweir // -----------------------------------------------------------------------------
addKeyHandler(const Reference<XKeyHandler> & _rxHandler)1515cdf0e10cSrcweir void SAL_CALL OGenericUnoController::addKeyHandler( const Reference< XKeyHandler >& _rxHandler ) throw (RuntimeException)
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir     if ( _rxHandler.is() )
1518cdf0e10cSrcweir         m_pData->m_aUserInputInterception.addKeyHandler( _rxHandler );
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeKeyHandler(const Reference<XKeyHandler> & _rxHandler)1522cdf0e10cSrcweir void SAL_CALL OGenericUnoController::removeKeyHandler( const Reference< XKeyHandler >& _rxHandler ) throw (RuntimeException)
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir     m_pData->m_aUserInputInterception.removeKeyHandler( _rxHandler );
1525cdf0e10cSrcweir }
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir // -----------------------------------------------------------------------------
addMouseClickHandler(const Reference<XMouseClickHandler> & _rxHandler)1528cdf0e10cSrcweir void SAL_CALL OGenericUnoController::addMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) throw (RuntimeException)
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir     if ( _rxHandler.is() )
1531cdf0e10cSrcweir         m_pData->m_aUserInputInterception.addMouseClickHandler( _rxHandler );
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeMouseClickHandler(const Reference<XMouseClickHandler> & _rxHandler)1535cdf0e10cSrcweir void SAL_CALL OGenericUnoController::removeMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) throw (RuntimeException)
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir     m_pData->m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
1538cdf0e10cSrcweir }
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir // =============================================================================
1541cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeChecked(sal_uInt16 _nCommandId,const Sequence<PropertyValue> & aArgs)1542cdf0e10cSrcweir void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir 	if ( isCommandEnabled(_nCommandId) )
1545cdf0e10cSrcweir 		Execute(_nCommandId, aArgs);
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir // -----------------------------------------------------------------------------
isCommandEnabled(sal_uInt16 _nCommandId) const1549cdf0e10cSrcweir sal_Bool OGenericUnoController::isCommandEnabled(sal_uInt16 _nCommandId) const
1550cdf0e10cSrcweir {
1551cdf0e10cSrcweir 	return GetState( _nCommandId ).bEnabled;
1552cdf0e10cSrcweir }
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir // -----------------------------------------------------------------------------
registerCommandURL(const::rtl::OUString & _rCompleteCommandURL)1555cdf0e10cSrcweir sal_uInt16 OGenericUnoController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir     if ( !_rCompleteCommandURL.getLength() )
1558cdf0e10cSrcweir         return 0;
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL );
1561cdf0e10cSrcweir 	if ( aIter != m_aSupportedFeatures.end() )
1562cdf0e10cSrcweir 		return aIter->second.nFeatureId;
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir     // this is a previously unkwnon command
1565cdf0e10cSrcweir     sal_uInt16 nFeatureId = FIRST_USER_DEFINED_FEATURE;
1566cdf0e10cSrcweir     while ( isFeatureSupported( nFeatureId ) && ( nFeatureId < LAST_USER_DEFINED_FEATURE ) )
1567cdf0e10cSrcweir         ++nFeatureId;
1568cdf0e10cSrcweir     if ( nFeatureId == LAST_USER_DEFINED_FEATURE )
1569cdf0e10cSrcweir     {
1570cdf0e10cSrcweir         OSL_ENSURE( false, "OGenericUnoController::registerCommandURL: no more space for user defined features!" );
1571cdf0e10cSrcweir         return 0L;
1572cdf0e10cSrcweir     }
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir     ControllerFeature aFeature;
1575cdf0e10cSrcweir     aFeature.Command = _rCompleteCommandURL;
1576cdf0e10cSrcweir     aFeature.nFeatureId = nFeatureId;
1577cdf0e10cSrcweir     aFeature.GroupId = CommandGroup::INTERNAL;
1578cdf0e10cSrcweir     m_aSupportedFeatures[ aFeature.Command ] = aFeature;
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir     return nFeatureId;
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyHiContrastChanged()1584cdf0e10cSrcweir void OGenericUnoController::notifyHiContrastChanged()
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir // -----------------------------------------------------------------------------
isDataSourceReadOnly() const1589cdf0e10cSrcweir sal_Bool OGenericUnoController::isDataSourceReadOnly() const
1590cdf0e10cSrcweir {
1591cdf0e10cSrcweir     return sal_False;
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir // -----------------------------------------------------------------------------
getXController()1595cdf0e10cSrcweir Reference< XController > OGenericUnoController::getXController() throw( RuntimeException )
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir     return this;
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir // -----------------------------------------------------------------------------
interceptUserInput(const NotifyEvent & _rEvent)1601cdf0e10cSrcweir bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent )
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir     return m_pData->m_aUserInputInterception.handleNotifyEvent( _rEvent );
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir // -----------------------------------------------------------------------------
isCommandChecked(sal_uInt16 _nCommandId) const1607cdf0e10cSrcweir sal_Bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir     FeatureState aState = GetState( _nCommandId );
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir 	return aState.bChecked && (sal_Bool)*aState.bChecked;
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir // -----------------------------------------------------------------------------
isCommandEnabled(const::rtl::OUString & _rCompleteCommandURL) const1614cdf0e10cSrcweir sal_Bool OGenericUnoController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
1615cdf0e10cSrcweir {
1616cdf0e10cSrcweir     OSL_ENSURE( _rCompleteCommandURL.getLength(), "OGenericUnoController::isCommandEnabled: Empty command url!" );
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir 	sal_Bool bIsEnabled = sal_False;
1619cdf0e10cSrcweir     SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL );
1620cdf0e10cSrcweir 	if ( aIter != m_aSupportedFeatures.end() )
1621cdf0e10cSrcweir 		bIsEnabled = isCommandEnabled( aIter->second.nFeatureId );
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	return bIsEnabled;
1624cdf0e10cSrcweir }
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSupportedCommandGroups()1627cdf0e10cSrcweir Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroups() throw (RuntimeException)
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir     CommandHashMap aCmdHashMap;
1630cdf0e10cSrcweir 	for (   SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
1631cdf0e10cSrcweir             aIter != m_aSupportedFeatures.end();
1632cdf0e10cSrcweir             ++aIter
1633cdf0e10cSrcweir         )
1634cdf0e10cSrcweir         if ( aIter->second.GroupId != CommandGroup::INTERNAL )
1635cdf0e10cSrcweir             aCmdHashMap.insert( CommandHashMap::value_type( aIter->second.GroupId, 0 ));
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir     Sequence< sal_Int16 > aCommandGroups( aCmdHashMap.size() );
1638cdf0e10cSrcweir     ::std::transform( aCmdHashMap.begin(),
1639cdf0e10cSrcweir         aCmdHashMap.end(),
1640cdf0e10cSrcweir         aCommandGroups.getArray(),
1641cdf0e10cSrcweir         ::std::select1st< CommandHashMap::value_type >()
1642cdf0e10cSrcweir     );
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir     return aCommandGroups;
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir // -----------------------------------------------------------------------------
getConfigurableDispatchInformation(::sal_Int16 CommandGroup)1648cdf0e10cSrcweir Sequence< DispatchInformation > SAL_CALL OGenericUnoController::getConfigurableDispatchInformation( ::sal_Int16 CommandGroup ) throw (RuntimeException)
1649cdf0e10cSrcweir {
1650cdf0e10cSrcweir     DispatchInfoList    aInformationList;
1651cdf0e10cSrcweir     DispatchInformation aDispatchInfo;
1652cdf0e10cSrcweir     for (   SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
1653cdf0e10cSrcweir             aIter != m_aSupportedFeatures.end();
1654cdf0e10cSrcweir             ++aIter
1655cdf0e10cSrcweir         )
1656cdf0e10cSrcweir     {
1657cdf0e10cSrcweir         if ( sal_Int16( aIter->second.GroupId ) == CommandGroup )
1658cdf0e10cSrcweir         {
1659cdf0e10cSrcweir             aDispatchInfo = aIter->second;
1660cdf0e10cSrcweir             aInformationList.push_back( aDispatchInfo );
1661cdf0e10cSrcweir         }
1662cdf0e10cSrcweir     }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir     Sequence< DispatchInformation > aInformation( aInformationList.size() );
1665cdf0e10cSrcweir     ::std::transform( aInformationList.begin(),
1666cdf0e10cSrcweir         aInformationList.end(),
1667cdf0e10cSrcweir         aInformation.getArray(),
1668cdf0e10cSrcweir         ::std::identity< DispatchInformation >()
1669cdf0e10cSrcweir     );
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir     return aInformation;
1672cdf0e10cSrcweir }
1673cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillSupportedFeatures()1674cdf0e10cSrcweir void OGenericUnoController::fillSupportedFeatures()
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir #ifdef DBG_UTIL
1677cdf0e10cSrcweir     m_bDescribingSupportedFeatures = true;
1678cdf0e10cSrcweir #endif
1679cdf0e10cSrcweir 	describeSupportedFeatures();
1680cdf0e10cSrcweir // -----------------------------------------------------------------------------
1681cdf0e10cSrcweir #ifdef DBG_UTIL
1682cdf0e10cSrcweir     m_bDescribingSupportedFeatures = false;
1683cdf0e10cSrcweir #endif
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir 
dispose()1687cdf0e10cSrcweir void SAL_CALL OGenericUnoController::dispose() throw(::com::sun::star::uno::RuntimeException)
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir 	::vos::OGuard aSolarGuard(Application::GetSolarMutex());
1690cdf0e10cSrcweir 	OGenericUnoController_Base::dispose();
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir }   // namespace dbaui
1693cdf0e10cSrcweir 
1694