2010-10-12 15:59:03 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-14 17:39:53 +01:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2006-09-17 05:58:43 +00:00
2013-05-06 17:19:41 +02:00
# include <dbaccess/genericcontroller.hxx>
2001-01-09 14:43:04 +00:00
# include <comphelper/uno3.hxx>
# include <toolkit/awt/vclxwindow.hxx>
# include "browserids.hxx"
2004-08-02 14:34:22 +00:00
# include <vcl/svapp.hxx>
2001-04-23 08:30:31 +00:00
# include <toolkit/helper/vclunohelper.hxx>
2013-05-06 17:19:41 +02:00
# include <dbaccess/dataview.hxx>
2006-06-20 01:58:07 +00:00
# include <tools/diagnose_ex.h>
2011-02-03 00:33:36 +01:00
# include <osl/diagnose.h>
2001-01-09 14:43:04 +00:00
# include "dbustrings.hrc"
# include <vcl/stdtext.hxx>
2012-09-19 13:15:15 +02:00
# include <comphelper/processfactory.hxx>
2001-06-21 16:51:14 +00:00
# include <cppuhelper/typeprovider.hxx>
2008-04-04 13:56:57 +00:00
# include <framework/titlehelper.hxx>
2001-06-21 16:51:14 +00:00
# include <comphelper/sequence.hxx>
2001-03-15 07:29:16 +00:00
# include <comphelper/extract.hxx>
2013-10-16 19:25:05 -03:00
# include <cppuhelper/supportsservice.hxx>
2001-01-09 14:43:04 +00:00
# include <com/sun/star/sdbc/XDataSource.hpp>
2012-09-18 09:46:34 +02:00
# include <com/sun/star/sdb/DatabaseContext.hpp>
2001-02-27 14:11:05 +00:00
# include <com/sun/star/sdb/SQLContext.hpp>
2001-01-09 14:43:04 +00:00
# include <com/sun/star/sdb/XCompletedConnection.hpp>
# include <com/sun/star/beans/XPropertySet.hpp>
# include <com/sun/star/task/XInteractionHandler.hpp>
2012-06-01 15:15:25 +02:00
# include <com/sun/star/util/URLTransformer.hpp>
2002-06-26 07:17:57 +00:00
# include <com/sun/star/util/XCloseable.hpp>
2001-02-23 14:17:34 +00:00
# include "UITools.hxx"
2004-11-16 13:31:01 +00:00
# include "commontypes.hxx"
2015-04-30 16:56:14 +02:00
# include <com/sun/star/ui/XSidebarProvider.hpp>
# include <sfx2/sidebar/UnoSidebar.hxx>
2001-03-30 12:04:24 +00:00
# include <vcl/waitobj.hxx>
2009-10-16 00:05:16 +02:00
# include <svl/urihelper.hxx>
2001-05-10 11:25:36 +00:00
# include "datasourceconnector.hxx"
2009-10-06 07:38:24 +02:00
# include <unotools/moduleoptions.hxx>
2002-08-26 06:52:15 +00:00
# include <com/sun/star/frame/FrameSearchFlag.hpp>
2008-03-05 16:08:08 +00:00
# include <com/sun/star/frame/status/Visibility.hpp>
2004-08-02 14:34:22 +00:00
# include <com/sun/star/util/XModifiable.hpp>
2004-02-25 14:32:25 +00:00
# include <rtl/ustring.hxx>
2001-10-26 12:10:16 +00:00
# include <algorithm>
2015-08-11 14:51:35 -04:00
# include <o3tl/compat_functional.hxx>
2014-02-22 21:51:27 +09:00
# include <boost/scoped_ptr.hpp>
2008-06-16 11:33:12 +00:00
# include <cppuhelper/implbase1.hxx>
2008-06-25 13:02:57 +00:00
# include <limits>
2015-01-01 19:58:59 +00:00
# include <unordered_map>
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 ;
2015-04-30 16:56:14 +02:00
using namespace : : com : : sun : : star : : ui ;
2001-01-09 14:43:04 +00:00
using namespace : : dbtools ;
using namespace : : comphelper ;
2008-06-25 13:02:57 +00:00
# define ALL_FEATURES -1
# define FIRST_USER_DEFINED_FEATURE ( ::std::numeric_limits< sal_uInt16 >::max() - 1000 )
# define LAST_USER_DEFINED_FEATURE ( ::std::numeric_limits< sal_uInt16 >::max() )
2002-01-24 16:43:35 +00:00
2015-01-01 19:58:59 +00:00
typedef std : : unordered_map < sal_Int16 , sal_Int16 > CommandHashMap ;
2004-11-16 13:31:01 +00:00
2008-06-25 13:02:57 +00:00
namespace dbaui
{
2013-08-17 23:43:14 +02:00
// UserDefinedFeatures
2008-10-01 12:28:29 +00:00
class UserDefinedFeatures
{
public :
2015-07-20 13:06:13 +01:00
explicit UserDefinedFeatures ( const Reference < XController > & _rxController ) ;
2008-10-01 12:28:29 +00:00
2015-04-24 15:29:31 +02:00
static FeatureState getState ( const URL & _rFeatureURL ) ;
2008-10-01 12:28:29 +00:00
void execute ( const URL & _rFeatureURL , const Sequence < PropertyValue > & _rArgs ) ;
private :
2015-08-03 09:14:58 +02:00
css : : uno : : WeakReference < XController > m_aController ;
2008-10-01 12:28:29 +00:00
} ;
UserDefinedFeatures : : UserDefinedFeatures ( const Reference < XController > & _rxController )
: m_aController ( _rxController )
{
}
FeatureState UserDefinedFeatures : : getState ( const URL & /*_rFeatureURL*/ )
{
// for now, enable all the time
// TODO: we should ask the dispatcher. However, this is laborious, since you cannot ask a dispatcher
// directly, but need to add a status listener.
FeatureState aState ;
2014-04-01 09:53:24 +02:00
aState . bEnabled = true ;
2008-10-01 12:28:29 +00:00
return aState ;
}
void UserDefinedFeatures : : execute ( const URL & _rFeatureURL , const Sequence < PropertyValue > & _rArgs )
{
try
{
2014-10-02 13:37:01 +02:00
Reference < XController > xController ( Reference < XController > ( m_aController ) , UNO_SET_THROW ) ;
2008-10-01 12:28:29 +00:00
Reference < XDispatchProvider > xDispatchProvider ( xController - > getFrame ( ) , UNO_QUERY_THROW ) ;
Reference < XDispatch > xDispatch ( xDispatchProvider - > queryDispatch (
_rFeatureURL ,
2013-03-05 12:57:54 +01:00
OUString ( " _self " ) ,
2008-10-01 12:28:29 +00:00
FrameSearchFlag : : AUTO
) ) ;
if ( xDispatch = = xController )
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " UserDefinedFeatures::execute: the controller shouldn't be the dispatcher here! " ) ;
2008-10-01 12:28:29 +00:00
xDispatch . clear ( ) ;
}
if ( xDispatch . is ( ) )
xDispatch - > dispatch ( _rFeatureURL , _rArgs ) ;
}
catch ( const Exception & )
{
DBG_UNHANDLED_EXCEPTION ( ) ;
}
}
2013-08-17 23:43:14 +02:00
// OGenericUnoController_Data
2008-06-25 13:02:57 +00:00
struct OGenericUnoController_Data
{
: : sfx2 : : UserInputInterception m_aUserInputInterception ;
2008-10-01 12:28:29 +00:00
UserDefinedFeatures m_aUserDefinedFeatures ;
2008-06-25 13:02:57 +00:00
OGenericUnoController_Data ( OGenericUnoController & _rController , : : osl : : Mutex & _rMutex )
: m_aUserInputInterception ( _rController , _rMutex )
2008-10-01 12:28:29 +00:00
, m_aUserDefinedFeatures ( _rController . getXController ( ) )
2008-06-25 13:02:57 +00:00
{
}
} ;
2013-08-17 23:43:14 +02:00
// OGenericUnoController
2013-01-07 17:46:55 +02:00
OGenericUnoController : : OGenericUnoController ( const Reference < XComponentContext > & _rM )
2008-12-01 12:31:27 +00:00
: OGenericUnoController_Base ( getMutex ( ) )
2010-02-09 17:26:40 +01:00
, m_pView ( NULL )
2006-06-20 01:58:07 +00:00
# ifdef DBG_UTIL
, m_bDescribingSupportedFeatures ( false )
# endif
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 ) )
2013-01-07 17:46:55 +02:00
, m_xContext ( _rM )
2008-03-06 17:14:19 +00:00
, m_aCurrentFrame ( * this )
2014-04-01 09:53:24 +02:00
, m_bPreview ( false )
, m_bReadOnly ( false )
, m_bCurrentlyModified ( false )
, m_bExternalTitle ( false )
2001-01-09 14:43:04 +00:00
{
2012-09-22 01:51:12 -05:00
osl_atomic_increment ( & m_refCount ) ;
2008-10-01 12:28:29 +00:00
{
2008-12-01 12:31:27 +00:00
m_pData . reset ( new OGenericUnoController_Data ( * this , getMutex ( ) ) ) ;
2008-10-01 12:28:29 +00:00
}
2012-09-22 01:51:12 -05:00
osl_atomic_decrement ( & m_refCount ) ;
2008-10-01 12:28:29 +00:00
2005-09-23 11:21:38 +00:00
2001-01-09 14:43:04 +00:00
try
{
2013-01-07 17:46:55 +02:00
m_xUrlTransformer = URLTransformer : : create ( _rM ) ;
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
2012-12-21 11:33:39 +02:00
# ifdef _MSC_VER
2012-12-21 16:03:56 +02:00
# pragma warning(push)
# pragma warning(disable:4702)
2008-03-06 17:14:19 +00:00
OGenericUnoController : : OGenericUnoController ( )
2008-12-01 12:31:27 +00:00
: OGenericUnoController_Base ( getMutex ( ) )
2010-02-09 17:26:40 +01:00
, m_pView ( NULL )
2008-03-06 17:14:19 +00:00
# ifdef DBG_UTIL
, m_bDescribingSupportedFeatures ( false )
# endif
, m_aAsyncInvalidateAll ( LINK ( this , OGenericUnoController , OnAsyncInvalidateAll ) )
, m_aAsyncCloseTask ( LINK ( this , OGenericUnoController , OnAsyncCloseTask ) )
, m_aCurrentFrame ( * this )
, m_bPreview ( sal_False )
, m_bReadOnly ( sal_False )
, m_bCurrentlyModified ( sal_False )
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " OGenericUnoController::OGenericUnoController: illegal call! " ) ;
2008-03-06 17:14:19 +00:00
// 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 ( ) ;
}
2012-12-21 16:03:56 +02:00
# pragma warning(pop)
dba33a: summary migration from SVN
2009-11-06 13:10:39 +0000 msc r277387 : minor fix for automatic test
2009-11-06 13:09:33 +0000 msc r277385 : minor fix for automatic test
2009-11-06 12:30:57 +0000 fs r277383 : argh. On some virtual machines, waiting 5 seconds for the event to arrive is not enough. Increasing the timeout ...
2009-11-06 12:13:34 +0000 fs r277382 : this diagnostic code should not have slipped in
2009-11-05 13:21:06 +0000 fs r277369 : SHL2NOCHECK=TRUE (requested by hjs)
2009-11-04 14:09:46 +0000 msc r277355 : minor fix for automatic testing
2009-11-04 13:23:02 +0000 msc r277352 : minor fix for automatic testing
2009-11-04 10:53:28 +0000 msc r277341 : minor fix for automated testscript
2009-11-04 08:30:58 +0000 msc r277333 : minor fix for automatic test
2009-11-04 08:15:43 +0000 msc r277332 : minor fix for automatic test
2009-11-03 14:25:44 +0000 fs r277324 : #i10000#
2009-11-03 09:47:47 +0000 fs r277315 : found yet another help ID zombie ... moved formhelpid.hrc content to propctrlr.hrc, where it belongs
2009-11-03 08:50:24 +0000 fs r277312 : use createTempFileURL, which cares for some more specialities ...
2009-11-03 08:44:55 +0000 fs r277311 : when creating a temp file for purpose of getting a temp file URL, the delete the file immediately. On some machines/JVMs, the file exists, with write access denied, which isn't Good (TM)
2009-10-22 13:06:17 +0000 fs r277126 : removed wrong assertion
2009-10-21 08:10:35 +0000 fs r277077 : reverted the previous change, which was nonsense
2009-10-21 07:19:43 +0000 fs r277076 : export the component_foo functions, now that some of the objects are built with VISIBILITY_HIDDEN=TRUE
2009-10-21 07:08:35 +0000 fs r277075 : spare useless call
2009-10-20 21:26:31 +0000 fs r277072 : #i10000#
2009-10-20 08:06:04 +0000 fs r277039 : CWS-TOOLING: rebase CWS dba33a to trunk@277035 (milestone: DEV300:m62)
2009-10-16 09:55:25 +0000 fs r276960 : remove one of the superfluous implts_doLayout calls introduced with the previous patch
2009-10-15 13:18:52 +0000 fs r276941 : removed the basic tests. According to cn, they're not used anymore (for a long time), and according to 'du -h', they take up 6.0M on my hard disc. For too much for useless code, /me thinks.
2009-10-15 13:06:51 +0000 fs r276940 : #i10000# remove useless include (otherwise the compiler warning it provokes would need to be fixed by declaring VISIBILITY_HIDDEN=TRUE in the makefile.mk)
2009-10-15 12:52:39 +0000 fs r276939 : #i10000#
2009-10-15 12:44:26 +0000 fs r276938 : #i10000#
2009-10-15 12:00:33 +0000 fs r276936 : #i10000#
2009-10-15 10:31:37 +0000 fs r276934 : #i105259# prepare for the Hidden arg
2009-10-15 10:31:05 +0000 fs r276933 : IsMaximized -> const
2009-10-15 09:50:15 +0000 fs r276932 : during #i105259#:
introduce an option to the layout manager to preserve, if possible, the size of the content window
when layouting. Enable this option for embedded (SFX-based) documents opened for outplace editing.
(the option is incompatible with in-place editing, anyway)
This is because such embedded objects couple the (content) window size to the VisAreaSize, in that
both are used interchangeably. When an embedded object is closed, it remembers the VisAreaSize,
and restores it upon next open. This, however, leads to different content window sizes when the
window is closed with another toolbar set than used during opening.
This patch here prevents those different content window sizes. Also, now the content window size
doesn't change when, explicitly or implicitly, a toolbar is shown or hidden. Instead, the content
window size stays the same, and the container window size is adjusted.
2009-10-15 09:32:41 +0000 fs r276931 : during #i105259#: UNO access to more attributes of top windows
2009-10-15 09:30:28 +0000 fs r276930 : indention corrected (better readable)
2009-10-15 09:26:46 +0000 fs r276929 : during #i105259#: access to more attributes of top windows
2009-10-14 10:04:39 +0000 fs r276889 : connecting via services manager, not naming service
2009-10-12 11:31:08 +0000 fs r276831 : during #i105806# FillPropertySet: do not attempt to set *AutoStyleName if it doesn't exist
2009-10-12 11:24:44 +0000 fs r276830 : #i105806# getPropertyValue: throw an UnknownPropertyException for, well, unknown properties
2009-10-08 08:20:58 +0000 fs r276774 : implSubmit: re-throw WrappedTargetExceptions unmodified
2009-10-07 19:19:42 +0000 fs r276770 : #i105198# do not pass an CommandType if we do not have a command
2009-10-07 17:39:36 +0000 fs r276768 : export the OWeakObject::disposeWeakConnectionPoint symbol
2009-10-07 12:59:17 +0000 fs r276754 : #i87693#
2009-10-07 11:19:22 +0000 fs r276752 : #i10000#
2009-10-07 10:21:08 +0000 fs r276748 : #105482# do not require a controller, at least not in *all* circumstances (executed reports have a model, the ReportDefinition, but no Controller)
2009-10-07 10:04:08 +0000 fs r276747 : copying the changes from CWS fwk121 herein, in particular the fix for
issue #i105371#
2009-10-07 09:58:30 +0000 fs r276746 : copying the changes from CWS fwk121 herein, in particular the fix for
issue #i105371#
2009-10-07 09:48:14 +0000 fs r276744 : removed (now) pointless assertion
2009-10-07 06:59:19 +0000 fs r276740 : export the OWeakObject::disposeWeakConnectionPoint symbol
2009-10-07 06:44:43 +0000 fs r276739 : OComponentHelper::release & WeakAggComponentImplHelperBase::release:
when our ref count drops to 0, call OWeakObject's disposeWeakConnectionPoint before (temporarily) incrementing
the ref count, again. This ensures that our adapter cannot create references to the dying object anymore.
(A complex test case in dbaccess (#i105505#) triggered such a situation, but in another class using an analogous
release/dispose/destroy pattern, namely WeakComponentImplHelperBase)
2009-10-07 06:37:20 +0000 fs r276738 : found during some new complex test cases: call disposeWeakConnectionPoint before actually starting to destroy the object, this ensures no other threads will resurrect it while it is dying
2009-10-06 21:58:24 +0000 fs r276734 : oops, two small corrections to the previous fix (hey, complex test cases are cool)
2009-10-06 21:51:16 +0000 fs r276733 : log the name of the data source which cannot be revoked
2009-10-06 21:50:41 +0000 fs r276732 : more detailed error message when cleanup fails
2009-10-06 21:50:01 +0000 fs r276731 : reworked the ModelImpl caching. The new and improved UNO API test for css.sdb.RowSet
revealed some inconsistencies, in whether the objects are cached by their URL, or by their
registration name. This has been changed to caching by registration name.
2009-10-06 13:50:34 +0000 fs r276714 : print diagnostics when we cannot clean up the test case
2009-10-06 13:45:02 +0000 fs r276713 : this test failed all the time, since the core (rightfully) threw an exception. Disabled it for the moment, until issue 84253 is fixed
2009-10-06 12:52:46 +0000 fs r276711 : rewrote this test. Now we do not re-use the same .odb across different test cases, as this leads to unreliable
(timing-dependent) results/failures. Instead, every test sets up a new odb file.
Also, did some re-factoring, improved the cleanup code, and caught a few more errors.
2009-10-06 12:51:07 +0000 fs r276710 : DBTools taking a logger now
2009-10-06 12:50:42 +0000 fs r276709 : taking a PrintWriter for logging purpose
2009-10-06 12:50:03 +0000 fs r276708 : DBTools taking a logger now
2009-10-06 12:49:22 +0000 fs r276707 : typo
2009-10-06 12:49:03 +0000 fs r276706 : typo
2009-10-06 12:48:52 +0000 fs r276705 : wrappers around some database-related services - initial versions only, to evolve over time, and intended to finally replace the DBTools class
2009-10-06 12:48:02 +0000 fs r276704 : typo
2009-10-06 12:38:42 +0000 fs r276702 : some better diagnostics, done during getting the API tests to work more reliably
2009-10-06 10:35:51 +0000 fs r276698 : when living in, e.g., the DataSourceBrowser, we can't expect to find an XModifiable2, so don't assert its existence
2009-10-05 12:47:52 +0000 oj r276677 : #i105607# check for read moved into if scope
2009-10-05 11:37:06 +0000 fs r276676 : when saving a file fails, retrieve the error message from the InteractionRequestStringResolver - this is better than any generic message we can create
2009-10-05 10:04:23 +0000 oj r276673 : #i105607# check for read moved into if scope
2009-10-05 09:46:17 +0000 fs r276671 : #i10000#
2009-10-05 08:43:58 +0000 fs r276664 : #i105505#
release: dispose the (base classes) weak connection point before disposing ourself,
and in particular before temporarily incrementing our ref count, again.
This way, we prevent that a separate thread re-surrects us (using the weak connection
point's queryAdapted) while we're in the process of destruction
2009-10-05 08:41:49 +0000 fs r276663 : #i105505# +disposeWeakConnectionPoint (outsourced into dedicated method from ::release)
2009-10-05 08:40:26 +0000 fs r276662 : no need to derived from OSubComponent, its features are not used, directly derive from WeakComponentImplFoo instead
2009-10-05 08:39:38 +0000 fs r276661 : #i105505# diagnostics
2009-10-05 08:39:16 +0000 fs r276660 : #i105505# +testDocumentRevenants
2009-10-05 08:36:01 +0000 fs r276659 : #i105560# reverted the removal of GenericController::openHelpAgent - this is needed in module reportdesign
2009-10-04 19:53:30 +0000 fs r276657 : #105560#
remove unused code
thanks to cmc@openoffice.org for submitting the patch
2009-10-04 19:50:28 +0000 fs r276656 : #i105550# remove unused 'fire' method (thanks to cmc)
2009-10-03 16:13:15 +0000 fs r276655 : CWS-TOOLING: rebase CWS dba33a to trunk@276429 (milestone: DEV300:m60)
2009-10-02 19:20:48 +0000 fs r276651 : #i104117# lotta changed IDs ...
2009-10-02 10:52:24 +0000 fs r276634 : #i105505#
If a model is created, and is a revenant of a previous incarnation, then ensure it is properly initialized.
In particular, in its ctor, set the state to "Initializing", not "Initialized", and then let the ModelImpl
call attachResource. This ensures that the model is initialized completely, including firing the necessary
events.
2009-10-02 10:51:08 +0000 fs r276633 : #i105505# always do an attachResource at the newly loaded model, even if it (internally) was not really loaded, but only a revenant of a previous incarnation of this document
2009-10-01 11:10:13 +0000 fs r276597 : do not rely on the name 'Standard' for the one and only form in a document
2009-10-01 10:36:29 +0000 fs r276590 : #i105509# don't rely on default form component names, use indexes
2009-10-01 09:12:20 +0000 fs r276582 : #i105505#
2009-09-30 07:55:21 +0000 fs r276542 : removed some unsed methods / spared some unnecessary pixel<->logic conversion
2009-09-30 07:53:22 +0000 fs r276541 : removed unneeded methods
2009-09-30 06:35:59 +0000 fs r276538 : #i10000#
2009-09-29 13:45:02 +0000 fs r276531 : refactored the Roadmap* classes, to be able to fix above-mentioned #i105113#
2009-09-29 10:27:10 +0000 fs r276520 : #i105367#
2009-09-29 08:46:45 +0000 fs r276510 : #i104956# cleaned up the makefiles
2009-09-28 21:00:07 +0000 fs r276505 : #i104117# sourced those IDs out from extension.hrc
2009-09-28 20:59:05 +0000 fs r276504 : no need to let one FREE...
2009-09-28 20:53:36 +0000 fs r276503 : #i104117#
cleaned up the mess with help IDs in module extensions.
Formerly, extensions used to use help IDs which were declared in module svx, and vice versa.
Also, help ID ranges were not respected.
2009-09-28 11:25:36 +0000 fs r276489 : typo
2009-09-28 11:25:10 +0000 fs r276488 : #i105235#
2009-09-24 11:53:16 +0000 fs r276423 : #i105234# do not zoom the control when they view information is still uninitialized (happens at least in Writer when opening a form document)
2009-09-24 09:42:28 +0000 fs r276415 : #i105234# proper zoom handling for the nav bar
2009-09-24 09:42:19 +0000 fs r276414 : #i105234# setZoom: care for precision errors caused by implicit conversion float->double
2009-09-16 11:11:43 +0000 fs r276195 : #i105082#
consolidated the sub storage handling, by delegating more functionality into
the DocumentStorageAccess class. As a result, there won't be that many unnecessary
commits anymore. Also, the two different storage caches (in ModelImpl::m_aStorages
and DocumentStorageAccess::m_aExposedStorages) have been consolidated.
This is not really part of the fix of issue 105082, but it helped reducing the
calls to the storage/package implementation.
2009-09-15 21:42:27 +0000 fs r276190 : don't calculate space for BOLD if the text is not really bold (speeds up rendering for large tree structures)
2009-09-15 20:20:23 +0000 fs r276188 : getTypeInfo: fill m_aTypeInfoRows only if really all type infos could be retrieved
2009-09-15 20:19:29 +0000 fs r276187 : do not continue loading when the controller initialization throws an error
2009-09-14 12:25:57 +0000 fs r276119 : oops, this patch was not intended for this CWS
2009-09-14 12:13:57 +0000 fs r276114 : #cr6875455# introduce a ReferenceDevice property for various control models
2009-09-14 10:33:02 +0000 fs r276106 : removed dead file
2009-09-09 08:37:31 +0000 fs r275972 : remove OSL_TRACE in VCLXButton dtor
2009-09-08 11:19:17 +0000 oj r275926 : i76534# remove mnemonic from fixed text
2009-09-07 08:39:37 +0000 fs r275874 : create CWS dba33a from cws/dba32g@275857 (CWS: dba32g)
2009-11-27 12:39:32 +00:00
# endif
2008-03-06 17:14:19 +00:00
2004-11-16 13:31:01 +00:00
OGenericUnoController : : ~ OGenericUnoController ( )
{
2005-09-23 11:21:38 +00:00
2004-11-16 13:31:01 +00:00
}
2014-09-23 11:20:40 +02:00
bool OGenericUnoController : : Construct ( vcl : : 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
2011-02-03 00:33:36 +01:00
OSL_ENSURE ( getORB ( ) . is ( ) , " OGenericUnoController::Construct need a service factory! " ) ;
2001-01-09 14:43:04 +00:00
try
{
2013-01-07 17:46:55 +02:00
m_xDatabaseContext = DatabaseContext : : create ( getORB ( ) ) ;
2001-01-09 14:43:04 +00:00
}
2012-12-03 11:10:46 +02:00
catch ( const Exception & )
2001-01-09 14:43:04 +00:00
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " OGenericUnoController::Construct: could not create (or start listening at) the database context! " ) ;
2012-12-03 11:10:46 +02:00
// at least notify the user. Though the whole component does not make any sense without the database context ...
2014-01-28 20:02:35 +01:00
ShowServiceNotAvailableError ( getView ( ) , OUString ( " com.sun.star.sdb.DatabaseContext " ) , true ) ;
2001-01-09 14:43:04 +00:00
}
2014-04-01 09:53:24 +02:00
return true ;
2001-01-09 14:43:04 +00:00
}
2013-08-17 23:43:14 +02:00
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( OGenericUnoController , OnAsyncInvalidateAll )
2001-01-09 14:43:04 +00:00
{
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 ;
}
2013-08-17 23:43:14 +02:00
2006-07-10 14:23:57 +00:00
void OGenericUnoController : : impl_initialize ( )
2004-08-02 14:34:22 +00:00
{
}
2013-08-17 23:43:14 +02:00
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : initialize ( const Sequence < Any > & aArguments ) throw ( Exception , RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
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
{
2014-12-15 10:11:27 +01:00
if ( ( * pIter > > = aValue ) & & aValue . Name = = " 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
}
2014-12-15 10:11:27 +01:00
else if ( ( * pIter > > = aValue ) & & aValue . Name = = " Preview " )
2005-01-05 11:33:47 +00:00
{
aValue . Value > > = m_bPreview ;
2014-04-01 09:53:24 +02:00
m_bReadOnly = 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 ( ) )
2013-06-29 21:24:12 +02:00
throw IllegalArgumentException ( " need a frame " , * this , 1 ) ;
2008-06-06 13:08:24 +00:00
xParent = xFrame - > getContainerWindow ( ) ;
VCLXWindow * pParentComponent = VCLXWindow : : GetImplementation ( xParent ) ;
2015-03-16 17:28:03 +00:00
VclPtr < vcl : : Window > pParentWin = pParentComponent ? pParentComponent - > GetWindow ( ) : VclPtr < vcl : : Window > ( ) ;
2008-06-06 13:08:24 +00:00
if ( ! pParentWin )
2005-03-10 15:45:35 +00:00
{
2013-06-29 21:24:12 +02:00
throw IllegalArgumentException ( " 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 )
2013-06-29 21:24:12 +02:00
throw RuntimeException ( " unable to create a view " , * this ) ;
2008-06-06 13:08:24 +00:00
if ( m_bReadOnly | | m_bPreview )
2014-01-28 20:02:35 +01:00
pView - > EnableInput ( false ) ;
2006-07-10 14:23:57 +00:00
impl_initialize ( ) ;
2005-01-05 11:33:47 +00:00
}
2011-10-25 11:27:54 +03:00
catch ( Exception & )
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
m_pView = NULL ;
2010-02-09 17:26:40 +01:00
throw ;
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
}
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
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : disposing ( const EventObject & Source ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
// our frame ?
2008-03-06 17:14:19 +00:00
if ( Source . Source = = getFrame ( ) )
stopFrameListening ( getFrame ( ) ) ;
2001-01-09 14:43:04 +00:00
}
2013-08-17 23:43:14 +02:00
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : modified ( const EventObject & aEvent ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
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
2014-04-01 09:53:24 +02:00
m_bCurrentlyModified = true ;
2004-08-02 14:34:22 +00:00
}
2002-01-24 16:43:35 +00:00
InvalidateFeature ( ID_BROWSER_SAVEDOC ) ;
2001-01-09 14:43:04 +00:00
InvalidateFeature ( ID_BROWSER_UNDO ) ;
}
2013-08-17 23:43:14 +02:00
2014-02-25 21:31:58 +01:00
Reference < XWindow > SAL_CALL OGenericUnoController : : getComponentWindow ( ) throw ( RuntimeException , std : : exception )
2008-06-06 13:08:24 +00:00
{
2015-06-17 15:18:10 +02:00
SolarMutexGuard g ;
2008-06-06 13:08:24 +00:00
return VCLUnoHelper : : GetInterface ( getView ( ) ) ;
}
2015-04-30 16:56:14 +02:00
Reference < XSidebarProvider > SAL_CALL OGenericUnoController : : getSidebar ( ) throw ( RuntimeException , std : : exception )
{
return NULL ;
}
2015-08-03 09:14:58 +02:00
OUString SAL_CALL OGenericUnoController : : getViewControllerName ( ) throw ( css : : uno : : RuntimeException , std : : exception )
2008-06-06 13:08:24 +00:00
{
2013-03-05 12:57:54 +01:00
return OUString ( " Default " ) ;
2008-06-06 13:08:24 +00:00
}
2014-02-25 21:31:58 +01:00
Sequence < PropertyValue > SAL_CALL OGenericUnoController : : getCreationArguments ( ) throw ( RuntimeException , std : : exception )
2009-12-11 11:28:14 +01:00
{
// currently we do not support any creation args, so anything passed to XModel2::createViewController would be
// lost, so we can equally return an empty sequence here
return Sequence < PropertyValue > ( ) ;
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : attachFrame ( const Reference < XFrame > & _rxFrame ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
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-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-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 )
2014-04-17 11:16:55 +02:00
_out_rStates . push_back ( makeAny ( * _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 ( ) ) ;
}
}
2014-04-01 09:53:24 +02:00
void OGenericUnoController : : ImplBroadcastFeatureState ( const OUString & _rFeature , const Reference < XStatusListener > & xListener , 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
2013-03-03 17:11:39 +01:00
FeatureState & rCachedState = m_aStateCache [ nFeat ] ; // creates if necessary
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
2014-04-17 11:16:55 +02:00
bool bAlreadyCached = ( m_aStateCache . find ( nFeat ) ! = m_aStateCache . end ( ) ) ;
2006-07-10 14:23:57 +00:00
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 ) ;
2015-06-08 16:24:31 +02:00
aEvent . Source = static_cast < 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
Dispatch aNotifyLoop ( m_arrStatusListener ) ;
2013-12-05 23:42:23 +01:00
Dispatch : : iterator iterSearch = aNotifyLoop . begin ( ) ;
Dispatch : : iterator 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 ;
}
}
}
2014-04-01 09:53:24 +02:00
bool OGenericUnoController : : isFeatureSupported ( sal_Int32 _nId )
2005-03-10 15:45:35 +00:00
{
SupportedFeatures : : iterator aFeaturePos = : : std : : find_if (
m_aSupportedFeatures . begin ( ) ,
m_aSupportedFeatures . end ( ) ,
2008-10-01 12:28:29 +00:00
: : std : : bind2nd ( CompareFeatureById ( ) , _nId )
2005-03-10 15:45:35 +00:00
) ;
2011-12-19 18:10:37 -02:00
return ( m_aSupportedFeatures . end ( ) ! = aFeaturePos & & ! aFeaturePos - > first . isEmpty ( ) ) ;
2005-03-10 15:45: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
2014-04-17 11:16:55 +02:00
bool bEmpty = true ;
2008-10-01 12:28:29 +00:00
FeatureListener 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 ( ) ,
2008-10-01 12:28:29 +00:00
: : std : : bind2nd ( CompareFeatureById ( ) , 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 )
{
2013-04-07 12:06:47 +02:00
OString sMessage ( " OGenericUnoController::InvalidateFeature_Impl: feature id " ) ;
2013-08-21 15:07:31 +02:00
sMessage + = OString : : number ( aNextFeature . nId ) ;
2013-04-07 12:06:47 +02:00
sMessage + = OString ( " has been invalidated, but is not supported! " ) ;
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , sMessage . getStr ( ) ) ;
2005-07-08 09:38:35 +00:00
}
# 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
2014-04-01 09:53:24 +02:00
void OGenericUnoController : : ImplInvalidateFeature ( sal_Int32 _nId , const Reference < XStatusListener > & _xListener , bool _bForceBroadcast )
2001-01-09 14:43:04 +00:00
{
2010-11-26 09:46:54 +01:00
# if OSL_DEBUG_LEVEL > 0
if ( _nId ! = - 1 )
{
SupportedFeatures : : iterator aFeaturePos = : : std : : find_if (
m_aSupportedFeatures . begin ( ) ,
m_aSupportedFeatures . end ( ) ,
: : std : : bind2nd ( CompareFeatureById ( ) , _nId )
) ;
OSL_ENSURE ( aFeaturePos ! = m_aSupportedFeatures . end ( ) , " OGenericUnoController::ImplInvalidateFeature: invalidating an unsupported feature is suspicious, at least! " ) ;
}
# endif
2008-10-01 12:28:29 +00:00
FeatureListener aListener ;
aListener . nId = _nId ;
aListener . xListener = _xListener ;
aListener . bForceBroadcast = _bForceBroadcast ;
2001-01-09 14:43:04 +00:00
2014-04-17 11:16:55 +02:00
bool bWasEmpty ;
2001-01-09 14:43:04 +00:00
{
2008-10-01 12:28:29 +00:00
: : osl : : MutexGuard aGuard ( m_aFeatureMutex ) ;
2001-01-09 14:43:04 +00:00
bWasEmpty = m_aFeaturesToInvalidate . empty ( ) ;
2008-10-01 12:28:29 +00:00
m_aFeaturesToInvalidate . push_back ( aListener ) ;
2001-01-09 14:43:04 +00:00
}
2002-01-24 16:43:35 +00:00
if ( bWasEmpty )
2001-01-09 14:43:04 +00:00
m_aAsyncInvalidateAll . Call ( ) ;
}
2014-04-01 09:53:24 +02:00
void OGenericUnoController : : InvalidateFeature ( sal_uInt16 _nId , const Reference < XStatusListener > & _xListener , bool _bForceBroadcast )
2002-01-24 18:23:16 +00:00
{
ImplInvalidateFeature ( _nId , _xListener , _bForceBroadcast ) ;
}
2001-01-09 14:43:04 +00:00
void OGenericUnoController : : InvalidateAll ( )
{
2014-04-01 09:53:24 +02:00
ImplInvalidateFeature ( ALL_FEATURES , NULL , 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 ( )
{
2010-11-24 01:07:16 +00:00
// invalidate all supported features
2004-11-16 13:31:01 +00:00
for ( SupportedFeatures : : const_iterator aIter = m_aSupportedFeatures . begin ( ) ;
aIter ! = m_aSupportedFeatures . end ( ) ;
+ + aIter
)
2014-04-01 09:53:24 +02:00
ImplBroadcastFeatureState ( aIter - > first , NULL , true ) ;
2001-01-09 14:43:04 +00:00
{
: : osl : : MutexGuard aGuard ( m_aFeatureMutex ) ;
2011-02-03 00:33:36 +01:00
OSL_ENSURE ( 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 ( ) ;
}
}
2014-02-25 21:31:58 +01:00
Reference < XDispatch > OGenericUnoController : : queryDispatch ( const URL & aURL , const OUString & aTargetFrameName , sal_Int32 nSearchFlags ) throw ( RuntimeException , std : : exception )
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
2008-06-25 13:02:57 +00:00
OSL_PRECOND ( ! m_aSupportedFeatures . empty ( ) , " OGenericUnoController::queryDispatch: shouldn't this be filled at construction time? " ) ;
2007-07-06 07:04:34 +00:00
if ( m_aSupportedFeatures . empty ( ) )
fillSupportedFeatures ( ) ;
2008-06-25 13:02:57 +00:00
2002-01-24 16:43:35 +00:00
// URL's we can handle ourself?
2014-11-03 14:03:54 +02:00
if ( aURL . Complete = = " .uno:FormSlots/ConfirmDeletion "
2008-10-01 12:28:29 +00:00
| | ( ( m_aSupportedFeatures . find ( aURL . Complete ) ! = m_aSupportedFeatures . end ( ) )
& & ! isUserDefinedFeature ( aURL . Complete )
)
2002-01-24 16:43:35 +00:00
)
{
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
}
2014-02-25 21:31:58 +01:00
Sequence < Reference < XDispatch > > OGenericUnoController : : queryDispatches ( const Sequence < DispatchDescriptor > & aDescripts ) throw ( RuntimeException , std : : exception )
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 ;
}
2015-04-14 12:44:47 +02:00
Reference < XDispatchProvider > OGenericUnoController : : getSlaveDispatchProvider ( ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
return m_xSlaveDispatcher ;
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : setSlaveDispatchProvider ( const Reference < XDispatchProvider > & _xNewProvider ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
m_xSlaveDispatcher = _xNewProvider ;
}
2015-04-14 12:44:47 +02:00
Reference < XDispatchProvider > OGenericUnoController : : getMasterDispatchProvider ( ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
return m_xMasterDispatcher ;
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : setMasterDispatchProvider ( const Reference < XDispatchProvider > & _xNewProvider ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
m_xMasterDispatcher = _xNewProvider ;
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : dispatch ( const URL & _aURL , const Sequence < PropertyValue > & aArgs ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2011-02-07 20:20:28 +01:00
// The SolarMutex is not locked anymore when the framework calls into
2005-09-23 11:21:38 +00:00
// 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.
2011-02-27 22:55:22 +01:00
// #i52602#
2006-10-18 12:30:13 +00:00
executeChecked ( _aURL , aArgs ) ;
2001-01-09 14:43:04 +00:00
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : addStatusListener ( const Reference < XStatusListener > & aListener , const URL & _rURL ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2014-04-10 10:28:38 +02:00
// parse the URL now and here, this saves later parsing in each notification round
2006-07-10 14:23:57 +00:00
URL aParsedURL ( _rURL ) ;
if ( m_xUrlTransformer . is ( ) )
m_xUrlTransformer - > parseStrict ( aParsedURL ) ;
2010-11-24 01:07:16 +00:00
// remember 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
2014-04-01 09:53:24 +02:00
ImplBroadcastFeatureState ( aParsedURL . Complete , aListener , true ) ;
2010-11-24 01:07:16 +00:00
// force the new state to be broadcast to the new listener
2001-01-09 14:43:04 +00:00
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : removeStatusListener ( const Reference < XStatusListener > & aListener , const URL & _rURL ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2013-12-05 23:42:23 +01:00
Dispatch : : iterator iterSearch = m_arrStatusListener . begin ( ) ;
2001-01-09 14:43:04 +00:00
2014-04-17 11:16:55 +02:00
bool bRemoveForAll = _rURL . Complete . isEmpty ( ) ;
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
)
)
{
2013-03-01 06:11:09 +01: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 ;
}
2008-06-25 13:02:57 +00:00
OSL_PRECOND ( ! m_aSupportedFeatures . empty ( ) , " OGenericUnoController::removeStatusListener: shouldn't this be filled at construction time? " ) ;
2007-07-06 07:04:34 +00:00
if ( m_aSupportedFeatures . empty ( ) )
fillSupportedFeatures ( ) ;
2008-06-25 13:02:57 +00:00
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
2013-12-06 10:17:37 +01:00
StateCache : : iterator aCachePos = m_aStateCache . find ( aIter - > second . nFeatureId ) ;
2004-11-16 13:31:01 +00:00
if ( aCachePos ! = m_aStateCache . end ( ) )
m_aStateCache . erase ( aCachePos ) ;
2001-01-09 14:43:04 +00:00
}
// now remove the listener from the deque
2008-10-01 12:28:29 +00:00
: : 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 ( ) ,
2008-10-01 12:28:29 +00:00
: : std : : bind2nd ( FindFeatureListener ( ) , aListener ) )
2001-08-27 05:57:24 +00:00
, m_aFeaturesToInvalidate . end ( ) ) ;
2001-01-09 14:43:04 +00:00
}
2013-08-17 23:43:14 +02:00
2008-10-01 12:28:29 +00:00
void OGenericUnoController : : releaseNumberForComponent ( )
{
try
{
Reference < XUntitledNumbers > xUntitledProvider ( getPrivateModel ( ) , UNO_QUERY ) ;
if ( xUntitledProvider . is ( ) )
xUntitledProvider - > releaseNumberForComponent ( static_cast < XWeak * > ( this ) ) ;
}
catch ( const Exception & )
{
// NII
}
}
2013-08-17 23:43:14 +02: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 ( ) ;
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-10-01 12:28:29 +00:00
releaseNumberForComponent ( ) ;
2008-04-04 13:56:57 +00:00
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 ;
2011-03-10 10:59:14 +01:00
m_xTitleHelper . clear ( ) ;
m_xUrlTransformer . clear ( ) ;
m_aInitParameters . clear ( ) ;
2001-01-09 14:43:04 +00:00
}
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : addEventListener ( const Reference < XEventListener > & xListener ) throw ( RuntimeException , std : : exception )
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
}
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : removeEventListener ( const Reference < XEventListener > & xListener ) throw ( RuntimeException , std : : exception )
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
}
2014-02-25 21:31:58 +01:00
void OGenericUnoController : : frameAction ( const FrameActionEvent & aEvent ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
2008-03-06 17:14:19 +00:00
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
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
2011-02-03 00:33:36 +01:00
OSL_ENSURE ( m_bDescribingSupportedFeatures , " OGenericUnoController::implDescribeSupportedFeature: bad timing for this call! " ) ;
2004-11-16 13:31:01 +00:00
# endif
2008-06-25 13:02:57 +00:00
OSL_PRECOND ( _nFeatureId < FIRST_USER_DEFINED_FEATURE , " OGenericUnoController::implDescribeSupportedFeature: invalid feature id! " ) ;
2004-11-16 13:31:01 +00:00
ControllerFeature aFeature ;
2013-03-05 12:57:54 +01:00
aFeature . Command = OUString : : createFromAscii ( _pAsciiCommandURL ) ;
2004-11-16 13:31:01 +00:00
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
}
2008-10-01 12:28:29 +00:00
FeatureState OGenericUnoController : : GetState ( sal_uInt16 _nId ) const
2001-01-09 14:43:04 +00:00
{
FeatureState aReturn ;
// (disabled automatically)
2008-10-01 12:28:29 +00:00
switch ( _nId )
2001-01-09 14:43:04 +00:00
{
2008-10-01 12:28:29 +00:00
case ID_BROWSER_UNDO :
case ID_BROWSER_SAVEDOC :
2014-04-01 09:53:24 +02:00
aReturn . bEnabled = true ;
2008-10-01 12:28:29 +00:00
break ;
default :
2015-04-24 15:29:31 +02:00
aReturn = UserDefinedFeatures : : getState ( getURLForId ( _nId ) ) ;
2008-10-01 12:28:29 +00:00
break ;
2001-01-09 14:43:04 +00:00
}
return aReturn ;
}
2008-06-25 13:02:57 +00:00
void OGenericUnoController : : Execute ( sal_uInt16 _nId , const Sequence < PropertyValue > & _rArgs )
{
OSL_ENSURE ( isUserDefinedFeature ( _nId ) ,
" OGenericUnoController::Execute: responsible for user defined features only! " ) ;
2008-10-01 12:28:29 +00:00
// user defined features can be handled by dispatch interceptors resp. protocol handlers only.
// So, we need to do a queryDispatch, and dispatch the URL
m_pData - > m_aUserDefinedFeatures . execute ( getURLForId ( _nId ) , _rArgs ) ;
2008-06-25 13:02:57 +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 ( ) ,
2008-10-01 12:28:29 +00:00
: : std : : bind2nd ( CompareFeatureById ( ) , _nId )
2002-01-24 16:43:35 +00:00
) ;
2011-12-19 18:10:37 -02:00
if ( m_aSupportedFeatures . end ( ) ! = aIter & & ! aIter - > first . isEmpty ( ) )
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
2015-04-24 15:29:31 +02:00
bool OGenericUnoController : : isUserDefinedFeature ( const sal_uInt16 _nFeatureId )
2008-06-25 13:02:57 +00:00
{
return ( _nFeatureId > = FIRST_USER_DEFINED_FEATURE ) & & ( _nFeatureId < LAST_USER_DEFINED_FEATURE ) ;
}
2013-03-05 12:57:54 +01:00
bool OGenericUnoController : : isUserDefinedFeature ( const OUString & _rFeatureURL ) const
2008-10-01 12:28:29 +00:00
{
SupportedFeatures : : const_iterator pos = m_aSupportedFeatures . find ( _rFeatureURL ) ;
OSL_PRECOND ( pos ! = m_aSupportedFeatures . end ( ) ,
" OGenericUnoController::isUserDefinedFeature: this is no supported feature at all! " ) ;
2014-05-02 15:42:25 +02:00
return ( pos ! = m_aSupportedFeatures . end ( ) ) & & isUserDefinedFeature ( pos - > second . nFeatureId ) ;
2008-10-01 12:28:29 +00:00
}
2014-02-25 21:31:58 +01:00
sal_Bool SAL_CALL OGenericUnoController : : supportsService ( const OUString & ServiceName ) throw ( RuntimeException , std : : exception )
2001-01-09 14:43:04 +00:00
{
2013-10-16 19:25:05 -03:00
return cppu : : supportsService ( this , ServiceName ) ;
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
}
2013-08-17 23:43:14 +02:00
2008-12-01 12:31:27 +00:00
Reference < XConnection > OGenericUnoController : : connect ( const Reference < XDataSource > & _xDataSource ,
: : dbtools : : SQLExceptionInfo * _pErrorInfo )
2004-08-02 14:34:22 +00:00
{
2008-12-01 12:31:27 +00:00
WaitObject aWaitCursor ( getView ( ) ) ;
2004-08-02 14:34:22 +00:00
2013-03-05 12:57:54 +01:00
ODatasourceConnector aConnector ( getORB ( ) , getView ( ) , OUString ( ) ) ;
2008-12-01 12:31:27 +00:00
Reference < XConnection > xConnection = aConnector . connect ( _xDataSource , _pErrorInfo ) ;
startConnectionListening ( xConnection ) ;
2004-08-02 14:34:22 +00:00
return xConnection ;
}
2013-08-17 23:43:14 +02:00
2013-03-05 12:57:54 +01:00
Reference < XConnection > OGenericUnoController : : connect ( const OUString & _rDataSourceName ,
const OUString & _rContextInformation , : : dbtools : : SQLExceptionInfo * _pErrorInfo )
2001-05-10 11:25:36 +00:00
{
2008-12-01 12:31:27 +00:00
WaitObject aWaitCursor ( getView ( ) ) ;
2001-01-09 14:43:04 +00:00
2013-01-07 17:46:55 +02:00
ODatasourceConnector aConnector ( getORB ( ) , getView ( ) , _rContextInformation ) ;
2008-12-01 12:31:27 +00:00
Reference < XConnection > xConnection = aConnector . connect ( _rDataSourceName , _pErrorInfo ) ;
startConnectionListening ( xConnection ) ;
2001-01-15 08:37:29 +00:00
return xConnection ;
}
2001-05-10 11:25:36 +00:00
2015-04-20 14:00:04 +01:00
void OGenericUnoController : : setView ( const VclPtr < ODataView > & i_rView )
2015-03-09 14:29:30 +02:00
{
2015-04-20 14:00:04 +01:00
m_pView = i_rView ;
2015-03-09 14:29:30 +02:00
}
void OGenericUnoController : : clearView ( )
{
m_pView = NULL ;
}
2001-01-15 08:37:29 +00:00
void OGenericUnoController : : showError ( const SQLExceptionInfo & _rInfo )
{
2013-01-07 17:46:55 +02:00
: : dbaui : : showError ( _rInfo , getView ( ) , getORB ( ) ) ;
2001-01-09 14:43:04 +00:00
}
2013-08-17 23:43:14 +02:00
2015-04-24 15:29:31 +02:00
Reference < XLayoutManager > OGenericUnoController : : getLayoutManager ( const Reference < XFrame > & _xFrame )
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
{
2013-06-29 21:24:12 +02:00
xLayoutManager . set ( xPropSet - > getPropertyValue ( " LayoutManager " ) , UNO_QUERY ) ;
2004-02-25 14:32:25 +00:00
}
catch ( Exception & )
{
}
}
2004-09-09 08:41:47 +00:00
return xLayoutManager ;
}
2013-08-17 23:43:14 +02:00
2004-09-09 08:41:47 +00:00
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 ( ) ;
2013-03-05 12:57:54 +01:00
xLayoutManager - > createElement ( OUString ( " private:resource/menubar/menubar " ) ) ;
xLayoutManager - > createElement ( OUString ( " private:resource/toolbar/toolbar " ) ) ;
2004-09-09 08:41:47 +00:00
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
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 ( ) ;
}
2013-08-17 23:43:14 +02:00
2012-03-01 18:00:32 +01:00
IMPL_LINK_NOARG ( OGenericUnoController , OnAsyncCloseTask )
2001-09-19 12:20:12 +00:00
{
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
}
2013-08-17 23:43:14 +02:00
2015-04-14 12:44:47 +02:00
Any SAL_CALL OGenericUnoController : : getViewData ( ) throw ( RuntimeException , std : : exception )
2001-10-18 05:50:04 +00:00
{
return Any ( ) ;
}
2013-08-17 23:43:14 +02:00
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : restoreViewData ( const Any & /*Data*/ ) throw ( RuntimeException , std : : exception )
2001-10-18 05:50:04 +00:00
{
}
2008-03-06 17:14:19 +00:00
2015-04-14 12:44:47 +02:00
Reference < XModel > SAL_CALL OGenericUnoController : : getModel ( ) throw ( RuntimeException , std : : exception )
2008-03-06 17:14:19 +00:00
{
return Reference < XModel > ( ) ;
}
2015-04-14 12:44:47 +02:00
Reference < XFrame > SAL_CALL OGenericUnoController : : getFrame ( ) throw ( RuntimeException , std : : exception )
2008-03-06 17:14:19 +00:00
{
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
2008-03-06 17:14:19 +00:00
return m_aCurrentFrame . getFrame ( ) ;
}
2014-02-25 21:31:58 +01:00
sal_Bool SAL_CALL OGenericUnoController : : attachModel ( const Reference < XModel > & /*xModel*/ ) throw ( RuntimeException , std : : exception )
2001-10-18 05:50:04 +00:00
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " OGenericUnoController::attachModel: not supported! " ) ;
2001-10-18 05:50:04 +00:00
return sal_False ;
}
2008-03-06 17:14:19 +00:00
2007-07-06 07:04:34 +00:00
void OGenericUnoController : : executeUnChecked ( sal_uInt16 _nCommandId , const Sequence < PropertyValue > & aArgs )
{
Execute ( _nCommandId , aArgs ) ;
}
2013-08-17 23:43:14 +02:00
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
{
2008-06-25 13:02:57 +00:00
OSL_PRECOND ( ! m_aSupportedFeatures . empty ( ) , " OGenericUnoController::executeUnChecked: shouldn't this be filled at construction time? " ) ;
2007-07-06 07:04:34 +00:00
if ( m_aSupportedFeatures . empty ( ) )
fillSupportedFeatures ( ) ;
2008-06-25 13:02:57 +00:00
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
}
2013-08-17 23:43:14 +02: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
{
2008-06-25 13:02:57 +00:00
OSL_PRECOND ( ! m_aSupportedFeatures . empty ( ) , " OGenericUnoController::executeChecked: shouldn't this be filled at construction time? " ) ;
2007-07-06 07:04:34 +00:00
if ( m_aSupportedFeatures . empty ( ) )
fillSupportedFeatures ( ) ;
2008-06-25 13:02:57 +00:00
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
}
}
2013-08-17 23:43:14 +02:00
2002-08-26 06:52:15 +00:00
namespace
{
2013-03-05 12:57:54 +01:00
OUString lcl_getModuleHelpModuleName ( const Reference < XFrame > & _rxFrame )
2002-08-26 06:52:15 +00:00
{
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 ( ) )
2014-06-13 17:49:30 +02:00
xParentFrame . set ( _rxFrame - > getCreator ( ) , css : : uno : : UNO_QUERY ) ;
2002-08-26 06:52:15 +00:00
// 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
2013-03-05 12:57:54 +01:00
Sequence < OUString > sServiceNames = xSI - > getSupportedServiceNames ( ) ;
const OUString * pLoop = sServiceNames . getConstArray ( ) ;
2002-08-26 06:52:15 +00:00
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 "
} ;
2012-05-31 12:36:21 +01:00
OSL_ENSURE ( ( sizeof ( pTransTable ) / sizeof ( pTransTable [ 0 ] ) ) % 2 = = 0 ,
2002-08-26 06:52:15 +00:00
" lcl_getModuleHelpModuleName: odd size of translation table! " ) ;
// loop through the table
2012-05-31 12:36:21 +01:00
sal_Int32 nTableEntries = ( sizeof ( pTransTable ) / sizeof ( pTransTable [ 0 ] ) ) / 2 ;
2002-08-26 06:52:15 +00:00
const sal_Char * * pDocumentService = pTransTable ;
const sal_Char * * pHelpModuleName = pTransTable + 1 ;
for ( sal_Int32 j = 0 ; j < nTableEntries ; + + j )
{
2013-03-05 12:57:54 +01:00
if ( xSI - > supportsService ( OUString : : createFromAscii ( * pDocumentService ) ) )
2002-08-26 06:52:15 +00:00
{ // 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 ;
2015-04-07 10:59:56 +02:00
if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : WRITER ) )
2002-08-26 06:52:15 +00:00
pReturn = " swriter " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : DATABASE ) )
2004-08-02 14:34:22 +00:00
pReturn = " sdatabase " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : CALC ) )
2002-08-26 06:52:15 +00:00
pReturn = " scalc " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : IMPRESS ) )
2002-08-26 06:52:15 +00:00
pReturn = " simpress " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : DRAW ) )
2002-08-26 06:52:15 +00:00
pReturn = " sdraw " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : MATH ) )
2002-08-26 06:52:15 +00:00
pReturn = " smath " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : CHART ) )
2002-08-26 06:52:15 +00:00
pReturn = " schart " ;
2015-04-07 10:59:56 +02:00
else if ( aModOpt . IsModuleInstalled ( SvtModuleOptions : : EModule : : BASIC ) )
2002-08-26 06:52:15 +00:00
pReturn = " sbasic " ;
else
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " lcl_getModuleHelpModuleName: no installed module found " ) ;
2002-08-26 06:52:15 +00:00
}
}
}
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 " ;
2013-03-05 12:57:54 +01:00
return OUString : : createFromAscii ( pReturn ) ;
2002-08-26 06:52:15 +00:00
}
}
2013-03-05 12:57:54 +01:00
void OGenericUnoController : : openHelpAgent ( OUString const & _suHelpStringURL )
2007-08-02 13:26:28 +00:00
{
2013-03-05 12:57:54 +01:00
OUString suURL ( _suHelpStringURL ) ;
OUString sLanguage ( " Language= " ) ;
2007-08-02 13:26:28 +00:00
if ( suURL . indexOf ( sLanguage ) = = - 1 )
{
2014-04-17 11:16:55 +02:00
AppendConfigToken ( suURL , false /* sal_False := add '&' */ ) ;
2007-08-02 13:26:28 +00:00
}
URL aURL ;
aURL . Complete = suURL ;
2008-03-06 17:14:19 +00:00
openHelpAgent ( aURL ) ;
2007-08-02 13:26:28 +00:00
}
2013-04-07 12:06:47 +02:00
void OGenericUnoController : : openHelpAgent ( const OString & _sHelpId )
2008-03-06 17:14:19 +00:00
{
2010-07-10 18:21:24 +02:00
openHelpAgent ( createHelpAgentURL ( lcl_getModuleHelpModuleName ( getFrame ( ) ) , _sHelpId ) ) ;
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 ( ) )
2013-03-05 12:57:54 +01:00
xHelpDispatch = xDispProv - > queryDispatch ( aURL , OUString ( " _helpagent " ) , FrameSearchFlag : : PARENT | FrameSearchFlag : : SELF ) ;
2002-08-26 06:52:15 +00:00
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
}
}
2013-08-17 23:43:14 +02:00
2008-04-04 13:56:57 +00:00
Reference < awt : : XWindow > OGenericUnoController : : getTopMostContainerWindow ( ) const
2003-03-19 16:57:12 +00:00
{
2015-08-03 09:14:58 +02:00
Reference < css : : 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 ;
}
2013-08-17 23:43:14 +02:00
2008-04-04 13:56:57 +00:00
Reference < XTitle > OGenericUnoController : : impl_getTitleHelper_throw ( )
2004-08-02 14:34:22 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
2008-04-04 13:56:57 +00:00
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 ) ;
2013-01-07 17:46:55 +02:00
: : framework : : TitleHelper * pHelper = new : : framework : : TitleHelper ( m_xContext ) ;
2008-04-04 13:56:57 +00:00
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
2013-03-05 12:57:54 +01:00
OUString SAL_CALL OGenericUnoController : : getTitle ( )
2014-02-25 21:31:58 +01:00
throw ( RuntimeException , std : : exception )
2008-04-04 13:56:57 +00:00
{
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
2008-04-04 13:56:57 +00:00
if ( m_bExternalTitle )
return impl_getTitleHelper_throw ( ) - > getTitle ( ) ;
return getPrivateTitle ( ) + impl_getTitleHelper_throw ( ) - > getTitle ( ) ;
}
// XTitle
2013-03-05 12:57:54 +01:00
void SAL_CALL OGenericUnoController : : setTitle ( const OUString & sTitle )
2014-02-25 21:31:58 +01:00
throw ( RuntimeException , std : : exception )
2008-04-04 13:56:57 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2008-12-01 12:31:27 +00:00
: : osl : : MutexGuard aGuard ( getMutex ( ) ) ;
2014-04-01 09:53:24 +02:00
m_bExternalTitle = true ;
2008-04-04 13:56:57 +00:00
impl_getTitleHelper_throw ( ) - > setTitle ( sTitle ) ;
}
// XTitleChangeBroadcaster
void SAL_CALL OGenericUnoController : : addTitleChangeListener ( const Reference < XTitleChangeListener > & xListener )
2014-02-25 21:31:58 +01:00
throw ( RuntimeException , std : : exception )
2008-04-04 13:56:57 +00:00
{
Reference < XTitleChangeBroadcaster > xBroadcaster ( impl_getTitleHelper_throw ( ) , UNO_QUERY ) ;
if ( xBroadcaster . is ( ) )
xBroadcaster - > addTitleChangeListener ( xListener ) ;
}
void SAL_CALL OGenericUnoController : : removeTitleChangeListener ( const Reference < XTitleChangeListener > & xListener )
2014-02-25 21:31:58 +01:00
throw ( RuntimeException , std : : exception )
2008-04-04 13:56:57 +00:00
{
Reference < XTitleChangeBroadcaster > xBroadcaster ( impl_getTitleHelper_throw ( ) , UNO_QUERY ) ;
if ( xBroadcaster . is ( ) )
xBroadcaster - > removeTitleChangeListener ( xListener ) ;
2004-08-02 14:34:22 +00:00
}
2008-06-25 13:02:57 +00:00
// XUserInputInterception
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : addKeyHandler ( const Reference < XKeyHandler > & _rxHandler ) throw ( RuntimeException , std : : exception )
2008-06-25 13:02:57 +00:00
{
if ( _rxHandler . is ( ) )
m_pData - > m_aUserInputInterception . addKeyHandler ( _rxHandler ) ;
}
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : removeKeyHandler ( const Reference < XKeyHandler > & _rxHandler ) throw ( RuntimeException , std : : exception )
2008-06-25 13:02:57 +00:00
{
m_pData - > m_aUserInputInterception . removeKeyHandler ( _rxHandler ) ;
}
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : addMouseClickHandler ( const Reference < XMouseClickHandler > & _rxHandler ) throw ( RuntimeException , std : : exception )
2008-06-25 13:02:57 +00:00
{
if ( _rxHandler . is ( ) )
m_pData - > m_aUserInputInterception . addMouseClickHandler ( _rxHandler ) ;
}
2014-02-25 21:31:58 +01:00
void SAL_CALL OGenericUnoController : : removeMouseClickHandler ( const Reference < XMouseClickHandler > & _rxHandler ) throw ( RuntimeException , std : : exception )
2008-06-25 13:02:57 +00:00
{
m_pData - > m_aUserInputInterception . removeMouseClickHandler ( _rxHandler ) ;
}
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
2014-04-01 09:53:24 +02:00
bool OGenericUnoController : : isCommandEnabled ( sal_uInt16 _nCommandId ) const
2004-08-02 14:34:22 +00:00
{
return GetState ( _nCommandId ) . bEnabled ;
}
2008-03-06 17:14:19 +00:00
2013-03-05 12:57:54 +01:00
sal_uInt16 OGenericUnoController : : registerCommandURL ( const OUString & _rCompleteCommandURL )
2008-06-25 13:02:57 +00:00
{
2011-12-19 18:10:37 -02:00
if ( _rCompleteCommandURL . isEmpty ( ) )
2008-06-25 13:02:57 +00:00
return 0 ;
SupportedFeatures : : const_iterator aIter = m_aSupportedFeatures . find ( _rCompleteCommandURL ) ;
if ( aIter ! = m_aSupportedFeatures . end ( ) )
return aIter - > second . nFeatureId ;
// this is a previously unkwnon command
sal_uInt16 nFeatureId = FIRST_USER_DEFINED_FEATURE ;
while ( isFeatureSupported ( nFeatureId ) & & ( nFeatureId < LAST_USER_DEFINED_FEATURE ) )
+ + nFeatureId ;
if ( nFeatureId = = LAST_USER_DEFINED_FEATURE )
{
2013-06-29 17:38:04 +03:00
SAL_WARN ( " dbaccess.ui " , " OGenericUnoController::registerCommandURL: no more space for user defined features! " ) ;
2008-06-25 13:02:57 +00:00
return 0L ;
}
ControllerFeature aFeature ;
aFeature . Command = _rCompleteCommandURL ;
aFeature . nFeatureId = nFeatureId ;
aFeature . GroupId = CommandGroup : : INTERNAL ;
m_aSupportedFeatures [ aFeature . Command ] = aFeature ;
return nFeatureId ;
}
void OGenericUnoController : : notifyHiContrastChanged ( )
{
}
2014-04-01 09:53:24 +02:00
bool OGenericUnoController : : isDataSourceReadOnly ( ) const
2008-03-06 17:14:19 +00:00
{
2014-04-01 09:53:24 +02:00
return false ;
2008-03-06 17:14:19 +00:00
}
2008-06-25 13:02:57 +00:00
Reference < XController > OGenericUnoController : : getXController ( ) throw ( RuntimeException )
2008-03-06 17:14:19 +00:00
{
return this ;
}
2008-06-25 13:02:57 +00:00
bool OGenericUnoController : : interceptUserInput ( const NotifyEvent & _rEvent )
{
return m_pData - > m_aUserInputInterception . handleNotifyEvent ( _rEvent ) ;
}
2014-04-01 09:53:24 +02:00
bool OGenericUnoController : : isCommandChecked ( sal_uInt16 _nCommandId ) const
2007-07-06 07:04:34 +00:00
{
FeatureState aState = GetState ( _nCommandId ) ;
2004-11-16 13:31:01 +00:00
2014-04-01 09:53:24 +02:00
return aState . bChecked & & * aState . bChecked ;
2007-07-06 07:04:34 +00:00
}
2013-08-17 23:43:14 +02:00
2014-04-01 09:53:24 +02:00
bool OGenericUnoController : : isCommandEnabled ( const OUString & _rCompleteCommandURL ) const
2004-09-09 08:41:47 +00:00
{
2011-12-19 18:10:37 -02:00
OSL_ENSURE ( ! _rCompleteCommandURL . isEmpty ( ) , " OGenericUnoController::isCommandEnabled: Empty command url! " ) ;
2007-07-06 07:04:34 +00:00
2014-04-01 09:53:24 +02:00
bool bIsEnabled = 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
2014-02-25 21:31:58 +01:00
Sequence < : : sal_Int16 > SAL_CALL OGenericUnoController : : getSupportedCommandGroups ( ) throw ( RuntimeException , std : : exception )
2004-11-16 13:31:01 +00:00
{
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 ( ) ,
2015-08-11 14:51:35 -04:00
: : o3tl : : select1st < CommandHashMap : : value_type > ( )
2004-11-16 13:31:01 +00:00
) ;
return aCommandGroups ;
}
2010-11-23 15:43:42 +00:00
namespace
{
//Current c++0x draft (apparently) has std::identity, but not operator()
template < typename T > struct SGI_identity : public std : : unary_function < T , T >
{
T & operator ( ) ( T & x ) const { return x ; }
const T & operator ( ) ( const T & x ) const { return x ; }
} ;
}
2014-02-25 21:31:58 +01:00
Sequence < DispatchInformation > SAL_CALL OGenericUnoController : : getConfigurableDispatchInformation ( : : sal_Int16 CommandGroup ) throw ( RuntimeException , std : : exception )
2004-11-16 13:31:01 +00:00
{
2015-08-03 15:12:45 +02:00
: : std : : list < DispatchInformation > aInformationList ;
2004-11-16 13:31:01 +00:00
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 ( ) ,
2010-11-23 15:43:42 +00:00
SGI_identity < DispatchInformation > ( )
2004-11-16 13:31:01 +00:00
) ;
return aInformation ;
}
2013-08-17 23:43:14 +02:00
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
}
2015-08-03 09:14:58 +02:00
void SAL_CALL OGenericUnoController : : dispose ( ) throw ( css : : uno : : RuntimeException , std : : exception )
2008-06-25 13:52:19 +00:00
{
2010-10-13 01:38:41 -05:00
SolarMutexGuard aSolarGuard ;
2008-06-25 13:52:19 +00:00
OGenericUnoController_Base : : dispose ( ) ;
}
2013-08-17 23:43:14 +02:00
2008-06-26 10:43:10 +00:00
} // namespace dbaui
2010-10-12 15:59:03 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */