2001-01-09 14:43:04 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* $RCSfile: genericcontroller.cxx,v $
|
2008-06-16 11:33:12 +00:00
|
|
|
* $Revision: 1.90 $
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
2008-04-10 13:07:57 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-01-09 14:43:04 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 05:58:43 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2001-01-09 14:43:04 +00:00
|
|
|
#ifndef DBAUI_GENERICCONTROLLER_HXX
|
|
|
|
#include "genericcontroller.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_UNO3_HXX_
|
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
|
|
|
|
#include <toolkit/awt/vclxwindow.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_UI_BROWSER_ID_HXX
|
|
|
|
#include "browserids.hxx"
|
|
|
|
#endif
|
2004-08-02 14:34:22 +00:00
|
|
|
#ifndef _SV_SVAPP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
2001-04-23 08:30:31 +00:00
|
|
|
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#endif
|
2001-01-09 14:43:04 +00:00
|
|
|
#ifndef DBAUI_DATAVIEW_HXX
|
|
|
|
#include "dataview.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2006-06-20 01:58:07 +00:00
|
|
|
#ifndef TOOLS_DIAGNOSE_EX_H
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#endif
|
2001-01-09 14:43:04 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
|
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef _VCL_STDTEXT_HXX
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#endif
|
2001-06-21 16:51:14 +00:00
|
|
|
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#endif
|
2008-04-04 13:56:57 +00:00
|
|
|
#include <framework/titlehelper.hxx>
|
2001-06-21 16:51:14 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#endif
|
2001-03-15 07:29:16 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2001-01-09 14:43:04 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#endif
|
2001-02-27 14:11:05 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
#endif
|
2001-01-09 14:43:04 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
|
|
|
#endif
|
2002-06-26 07:17:57 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
|
|
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
|
|
|
#endif
|
2001-02-23 14:17:34 +00:00
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
2001-01-09 14:43:04 +00:00
|
|
|
#endif
|
2004-11-16 13:31:01 +00:00
|
|
|
#ifndef _DBAUI_COMMON_TYPES_HXX_
|
|
|
|
#include "commontypes.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-03-30 12:04:24 +00:00
|
|
|
#ifndef _SV_WAITOBJ_HXX
|
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#endif
|
2001-04-24 13:36:44 +00:00
|
|
|
#ifndef _URLOBJ_HXX
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef SVTOOLS_URIHELPER_HXX
|
|
|
|
#include <svtools/urihelper.hxx>
|
|
|
|
#endif
|
2001-05-10 11:25:36 +00:00
|
|
|
#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
|
|
|
|
#include "datasourceconnector.hxx"
|
|
|
|
#endif
|
2002-08-26 06:52:15 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
|
|
|
|
#include <svtools/moduleoptions.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#endif
|
2008-03-06 17:14:19 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_STATUS_VISIBILITY_HPP_
|
2008-03-05 16:08:08 +00:00
|
|
|
#include <com/sun/star/frame/status/Visibility.hpp>
|
2008-03-06 17:14:19 +00:00
|
|
|
#endif
|
2004-08-02 14:34:22 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
|
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
|
|
|
#endif
|
2004-02-25 14:32:25 +00:00
|
|
|
#ifndef _RTL_USTRING_HXX_
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#endif
|
2006-08-15 09:49:24 +00:00
|
|
|
#ifndef _RTL_LOGFILE_HXX_
|
|
|
|
#include <rtl/logfile.hxx>
|
|
|
|
#endif
|
2001-10-26 12:10:16 +00:00
|
|
|
#include <algorithm>
|
2007-01-29 14:47:50 +00:00
|
|
|
#include <hash_map>
|
2008-06-16 11:33:12 +00:00
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2001-10-26 12:10:16 +00:00
|
|
|
|
2008-03-05 15:52:59 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-01-09 14:43:04 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2008-03-05 16:08:08 +00:00
|
|
|
using namespace ::com::sun::star::frame::status;
|
2001-01-09 14:43:04 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::task;
|
2001-04-23 08:30:31 +00:00
|
|
|
using namespace ::com::sun::star::awt;
|
2008-04-04 13:56:57 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-01-09 14:43:04 +00:00
|
|
|
using namespace ::dbtools;
|
|
|
|
using namespace ::dbaui;
|
|
|
|
using namespace ::comphelper;
|
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
#define ALL_FEATURES -1
|
|
|
|
|
2004-11-16 13:31:01 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
typedef ::std::hash_map< sal_Int16, sal_Int16 > CommandHashMap;
|
|
|
|
typedef ::std::list< DispatchInformation > DispatchInfoList;
|
|
|
|
|
2008-06-16 11:33:12 +00:00
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
const ::rtl::OUString& getConfirmDeletionURL()
|
|
|
|
{
|
|
|
|
static const ::rtl::OUString sConfirmDeletionURL( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/ConfirmDeletion" ) );
|
|
|
|
return sConfirmDeletionURL;
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2005-09-23 11:21:38 +00:00
|
|
|
DBG_NAME(OGenericUnoController)
|
2001-01-09 14:43:04 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFactory >& _rM)
|
2008-03-06 17:14:19 +00:00
|
|
|
:OGenericUnoController_Base(m_aMutex)
|
2006-06-20 01:58:07 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
,m_bDescribingSupportedFeatures( false )
|
|
|
|
#endif
|
2007-07-06 07:04:34 +00:00
|
|
|
,m_aSelectionListeners(m_aMutex)
|
2001-03-01 14:17:55 +00:00
|
|
|
,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
|
2001-09-19 12:20:12 +00:00
|
|
|
,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
|
2007-07-06 07:04:34 +00:00
|
|
|
,m_xServiceFactory(_rM)
|
2008-03-06 17:14:19 +00:00
|
|
|
,m_aCurrentFrame( *this )
|
2001-01-09 14:43:04 +00:00
|
|
|
,m_pView(NULL)
|
2005-01-05 11:33:47 +00:00
|
|
|
,m_bPreview(sal_False)
|
|
|
|
,m_bReadOnly(sal_False)
|
2006-06-20 01:58:07 +00:00
|
|
|
,m_bCurrentlyModified(sal_False)
|
2008-04-04 13:56:57 +00:00
|
|
|
,m_bExternalTitle(sal_False)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2005-09-23 11:21:38 +00:00
|
|
|
DBG_CTOR(OGenericUnoController,NULL);
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
try
|
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
m_xUrlTransformer = Reference< XURLTransformer > (_rM->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), UNO_QUERY);
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-16 13:31:01 +00:00
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OGenericUnoController::OGenericUnoController()
|
|
|
|
:OGenericUnoController_Base(m_aMutex)
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
,m_bDescribingSupportedFeatures( false )
|
|
|
|
#endif
|
|
|
|
,m_aSelectionListeners(m_aMutex)
|
|
|
|
,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
|
|
|
|
,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
|
|
|
|
,m_aCurrentFrame( *this )
|
|
|
|
,m_pView(NULL)
|
|
|
|
,m_bPreview(sal_False)
|
|
|
|
,m_bReadOnly(sal_False)
|
|
|
|
,m_bCurrentlyModified(sal_False)
|
|
|
|
{
|
|
|
|
OSL_ENSURE( false, "OGenericUnoController::OGenericUnoController: illegal call!" );
|
|
|
|
// This ctor only exists because the MSVC compiler complained about an unresolved external
|
|
|
|
// symbol. It should not be used at all. Since using it yields strange runtime problems,
|
|
|
|
// we simply abort here.
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2004-11-16 13:31:01 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OGenericUnoController::~OGenericUnoController()
|
|
|
|
{
|
2005-09-23 11:21:38 +00:00
|
|
|
|
|
|
|
DBG_DTOR(OGenericUnoController,NULL);
|
2004-11-16 13:31:01 +00:00
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:58:07 +00:00
|
|
|
sal_Bool OGenericUnoController::Construct(Window* /*pParent*/)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2001-08-23 13:46:27 +00:00
|
|
|
OSL_ENSURE( getView(), "the view is NULL!" );
|
|
|
|
|
|
|
|
if ( getView() )
|
|
|
|
{
|
|
|
|
getView()->Construct();
|
|
|
|
getView()->Show();
|
|
|
|
}
|
|
|
|
|
2005-03-10 15:45:35 +00:00
|
|
|
m_aSupportedFeatures.clear();
|
2007-07-06 07:04:34 +00:00
|
|
|
fillSupportedFeatures();
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
// create the database context
|
2007-07-06 07:04:34 +00:00
|
|
|
DBG_ASSERT(getORB().is(), "OGenericUnoController::Construct need a service factory!");
|
2001-01-09 14:43:04 +00:00
|
|
|
try
|
|
|
|
{
|
2007-07-06 07:04:34 +00:00
|
|
|
m_xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2001-06-21 16:51:14 +00:00
|
|
|
DBG_ERROR("OGenericUnoController::Construct: could not create (or start listening at) the database context!");
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_xDatabaseContext.is())
|
|
|
|
{ // at least notify the user. Though the whole component does not make any sense without the database context ...
|
|
|
|
ShowServiceNotAvailableError(getView(), String(SERVICE_SDB_DATABASECONTEXT), sal_True);
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OGenericUnoController, OnAsyncInvalidateAll, void*, EMPTYARG)
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( !OGenericUnoController_Base::rBHelper.bInDispose && !OGenericUnoController_Base::rBHelper.bDisposed )
|
2001-05-22 07:51:23 +00:00
|
|
|
InvalidateFeature_Impl();
|
2001-01-09 14:43:04 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-07-10 14:23:57 +00:00
|
|
|
void OGenericUnoController::impl_initialize()
|
2004-08-02 14:34:22 +00:00
|
|
|
{
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
|
|
|
|
{
|
2004-08-02 14:34:22 +00:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2005-03-10 15:45:35 +00:00
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
Reference< XWindow > xParent;
|
|
|
|
Reference< XFrame > xFrame;
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
PropertyValue aValue;
|
2005-01-05 11:33:47 +00:00
|
|
|
const Any* pIter = aArguments.getConstArray();
|
|
|
|
const Any* pEnd = pIter + aArguments.getLength();
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2005-01-05 11:33:47 +00:00
|
|
|
for ( ; pIter != pEnd; ++pIter )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2005-01-05 11:33:47 +00:00
|
|
|
if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Frame" ) ) )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2005-09-23 11:21:38 +00:00
|
|
|
xFrame.set(aValue.Value,UNO_QUERY_THROW);
|
2005-01-05 11:33:47 +00:00
|
|
|
}
|
2005-02-09 14:18:26 +00:00
|
|
|
/* #i42316#
|
2005-01-05 11:33:47 +00:00
|
|
|
else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "ReadOnly" ) ) )
|
|
|
|
{
|
|
|
|
aValue.Value >>= m_bReadOnly;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2005-02-09 14:18:26 +00:00
|
|
|
*/
|
2005-01-05 11:33:47 +00:00
|
|
|
else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Preview" ) ) )
|
|
|
|
{
|
|
|
|
aValue.Value >>= m_bPreview;
|
2005-02-09 14:18:26 +00:00
|
|
|
m_bReadOnly = sal_True;
|
2005-01-05 11:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-10 15:45:35 +00:00
|
|
|
try
|
2005-01-05 11:33:47 +00:00
|
|
|
{
|
2008-06-06 13:08:24 +00:00
|
|
|
if ( !xFrame.is() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "need a frame" ) ), *this, 1 );
|
|
|
|
|
|
|
|
xParent = xFrame->getContainerWindow();
|
|
|
|
VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent);
|
|
|
|
Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL;
|
|
|
|
if (!pParentWin)
|
2005-03-10 15:45:35 +00:00
|
|
|
{
|
2008-06-06 13:08:24 +00:00
|
|
|
throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "Parent window is null" ), *this, 1 );
|
2005-03-10 15:45:35 +00:00
|
|
|
}
|
2008-06-06 13:08:24 +00:00
|
|
|
|
|
|
|
m_aInitParameters.assign( aArguments );
|
|
|
|
Construct( pParentWin );
|
|
|
|
|
2005-03-10 15:45:35 +00:00
|
|
|
ODataView* pView = getView();
|
2008-06-06 13:08:24 +00:00
|
|
|
if ( !pView )
|
|
|
|
throw RuntimeException( ::rtl::OUString::createFromAscii( "unable to create a view" ), *this );
|
|
|
|
|
|
|
|
if ( m_bReadOnly || m_bPreview )
|
|
|
|
pView->EnableInput( FALSE );
|
2006-07-10 14:23:57 +00:00
|
|
|
|
|
|
|
impl_initialize();
|
2005-01-05 11:33:47 +00:00
|
|
|
}
|
2005-03-10 15:45:35 +00:00
|
|
|
catch(Exception& e)
|
2005-01-05 11:33:47 +00:00
|
|
|
{
|
2005-03-10 15:45:35 +00:00
|
|
|
// no one clears my view if I won't
|
|
|
|
::std::auto_ptr<Window> aTemp(m_pView);
|
|
|
|
m_pView = NULL;
|
|
|
|
throw e;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-21 16:51:14 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::acquire( ) throw ()
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
OGenericUnoController_Base::acquire();
|
2001-06-21 16:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::release( ) throw ()
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
OGenericUnoController_Base::release();
|
2001-06-21 16:51:14 +00:00
|
|
|
}
|
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2008-03-06 17:14:19 +00:00
|
|
|
void OGenericUnoController::startFrameListening( const Reference< XFrame >& _rxFrame )
|
2002-01-24 16:43:35 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( _rxFrame.is() )
|
|
|
|
_rxFrame->addFrameActionListener( this );
|
2002-01-24 16:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2008-03-06 17:14:19 +00:00
|
|
|
void OGenericUnoController::stopFrameListening( const Reference< XFrame >& _rxFrame )
|
2002-01-24 16:43:35 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( _rxFrame.is() )
|
|
|
|
_rxFrame->removeFrameActionListener( this );
|
2002-01-24 16:43:35 +00:00
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::disposing(const EventObject& Source) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
// our frame ?
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( Source.Source == getFrame() )
|
|
|
|
stopFrameListening( getFrame() );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::modified(const EventObject& aEvent) throw( RuntimeException )
|
|
|
|
{
|
2004-10-22 08:04:44 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2004-08-02 14:34:22 +00:00
|
|
|
if ( !isDataSourceReadOnly() )
|
|
|
|
{
|
|
|
|
Reference<XModifiable> xModi(aEvent.Source,UNO_QUERY);
|
|
|
|
if ( xModi.is() )
|
2005-01-21 16:09:05 +00:00
|
|
|
m_bCurrentlyModified = xModi->isModified(); // can only be reset by save
|
2004-08-02 14:34:22 +00:00
|
|
|
else
|
|
|
|
m_bCurrentlyModified = sal_True;
|
|
|
|
}
|
2002-01-24 16:43:35 +00:00
|
|
|
InvalidateFeature(ID_BROWSER_SAVEDOC);
|
2001-01-09 14:43:04 +00:00
|
|
|
InvalidateFeature(ID_BROWSER_UNDO);
|
|
|
|
}
|
2008-06-06 13:08:24 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return VCLUnoHelper::GetInterface( getView() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL OGenericUnoController::getViewControllerName() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2008-03-06 17:14:19 +00:00
|
|
|
void OGenericUnoController::attachFrame( const Reference< XFrame >& _rxFrame ) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2007-09-26 13:48:32 +00:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
2004-11-17 13:47:54 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
stopFrameListening( m_aCurrentFrame.getFrame() );
|
|
|
|
Reference< XFrame > xFrame = m_aCurrentFrame.attachFrame( _rxFrame );
|
2008-04-08 11:46:07 +00:00
|
|
|
startFrameListening( xFrame );
|
2002-01-24 16:43:35 +00:00
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
loadMenu( xFrame );
|
|
|
|
|
2004-11-17 13:47:54 +00:00
|
|
|
if ( getView() )
|
2008-03-06 17:14:19 +00:00
|
|
|
getView()->attachFrame( xFrame );
|
2004-08-02 14:34:22 +00:00
|
|
|
}
|
2008-03-06 17:14:19 +00:00
|
|
|
|
2004-09-09 08:41:47 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-11-16 13:31:01 +00:00
|
|
|
struct CommandCollector : public ::std::unary_function< SupportedFeatures::value_type, void>
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2004-11-16 13:31:01 +00:00
|
|
|
sal_uInt16 m_nFeature;
|
|
|
|
StringBag& m_rFeatureCommands;
|
|
|
|
CommandCollector( sal_uInt16 _nFeature, StringBag& _rFeatureCommands )
|
|
|
|
:m_nFeature ( _nFeature )
|
|
|
|
,m_rFeatureCommands( _rFeatureCommands )
|
|
|
|
{
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2004-11-16 13:31:01 +00:00
|
|
|
void operator() ( const SupportedFeatures::value_type& lhs )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2004-11-16 13:31:01 +00:00
|
|
|
if ( lhs.second.nFeatureId == m_nFeature )
|
|
|
|
m_rFeatureCommands.insert( lhs.first );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2004-09-09 08:41:47 +00:00
|
|
|
};
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2006-07-10 14:23:57 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
typedef ::std::vector< Any > States;
|
|
|
|
|
|
|
|
// ...................................................................
|
|
|
|
void lcl_notifyMultipleStates( XStatusListener& _rListener, FeatureStateEvent& _rEvent, const States& _rStates )
|
|
|
|
{
|
|
|
|
for ( States::const_iterator state = _rStates.begin();
|
|
|
|
state != _rStates.end();
|
|
|
|
++state
|
|
|
|
)
|
|
|
|
{
|
|
|
|
_rEvent.State = *state;
|
|
|
|
_rListener.statusChanged( _rEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ...................................................................
|
|
|
|
void lcl_collectStates( const FeatureState& _rFeatureState, States& _out_rStates )
|
|
|
|
{
|
2006-08-11 16:16:41 +00:00
|
|
|
// order matters, due to a bug in framework which resets the check state when any non-boolean event
|
|
|
|
// arrives
|
|
|
|
// #i68215# is the bug to (re-)introduce this "ordered" notification here
|
|
|
|
// #i67882# is the bug which was caused by the real fix which we did in framework
|
|
|
|
// #i68216# is the bug which requests to fix the code in Draw which relies on
|
|
|
|
// framework's implementation details
|
|
|
|
// 2006-08-07 / frank.schoenheit@sun.com
|
2006-07-10 14:23:57 +00:00
|
|
|
if ( !!_rFeatureState.sTitle )
|
|
|
|
_out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) );
|
2006-08-11 16:16:41 +00:00
|
|
|
if ( !!_rFeatureState.bChecked )
|
|
|
|
_out_rStates.push_back( makeAny( (sal_Bool)*_rFeatureState.bChecked ) );
|
2008-03-05 16:08:08 +00:00
|
|
|
if ( !!_rFeatureState.bInvisible )
|
|
|
|
_out_rStates.push_back( makeAny( Visibility( !*_rFeatureState.bInvisible ) ) );
|
2007-07-06 07:04:34 +00:00
|
|
|
if ( _rFeatureState.aValue.hasValue() )
|
|
|
|
_out_rStates.push_back( _rFeatureState.aValue );
|
2006-07-10 14:23:57 +00:00
|
|
|
if ( _out_rStates.empty() )
|
|
|
|
_out_rStates.push_back( Any() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::ImplBroadcastFeatureState(const ::rtl::OUString& _rFeature, const Reference< XStatusListener > & xListener, sal_Bool _bIgnoreCache)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2004-11-16 13:31:01 +00:00
|
|
|
sal_uInt16 nFeat = m_aSupportedFeatures[ _rFeature ].nFeatureId;
|
|
|
|
FeatureState aFeatState( GetState( nFeat ) );
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
FeatureState& rCachedState = m_aStateCache[nFeat]; // creates if neccessary
|
2006-07-10 14:23:57 +00:00
|
|
|
if ( !_bIgnoreCache )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
// check if we really need to notify the listeners : this method may be called much more often than needed, so check
|
|
|
|
// the cached state of the feature
|
2006-07-10 14:23:57 +00:00
|
|
|
sal_Bool bAlreadyCached = ( m_aStateCache.find(nFeat) != m_aStateCache.end() );
|
|
|
|
if ( bAlreadyCached )
|
|
|
|
if ( ( rCachedState.bEnabled == aFeatState.bEnabled )
|
|
|
|
&& ( rCachedState.bChecked == aFeatState.bChecked )
|
2008-03-05 16:08:08 +00:00
|
|
|
&& ( rCachedState.bInvisible == aFeatState.bInvisible )
|
2006-07-10 14:23:57 +00:00
|
|
|
&& ( rCachedState.sTitle == aFeatState.sTitle )
|
|
|
|
)
|
|
|
|
return;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
rCachedState = aFeatState;
|
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
FeatureStateEvent aEvent;
|
2001-01-09 14:43:04 +00:00
|
|
|
aEvent.FeatureURL.Complete = _rFeature;
|
|
|
|
if (m_xUrlTransformer.is())
|
|
|
|
m_xUrlTransformer->parseStrict(aEvent.FeatureURL);
|
2002-01-24 16:43:35 +00:00
|
|
|
aEvent.Source = (XDispatch*)this;
|
2001-01-09 14:43:04 +00:00
|
|
|
aEvent.IsEnabled = aFeatState.bEnabled;
|
2006-07-10 14:23:57 +00:00
|
|
|
|
|
|
|
// collect all states to be notified
|
|
|
|
States aStates;
|
|
|
|
lcl_collectStates( aFeatState, aStates );
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
// a special listener ?
|
2006-07-10 14:23:57 +00:00
|
|
|
if ( xListener.is() )
|
|
|
|
lcl_notifyMultipleStates( *xListener.get(), aEvent, aStates );
|
2001-01-09 14:43:04 +00:00
|
|
|
else
|
2002-01-24 16:43:35 +00:00
|
|
|
{ // no -> iterate through all listeners responsible for the URL
|
2004-11-16 13:31:01 +00:00
|
|
|
StringBag aFeatureCommands;
|
|
|
|
::std::for_each(
|
|
|
|
m_aSupportedFeatures.begin(),
|
|
|
|
m_aSupportedFeatures.end(),
|
|
|
|
CommandCollector( nFeat, aFeatureCommands )
|
|
|
|
);
|
2004-09-09 08:41:47 +00:00
|
|
|
|
2005-07-08 09:38:35 +00:00
|
|
|
// it is possible that listeners are registered or revoked while
|
|
|
|
// we are notifying them, so we must use a copy of m_arrStatusListener, not
|
|
|
|
// m_arrStatusListener itself
|
|
|
|
// #121276# / 2005-05-19 / frank.schoenheit@sun.com
|
|
|
|
Dispatch aNotifyLoop( m_arrStatusListener );
|
|
|
|
DispatchIterator iterSearch = aNotifyLoop.begin();
|
|
|
|
DispatchIterator iterEnd = aNotifyLoop.end();
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
while (iterSearch != iterEnd)
|
|
|
|
{
|
|
|
|
DispatchTarget& rCurrent = *iterSearch;
|
2004-11-16 13:31:01 +00:00
|
|
|
if ( aFeatureCommands.find( rCurrent.aURL.Complete ) != aFeatureCommands.end() )
|
2004-09-09 08:41:47 +00:00
|
|
|
{
|
2006-07-10 14:23:57 +00:00
|
|
|
aEvent.FeatureURL = rCurrent.aURL;
|
|
|
|
lcl_notifyMultipleStates( *rCurrent.xListener.get(), aEvent, aStates );
|
2004-09-09 08:41:47 +00:00
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
++iterSearch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-03-10 15:45:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool OGenericUnoController::isFeatureSupported( sal_Int32 _nId )
|
|
|
|
{
|
|
|
|
SupportedFeatures::iterator aFeaturePos = ::std::find_if(
|
|
|
|
m_aSupportedFeatures.begin(),
|
|
|
|
m_aSupportedFeatures.end(),
|
|
|
|
::std::bind2nd( SupportedFeaturesEqualId(), _nId )
|
|
|
|
);
|
|
|
|
|
|
|
|
return ( m_aSupportedFeatures.end() != aFeaturePos && aFeaturePos->first.getLength());
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::InvalidateFeature(const ::rtl::OUString& _rURLPath, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2004-11-16 13:31:01 +00:00
|
|
|
ImplInvalidateFeature( m_aSupportedFeatures[ _rURLPath ].nFeatureId, _xListener, _bForceBroadcast );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2002-01-24 16:43:35 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::InvalidateFeature_Impl()
|
|
|
|
{
|
2001-02-19 11:07:30 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
static sal_Int32 s_nRecursions = 0;
|
|
|
|
++s_nRecursions;
|
|
|
|
#endif
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
sal_Bool bEmpty = sal_True;
|
2001-02-12 12:56:51 +00:00
|
|
|
FeaturePair aNextFeature;
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
|
|
|
bEmpty = m_aFeaturesToInvalidate.empty();
|
2001-02-12 12:56:51 +00:00
|
|
|
if (!bEmpty)
|
|
|
|
aNextFeature = m_aFeaturesToInvalidate.front();
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
while(!bEmpty)
|
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
if ( ALL_FEATURES == aNextFeature.nId )
|
2001-02-19 11:07:30 +00:00
|
|
|
{
|
2001-01-09 14:43:04 +00:00
|
|
|
InvalidateAll_Impl();
|
2001-02-19 11:07:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
else
|
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
SupportedFeatures::iterator aFeaturePos = ::std::find_if(
|
|
|
|
m_aSupportedFeatures.begin(),
|
|
|
|
m_aSupportedFeatures.end(),
|
2004-11-16 13:31:01 +00:00
|
|
|
::std::bind2nd( SupportedFeaturesEqualId(), aNextFeature.nId )
|
2002-01-24 16:43:35 +00:00
|
|
|
);
|
|
|
|
|
2005-07-08 09:38:35 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
if ( m_aSupportedFeatures.end() == aFeaturePos )
|
|
|
|
{
|
|
|
|
::rtl::OString sMessage( "OGenericUnoController::InvalidateFeature_Impl: feature id " );
|
|
|
|
sMessage += ::rtl::OString::valueOf( aNextFeature.nId );
|
|
|
|
sMessage += ::rtl::OString( " has been invalidated, but is not supported!" );
|
|
|
|
OSL_ENSURE( false, sMessage.getStr() );
|
|
|
|
}
|
|
|
|
#endif
|
2002-01-24 16:43:35 +00:00
|
|
|
if ( m_aSupportedFeatures.end() != aFeaturePos )
|
|
|
|
// we really know this feature
|
|
|
|
ImplBroadcastFeatureState( aFeaturePos->first, aNextFeature.xListener, aNextFeature.bForceBroadcast );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-02-19 11:07:30 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
|
|
|
m_aFeaturesToInvalidate.pop_front();
|
|
|
|
bEmpty = m_aFeaturesToInvalidate.empty();
|
|
|
|
if (!bEmpty)
|
|
|
|
aNextFeature = m_aFeaturesToInvalidate.front();
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-02-19 11:07:30 +00:00
|
|
|
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
--s_nRecursions;
|
|
|
|
#endif
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-02-19 11:07:30 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Reference< XStatusListener >& _xListener, sal_Bool _bForceBroadcast )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
FeaturePair aPair;
|
|
|
|
aPair.nId = _nId;
|
|
|
|
aPair.xListener = _xListener;
|
|
|
|
aPair.bForceBroadcast = _bForceBroadcast;
|
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
sal_Bool bWasEmpty;
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
|
|
|
bWasEmpty = m_aFeaturesToInvalidate.empty();
|
|
|
|
m_aFeaturesToInvalidate.push_back(aPair);
|
|
|
|
}
|
2002-01-24 16:43:35 +00:00
|
|
|
|
|
|
|
if ( bWasEmpty )
|
2001-01-09 14:43:04 +00:00
|
|
|
m_aAsyncInvalidateAll.Call();
|
|
|
|
}
|
|
|
|
|
2002-01-24 18:23:16 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::InvalidateFeature(sal_uInt16 _nId, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
|
|
|
|
{
|
|
|
|
ImplInvalidateFeature( _nId, _xListener, _bForceBroadcast );
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::InvalidateAll()
|
|
|
|
{
|
2002-01-24 18:23:16 +00:00
|
|
|
ImplInvalidateFeature( ALL_FEATURES, NULL, sal_True );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2002-01-24 16:43:35 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::InvalidateAll_Impl()
|
|
|
|
{
|
|
|
|
// ---------------------------------
|
|
|
|
// invalidate all aupported features
|
2004-11-16 13:31:01 +00:00
|
|
|
|
|
|
|
for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
|
|
|
|
aIter != m_aSupportedFeatures.end();
|
|
|
|
++aIter
|
|
|
|
)
|
|
|
|
ImplBroadcastFeatureState( aIter->first, NULL, sal_True );
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
2001-02-19 11:07:30 +00:00
|
|
|
DBG_ASSERT(m_aFeaturesToInvalidate.size(), "OGenericUnoController::InvalidateAll_Impl: to be called from within InvalidateFeature_Impl only!");
|
2001-01-09 14:43:04 +00:00
|
|
|
m_aFeaturesToInvalidate.pop_front();
|
|
|
|
if(!m_aFeaturesToInvalidate.empty())
|
|
|
|
m_aAsyncInvalidateAll.Call();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
Reference< XDispatch > OGenericUnoController::queryDispatch(const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
Reference< XDispatch > xReturn;
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2007-07-06 07:04:34 +00:00
|
|
|
if ( m_aSupportedFeatures.empty() )
|
|
|
|
fillSupportedFeatures();
|
2002-01-24 16:43:35 +00:00
|
|
|
// URL's we can handle ourself?
|
|
|
|
if ( aURL.Complete.equals( getConfirmDeletionURL() )
|
|
|
|
|| ( m_aSupportedFeatures.find( aURL.Complete ) != m_aSupportedFeatures.end() )
|
|
|
|
)
|
|
|
|
{
|
2008-06-16 11:33:12 +00:00
|
|
|
xReturn = this;
|
2002-01-24 16:43:35 +00:00
|
|
|
}
|
|
|
|
// no? -> ask the slave dispatcher
|
|
|
|
else if ( m_xSlaveDispatcher.is() )
|
|
|
|
{
|
|
|
|
xReturn = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
// outta here
|
|
|
|
return xReturn;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
Sequence< Reference< XDispatch > > OGenericUnoController::queryDispatches(const Sequence< DispatchDescriptor >& aDescripts) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
Sequence< Reference< XDispatch > > aReturn;
|
|
|
|
sal_Int32 nLen = aDescripts.getLength();
|
|
|
|
if ( nLen )
|
|
|
|
{
|
|
|
|
aReturn.realloc( nLen );
|
|
|
|
Reference< XDispatch >* pReturn = aReturn.getArray();
|
|
|
|
const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen;
|
|
|
|
const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
|
|
|
|
{
|
|
|
|
*pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
|
|
|
|
}
|
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
Reference< XDispatchProvider > OGenericUnoController::getSlaveDispatchProvider(void) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
return m_xSlaveDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::setSlaveDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
m_xSlaveDispatcher = _xNewProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
Reference< XDispatchProvider > OGenericUnoController::getMasterDispatchProvider(void) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
return m_xMasterDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::setMasterDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
m_xMasterDispatcher = _xNewProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-02-19 12:54:45 +00:00
|
|
|
void OGenericUnoController::dispatch(const URL& _aURL, const Sequence< PropertyValue >& aArgs) throw(RuntimeException)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2005-09-23 11:21:38 +00:00
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
// Since the fix for #123967#, the SolarMutex is not locked anymore when the framework calls into
|
|
|
|
// here. So, lock it ourself. The real solution would be to lock it only in the places
|
|
|
|
// where it's needed, but a) this might turn out difficult, since we then also need to care
|
|
|
|
// for locking in the proper order (SolarMutex and m_aMutex), and b) this would be too many places
|
|
|
|
// for the time frame of the fix.
|
|
|
|
// #i52602# / frank.schoenheit@sun.com / 2005-07-29
|
2006-08-15 09:49:24 +00:00
|
|
|
|
|
|
|
#ifdef TIMELOG
|
|
|
|
::rtl::OString sLog( "OGenericUnoController::dispatch( '" );
|
|
|
|
sLog += ::rtl::OString( _aURL.Main.getStr(), _aURL.Main.getLength(), osl_getThreadTextEncoding() );
|
|
|
|
sLog += ::rtl::OString( "' )" );
|
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", sLog.getStr() );
|
|
|
|
#endif
|
|
|
|
|
2006-10-18 12:30:13 +00:00
|
|
|
executeChecked(_aURL,aArgs);
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::addStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2006-07-10 14:23:57 +00:00
|
|
|
// parse the ULR now and here, this saves later parsing in each notification round
|
|
|
|
URL aParsedURL( _rURL );
|
|
|
|
if ( m_xUrlTransformer.is() )
|
|
|
|
m_xUrlTransformer->parseStrict( aParsedURL );
|
|
|
|
|
2002-01-24 16:43:35 +00:00
|
|
|
// remeber the listener together with the URL
|
2006-07-10 14:23:57 +00:00
|
|
|
m_arrStatusListener.insert( m_arrStatusListener.end(), DispatchTarget( aParsedURL, aListener ) );
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// initially broadcast the state
|
2006-07-10 14:23:57 +00:00
|
|
|
ImplBroadcastFeatureState( aParsedURL.Complete, aListener, sal_True );
|
2001-01-09 14:43:04 +00:00
|
|
|
// force the new state to be broadcasted to the new listener
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::removeStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
DispatchIterator iterSearch = m_arrStatusListener.begin();
|
|
|
|
|
2001-04-24 13:36:44 +00:00
|
|
|
sal_Bool bRemoveForAll = (_rURL.Complete.getLength() == 0);
|
2002-01-24 16:43:35 +00:00
|
|
|
while ( iterSearch != m_arrStatusListener.end() )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
DispatchTarget& rCurrent = *iterSearch;
|
|
|
|
if ( (rCurrent.xListener == aListener)
|
|
|
|
&& ( bRemoveForAll
|
2001-04-24 13:36:44 +00:00
|
|
|
|| (rCurrent.aURL.Complete.equals(_rURL.Complete))
|
2001-01-09 14:43:04 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
m_arrStatusListener.erase( iterSearch );
|
2001-01-09 14:43:04 +00:00
|
|
|
if (!bRemoveForAll)
|
2002-01-24 16:43:35 +00:00
|
|
|
// remove the listener only for the given URL, so we can exit the loop after deletion
|
2001-01-09 14:43:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++iterSearch;
|
|
|
|
}
|
|
|
|
|
2007-07-06 07:04:34 +00:00
|
|
|
if ( m_aSupportedFeatures.empty() )
|
|
|
|
fillSupportedFeatures();
|
2001-04-24 13:36:44 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(_rURL.Complete);
|
2001-01-09 14:43:04 +00:00
|
|
|
if (aIter != m_aSupportedFeatures.end())
|
|
|
|
{ // clear the cache for that feature
|
2004-11-16 13:31:01 +00:00
|
|
|
StateCacheIterator aCachePos = m_aStateCache.find( aIter->second.nFeatureId );
|
|
|
|
if ( aCachePos != m_aStateCache.end() )
|
|
|
|
m_aStateCache.erase( aCachePos );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// now remove the listener from the deque
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
2001-08-27 05:57:24 +00:00
|
|
|
m_aFeaturesToInvalidate.erase(
|
|
|
|
::std::remove_if( m_aFeaturesToInvalidate.begin(),
|
|
|
|
m_aFeaturesToInvalidate.end(),
|
|
|
|
::std::bind2nd(FeaturePairFunctor(),aListener))
|
|
|
|
,m_aFeaturesToInvalidate.end());
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::dispose( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
// disambiguate
|
|
|
|
OGenericUnoController_Base::WeakComponentImplHelperBase::dispose();
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2001-03-01 14:17:55 +00:00
|
|
|
void OGenericUnoController::disposing()
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
EventObject aDisposeEvent;
|
2001-06-21 16:51:14 +00:00
|
|
|
aDisposeEvent.Source = static_cast<XWeak*>(this);
|
2004-08-02 14:34:22 +00:00
|
|
|
Dispatch aStatusListener = m_arrStatusListener;
|
|
|
|
Dispatch::iterator aEnd = aStatusListener.end();
|
|
|
|
for (Dispatch::iterator aIter = aStatusListener.begin(); aIter != aEnd; ++aIter)
|
|
|
|
{
|
|
|
|
aIter->xListener->disposing(aDisposeEvent);
|
|
|
|
}
|
|
|
|
m_arrStatusListener.clear();
|
2007-07-06 07:04:34 +00:00
|
|
|
m_aSelectionListeners.disposeAndClear( aDisposeEvent );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 14:34:22 +00:00
|
|
|
m_xDatabaseContext = NULL;
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aFeatureMutex);
|
2001-01-23 09:35:13 +00:00
|
|
|
m_aAsyncInvalidateAll.CancelCall();
|
2001-01-09 14:43:04 +00:00
|
|
|
m_aFeaturesToInvalidate.clear();
|
|
|
|
}
|
|
|
|
|
2008-04-04 13:56:57 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY );
|
|
|
|
if ( xUntitledProvider.is() )
|
|
|
|
xUntitledProvider->releaseNumberForComponent(static_cast<XWeak*>(this));
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// check out from all the objects we are listening
|
|
|
|
// the frame
|
2008-03-06 17:14:19 +00:00
|
|
|
stopFrameListening( m_aCurrentFrame.getFrame() );
|
|
|
|
m_aCurrentFrame.attachFrame( NULL );
|
|
|
|
|
2005-09-23 11:21:38 +00:00
|
|
|
m_xMasterDispatcher = NULL;
|
|
|
|
m_xSlaveDispatcher = NULL;
|
2007-07-06 07:04:34 +00:00
|
|
|
m_xServiceFactory = NULL;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
// disambiguate
|
|
|
|
OGenericUnoController_Base::WeakComponentImplHelperBase::addEventListener( xListener );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OGenericUnoController::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
// disambiguate
|
|
|
|
OGenericUnoController_Base::WeakComponentImplHelperBase::removeEventListener( xListener );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
void OGenericUnoController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( aEvent.Frame == m_aCurrentFrame.getFrame() )
|
|
|
|
m_aCurrentFrame.frameAction( aEvent.Action );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2004-11-16 13:31:01 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2004-11-16 13:31:01 +00:00
|
|
|
void OGenericUnoController::implDescribeSupportedFeature( const sal_Char* _pAsciiCommandURL,
|
|
|
|
sal_uInt16 _nFeatureId, sal_Int16 _nCommandGroup )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2006-03-31 11:12:49 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
DBG_ASSERT( m_bDescribingSupportedFeatures, "OGenericUnoController::implDescribeSupportedFeature: bad timing for this call!" );
|
2004-11-16 13:31:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
ControllerFeature aFeature;
|
|
|
|
aFeature.Command = ::rtl::OUString::createFromAscii( _pAsciiCommandURL );
|
|
|
|
aFeature.nFeatureId = _nFeatureId;
|
|
|
|
aFeature.GroupId = _nCommandGroup;
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
OSL_ENSURE( m_aSupportedFeatures.find( aFeature.Command ) == m_aSupportedFeatures.end(),
|
|
|
|
"OGenericUnoController::implDescribeSupportedFeature: this feature is already there!" );
|
|
|
|
#endif
|
|
|
|
m_aSupportedFeatures[ aFeature.Command ] = aFeature;
|
|
|
|
}
|
2004-09-09 08:41:47 +00:00
|
|
|
|
2004-11-16 13:31:01 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::describeSupportedFeatures()
|
|
|
|
{
|
|
|
|
// add all supported features
|
|
|
|
implDescribeSupportedFeature( ".uno:Copy", ID_BROWSER_COPY, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:Cut", ID_BROWSER_CUT, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:Paste", ID_BROWSER_PASTE, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:ClipboardFormatItems", ID_BROWSER_CLIPBOARD_FORMAT_ITEMS );
|
|
|
|
implDescribeSupportedFeature( ".uno:DSBEditDoc", ID_BROWSER_EDITDOC, CommandGroup::DOCUMENT );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
FeatureState OGenericUnoController::GetState(sal_uInt16 nId) const
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
FeatureState aReturn;
|
|
|
|
// (disabled automatically)
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch (nId)
|
|
|
|
{
|
|
|
|
case ID_BROWSER_UNDO:
|
|
|
|
case ID_BROWSER_SAVEDOC:
|
|
|
|
aReturn.bEnabled = sal_True;
|
2004-09-09 08:41:47 +00:00
|
|
|
break;
|
|
|
|
case 99:
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
break;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-20 01:58:07 +00:00
|
|
|
catch( const Exception& )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2006-06-20 01:58:07 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
2001-08-16 09:39:41 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2002-01-24 16:43:35 +00:00
|
|
|
URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
|
|
|
URL aReturn;
|
2002-01-24 16:43:35 +00:00
|
|
|
if ( m_xUrlTransformer.is() )
|
2001-08-27 05:57:24 +00:00
|
|
|
{
|
2002-01-24 16:43:35 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = ::std::find_if(
|
|
|
|
m_aSupportedFeatures.begin(),
|
|
|
|
m_aSupportedFeatures.end(),
|
2004-11-16 13:31:01 +00:00
|
|
|
::std::bind2nd( SupportedFeaturesEqualId(), _nId )
|
2002-01-24 16:43:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if ( m_aSupportedFeatures.end() != aIter && aIter->first.getLength() )
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2001-08-27 05:57:24 +00:00
|
|
|
aReturn.Complete = aIter->first;
|
2002-01-24 16:43:35 +00:00
|
|
|
m_xUrlTransformer->parseStrict( aReturn );
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-08-27 05:57:24 +00:00
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
return aReturn;
|
|
|
|
}
|
2001-05-10 11:25:36 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL OGenericUnoController::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
|
2002-01-24 16:43:35 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
const ::rtl::OUString* pArray = aSupported.getConstArray();
|
2002-01-24 16:43:35 +00:00
|
|
|
const ::rtl::OUString* pArrayEnd = aSupported.getConstArray() + aSupported.getLength();
|
|
|
|
|
|
|
|
for ( ;( pArray != pArrayEnd ) && !pArray->equals( ServiceName ); ++pArray )
|
|
|
|
;
|
|
|
|
return pArray != pArrayEnd;
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-05-10 11:25:36 +00:00
|
|
|
|
2001-01-09 14:43:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2001-05-10 11:25:36 +00:00
|
|
|
void OGenericUnoController::startConnectionListening(const Reference< XConnection >& _rxConnection)
|
2001-01-09 14:43:04 +00:00
|
|
|
{
|
2001-05-10 11:25:36 +00:00
|
|
|
// we have to remove ourself before dispoing the connection
|
|
|
|
Reference< XComponent > xComponent(_rxConnection, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
2001-06-21 16:51:14 +00:00
|
|
|
xComponent->addEventListener(static_cast<XFrameActionListener*>(this));
|
2001-05-10 11:25:36 +00:00
|
|
|
}
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2001-05-10 11:25:36 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::stopConnectionListening(const Reference< XConnection >& _rxConnection)
|
|
|
|
{
|
|
|
|
// we have to remove ourself before dispoing the connection
|
|
|
|
Reference< XComponent > xComponent(_rxConnection, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
2001-06-21 16:51:14 +00:00
|
|
|
xComponent->removeEventListener(static_cast<XFrameActionListener*>(this));
|
2001-05-10 11:25:36 +00:00
|
|
|
}
|
2004-08-02 14:34:22 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XConnection > OGenericUnoController::connect(
|
|
|
|
const Reference< XDataSource>& _xDataSource
|
|
|
|
,sal_Bool _bStartListening
|
|
|
|
)
|
|
|
|
{
|
|
|
|
WaitObject aWaitCursor(getView());
|
|
|
|
|
2007-07-24 11:07:21 +00:00
|
|
|
ODatasourceConnector aConnector( getORB(), getView(), ::rtl::OUString() );
|
2004-08-02 14:34:22 +00:00
|
|
|
Reference<XConnection> xConnection = aConnector.connect(_xDataSource);
|
2001-01-26 13:15:24 +00:00
|
|
|
|
2004-08-02 14:34:22 +00:00
|
|
|
// be notified when connection is in disposing
|
|
|
|
if (_bStartListening)
|
|
|
|
startConnectionListening(xConnection);
|
|
|
|
|
|
|
|
return xConnection;
|
|
|
|
}
|
2001-08-15 05:47:21 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XConnection > OGenericUnoController::connect(
|
|
|
|
const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rContextInformation,
|
2007-07-24 11:07:21 +00:00
|
|
|
sal_Bool _bStartListening )
|
2001-05-10 11:25:36 +00:00
|
|
|
{
|
|
|
|
WaitObject aWaitCursor(getView());
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2007-07-24 11:07:21 +00:00
|
|
|
ODatasourceConnector aConnector( getORB(), getView(), _rContextInformation );
|
2001-08-15 05:47:21 +00:00
|
|
|
Reference<XConnection> xConnection = aConnector.connect(_rDataSourceName);
|
2001-01-09 14:43:04 +00:00
|
|
|
|
2001-05-10 11:25:36 +00:00
|
|
|
// be notified when connection is in disposing
|
|
|
|
if (_bStartListening)
|
|
|
|
startConnectionListening(xConnection);
|
2001-01-15 08:37:29 +00:00
|
|
|
|
|
|
|
return xConnection;
|
|
|
|
}
|
2001-05-10 11:25:36 +00:00
|
|
|
|
2001-01-15 08:37:29 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::showError(const SQLExceptionInfo& _rInfo)
|
|
|
|
{
|
2001-02-23 14:17:34 +00:00
|
|
|
::dbaui::showError(_rInfo,getView(),getORB());
|
2001-01-09 14:43:04 +00:00
|
|
|
}
|
2001-02-23 14:17:34 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< XLayoutManager > OGenericUnoController::getLayoutManager(const Reference< XFrame >& _xFrame) const
|
2001-04-24 13:36:44 +00:00
|
|
|
{
|
2004-02-25 14:32:25 +00:00
|
|
|
Reference< XPropertySet > xPropSet( _xFrame, UNO_QUERY );
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< XLayoutManager > xLayoutManager;
|
2004-02-25 14:32:25 +00:00
|
|
|
if ( xPropSet.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2004-08-02 14:34:22 +00:00
|
|
|
xLayoutManager.set(xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))),UNO_QUERY);
|
2004-02-25 14:32:25 +00:00
|
|
|
}
|
|
|
|
catch ( Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2004-09-09 08:41:47 +00:00
|
|
|
return xLayoutManager;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::loadMenu(const Reference< XFrame >& _xFrame)
|
|
|
|
{
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< XLayoutManager > xLayoutManager = getLayoutManager(_xFrame);
|
2004-02-25 14:32:25 +00:00
|
|
|
if ( xLayoutManager.is() )
|
2004-09-09 08:41:47 +00:00
|
|
|
{
|
|
|
|
xLayoutManager->lock();
|
2004-02-25 14:32:25 +00:00
|
|
|
xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
|
2004-09-09 08:41:47 +00:00
|
|
|
xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/toolbar" )));
|
|
|
|
xLayoutManager->unlock();
|
|
|
|
xLayoutManager->doLayout();
|
|
|
|
}
|
2004-10-22 11:03:46 +00:00
|
|
|
|
|
|
|
onLoadedMenu( xLayoutManager );
|
2004-09-09 08:41:47 +00:00
|
|
|
}
|
2004-10-22 11:03:46 +00:00
|
|
|
|
2004-09-09 08:41:47 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void OGenericUnoController::onLoadedMenu(const Reference< XLayoutManager >& /*_xLayoutManager*/)
|
2004-09-09 08:41:47 +00:00
|
|
|
{
|
2004-10-22 11:03:46 +00:00
|
|
|
// not interested in
|
2001-04-24 13:36:44 +00:00
|
|
|
}
|
2004-10-22 11:03:46 +00:00
|
|
|
|
2001-04-24 13:36:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::closeTask()
|
|
|
|
{
|
2001-09-19 12:20:12 +00:00
|
|
|
m_aAsyncCloseTask.Call();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OGenericUnoController, OnAsyncCloseTask, void*, EMPTYARG)
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( !OGenericUnoController_Base::rBHelper.bInDispose )
|
2001-09-19 12:20:12 +00:00
|
|
|
{
|
2002-06-24 09:29:26 +00:00
|
|
|
try
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
Reference< util::XCloseable > xCloseable( m_aCurrentFrame.getFrame(), UNO_QUERY_THROW );
|
2008-03-05 15:52:59 +00:00
|
|
|
xCloseable->close( sal_False ); // false - holds the owner ship for this frame inside this object!
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2002-10-11 07:53:05 +00:00
|
|
|
}
|
2001-09-19 12:20:12 +00:00
|
|
|
}
|
|
|
|
return 0L;
|
2001-04-24 13:36:44 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-18 05:50:04 +00:00
|
|
|
Any SAL_CALL OGenericUnoController::getViewData(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:58:07 +00:00
|
|
|
void SAL_CALL OGenericUnoController::restoreViewData(const Any& /*Data*/) throw( RuntimeException )
|
2001-10-18 05:50:04 +00:00
|
|
|
{
|
|
|
|
}
|
2008-03-06 17:14:19 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XModel > SAL_CALL OGenericUnoController::getModel(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return Reference< XModel >();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XFrame > SAL_CALL OGenericUnoController::getFrame(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
return m_aCurrentFrame.getFrame();
|
|
|
|
}
|
|
|
|
|
2001-10-18 05:50:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:58:07 +00:00
|
|
|
sal_Bool SAL_CALL OGenericUnoController::attachModel(const Reference< XModel > & /*xModel*/) throw( RuntimeException )
|
2001-10-18 05:50:04 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
OSL_ENSURE( false, "OGenericUnoController::attachModel: not supported!" );
|
2001-10-18 05:50:04 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
2008-03-06 17:14:19 +00:00
|
|
|
|
2001-10-18 05:50:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-07-06 07:04:34 +00:00
|
|
|
void OGenericUnoController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
|
|
|
|
{
|
|
|
|
Execute(_nCommandId, aArgs);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void OGenericUnoController::executeUnChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
|
2002-02-11 11:43:58 +00:00
|
|
|
{
|
2007-07-06 07:04:34 +00:00
|
|
|
if ( m_aSupportedFeatures.empty() )
|
|
|
|
fillSupportedFeatures();
|
2004-11-16 13:31:01 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
|
2002-02-11 11:43:58 +00:00
|
|
|
if (aIter != m_aSupportedFeatures.end())
|
2004-11-16 13:31:01 +00:00
|
|
|
Execute( aIter->second.nFeatureId, aArgs );
|
2002-02-11 11:43:58 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void OGenericUnoController::executeChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
|
2002-02-11 11:43:58 +00:00
|
|
|
{
|
2007-07-06 07:04:34 +00:00
|
|
|
if ( m_aSupportedFeatures.empty() )
|
|
|
|
fillSupportedFeatures();
|
2004-11-16 13:31:01 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
|
|
|
|
if ( aIter != m_aSupportedFeatures.end() )
|
2002-02-11 11:43:58 +00:00
|
|
|
{
|
2004-11-16 13:31:01 +00:00
|
|
|
sal_uInt16 nFeatureId = aIter->second.nFeatureId;
|
|
|
|
if ( GetState( nFeatureId ).bEnabled )
|
|
|
|
Execute( nFeatureId, aArgs );
|
2002-02-11 11:43:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-08-26 06:52:15 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
::rtl::OUString lcl_getModuleHelpModuleName( const Reference< XFrame >& _rxFrame )
|
|
|
|
{
|
|
|
|
const sal_Char* pReturn = NULL;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// get the model of the document in the given frame
|
|
|
|
Reference< XController > xController;
|
|
|
|
if ( _rxFrame.is() )
|
|
|
|
xController = _rxFrame->getController();
|
|
|
|
Reference< XModel > xModel;
|
|
|
|
if ( xController.is() )
|
|
|
|
xModel = xController->getModel();
|
|
|
|
Reference< XServiceInfo > xSI( xModel, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( !xSI.is() )
|
|
|
|
{ // try to go up the frame hierarchy
|
|
|
|
|
|
|
|
Reference< XFrame > xParentFrame;
|
|
|
|
if ( _rxFrame.is() )
|
|
|
|
xParentFrame = xParentFrame.query( _rxFrame->getCreator() );
|
|
|
|
// did we find a parent frame? Which is no top-level frame?
|
|
|
|
if ( xParentFrame.is() && !_rxFrame->isTop() )
|
|
|
|
// TODO: to prevent framework assertions, re-insert this "isTop" once 98303 is fixed
|
|
|
|
return lcl_getModuleHelpModuleName( xParentFrame );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-15 15:03:18 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2002-08-26 06:52:15 +00:00
|
|
|
Sequence< ::rtl::OUString > sServiceNames = xSI->getSupportedServiceNames();
|
|
|
|
const ::rtl::OUString* pLoop = sServiceNames.getConstArray();
|
|
|
|
for ( sal_Int32 i=0; i<sServiceNames.getLength(); ++i, ++pLoop )
|
|
|
|
{
|
|
|
|
sal_Int32 nDummy = 0;
|
2006-06-20 01:58:07 +00:00
|
|
|
(void)nDummy;
|
2002-08-26 06:52:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// check which service we know ....
|
|
|
|
static const sal_Char* pTransTable[] = {
|
2005-02-17 10:06:30 +00:00
|
|
|
"com.sun.star.sdb.OfficeDatabaseDocument","sdatabase",
|
2007-07-06 07:04:34 +00:00
|
|
|
"com.sun.star.report.ReportDefinition","sdatabase",
|
2002-08-26 06:52:15 +00:00
|
|
|
"com.sun.star.text.TextDocument", "swriter",
|
|
|
|
"com.sun.star.sheet.SpreadsheetDocument", "scalc",
|
|
|
|
"com.sun.star.presentation.PresentationDocument", "simpress",
|
|
|
|
"com.sun.star.drawing.DrawingDocument", "sdraw",
|
|
|
|
"com.sun.star.formula.FormularProperties", "smath",
|
|
|
|
"com.sun.star.chart.ChartDocument", "schart"
|
|
|
|
};
|
|
|
|
OSL_ENSURE( ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) % 2 == 0,
|
|
|
|
"lcl_getModuleHelpModuleName: odd size of translation table!" );
|
|
|
|
|
|
|
|
// loop through the table
|
|
|
|
sal_Int32 nTableEntries = ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) / 2;
|
|
|
|
const sal_Char** pDocumentService = pTransTable;
|
|
|
|
const sal_Char** pHelpModuleName = pTransTable + 1;
|
|
|
|
for ( sal_Int32 j=0; j<nTableEntries; ++j )
|
|
|
|
{
|
|
|
|
if ( xSI->supportsService( ::rtl::OUString::createFromAscii( *pDocumentService ) ) )
|
|
|
|
{ // found a table entry which matches the model's services
|
|
|
|
pReturn = *pHelpModuleName;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++pDocumentService; ++pDocumentService;
|
|
|
|
++pHelpModuleName; ++pHelpModuleName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !pReturn )
|
|
|
|
{
|
|
|
|
// could not determine the document type we're living in
|
|
|
|
// ->fallback
|
|
|
|
SvtModuleOptions aModOpt;
|
|
|
|
if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
|
|
|
|
pReturn = "swriter";
|
2004-08-02 14:34:22 +00:00
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
|
|
|
|
pReturn = "sdatabase";
|
2002-08-26 06:52:15 +00:00
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
|
|
|
|
pReturn = "scalc";
|
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
|
|
|
|
pReturn = "simpress";
|
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
|
|
|
|
pReturn = "sdraw";
|
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
|
|
|
|
pReturn = "smath";
|
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCHART ) )
|
|
|
|
pReturn = "schart";
|
|
|
|
else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SBASIC ) )
|
|
|
|
pReturn = "sbasic";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "lcl_getModuleHelpModuleName: no installed module found" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2008-05-05 14:53:19 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2002-08-26 06:52:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !pReturn )
|
|
|
|
pReturn = "swriter";
|
|
|
|
|
|
|
|
return ::rtl::OUString::createFromAscii( pReturn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-08-02 13:26:28 +00:00
|
|
|
// prototype out of UITools.cxx
|
|
|
|
namespace dbaui
|
2002-08-26 06:52:15 +00:00
|
|
|
{
|
2007-08-02 13:26:28 +00:00
|
|
|
void AppendConfigToken_Impl( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OGenericUnoController::openHelpAgent(rtl::OUString const& _suHelpStringURL )
|
|
|
|
{
|
|
|
|
rtl::OUString suURL(_suHelpStringURL);
|
|
|
|
rtl::OUString sLanguage = rtl::OUString::createFromAscii("Language=");
|
|
|
|
if (suURL.indexOf(sLanguage) == -1)
|
|
|
|
{
|
|
|
|
dbaui::AppendConfigToken_Impl(suURL, sal_False /* sal_False := add '&' */ );
|
|
|
|
}
|
|
|
|
URL aURL;
|
|
|
|
aURL.Complete = suURL;
|
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
openHelpAgent( aURL );
|
2007-08-02 13:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OGenericUnoController::openHelpAgent(sal_Int32 _nHelpId)
|
2008-03-06 17:14:19 +00:00
|
|
|
{
|
|
|
|
openHelpAgent( createHelpAgentURL( lcl_getModuleHelpModuleName( getFrame() ), _nHelpId ) );
|
2007-08-02 13:26:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
void OGenericUnoController::openHelpAgent( const URL& _rURL )
|
2007-08-02 13:26:28 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
URL aURL( _rURL );
|
2007-08-02 13:26:28 +00:00
|
|
|
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( m_xUrlTransformer.is() )
|
|
|
|
m_xUrlTransformer->parseStrict(aURL);
|
|
|
|
|
|
|
|
Reference< XDispatchProvider > xDispProv( m_aCurrentFrame.getFrame(), UNO_QUERY );
|
2002-08-26 06:52:15 +00:00
|
|
|
Reference< XDispatch > xHelpDispatch;
|
2008-03-06 17:14:19 +00:00
|
|
|
if ( xDispProv.is() )
|
2002-08-26 06:52:15 +00:00
|
|
|
xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_helpagent")), FrameSearchFlag::PARENT | FrameSearchFlag::SELF);
|
|
|
|
OSL_ENSURE(xHelpDispatch.is(), "SbaTableQueryBrowser::openHelpAgent: could not get a dispatcher!");
|
|
|
|
if (xHelpDispatch.is())
|
|
|
|
{
|
|
|
|
xHelpDispatch->dispatch(aURL, Sequence< PropertyValue >());
|
|
|
|
}
|
|
|
|
}
|
2008-05-05 14:53:19 +00:00
|
|
|
catch( const Exception& )
|
2002-08-26 06:52:15 +00:00
|
|
|
{
|
2008-05-05 14:53:19 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2002-08-26 06:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() const
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::awt::XWindow> xWindow;
|
2008-03-06 17:14:19 +00:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
// get the top most window
|
2008-03-06 17:14:19 +00:00
|
|
|
Reference< XFrame > xFrame( m_aCurrentFrame.getFrame() );
|
|
|
|
if ( xFrame.is() )
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
xWindow = xFrame->getContainerWindow();
|
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
while ( xFrame.is() && !xFrame->isTop() )
|
|
|
|
{
|
2008-03-06 17:14:19 +00:00
|
|
|
xFrame.set( xFrame->getCreator(), UNO_QUERY );
|
2003-03-19 16:57:12 +00:00
|
|
|
}
|
|
|
|
if ( xFrame.is() )
|
|
|
|
xWindow = xFrame->getContainerWindow();
|
|
|
|
}
|
|
|
|
return xWindow;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
|
2004-08-02 14:34:22 +00:00
|
|
|
{
|
2008-04-04 13:56:57 +00:00
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
if ( ! m_xTitleHelper.is ())
|
2004-08-02 14:34:22 +00:00
|
|
|
{
|
2008-04-04 13:56:57 +00:00
|
|
|
Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY );
|
|
|
|
Reference< XController > xThis(static_cast< XController* >(this), UNO_QUERY_THROW);
|
|
|
|
|
|
|
|
::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_xServiceFactory);
|
|
|
|
m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), UNO_QUERY_THROW);
|
|
|
|
|
|
|
|
pHelper->setOwner (xThis );
|
|
|
|
pHelper->connectWithUntitledNumbers (xUntitledProvider);
|
2004-08-02 14:34:22 +00:00
|
|
|
}
|
2008-04-04 13:56:57 +00:00
|
|
|
|
|
|
|
return m_xTitleHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// XTitle
|
|
|
|
::rtl::OUString SAL_CALL OGenericUnoController::getTitle()
|
|
|
|
throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
if ( m_bExternalTitle )
|
|
|
|
return impl_getTitleHelper_throw()->getTitle ();
|
|
|
|
return getPrivateTitle() + impl_getTitleHelper_throw()->getTitle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// XTitle
|
|
|
|
void SAL_CALL OGenericUnoController::setTitle(const ::rtl::OUString& sTitle)
|
|
|
|
throw (RuntimeException)
|
|
|
|
{
|
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
m_bExternalTitle = sal_True;
|
|
|
|
impl_getTitleHelper_throw()->setTitle (sTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// XTitleChangeBroadcaster
|
|
|
|
void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
|
|
|
|
throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
|
|
|
|
if (xBroadcaster.is ())
|
|
|
|
xBroadcaster->addTitleChangeListener (xListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// XTitleChangeBroadcaster
|
|
|
|
void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
|
|
|
|
throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
|
|
|
|
if (xBroadcaster.is ())
|
|
|
|
xBroadcaster->removeTitleChangeListener (xListener);
|
2004-08-02 14:34:22 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2004-09-09 08:41:47 +00:00
|
|
|
void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
|
2004-08-02 14:34:22 +00:00
|
|
|
{
|
|
|
|
if ( isCommandEnabled(_nCommandId) )
|
2004-09-09 08:41:47 +00:00
|
|
|
Execute(_nCommandId, aArgs);
|
2004-08-02 14:34:22 +00:00
|
|
|
}
|
2004-11-16 13:31:01 +00:00
|
|
|
|
2004-08-02 14:34:22 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OGenericUnoController::isCommandEnabled(sal_uInt16 _nCommandId) const
|
|
|
|
{
|
|
|
|
return GetState( _nCommandId ).bEnabled;
|
|
|
|
}
|
2008-03-06 17:14:19 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OGenericUnoController::isDataSourceReadOnly() const
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XController > SAL_CALL OGenericUnoController::getXController() throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-07-06 07:04:34 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const
|
|
|
|
{
|
|
|
|
FeatureState aState = GetState( _nCommandId );
|
2004-11-16 13:31:01 +00:00
|
|
|
|
2007-07-06 07:04:34 +00:00
|
|
|
return aState.bChecked && (sal_Bool)*aState.bChecked;
|
|
|
|
}
|
2004-08-02 14:34:22 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-06-12 04:33:49 +00:00
|
|
|
sal_Bool OGenericUnoController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
|
2004-09-09 08:41:47 +00:00
|
|
|
{
|
2007-06-12 04:33:49 +00:00
|
|
|
OSL_ENSURE( _rCompleteCommandURL.getLength(), "OGenericUnoController::isCommandEnabled: Empty command url!" );
|
2007-07-06 07:04:34 +00:00
|
|
|
|
2004-09-09 08:41:47 +00:00
|
|
|
sal_Bool bIsEnabled = sal_False;
|
2007-06-12 04:33:49 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL );
|
2004-11-16 13:31:01 +00:00
|
|
|
if ( aIter != m_aSupportedFeatures.end() )
|
|
|
|
bIsEnabled = isCommandEnabled( aIter->second.nFeatureId );
|
2004-09-09 08:41:47 +00:00
|
|
|
|
|
|
|
return bIsEnabled;
|
|
|
|
}
|
2004-11-16 13:31:01 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroups() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
CommandHashMap aCmdHashMap;
|
|
|
|
for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
|
|
|
|
aIter != m_aSupportedFeatures.end();
|
|
|
|
++aIter
|
|
|
|
)
|
2005-09-23 11:21:38 +00:00
|
|
|
if ( aIter->second.GroupId != CommandGroup::INTERNAL )
|
|
|
|
aCmdHashMap.insert( CommandHashMap::value_type( aIter->second.GroupId, 0 ));
|
2004-11-16 13:31:01 +00:00
|
|
|
|
|
|
|
Sequence< sal_Int16 > aCommandGroups( aCmdHashMap.size() );
|
|
|
|
::std::transform( aCmdHashMap.begin(),
|
|
|
|
aCmdHashMap.end(),
|
|
|
|
aCommandGroups.getArray(),
|
|
|
|
::std::select1st< CommandHashMap::value_type >()
|
|
|
|
);
|
|
|
|
|
|
|
|
return aCommandGroups;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< DispatchInformation > SAL_CALL OGenericUnoController::getConfigurableDispatchInformation( ::sal_Int16 CommandGroup ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
DispatchInfoList aInformationList;
|
|
|
|
DispatchInformation aDispatchInfo;
|
|
|
|
for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
|
|
|
|
aIter != m_aSupportedFeatures.end();
|
|
|
|
++aIter
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( sal_Int16( aIter->second.GroupId ) == CommandGroup )
|
|
|
|
{
|
|
|
|
aDispatchInfo = aIter->second;
|
|
|
|
aInformationList.push_back( aDispatchInfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Sequence< DispatchInformation > aInformation( aInformationList.size() );
|
|
|
|
::std::transform( aInformationList.begin(),
|
|
|
|
aInformationList.end(),
|
|
|
|
aInformation.getArray(),
|
|
|
|
::std::identity< DispatchInformation >()
|
|
|
|
);
|
|
|
|
|
|
|
|
return aInformation;
|
|
|
|
}
|
2007-07-06 07:04:34 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OGenericUnoController::fillSupportedFeatures()
|
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
m_bDescribingSupportedFeatures = true;
|
|
|
|
#endif
|
|
|
|
describeSupportedFeatures();
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
m_bDescribingSupportedFeatures = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::sal_Bool SAL_CALL OGenericUnoController::select( const Any& /*xSelection*/ ) throw (IllegalArgumentException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL OGenericUnoController::getSelection( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void SAL_CALL OGenericUnoController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& xListener ) throw (RuntimeException)
|
2007-07-06 07:04:34 +00:00
|
|
|
{
|
|
|
|
m_aSelectionListeners.addInterface(xListener);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-04-04 13:56:57 +00:00
|
|
|
void SAL_CALL OGenericUnoController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& xListener ) throw (RuntimeException)
|
2007-07-06 07:04:34 +00:00
|
|
|
{
|
|
|
|
m_aSelectionListeners.removeInterface(xListener);
|
|
|
|
}
|
|
|
|
|