summaryrefslogtreecommitdiff
path: root/forms/source/helper
diff options
context:
space:
mode:
Diffstat (limited to 'forms/source/helper')
-rw-r--r--forms/source/helper/commanddescriptionprovider.cxx143
-rw-r--r--forms/source/helper/commandimageprovider.cxx183
-rw-r--r--forms/source/helper/controlfeatureinterception.cxx172
-rw-r--r--forms/source/helper/formnavigation.cxx487
-rw-r--r--forms/source/helper/resettable.cxx105
-rw-r--r--forms/source/helper/urltransformer.cxx105
-rw-r--r--forms/source/helper/windowstateguard.cxx234
7 files changed, 0 insertions, 1429 deletions
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
deleted file mode 100644
index e61810f60..000000000
--- a/forms/source/helper/commanddescriptionprovider.cxx
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
-************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-
-#include "commanddescriptionprovider.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-/** === end UNO includes === **/
-
-#include <comphelper/namedvaluecollection.hxx>
-#include <tools/diagnose_ex.h>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- /** === begin UNO using === **/
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::uno::XInterface;
- using ::com::sun::star::uno::UNO_QUERY;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
- using ::com::sun::star::uno::UNO_SET_THROW;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::Any;
- using ::com::sun::star::uno::makeAny;
- using ::com::sun::star::uno::Sequence;
- using ::com::sun::star::uno::Type;
- using ::com::sun::star::frame::XModel;
- using ::com::sun::star::container::XNameAccess;
- using ::com::sun::star::frame::XModuleManager;
- using ::com::sun::star::beans::PropertyValue;
- /** === end UNO using === **/
-
- //====================================================================
- //= DefaultCommandDescriptionProvider
- //====================================================================
- class DefaultCommandDescriptionProvider : public ICommandDescriptionProvider
- {
- public:
- DefaultCommandDescriptionProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- impl_init_nothrow( _rContext, _rxDocument );
- }
-
- ~DefaultCommandDescriptionProvider()
- {
- }
-
- // ICommandDescriptionProvider
- virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const;
-
- private:
- void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument );
-
- private:
- Reference< XNameAccess > m_xCommandAccess;
- };
-
-
- //--------------------------------------------------------------------
- void DefaultCommandDescriptionProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- OSL_ENSURE( _rxDocument.is(), "DefaultCommandDescriptionProvider::impl_init_nothrow: no document => no command descriptions!" );
- if ( !_rxDocument.is() )
- return;
-
- try
- {
- Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
- ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
-
- Reference< XNameAccess > xUICommandDescriptions( _rContext.createComponent( "com.sun.star.frame.UICommandDescription" ), UNO_QUERY_THROW );
- m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-
- //--------------------------------------------------------------------
- ::rtl::OUString DefaultCommandDescriptionProvider::getCommandDescription( const ::rtl::OUString& _rCommandURL ) const
- {
- if ( !m_xCommandAccess.is() )
- return ::rtl::OUString();
-
- try
- {
- ::comphelper::NamedValueCollection aCommandProperties( m_xCommandAccess->getByName( _rCommandURL ) );
- return aCommandProperties.getOrDefault( "Name", ::rtl::OUString() );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-
- return ::rtl::OUString();
- }
-
- //--------------------------------------------------------------------
- PCommandDescriptionProvider createDocumentCommandDescriptionProvider(
- const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rContext, _rxDocument ) );
- return pDescriptionProvider;
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx
deleted file mode 100644
index 6b3599678..000000000
--- a/forms/source/helper/commandimageprovider.cxx
+++ /dev/null
@@ -1,183 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
-************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-
-#include "commandimageprovider.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/ui/XImageManager.hpp>
-#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
-#include <com/sun/star/ui/ImageType.hpp>
-/** === end UNO includes === **/
-
-#include <tools/diagnose_ex.h>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- /** === begin UNO using === **/
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::uno::XInterface;
- using ::com::sun::star::uno::UNO_QUERY;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
- using ::com::sun::star::uno::UNO_SET_THROW;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::Any;
- using ::com::sun::star::uno::makeAny;
- using ::com::sun::star::uno::Sequence;
- using ::com::sun::star::uno::Type;
- using ::com::sun::star::frame::XModel;
- using ::com::sun::star::ui::XImageManager;
- using ::com::sun::star::ui::XUIConfigurationManagerSupplier;
- using ::com::sun::star::ui::XUIConfigurationManager;
- using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
- using ::com::sun::star::frame::XModuleManager;
- using ::com::sun::star::graphic::XGraphic;
- /** === end UNO using === **/
- namespace ImageType = ::com::sun::star::ui::ImageType;
-
- //====================================================================
- //= DocumentCommandImageProvider
- //====================================================================
- class DocumentCommandImageProvider : public ICommandImageProvider
- {
- public:
- DocumentCommandImageProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- impl_init_nothrow( _rContext, _rxDocument );
- }
- virtual ~DocumentCommandImageProvider()
- {
- }
-
- // ICommandImageProvider
- virtual CommandImages getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge ) const;
-
- private:
- void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument );
-
- private:
- Reference< XImageManager > m_xDocumentImageManager;
- Reference< XImageManager > m_xModuleImageManager;
- };
-
- //--------------------------------------------------------------------
- void DocumentCommandImageProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- OSL_ENSURE( _rxDocument.is(), "DocumentCommandImageProvider::impl_init_nothrow: no document => no images!" );
- if ( !_rxDocument.is() )
- return;
-
- // obtain the image manager of the document
- try
- {
- Reference< XUIConfigurationManagerSupplier > xSuppUIConfig( _rxDocument, UNO_QUERY_THROW );
- Reference< XUIConfigurationManager > xUIConfig( xSuppUIConfig->getUIConfigurationManager(), UNO_QUERY );
- m_xDocumentImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-
- // obtain the image manager or the module
- try
- {
- Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
- ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
-
- Reference< XModuleUIConfigurationManagerSupplier > xSuppUIConfig(
- _rContext.createComponent( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ), UNO_QUERY_THROW );
- Reference< XUIConfigurationManager > xUIConfig(
- xSuppUIConfig->getUIConfigurationManager( sModuleID ), UNO_SET_THROW );
- m_xModuleImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-
- //--------------------------------------------------------------------
- CommandImages DocumentCommandImageProvider::getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge ) const
- {
- const size_t nCommandCount = _rCommandURLs.getLength();
- CommandImages aImages( nCommandCount );
- try
- {
- const sal_Int16 nImageType = ImageType::COLOR_NORMAL
- + ( _bLarge ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT );
-
- Sequence< Reference< XGraphic > > aDocImages( nCommandCount );
- Sequence< Reference< XGraphic > > aModImages( nCommandCount );
-
- // first try the document image manager
- if ( m_xDocumentImageManager.is() )
- aDocImages = m_xDocumentImageManager->getImages( nImageType, _rCommandURLs );
-
- // then the module's image manager
- if ( m_xModuleImageManager.is() )
- aModImages = m_xModuleImageManager->getImages( nImageType, _rCommandURLs );
-
- ENSURE_OR_THROW( (size_t)aDocImages.getLength() == nCommandCount, "illegal array size returned by getImages (document image manager)" );
- ENSURE_OR_THROW( (size_t)aModImages.getLength() == nCommandCount, "illegal array size returned by getImages (module image manager)" );
-
- for ( size_t i=0; i<nCommandCount; ++i )
- {
- if ( aDocImages[i].is() )
- aImages[i] = Image( aDocImages[i] );
- else
- aImages[i] = Image( aModImages[i] );
- }
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return aImages;
- }
-
- //--------------------------------------------------------------------
- PCommandImageProvider createDocumentCommandImageProvider(
- const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
- {
- PCommandImageProvider pImageProvider( new DocumentCommandImageProvider( _rContext, _rxDocument ) );
- return pImageProvider;
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/controlfeatureinterception.cxx b/forms/source/helper/controlfeatureinterception.cxx
deleted file mode 100644
index bc9ab0c0c..000000000
--- a/forms/source/helper/controlfeatureinterception.cxx
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-#include "controlfeatureinterception.hxx"
-#include "urltransformer.hxx"
-
-/** === begin UNO includes === **/
-/** === end UNO includes === **/
-#include <tools/debug.hxx>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::frame;
- using namespace ::com::sun::star::util;
- using namespace ::com::sun::star::lang;
-
- //====================================================================
- //= ControlFeatureInterception
- //====================================================================
- //--------------------------------------------------------------------
- ControlFeatureInterception::ControlFeatureInterception( const Reference< XMultiServiceFactory >& _rxORB )
- :m_pUrlTransformer( new UrlTransformer( _rxORB ) )
- {
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL ControlFeatureInterception::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException )
- {
- if ( !_rxInterceptor.is() )
- {
- OSL_FAIL( "ControlFeatureInterception::registerDispatchProviderInterceptor: invalid interceptor!" );
- return;
- }
-
- if ( m_xFirstDispatchInterceptor.is() )
- {
- // there is already an interceptor; the new one will become its master
- Reference< XDispatchProvider > xFirstProvider( m_xFirstDispatchInterceptor, UNO_QUERY );
- _rxInterceptor->setSlaveDispatchProvider( xFirstProvider );
- m_xFirstDispatchInterceptor->setMasterDispatchProvider( xFirstProvider );
- }
-
- // we are the master of the chain's first interceptor
- m_xFirstDispatchInterceptor = _rxInterceptor;
- m_xFirstDispatchInterceptor->setMasterDispatchProvider( NULL );
- // it's the first of the interceptor chain
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL ControlFeatureInterception::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException )
- {
- if ( !_rxInterceptor.is() )
- {
- OSL_FAIL( "ControlFeatureInterception::releaseDispatchProviderInterceptor: invalid interceptor!" );
- return;
- }
-
- Reference< XDispatchProviderInterceptor > xChainWalk( m_xFirstDispatchInterceptor );
-
- if ( m_xFirstDispatchInterceptor == _rxInterceptor )
- { // our chain will have a new first element
- Reference< XDispatchProviderInterceptor > xSlave( m_xFirstDispatchInterceptor->getSlaveDispatchProvider(), UNO_QUERY );
- m_xFirstDispatchInterceptor = xSlave;
- }
- // do this before removing the interceptor from the chain as we won't know it's slave afterwards)
-
- while ( xChainWalk.is() )
- {
- // walk along the chain of interceptors and look for the interceptor that has to be removed
- Reference< XDispatchProviderInterceptor > xSlave( xChainWalk->getSlaveDispatchProvider(), UNO_QUERY );
-
- if ( xChainWalk == _rxInterceptor )
- {
- // old master may be an interceptor too
- Reference< XDispatchProviderInterceptor > xMaster( xChainWalk->getMasterDispatchProvider(), UNO_QUERY );
-
- // unchain the interceptor that has to be removed
- xChainWalk->setSlaveDispatchProvider( NULL );
- xChainWalk->setMasterDispatchProvider( NULL );
-
- // reconnect the chain
- if ( xMaster.is() )
- {
- xMaster->setSlaveDispatchProvider( Reference< XDispatchProvider >::query( xSlave ) );
- }
-
- // if somebody has registered the same interceptor twice, then we will remove
- // it once per call ...
- break;
- }
-
- xChainWalk = xSlave;
- }
- }
-
- //--------------------------------------------------------------------
- void ControlFeatureInterception::dispose()
- {
- // release all interceptors
- Reference< XDispatchProviderInterceptor > xInterceptor( m_xFirstDispatchInterceptor );
- m_xFirstDispatchInterceptor.clear();
- while ( xInterceptor.is() )
- {
- // tell the interceptor it has a new (means no) predecessor
- xInterceptor->setMasterDispatchProvider( NULL );
-
- // ask for it's successor
- Reference< XDispatchProvider > xSlave = xInterceptor->getSlaveDispatchProvider();
- // and give it the new (means no) successoert
- xInterceptor->setSlaveDispatchProvider( NULL );
-
- // start over with the next chain element
- xInterceptor = xInterceptor.query( xSlave );
- }
- }
- //--------------------------------------------------------------------
- Reference< XDispatch > ControlFeatureInterception::queryDispatch( const URL& _rURL, const ::rtl::OUString& _rTargetFrameName, ::sal_Int32 _nSearchFlags ) SAL_THROW((RuntimeException))
- {
- Reference< XDispatch > xDispatcher;
- if ( m_xFirstDispatchInterceptor.is() )
- xDispatcher = m_xFirstDispatchInterceptor->queryDispatch( _rURL, _rTargetFrameName, _nSearchFlags );
- return xDispatcher;
- }
-
- //--------------------------------------------------------------------
- Reference< XDispatch > ControlFeatureInterception::queryDispatch( const URL& _rURL ) SAL_THROW((RuntimeException))
- {
- return queryDispatch( _rURL, ::rtl::OUString(), 0 );
- }
-
- //--------------------------------------------------------------------
- Reference< XDispatch > ControlFeatureInterception::queryDispatch( const sal_Char* _pAsciiURL ) SAL_THROW((RuntimeException))
- {
- return queryDispatch( m_pUrlTransformer->getStrictURLFromAscii( _pAsciiURL ) );
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx
deleted file mode 100644
index b6e81c2a7..000000000
--- a/forms/source/helper/formnavigation.cxx
+++ /dev/null
@@ -1,487 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-#include "formnavigation.hxx"
-#include "urltransformer.hxx"
-#include "controlfeatureinterception.hxx"
-#include "frm_strings.hxx"
-
-#include <com/sun/star/form/runtime/FormFeature.hpp>
-
-#include <tools/debug.hxx>
-
-
-//.........................................................................
-namespace frm
-{
-//.........................................................................
-
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::beans;
- using namespace ::com::sun::star::lang;
- using namespace ::com::sun::star::util;
- using namespace ::com::sun::star::frame;
- namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
-
- //==================================================================
- //= OFormNavigationHelper
- //==================================================================
- DBG_NAME( OFormNavigationHelper )
- //------------------------------------------------------------------
- OFormNavigationHelper::OFormNavigationHelper( const Reference< XMultiServiceFactory >& _rxORB )
- :m_xORB( _rxORB )
- ,m_nConnectedFeatures( 0 )
- {
- DBG_CTOR( OFormNavigationHelper, NULL );
- m_pFeatureInterception.reset( new ControlFeatureInterception( m_xORB ) );
- }
-
- //------------------------------------------------------------------
- OFormNavigationHelper::~OFormNavigationHelper()
- {
- DBG_DTOR( OFormNavigationHelper, NULL );
- }
-
- //------------------------------------------------------------------
- void SAL_CALL OFormNavigationHelper::dispose( ) throw( RuntimeException )
- {
- m_pFeatureInterception->dispose();
- disconnectDispatchers();
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::interceptorsChanged( )
- {
- updateDispatches();
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::featureStateChanged( sal_Int16 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ )
- {
- // not interested in
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::allFeatureStatesChanged( )
- {
- // not interested in
- }
-
- //------------------------------------------------------------------
- void SAL_CALL OFormNavigationHelper::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
- {
- m_pFeatureInterception->registerDispatchProviderInterceptor( _rxInterceptor );
- interceptorsChanged();
- }
-
- //------------------------------------------------------------------
- void SAL_CALL OFormNavigationHelper::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
- {
- m_pFeatureInterception->releaseDispatchProviderInterceptor( _rxInterceptor );
- interceptorsChanged();
- }
-
- //------------------------------------------------------------------
- void SAL_CALL OFormNavigationHelper::statusChanged( const FeatureStateEvent& _rState ) throw (RuntimeException)
- {
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
- {
- if ( aFeature->second.aURL.Main == _rState.FeatureURL.Main )
- {
- if ( ( aFeature->second.bCachedState != _rState.IsEnabled )
- || ( aFeature->second.aCachedAdditionalState != _rState.State )
- )
- {
- // change the cached state
- aFeature->second.bCachedState = _rState.IsEnabled;
- aFeature->second.aCachedAdditionalState = _rState.State;
- // tell derivees what happened
- featureStateChanged( aFeature->first, _rState.IsEnabled );
- }
- return;
- }
- }
-
- // unreachable
- OSL_FAIL( "OFormNavigationHelper::statusChanged: huh? An invalid/unknown URL?" );
- }
-
- //------------------------------------------------------------------
- void SAL_CALL OFormNavigationHelper::disposing( const EventObject& _rSource ) throw (RuntimeException)
- {
- // was it one of our external dispatchers?
- if ( m_nConnectedFeatures )
- {
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
- {
- if ( aFeature->second.xDispatcher == _rSource.Source )
- {
- aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
- aFeature->second.xDispatcher = NULL;
- aFeature->second.bCachedState = sal_False;
- aFeature->second.aCachedAdditionalState.clear();
- --m_nConnectedFeatures;
-
- featureStateChanged( aFeature->first, sal_False );
- break;
- }
- }
- }
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::updateDispatches()
- {
- if ( !m_nConnectedFeatures )
- { // we don't have any dispatchers yet -> do the initial connect
- connectDispatchers();
- return;
- }
-
- initializeSupportedFeatures();
-
- m_nConnectedFeatures = 0;
-
- Reference< XDispatch > xNewDispatcher;
- Reference< XDispatch > xCurrentDispatcher;
-
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
- {
- xNewDispatcher = queryDispatch( aFeature->second.aURL );
- xCurrentDispatcher = aFeature->second.xDispatcher;
- if ( xNewDispatcher != xCurrentDispatcher )
- {
- // the dispatcher for this particular URL changed
- if ( xCurrentDispatcher.is() )
- xCurrentDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
-
- xCurrentDispatcher = aFeature->second.xDispatcher = xNewDispatcher;
-
- if ( xCurrentDispatcher.is() )
- xCurrentDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
- }
-
- if ( xCurrentDispatcher.is() )
- ++m_nConnectedFeatures;
- else
- aFeature->second.bCachedState = sal_False;
- }
-
- // notify derivee that (potentially) all features changed their state
- allFeatureStatesChanged( );
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::connectDispatchers()
- {
- if ( m_nConnectedFeatures )
- { // already connected -> just do an update
- updateDispatches();
- return;
- }
-
- initializeSupportedFeatures();
-
- m_nConnectedFeatures = 0;
-
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
- {
- aFeature->second.bCachedState = sal_False;
- aFeature->second.aCachedAdditionalState.clear();
- aFeature->second.xDispatcher = queryDispatch( aFeature->second.aURL );
- if ( aFeature->second.xDispatcher.is() )
- {
- ++m_nConnectedFeatures;
- aFeature->second.xDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
- }
- }
-
- // notify derivee that (potentially) all features changed their state
- allFeatureStatesChanged( );
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::disconnectDispatchers()
- {
- if ( m_nConnectedFeatures )
- {
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
- {
- if ( aFeature->second.xDispatcher.is() )
- aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
-
- aFeature->second.xDispatcher = NULL;
- aFeature->second.bCachedState = sal_False;
- aFeature->second.aCachedAdditionalState.clear();
- }
-
- m_nConnectedFeatures = 0;
- }
-
- // notify derivee that (potentially) all features changed their state
- allFeatureStatesChanged( );
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::initializeSupportedFeatures( )
- {
- if ( m_aSupportedFeatures.empty() )
- {
- // ask the derivee which feature ids it wants us to support
- ::std::vector< sal_Int16 > aFeatureIds;
- getSupportedFeatures( aFeatureIds );
-
- OFormNavigationMapper aUrlMapper( m_xORB );
-
- for ( ::std::vector< sal_Int16 >::const_iterator aLoop = aFeatureIds.begin();
- aLoop != aFeatureIds.end();
- ++aLoop
- )
- {
- FeatureInfo aFeatureInfo;
-
- bool bKnownId =
- aUrlMapper.getFeatureURL( *aLoop, aFeatureInfo.aURL );
- DBG_ASSERT( bKnownId, "OFormNavigationHelper::initializeSupportedFeatures: unknown feature id!" );
-
- if ( bKnownId )
- // add to our map
- m_aSupportedFeatures.insert( FeatureMap::value_type( *aLoop, aFeatureInfo ) );
- }
- }
- }
-
- //------------------------------------------------------------------
- Reference< XDispatch > OFormNavigationHelper::queryDispatch( const URL& _rURL )
- {
- return m_pFeatureInterception->queryDispatch( _rURL );
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamAsciiName,
- const Any& _rParamValue ) const
- {
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- {
- if ( aInfo->second.xDispatcher.is() )
- {
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[0].Name = ::rtl::OUString::createFromAscii( _pParamAsciiName );
- aArgs[0].Value = _rParamValue;
-
- aInfo->second.xDispatcher->dispatch( aInfo->second.aURL, aArgs );
- }
- }
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::dispatch( sal_Int16 _nFeatureId ) const
- {
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- {
- if ( aInfo->second.xDispatcher.is() )
- {
- Sequence< PropertyValue > aEmptyArgs;
- aInfo->second.xDispatcher->dispatch( aInfo->second.aURL, aEmptyArgs );
- }
- }
- }
-
- //------------------------------------------------------------------
- bool OFormNavigationHelper::isEnabled( sal_Int16 _nFeatureId ) const
- {
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- return aInfo->second.bCachedState;
-
- return false;
- }
-
- //------------------------------------------------------------------
- bool OFormNavigationHelper::getBooleanState( sal_Int16 _nFeatureId ) const
- {
- sal_Bool bState = sal_False;
-
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- aInfo->second.aCachedAdditionalState >>= bState;
-
- return (bool)bState;
- }
-
- //------------------------------------------------------------------
- ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int16 _nFeatureId ) const
- {
- ::rtl::OUString sState;
-
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- aInfo->second.aCachedAdditionalState >>= sState;
-
- return sState;
- }
-
- //------------------------------------------------------------------
- sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int16 _nFeatureId ) const
- {
- sal_Int32 nState = 0;
-
- FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId );
- if ( m_aSupportedFeatures.end() != aInfo )
- aInfo->second.aCachedAdditionalState >>= nState;
-
- return nState;
- }
-
- //------------------------------------------------------------------
- void OFormNavigationHelper::invalidateSupportedFeaturesSet()
- {
- disconnectDispatchers( );
- // no supported features anymore:
- FeatureMap aEmpty;
- m_aSupportedFeatures.swap( aEmpty );
- }
-
- //==================================================================
- //= OFormNavigationMapper
- //==================================================================
- //------------------------------------------------------------------
- OFormNavigationMapper::OFormNavigationMapper( const Reference< XMultiServiceFactory >& _rxORB )
- {
- m_pUrlTransformer.reset( new UrlTransformer( _rxORB ) );
- }
-
- //------------------------------------------------------------------
- OFormNavigationMapper::~OFormNavigationMapper( )
- {
- }
-
- //------------------------------------------------------------------
- bool OFormNavigationMapper::getFeatureURL( sal_Int16 _nFeatureId, URL& /* [out] */ _rURL )
- {
- // get the ascii version of the URL
- const char* pAsciiURL = getFeatureURLAscii( _nFeatureId );
- if ( pAsciiURL )
- _rURL = m_pUrlTransformer->getStrictURLFromAscii( pAsciiURL );
-
- return ( pAsciiURL != NULL );
- }
-
- //------------------------------------------------------------------
- namespace
- {
- struct FeatureURL
- {
- const sal_Int16 nFormFeature;
- const sal_Char* pAsciiURL;
-
- FeatureURL( const sal_Int16 _nFormFeature, const sal_Char* _pAsciiURL )
- :nFormFeature( _nFormFeature )
- ,pAsciiURL( _pAsciiURL )
- {
- }
- };
- const FeatureURL* lcl_getFeatureTable()
- {
- static const FeatureURL s_aFeatureURLs[] =
- {
- FeatureURL( FormFeature::MoveAbsolute, URL_FORM_POSITION ),
- FeatureURL( FormFeature::TotalRecords, URL_FORM_RECORDCOUNT ),
- FeatureURL( FormFeature::MoveToFirst, URL_RECORD_FIRST ),
- FeatureURL( FormFeature::MoveToPrevious, URL_RECORD_PREV ),
- FeatureURL( FormFeature::MoveToNext, URL_RECORD_NEXT ),
- FeatureURL( FormFeature::MoveToLast, URL_RECORD_LAST ),
- FeatureURL( FormFeature::SaveRecordChanges, URL_RECORD_SAVE ),
- FeatureURL( FormFeature::UndoRecordChanges, URL_RECORD_UNDO ),
- FeatureURL( FormFeature::MoveToInsertRow, URL_RECORD_NEW ),
- FeatureURL( FormFeature::DeleteRecord, URL_RECORD_DELETE ),
- FeatureURL( FormFeature::ReloadForm, URL_FORM_REFRESH ),
- FeatureURL( FormFeature::RefreshCurrentControl, URL_FORM_REFRESH_CURRENT_CONTROL ),
- FeatureURL( FormFeature::SortAscending, URL_FORM_SORT_UP ),
- FeatureURL( FormFeature::SortDescending, URL_FORM_SORT_DOWN ),
- FeatureURL( FormFeature::InteractiveSort, URL_FORM_SORT ),
- FeatureURL( FormFeature::AutoFilter, URL_FORM_AUTO_FILTER ),
- FeatureURL( FormFeature::InteractiveFilter, URL_FORM_FILTER ),
- FeatureURL( FormFeature::ToggleApplyFilter, URL_FORM_APPLY_FILTER ),
- FeatureURL( FormFeature::RemoveFilterAndSort, URL_FORM_REMOVE_FILTER ),
- FeatureURL( 0, NULL )
- };
- return s_aFeatureURLs;
- }
- }
-
- //------------------------------------------------------------------
- const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int16 _nFeatureId )
- {
- const FeatureURL* pFeatures = lcl_getFeatureTable();
- while ( pFeatures->pAsciiURL )
- {
- if ( pFeatures->nFormFeature == _nFeatureId )
- return pFeatures->pAsciiURL;
- ++pFeatures;
- }
- return NULL;
- }
-
- //------------------------------------------------------------------
- sal_Int16 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL )
- {
- const FeatureURL* pFeatures = lcl_getFeatureTable();
- while ( pFeatures->pAsciiURL )
- {
- if ( _rCompleteURL.compareToAscii( pFeatures->pAsciiURL ) == 0 )
- return pFeatures->nFormFeature;
- ++pFeatures;
- }
- return -1;
- }
-
-//.........................................................................
-} // namespace frm
-//.........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/resettable.cxx b/forms/source/helper/resettable.cxx
deleted file mode 100644
index 94380fe7c..000000000
--- a/forms/source/helper/resettable.cxx
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
-************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-
-#include "resettable.hxx"
-
-/** === begin UNO includes === **/
-/** === end UNO includes === **/
-
-#include <cppuhelper/weak.hxx>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- /** === begin UNO using === **/
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::uno::XInterface;
- using ::com::sun::star::uno::UNO_QUERY;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
- using ::com::sun::star::uno::UNO_SET_THROW;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::Any;
- using ::com::sun::star::uno::makeAny;
- using ::com::sun::star::uno::Sequence;
- using ::com::sun::star::uno::Type;
- using ::com::sun::star::form::XResetListener;
- using ::com::sun::star::lang::EventObject;
- /** === end UNO using === **/
-
- //====================================================================
- //= ResetHelper
- //====================================================================
- //--------------------------------------------------------------------
- void ResetHelper::addResetListener( const Reference< XResetListener >& _listener )
- {
- m_aResetListeners.addInterface( _listener );
- }
-
- //--------------------------------------------------------------------
- void ResetHelper::removeResetListener( const Reference< XResetListener >& _listener )
- {
- m_aResetListeners.removeInterface( _listener );
- }
-
- //--------------------------------------------------------------------
- bool ResetHelper::approveReset()
- {
- ::cppu::OInterfaceIteratorHelper aIter( m_aResetListeners );
- EventObject aResetEvent( m_rParent );
-
- sal_Bool bContinue = sal_True;
- while ( aIter.hasMoreElements() && bContinue )
- bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent );
-
- return bContinue;
- }
-
- //--------------------------------------------------------------------
- void ResetHelper::notifyResetted()
- {
- EventObject aResetEvent( m_rParent );
- m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent );
- }
-
- //--------------------------------------------------------------------
- void ResetHelper::disposing()
- {
- EventObject aEvent( m_rParent );
- m_aResetListeners.disposeAndClear( aEvent );
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/urltransformer.cxx b/forms/source/helper/urltransformer.cxx
deleted file mode 100644
index 8788fa6bd..000000000
--- a/forms/source/helper/urltransformer.cxx
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-#include "urltransformer.hxx"
-
-/** === begin UNO includes === **/
-/** === end UNO includes === **/
-#include <tools/debug.hxx>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::util;
- using namespace ::com::sun::star::lang;
-
- //====================================================================
- //= UrlTransformer
- //====================================================================
- //--------------------------------------------------------------------
- UrlTransformer::UrlTransformer( const Reference< XMultiServiceFactory >& _rxORB )
- :m_xORB( _rxORB )
- ,m_bTriedToCreateTransformer( false )
- {
- DBG_ASSERT( _rxORB.is(), "UrlTransformer::UrlTransformer: invalid service factory!" );
- }
-
- //--------------------------------------------------------------------
- bool UrlTransformer::implEnsureTransformer() const
- {
- // create the transformer, if not already attempted to do so
- if ( !m_xTransformer.is() && !m_bTriedToCreateTransformer )
- {
- if ( m_xORB.is() )
- {
- m_xTransformer = m_xTransformer.query(
- m_xORB->createInstance(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) )
- )
- );
- DBG_ASSERT( m_xTransformer.is(), "UrlTransformer::getStrictURL: couldn't get an URL transformer!" );
- }
-
- m_bTriedToCreateTransformer = true;
- }
- return m_xTransformer.is();
- }
-
- //--------------------------------------------------------------------
- URL UrlTransformer::getStrictURL( const ::rtl::OUString& _rURL ) const
- {
- URL aReturn;
- aReturn.Complete = _rURL;
- if ( implEnsureTransformer() )
- m_xTransformer->parseStrict( aReturn );
- return aReturn;
- }
-
- //--------------------------------------------------------------------
- URL UrlTransformer::getStrictURLFromAscii( const sal_Char* _pAsciiURL ) const
- {
- return getStrictURL( ::rtl::OUString::createFromAscii( _pAsciiURL ) );
- }
-
- //--------------------------------------------------------------------
- void UrlTransformer::parseSmartWithAsciiProtocol( ::com::sun::star::util::URL& _rURL, const sal_Char* _pAsciiURL ) const
- {
- if ( implEnsureTransformer() )
- m_xTransformer->parseSmart( _rURL, ::rtl::OUString::createFromAscii( _pAsciiURL ) );
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/helper/windowstateguard.cxx b/forms/source/helper/windowstateguard.cxx
deleted file mode 100644
index f1fe62585..000000000
--- a/forms/source/helper/windowstateguard.cxx
+++ /dev/null
@@ -1,234 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_forms.hxx"
-#include "windowstateguard.hxx"
-#include "frm_strings.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/awt/XWindowListener2.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-/** === end UNO includes === **/
-#include <cppuhelper/implbase1.hxx>
-#include <tools/diagnose_ex.h>
-
-//........................................................................
-namespace frm
-{
-//........................................................................
-
- /** === begin UNO using === **/
- using ::com::sun::star::awt::XWindowListener2;
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::awt::XWindow2;
- using ::com::sun::star::awt::WindowEvent;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::awt::XControlModel;
- using ::com::sun::star::beans::XPropertySet;
- using ::com::sun::star::lang::EventObject;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::UNO_QUERY;
- using ::com::sun::star::uno::Exception;
- /** === end UNO using === **/
-
- //====================================================================
- //= WindowStateGuard_Impl
- //====================================================================
- typedef ::cppu::WeakImplHelper1 < XWindowListener2
- > WindowStateGuard_Impl_Base;
- class WindowStateGuard_Impl : public WindowStateGuard_Impl_Base
- {
- private:
- ::osl::Mutex m_aMutex;
- Reference< XWindow2 > m_xWindow;
- Reference< XPropertySet > m_xModelProps;
-
- public:
- /** constructs the instance
- @param _rxWindow
- the window at which to listen. Must not be <NULL/>.
- @param _rxModel
- the model which acts as the reference for the states to be enforced. Must not be <NULL/>.
- */
- WindowStateGuard_Impl( const Reference< XWindow2 >& _rxWindow, const Reference< XPropertySet >& _rxMdelProps );
-
- void dispose();
-
- protected:
- // XWindowListener2
- virtual void SAL_CALL windowEnabled( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL windowDisabled( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
-
- // XWindowListener
- virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
-
- // XEventListener
- virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
-
- private:
- /** ensures that the window's Enabled state matches what is described at the model
- @precond
- our mutex is locked
- */
- void impl_ensureEnabledState_nothrow_nolck();
- };
-
- //--------------------------------------------------------------------
- WindowStateGuard_Impl::WindowStateGuard_Impl( const Reference< XWindow2 >& _rxWindow, const Reference< XPropertySet >& _rxMdelProps )
- :m_xWindow( _rxWindow )
- ,m_xModelProps( _rxMdelProps )
- {
- if ( !m_xWindow.is() || !m_xModelProps.is() )
- throw RuntimeException();
-
- osl_incrementInterlockedCount( &m_refCount );
- {
- m_xWindow->addWindowListener( this );
- }
- osl_decrementInterlockedCount( &m_refCount );
- }
-
- //--------------------------------------------------------------------
- void WindowStateGuard_Impl::dispose()
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- if ( !m_xWindow.is() )
- // already disposed
- return;
-
- m_xWindow->removeWindowListener( this );
- m_xWindow.clear();
- }
-
- //--------------------------------------------------------------------
- void WindowStateGuard_Impl::impl_ensureEnabledState_nothrow_nolck()
- {
- try
- {
- Reference< XWindow2 > xWindow;
- sal_Bool bEnabled = sal_False;
- sal_Bool bShouldBeEnabled = sal_False;
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- if ( !m_xWindow.is() || !m_xModelProps.is() )
- return;
- xWindow = m_xWindow;
- bEnabled = xWindow->isEnabled();
- OSL_VERIFY( m_xModelProps->getPropertyValue( PROPERTY_ENABLED ) >>= bShouldBeEnabled );
- }
-
- if ( !bShouldBeEnabled && bEnabled && xWindow.is() )
- xWindow->setEnable( sal_False );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowEnabled( const EventObject& /*e*/ ) throw (RuntimeException)
- {
- impl_ensureEnabledState_nothrow_nolck();
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowDisabled( const EventObject& /*e*/ ) throw (RuntimeException)
- {
- impl_ensureEnabledState_nothrow_nolck();
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowResized( const WindowEvent& /*e*/ ) throw (RuntimeException)
- {
- // not interested in
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowMoved( const WindowEvent& /*e*/ ) throw (RuntimeException)
- {
- // not interested in
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowShown( const EventObject& /*e*/ ) throw (RuntimeException)
- {
- // not interested in
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::windowHidden( const EventObject& /*e*/ ) throw (RuntimeException)
- {
- // not interested in
- }
-
- //--------------------------------------------------------------------
- void SAL_CALL WindowStateGuard_Impl::disposing( const EventObject& Source ) throw (RuntimeException)
- {
- OSL_ENSURE( Source.Source == m_xWindow, "WindowStateGuard_Impl::disposing: where does this come from?" );
- (void)Source;
- dispose();
- }
-
- //====================================================================
- //= WindowStateGuard
- //====================================================================
- //--------------------------------------------------------------------
- WindowStateGuard::WindowStateGuard()
- {
- }
-
- //--------------------------------------------------------------------
- WindowStateGuard::~WindowStateGuard()
- {
- }
-
- //--------------------------------------------------------------------
- void WindowStateGuard::attach( const Reference< XWindow2 >& _rxWindow, const Reference< XControlModel >& _rxModel )
- {
- if ( m_pImpl.is() )
- {
- m_pImpl->dispose();
- m_pImpl = NULL;
- }
-
- Reference< XPropertySet > xModelProps( _rxModel, UNO_QUERY );
- OSL_ENSURE( xModelProps.is() || !_rxModel.is(), "WindowStateGuard::attach: a model which is no XPropertySet?" );
- if ( _rxWindow.is() && xModelProps.is() )
- m_pImpl = new WindowStateGuard_Impl( _rxWindow, xModelProps );
- }
-
-//........................................................................
-} // namespace frm
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */