diff options
Diffstat (limited to 'forms/source')
26 files changed, 1002 insertions, 489 deletions
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 5045c9fdb..09690f1b7 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -509,7 +509,7 @@ IMPL_LINK( OButtonControl, OnClick, void*, EMPTYARG ) void OButtonControl::actionPerformed_Impl( sal_Bool _bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ) { { - sal_Int32 nFeatureId = -1; + sal_Int16 nFeatureId = -1; { ::osl::MutexGuard aGuard( m_aMutex ); nFeatureId = m_nTargetUrlFeatureId; @@ -636,7 +636,7 @@ sal_Bool SAL_CALL OButtonControl::setModel( const Reference< XControlModel >& _r //------------------------------------------------------------------------------ void OButtonControl::modelFeatureUrlPotentiallyChanged( ) { - sal_Int32 nOldUrlFeatureId = m_nTargetUrlFeatureId; + sal_Int16 nOldUrlFeatureId = m_nTargetUrlFeatureId; // doe we have another TargetURL now? If so, we need to update our dispatches m_nTargetUrlFeatureId = getModelUrlFeatureId( ); @@ -675,9 +675,9 @@ namespace } //------------------------------------------------------------------------------ -sal_Int32 OButtonControl::getModelUrlFeatureId( ) const +sal_Int16 OButtonControl::getModelUrlFeatureId( ) const { - sal_Int32 nFeatureId = -1; + sal_Int16 nFeatureId = -1; // some URL related properties of the model ::rtl::OUString sUrl; @@ -717,14 +717,14 @@ void SAL_CALL OButtonControl::setDesignMode( sal_Bool _bOn ) throw( RuntimeExcep } //------------------------------------------------------------------------------ -void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ) +void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) { if ( -1 != m_nTargetUrlFeatureId ) _rFeatureIds.push_back( m_nTargetUrlFeatureId ); } //------------------------------------------------------------------ -void OButtonControl::featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ) +void OButtonControl::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ) { if ( _nFeatureId == m_nTargetUrlFeatureId ) { @@ -754,7 +754,7 @@ void OButtonControl::allFeatureStatesChanged( ) } //------------------------------------------------------------------ -bool OButtonControl::isEnabled( sal_Int32 _nFeatureId ) const +bool OButtonControl::isEnabled( sal_Int16 _nFeatureId ) const { if ( const_cast< OButtonControl* >( this )->isDesignMode() ) // TODO: the model property? diff --git a/forms/source/component/Button.hxx b/forms/source/component/Button.hxx index 1f4ed0302..f63b5a2e3 100644 --- a/forms/source/component/Button.hxx +++ b/forms/source/component/Button.hxx @@ -131,7 +131,7 @@ class OButtonControl :public OButtonControl_BASE { private: sal_uInt32 m_nClickEvent; - sal_Int32 m_nTargetUrlFeatureId; + sal_Int16 m_nTargetUrlFeatureId; /// caches the value of the "Enabled" property of our model sal_Bool m_bEnabledByPropertyValue; @@ -176,10 +176,10 @@ public: protected: // OFormNavigationHelper overriables - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ); - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); virtual void allFeatureStatesChanged( ); - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; // XDispatchProviderInterception disambiguaiton virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); @@ -198,7 +198,7 @@ private: /** retrieves the feature id (see OFormNavigationHelper) of the TargetURL of the model. */ - sal_Int32 getModelUrlFeatureId( ) const; + sal_Int16 getModelUrlFeatureId( ) const; /** starts or stops listening for changes in model properties we're interested in */ diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index 2c17f67bf..3127f8a68 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -342,7 +342,7 @@ void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, sal_B aForbiddenProperties.insert( PROPERTY_VSCROLL ); aForbiddenProperties.insert( PROPERTY_CONTROLLABEL ); aForbiddenProperties.insert( PROPERTY_RICH_TEXT ); - aForbiddenProperties.insert( PROPERTY_VERTICALALIGN ); + aForbiddenProperties.insert( PROPERTY_VERTICAL_ALIGN ); aForbiddenProperties.insert( PROPERTY_IMAGE_URL ); aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION ); aForbiddenProperties.insert( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) ); @@ -416,14 +416,14 @@ sal_Bool OGridColumn::convertFastPropertyValue( Any& rConvertedValue, Any& rOldV bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, ::getCppuType((const sal_Int32*)NULL)); break; case PROPERTY_ID_ALIGN: - try + bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType( (const sal_Int32*)NULL ) ); + // strange enough, css.awt.TextAlign is a 32-bit integer, while the Align property (both here for grid controls + // and for ordinary toolkit controls) is a 16-bit integer. So, allow for 32 bit, but normalize it to 16 bit + if ( bModified ) { - bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType((const sal_Int16*)NULL)); - } - catch(starlang::IllegalArgumentException&) - { - OSL_ENSURE(0,"OGridColumn::convertFastPropertyValue: TextAlign must be casted to sal_Int16!"); - throw; + sal_Int32 nAlign( 0 ); + if ( rConvertedValue >>= nAlign ) + rConvertedValue <<= (sal_Int16)nAlign; } break; case PROPERTY_ID_HIDDEN: diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 4e754854c..43e2fb0ac 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -31,72 +31,71 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include "componenttools.hxx"
-#include "DatabaseForm.hxx"
-#include "EventThread.hxx"
-#include "frm_module.hxx"
-#include "frm_resource.hrc"
-#include "frm_resource.hxx"
-#include "GroupManager.hxx"
-#include "property.hrc"
-#include "property.hxx"
-#include "services.hxx"
-
-#include <com/sun/star/awt/XControlContainer.hpp>
-#include <com/sun/star/awt/XTextComponent.hpp>
-#include <com/sun/star/form/DataSelectionType.hpp>
-#include <com/sun/star/form/FormComponentType.hpp>
-#include <com/sun/star/form/TabulatorCycle.hpp>
-#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/io/XObjectInputStream.hpp>
-#include <com/sun/star/io/XObjectOutputStream.hpp>
-#include <com/sun/star/sdb/CommandType.hpp>
-#include <com/sun/star/sdb/RowSetVetoException.hpp>
-#include <com/sun/star/sdb/SQLContext.hpp>
-#include <com/sun/star/sdb/XColumnUpdate.hpp>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
-#include <com/sun/star/sdbc/ResultSetType.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbcx/Privilege.hpp>
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#include <com/sun/star/util/XCancellable.hpp>
-#include <com/sun/star/util/XURLTransformer.hpp>
+#include "componenttools.hxx" +#include "DatabaseForm.hxx" +#include "EventThread.hxx" +#include "frm_module.hxx" +#include "frm_resource.hrc" +#include "frm_resource.hxx" +#include "GroupManager.hxx" +#include "property.hrc" +#include "property.hxx" +#include "services.hxx" + +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/form/DataSelectionType.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/TabulatorCycle.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/RowSetVetoException.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XModifiable2.hpp> -
-#include <comphelper/basicio.hxx>
-#include <comphelper/container.hxx>
-#include <comphelper/enumhelper.hxx>
-#include <comphelper/extract.hxx>
-#include <comphelper/seqstream.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/stl_types.hxx>
-#include <comphelper/uno3.hxx>
-#include <connectivity/dbtools.hxx>
-#include <cppuhelper/exc_hlp.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <osl/mutex.hxx>
-#include <rtl/math.hxx>
-#include <rtl/tencinfo.h>
-#include <svl/inetstrm.hxx>
-#include <svl/inettype.hxx>
-#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <tools/fsys.hxx>
-#include <tools/inetmsg.hxx>
-#include <tools/urlobj.hxx>
-#include <unotools/ucblockbytes.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/timer.hxx>
-#include <vos/mutex.hxx>
- -#include <ctype.h>
-#include <hash_map>
-//#include <stdio.h>
+ +#include <comphelper/basicio.hxx> +#include <comphelper/container.hxx> +#include <comphelper/enumhelper.hxx> +#include <comphelper/extract.hxx> +#include <comphelper/seqstream.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/stl_types.hxx> +#include <comphelper/uno3.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/implbase2.hxx> +#include <osl/mutex.hxx> +#include <rtl/math.hxx> +#include <rtl/tencinfo.h> +#include <svl/inetstrm.hxx> +#include <svl/inettype.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <tools/fsys.hxx> +#include <tools/inetmsg.hxx> +#include <tools/urlobj.hxx> +#include <unotools/ucblockbytes.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/timer.hxx> +#include <vos/mutex.hxx> + +#include <ctype.h> +#include <hash_map> // compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ... namespace com { @@ -2629,16 +2628,15 @@ void ODatabaseForm::impl_createLoadTimer() //------------------------------------------------------------------------------ void SAL_CALL ODatabaseForm::loaded(const EventObject& /*aEvent*/) throw( RuntimeException ) { - // now start the rowset listening to recover cursor events - load_impl(sal_True); { - ::osl::MutexGuard aGuard(m_aMutex); - Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY); - if (xParentRowSet.is()) - xParentRowSet->addRowSetListener(this); + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW ); + xParentRowSet->addRowSetListener( this ); impl_createLoadTimer(); } + + load_impl( sal_True ); } //------------------------------------------------------------------------------ @@ -2646,12 +2644,14 @@ void SAL_CALL ODatabaseForm::unloading(const EventObject& /*aEvent*/) throw( Run { { // now stop the rowset listening if we are a subform - ::osl::MutexGuard aGuard(m_aMutex); - DELETEZ(m_pLoadTimer); + ::osl::MutexGuard aGuard( m_aMutex ); - Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY); - if (xParentRowSet.is()) - xParentRowSet->removeRowSetListener(this); + if ( m_pLoadTimer && m_pLoadTimer->IsActive() ) + m_pLoadTimer->Stop(); + DELETEZ( m_pLoadTimer ); + + Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW ); + xParentRowSet->removeRowSetListener( this ); } unload(); @@ -2879,7 +2879,7 @@ sal_Bool ODatabaseForm::implEnsureConnection() } catch( Exception ) { - DBG_ERROR( "ODatabaseForm::implEnsureConnection: caught an exception which I cannot handle!" ); + DBG_UNHANDLED_EXCEPTION(); } return sal_False; diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 5c68f203f..b240ca066 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -2216,7 +2216,7 @@ sal_Bool OBoundControlModel::approveDbColumnType(sal_Int32 _nColumnType) || (_nColumnType == DataType::LONGVARBINARY) || (_nColumnType == DataType::OTHER) || (_nColumnType == DataType::OBJECT) || (_nColumnType == DataType::DISTINCT) || (_nColumnType == DataType::STRUCT) || (_nColumnType == DataType::ARRAY) - || (_nColumnType == DataType::BLOB) || (_nColumnType == DataType::CLOB) + || (_nColumnType == DataType::BLOB) /*|| (_nColumnType == DataType::CLOB)*/ || (_nColumnType == DataType::REF) || (_nColumnType == DataType::SQLNULL)) return sal_False; @@ -2551,10 +2551,11 @@ void OBoundControlModel::reset() throw (RuntimeException) || ( nFieldType == DataType::VARBINARY ) || ( nFieldType == DataType::LONGVARBINARY ) || ( nFieldType == DataType::OBJECT ) - || ( nFieldType == DataType::BLOB ) - || ( nFieldType == DataType::CLOB ) + /*|| ( nFieldType == DataType::CLOB )*/ ) m_xColumn->getBinaryStream(); + else if ( nFieldType == DataType::BLOB ) + m_xColumn->getBlob(); else m_xColumn->getString(); @@ -2803,7 +2804,14 @@ void SAL_CALL OBoundControlModel::modified( const EventObject& _rEvent ) throw ( //-------------------------------------------------------------------- void OBoundControlModel::transferDbValueToControl( ) { - setControlValue( translateDbColumnToControlValue(), eDbColumnBinding ); + try + { + setControlValue( translateDbColumnToControlValue(), eDbColumnBinding ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------------ diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index cf6bb8843..d9bd0f736 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -115,6 +115,7 @@ namespace || ( _nFieldType == DataType::OBJECT ) || ( _nFieldType == DataType::BLOB ) || ( _nFieldType == DataType::LONGVARCHAR ) + || ( _nFieldType == DataType::CLOB ) ) return ImageStoreBinary; diff --git a/forms/source/cppugen/makefile.mk b/forms/source/cppugen/makefile.mk deleted file mode 100644 index aa65a7122..000000000 --- a/forms/source/cppugen/makefile.mk +++ /dev/null @@ -1,68 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.6 $ -# -# 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. -# -#************************************************************************* - -PRJ=..$/.. -PRJINC=$(PRJ)$/source$/inc -PRJNAME=forms -TARGET=fm_cppugen - -# --- Settings ---------------------------------- - -.INCLUDE : settings.mk -.INCLUDE: $(PRJ)$/makefile.pmk - -# --- Types ------------------------------------- - - - -# --- Types ------------------------------------- - -UNOTYPES+= \ - com.sun.star.form.binding.XBindableValue \ - com.sun.star.form.binding.XValueBinding \ - com.sun.star.form.binding.XListEntrySink \ - com.sun.star.form.binding.XListEntrySource \ - com.sun.star.form.binding.XListEntryListener \ - com.sun.star.form.validation.XValidator \ - com.sun.star.form.validation.XValidatable \ - com.sun.star.form.validation.XValidityConstraintListener \ - com.sun.star.form.validation.XValidatableFormComponent \ - com.sun.star.form.submission.XSubmissionSupplier \ - com.sun.star.xforms.XModel \ - com.sun.star.xforms.XFormsSupplier \ - com.sun.star.xforms.XSubmission \ - com.sun.star.xsd.WhiteSpaceTreatment \ - com.sun.star.xsd.XDataType \ - -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx new file mode 100644 index 000000000..2eb79aa17 --- /dev/null +++ b/forms/source/helper/commanddescriptionprovider.cxx @@ -0,0 +1,139 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 +//........................................................................ diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx new file mode 100644 index 000000000..52ac2d95c --- /dev/null +++ b/forms/source/helper/commandimageprovider.cxx @@ -0,0 +1,180 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 bool _bHiContrast ) 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 bool _bHiContrast ) const + { + const size_t nCommandCount = _rCommandURLs.getLength(); + CommandImages aImages( nCommandCount ); + try + { + const sal_Int16 nImageType = + ( _bLarge ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT ) + + ( _bHiContrast ? ImageType::COLOR_HIGHCONTRAST : ImageType::COLOR_NORMAL ); + + 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 +//........................................................................ diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx index 3ddfd89ad..513496e2b 100644 --- a/forms/source/helper/formnavigation.cxx +++ b/forms/source/helper/formnavigation.cxx @@ -33,12 +33,13 @@ #include "formnavigation.hxx" #include "urltransformer.hxx" #include "controlfeatureinterception.hxx" -#include <tools/debug.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif #include "frm_strings.hxx" +#include <com/sun/star/form/runtime/FormFeature.hpp> + +#include <tools/debug.hxx> + + //......................................................................... namespace frm { @@ -49,6 +50,7 @@ namespace frm 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 @@ -83,7 +85,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::featureStateChanged( sal_Int32 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ ) + void OFormNavigationHelper::featureStateChanged( sal_Int16 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ ) { // not interested in } @@ -270,12 +272,12 @@ namespace frm if ( m_aSupportedFeatures.empty() ) { // ask the derivee which feature ids it wants us to support - ::std::vector< sal_Int32 > aFeatureIds; + ::std::vector< sal_Int16 > aFeatureIds; getSupportedFeatures( aFeatureIds ); OFormNavigationMapper aUrlMapper( m_xORB ); - for ( ::std::vector< sal_Int32 >::const_iterator aLoop = aFeatureIds.begin(); + for ( ::std::vector< sal_Int16 >::const_iterator aLoop = aFeatureIds.begin(); aLoop != aFeatureIds.end(); ++aLoop ) @@ -300,7 +302,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::dispatchWithArgument( sal_Int32 _nFeatureId, const sal_Char* _pParamAsciiName, + void OFormNavigationHelper::dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamAsciiName, const Any& _rParamValue ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); @@ -318,7 +320,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::dispatch( sal_Int32 _nFeatureId ) const + void OFormNavigationHelper::dispatch( sal_Int16 _nFeatureId ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); if ( m_aSupportedFeatures.end() != aInfo ) @@ -332,7 +334,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationHelper::isEnabled( sal_Int32 _nFeatureId ) const + bool OFormNavigationHelper::isEnabled( sal_Int16 _nFeatureId ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); if ( m_aSupportedFeatures.end() != aInfo ) @@ -342,7 +344,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationHelper::getBooleanState( sal_Int32 _nFeatureId ) const + bool OFormNavigationHelper::getBooleanState( sal_Int16 _nFeatureId ) const { sal_Bool bState = sal_False; @@ -354,7 +356,7 @@ namespace frm } //------------------------------------------------------------------ - ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int32 _nFeatureId ) const + ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int16 _nFeatureId ) const { ::rtl::OUString sState; @@ -366,7 +368,7 @@ namespace frm } //------------------------------------------------------------------ - sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int32 _nFeatureId ) const + sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int16 _nFeatureId ) const { sal_Int32 nState = 0; @@ -382,7 +384,7 @@ namespace frm { disconnectDispatchers( ); // no supported features anymore: - FeatureMap aEmpty; + FeatureMap aEmpty; m_aSupportedFeatures.swap( aEmpty ); } @@ -401,7 +403,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationMapper::getFeatureURL( sal_Int32 _nFeatureId, URL& /* [out] */ _rURL ) + bool OFormNavigationMapper::getFeatureURL( sal_Int16 _nFeatureId, URL& /* [out] */ _rURL ) { // get the ascii version of the URL const char* pAsciiURL = getFeatureURLAscii( _nFeatureId ); @@ -412,84 +414,72 @@ namespace frm } //------------------------------------------------------------------ - const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int32 _nFeatureId ) + namespace { - const char* pAsciiURL = NULL; - - switch ( _nFeatureId ) + struct FeatureURL { - case SID_FM_RECORD_ABSOLUTE : pAsciiURL = URL_FORM_POSITION; break; - case SID_FM_RECORD_TOTAL : pAsciiURL = URL_FORM_RECORDCOUNT; break; - case SID_FM_RECORD_FIRST : pAsciiURL = URL_RECORD_FIRST; break; - case SID_FM_RECORD_PREV : pAsciiURL = URL_RECORD_PREV; break; - case SID_FM_RECORD_NEXT : pAsciiURL = URL_RECORD_NEXT; break; - case SID_FM_RECORD_LAST : pAsciiURL = URL_RECORD_LAST; break; - case SID_FM_RECORD_SAVE : pAsciiURL = URL_RECORD_SAVE; break; - case SID_FM_RECORD_UNDO : pAsciiURL = URL_RECORD_UNDO; break; - case SID_FM_RECORD_NEW : pAsciiURL = URL_RECORD_NEW; break; - case SID_FM_RECORD_DELETE : pAsciiURL = URL_RECORD_DELETE; break; - case SID_FM_REFRESH : pAsciiURL = URL_FORM_REFRESH; break; - case SID_FM_REFRESH_FORM_CONTROL: pAsciiURL = URL_FORM_REFRESH_CURRENT_CONTROL; break; - - case SID_FM_SORTUP : pAsciiURL = URL_FORM_SORT_UP; break; - case SID_FM_SORTDOWN : pAsciiURL = URL_FORM_SORT_DOWN; break; - case SID_FM_ORDERCRIT : pAsciiURL = URL_FORM_SORT; break; - case SID_FM_AUTOFILTER : pAsciiURL = URL_FORM_AUTO_FILTER; break; - case SID_FM_FILTERCRIT : pAsciiURL = URL_FORM_FILTER; break; - case SID_FM_FORM_FILTERED : pAsciiURL = URL_FORM_APPLY_FILTER; break; - case SID_FM_REMOVE_FILTER_SORT : pAsciiURL = URL_FORM_REMOVE_FILTER; break; + const sal_Int16 nFormFeature; + const sal_Char* pAsciiURL; + + FeatureURL( const sal_Int16 _nFormFeature, const sal_Char* _pAsciiURL ) + :nFormFeature( _nFormFeature ) + ,pAsciiURL( _pAsciiURL ) + { + } }; - return 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_Int32 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL ) + sal_Int16 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL ) { - sal_Int32 nFeatureId = -1; - - if ( _rCompleteURL == URL_FORM_POSITION ) - nFeatureId = SID_FM_RECORD_ABSOLUTE; - else if ( _rCompleteURL == URL_FORM_RECORDCOUNT ) - nFeatureId = SID_FM_RECORD_TOTAL; - else if ( _rCompleteURL == URL_RECORD_FIRST ) - nFeatureId = SID_FM_RECORD_FIRST; - else if ( _rCompleteURL == URL_RECORD_PREV ) - nFeatureId = SID_FM_RECORD_PREV; - else if ( _rCompleteURL == URL_RECORD_NEXT ) - nFeatureId = SID_FM_RECORD_NEXT; - else if ( _rCompleteURL == URL_RECORD_LAST ) - nFeatureId = SID_FM_RECORD_LAST; - else if ( _rCompleteURL == URL_RECORD_SAVE ) - nFeatureId = SID_FM_RECORD_SAVE; - else if ( _rCompleteURL == URL_RECORD_UNDO ) - nFeatureId = SID_FM_RECORD_UNDO; - else if ( _rCompleteURL == URL_RECORD_NEW ) - nFeatureId = SID_FM_RECORD_NEW; - else if ( _rCompleteURL == URL_RECORD_DELETE ) - nFeatureId = SID_FM_RECORD_DELETE; - else if ( _rCompleteURL == URL_FORM_REFRESH ) - nFeatureId = SID_FM_REFRESH; - else if ( _rCompleteURL == URL_FORM_REFRESH_CURRENT_CONTROL ) - nFeatureId = SID_FM_REFRESH_FORM_CONTROL; - else if ( _rCompleteURL == URL_FORM_SORT_UP ) - nFeatureId = SID_FM_SORTUP; - else if ( _rCompleteURL == URL_FORM_SORT_DOWN ) - nFeatureId = SID_FM_SORTDOWN; - else if ( _rCompleteURL == URL_FORM_SORT ) - nFeatureId = SID_FM_ORDERCRIT; - else if ( _rCompleteURL == URL_FORM_AUTO_FILTER ) - nFeatureId = SID_FM_AUTOFILTER; - else if ( _rCompleteURL == URL_FORM_FILTER ) - nFeatureId = SID_FM_FILTERCRIT; - else if ( _rCompleteURL == URL_FORM_APPLY_FILTER ) - nFeatureId = SID_FM_FORM_FILTERED; - else if ( _rCompleteURL == URL_FORM_REMOVE_FILTER ) - nFeatureId = SID_FM_REMOVE_FILTER_SORT; - - DBG_ASSERT( ( -1 == nFeatureId ) || _rCompleteURL.equalsAscii( getFeatureURLAscii( nFeatureId ) ), - "OFormNavigationMapper::getFeatureId: inconsistent maps!" ); - - return nFeatureId; + const FeatureURL* pFeatures = lcl_getFeatureTable(); + while ( pFeatures->pAsciiURL ) + { + if ( _rCompleteURL.compareToAscii( pFeatures->pAsciiURL ) == 0 ) + return pFeatures->nFormFeature; + ++pFeatures; + } + return -1; } //......................................................................... diff --git a/forms/source/helper/makefile.mk b/forms/source/helper/makefile.mk index 5739d1fcb..e451048dd 100644 --- a/forms/source/helper/makefile.mk +++ b/forms/source/helper/makefile.mk @@ -53,6 +53,8 @@ SLOFILES= $(SLO)$/formnavigation.obj \ $(SLO)$/urltransformer.obj \ $(SLO)$/windowstateguard.obj \ $(SLO)$/resettable.obj \ + $(SLO)$/commandimageprovider.obj \ + $(SLO)$/commanddescriptionprovider.obj \ # --- Targets ---------------------------------- diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 85f3c3e5f..8fbce5b83 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -31,61 +31,61 @@ #ifndef _FORMS_FORMCOMPONENT_HXX_ #define _FORMS_FORMCOMPONENT_HXX_ -#include "cloneable.hxx"
-#include "ids.hxx"
-#include "property.hrc"
-#include "property.hxx"
-#include "propertybaghelper.hxx"
+#include "cloneable.hxx" +#include "ids.hxx" +#include "property.hrc" +#include "property.hxx" +#include "propertybaghelper.hxx" #include "resettable.hxx" -#include "services.hxx"
-#include "windowstateguard.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/awt/XControl.hpp>
-#include <com/sun/star/beans/XPropertyAccess.hpp>
-#include <com/sun/star/beans/XPropertyContainer.hpp>
-#include <com/sun/star/container/XChild.hpp>
-#include <com/sun/star/container/XNamed.hpp>
-#include <com/sun/star/form/binding/XBindableValue.hpp>
-#include <com/sun/star/form/FormComponentType.hpp>
-#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
-#include <com/sun/star/form/validation/XValidityConstraintListener.hpp>
-#include <com/sun/star/form/XBoundComponent.hpp>
-#include <com/sun/star/form/XBoundControl.hpp>
-#include <com/sun/star/form/XFormComponent.hpp>
-#include <com/sun/star/form/XLoadListener.hpp>
-#include <com/sun/star/form/XReset.hpp>
-#include <com/sun/star/io/XMarkableStream.hpp>
-#include <com/sun/star/io/XPersistObject.hpp>
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdb/XColumn.hpp>
-#include <com/sun/star/sdb/XColumnUpdate.hpp>
-#include <com/sun/star/sdb/XRowSetChangeListener.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#include <com/sun/star/uno/XAggregation.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
+#include "services.hxx" +#include "windowstateguard.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> +#include <com/sun/star/form/validation/XValidityConstraintListener.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> +#include <com/sun/star/form/XBoundControl.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XLoadListener.hpp> +#include <com/sun/star/form/XReset.hpp> +#include <com/sun/star/io/XMarkableStream.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdb/XColumn.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> +#include <com/sun/star/sdb/XRowSetChangeListener.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/form/XLoadable.hpp>
-/** === end UNO includes === **/
-
-#include <comphelper/componentcontext.hxx>
-#include <comphelper/propagg.hxx>
-#include <comphelper/propertybag.hxx>
-#include <comphelper/propmultiplex.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/uno3.hxx>
-#include <cppuhelper/component.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/implbase3.hxx>
-#include <cppuhelper/implbase4.hxx>
-#include <cppuhelper/implbase7.hxx>
-#include <osl/mutex.hxx>
-#include <rtl/ustring.hxx>
+#include <com/sun/star/form/XLoadable.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <comphelper/propagg.hxx> +#include <comphelper/propertybag.hxx> +#include <comphelper/propmultiplex.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase7.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> #include <memory> diff --git a/forms/source/inc/commanddescriptionprovider.hxx b/forms/source/inc/commanddescriptionprovider.hxx new file mode 100644 index 000000000..86b7ad111 --- /dev/null +++ b/forms/source/inc/commanddescriptionprovider.hxx @@ -0,0 +1,68 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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. +************************************************************************/ + +#ifndef COMMANDDESCRIPTIONPROVIDER_HXX +#define COMMANDDESCRIPTIONPROVIDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XModel.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +namespace frm +{ +//........................................................................ + + //==================================================================== + //= ICommandDescriptionProvider + //==================================================================== + class SAL_NO_VTABLE ICommandDescriptionProvider + { + public: + virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const = 0; + + virtual ~ICommandDescriptionProvider() { } + }; + + typedef ::boost::shared_ptr< const ICommandDescriptionProvider > PCommandDescriptionProvider; + + //===================================================================== + //= factory + //===================================================================== + PCommandDescriptionProvider + createDocumentCommandDescriptionProvider( + const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument + ); + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // COMMANDDESCRIPTIONPROVIDER_HXX diff --git a/forms/source/inc/commandimageprovider.hxx b/forms/source/inc/commandimageprovider.hxx new file mode 100644 index 000000000..79aafb977 --- /dev/null +++ b/forms/source/inc/commandimageprovider.hxx @@ -0,0 +1,77 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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. +************************************************************************/ + +#ifndef COMMANDIMAGEPROVIDER_HXX +#define COMMANDIMAGEPROVIDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XModel.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <vcl/image.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +namespace frm +{ +//........................................................................ + + //===================================================================== + //= ICommandImageProvider + //===================================================================== + typedef ::rtl::OUString CommandURL; + typedef ::com::sun::star::uno::Sequence< CommandURL > CommandURLs; + typedef ::std::vector< Image > CommandImages; + + class SAL_NO_VTABLE ICommandImageProvider + { + public: + virtual CommandImages getCommandImages( + const CommandURLs& _rCommandURLs, + const bool _bLarge, + const bool _bHiContrast + ) const = 0; + + virtual ~ICommandImageProvider() { } + }; + + typedef ::boost::shared_ptr< const ICommandImageProvider > PCommandImageProvider; + + //===================================================================== + //= factory + //===================================================================== + PCommandImageProvider + createDocumentCommandImageProvider( + const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument + ); + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // COMMANDIMAGEPROVIDER_HXX diff --git a/forms/source/inc/featuredispatcher.hxx b/forms/source/inc/featuredispatcher.hxx index ebc52f088..64539cff7 100644 --- a/forms/source/inc/featuredispatcher.hxx +++ b/forms/source/inc/featuredispatcher.hxx @@ -49,7 +49,7 @@ namespace frm @param _nFeatureId the id of the feature to dispatch */ - virtual void dispatch( sal_Int32 _nFeatureId ) const = 0; + virtual void dispatch( sal_Int16 _nFeatureId ) const = 0; /** dispatches a feature, with an additional named parameter @@ -63,14 +63,14 @@ namespace frm the value of the parameter of the dispatch call */ virtual void dispatchWithArgument( - sal_Int32 _nFeatureId, + sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const = 0; /** checks whether a given feature is enabled */ - virtual bool isEnabled( sal_Int32 _nFeatureId ) const = 0; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const = 0; /** returns the boolean state of a feature @@ -81,7 +81,7 @@ namespace frm This method allows retrieving status information about features which have an additional boolean information associated with it. */ - virtual bool getBooleanState( sal_Int32 _nFeatureId ) const = 0; + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const = 0; /** returns the string state of a feature @@ -92,7 +92,7 @@ namespace frm This method allows retrieving status information about features which have an additional string information associated with it. */ - virtual ::rtl::OUString getStringState( sal_Int32 _nFeatureId ) const = 0; + virtual ::rtl::OUString getStringState( sal_Int16 _nFeatureId ) const = 0; /** returns the integer state of a feature @@ -103,7 +103,7 @@ namespace frm This method allows retrieving status information about features which have an additional integer information associated with it. */ - virtual sal_Int32 getIntegerState( sal_Int32 _nFeatureId ) const = 0; + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const = 0; }; //......................................................................... diff --git a/forms/source/inc/formnavigation.hxx b/forms/source/inc/formnavigation.hxx index d0abf0cf8..ae786aefd 100644 --- a/forms/source/inc/formnavigation.hxx +++ b/forms/source/inc/formnavigation.hxx @@ -71,7 +71,7 @@ namespace frm FeatureInfo() : bCachedState( sal_False ) { } }; - typedef ::std::map< sal_Int32, FeatureInfo > FeatureMap; + typedef ::std::map< sal_Int16, FeatureInfo > FeatureMap; private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > @@ -106,12 +106,12 @@ namespace frm virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); // IFeatureDispatcher - virtual void dispatch( sal_Int32 _nFeatureId ) const; - virtual void dispatchWithArgument( sal_Int32 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const; - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; - virtual bool getBooleanState( sal_Int32 _nFeatureId ) const; - virtual ::rtl::OUString getStringState( sal_Int32 _nFeatureId ) const; - virtual sal_Int32 getIntegerState( sal_Int32 _nFeatureId ) const; + virtual void dispatch( sal_Int16 _nFeatureId ) const; + virtual void dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const; + virtual ::rtl::OUString getStringState( sal_Int16 _nFeatureId ) const; + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const; // own overridables /** is called when the interceptors have. @@ -134,7 +134,7 @@ namespace frm determines if the features is enabled or disabled @see getBooleanState */ - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); /** notification for (potential) changes in the state of all features <p>The base class implementation does nothing. Derived classes could force @@ -149,7 +149,7 @@ namespace frm the array of features to support. Out parameter to fill by the derivee's implementation @pure */ - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ) = 0; + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0; protected: /** update all our dispatches which are controlled by our dispatch interceptors @@ -205,7 +205,7 @@ namespace frm @complexity O(log n) @return NULL if the given id is not a known feature id (which is a valid usage) */ - const char* getFeatureURLAscii( sal_Int32 _nFeatureId ); + const char* getFeatureURLAscii( sal_Int16 _nFeatureId ); /** retrieves the feature URL belonging to an feature id @@ -214,7 +214,7 @@ namespace frm <TRUE/> if and only if the given id is a known feature id (which is a valid usage) */ - bool getFeatureURL( sal_Int32 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL ); + bool getFeatureURL( sal_Int16 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL ); /** retrieves the feature id belonging to an feature URL @@ -223,7 +223,7 @@ namespace frm the id of the feature URL, or -1 if the URl is not known (which is a valid usage) */ - sal_Int32 getFeatureId( const ::rtl::OUString& _rCompleteURL ); + sal_Int16 getFeatureId( const ::rtl::OUString& _rCompleteURL ); private: OFormNavigationMapper( ); // never implemented diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index b153321de..63ad54d56 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -153,7 +153,7 @@ namespace frm FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_SELECT_SEQ, "DefaultSelection" ); FORMS_CONSTASCII_STRING( PROPERTY_MULTISELECTION, "MultiSelection" ); FORMS_CONSTASCII_STRING( PROPERTY_ALIGN, "Align" ); - FORMS_CONSTASCII_STRING( PROPERTY_VERTICALALIGN, "VerticalAlign" ); + FORMS_CONSTASCII_STRING( PROPERTY_VERTICAL_ALIGN, "VerticalAlign" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_DATE, "DefaultDate" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_TIME, "DefaultTime" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_VALUE, "DefaultValue" ); diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index 100a693a9..4d1b5d819 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -63,7 +63,7 @@ namespace frm #define PROPERTY_ID_INPUT_REQUIRED (PROPERTY_ID_START + 19) #define PROPERTY_ID_WRITING_MODE (PROPERTY_ID_START + 20) #define PROPERTY_ID_CONTEXT_WRITING_MODE (PROPERTY_ID_START + 21) - // free +#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) // free // free // free diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index c1454eea6..fe99d39dd 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -40,7 +40,9 @@ /** === begin UNO includes === **/ #include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> /** === end UNO includes === **/ + #include <cppuhelper/typeprovider.hxx> #include <comphelper/guarding.hxx> #include <toolkit/awt/vclxdevice.hxx> @@ -67,6 +69,7 @@ namespace frm using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; using namespace ::com::sun::star::util; + using namespace ::com::sun::star::style; namespace WritingMode2 = ::com::sun::star::text::WritingMode2; @@ -120,6 +123,7 @@ namespace frm m_aTabStop = _pOriginal->m_aTabStop; m_aBackgroundColor = _pOriginal->m_aBackgroundColor; m_aBorderColor = _pOriginal->m_aBorderColor; + m_aVerticalAlignment = _pOriginal->m_aVerticalAlignment; m_sDefaultControl = _pOriginal->m_sDefaultControl; m_sHelpText = _pOriginal->m_sHelpText; m_sHelpURL = _pOriginal->m_sHelpURL; @@ -201,9 +205,10 @@ namespace frm REGISTER_PROP_2( RICH_TEXT, m_bReallyActAsRichText, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HIDEINACTIVESELECTION, m_bHideInactiveSelection, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( TABSTOP, m_aTabStop, sal_Bool, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BORDERCOLOR, m_aBorderColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( TABSTOP, m_aTabStop, sal_Bool, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( BORDERCOLOR, m_aBorderColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( VERTICAL_ALIGN, m_aVerticalAlignment, VerticalAlignment, BOUND, MAYBEDEFAULT ); // properties which exist only for compatibility with the css.swt.UnoControlEditModel, // since we replace the default implementation for this service @@ -455,6 +460,7 @@ namespace frm case PROPERTY_ID_TABSTOP: case PROPERTY_ID_BACKGROUNDCOLOR: case PROPERTY_ID_BORDERCOLOR: + case PROPERTY_ID_VERTICAL_ALIGN: /* void */ break; diff --git a/forms/source/richtext/richtextmodel.hxx b/forms/source/richtext/richtextmodel.hxx index b6629aea2..e6c1f0a63 100644 --- a/forms/source/richtext/richtextmodel.hxx +++ b/forms/source/richtext/richtextmodel.hxx @@ -74,6 +74,7 @@ namespace frm ::com::sun::star::uno::Any m_aTabStop; ::com::sun::star::uno::Any m_aBackgroundColor; ::com::sun::star::uno::Any m_aBorderColor; + ::com::sun::star::uno::Any m_aVerticalAlignment; ::rtl::OUString m_sDefaultControl; ::rtl::OUString m_sHelpText; ::rtl::OUString m_sHelpURL; @@ -115,7 +116,7 @@ namespace frm DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel ); // UNO - DECLARE_UNO3_AGG_DEFAULTS( ONavigationBarModel, OControlModel ); + DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel ); virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 55bccbffe..66e2065a6 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -92,7 +92,7 @@ namespace frm using ::com::sun::star::uno::XInterface; using ::com::sun::star::sdbc::XRowSet; using ::com::sun::star::sdbc::XResultSetUpdate; - using ::com::sun::star::form::XFormController; + using ::com::sun::star::form::runtime::XFormController; using ::com::sun::star::form::runtime::XFeatureInvalidation; using ::com::sun::star::form::runtime::FeatureState; using ::com::sun::star::lang::IllegalArgumentException; diff --git a/forms/source/runtime/formoperations.hxx b/forms/source/runtime/formoperations.hxx index 4f1de98ae..9b3fe559d 100644 --- a/forms/source/runtime/formoperations.hxx +++ b/forms/source/runtime/formoperations.hxx @@ -71,16 +71,16 @@ namespace frm class MethodGuard; private: - ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xCursor; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xUpdateCursor; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCursorProperties; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xLoadableForm; + ::comphelper::ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xCursor; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xUpdateCursor; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCursorProperties; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xLoadableForm; ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > - m_xFeatureInvalidation; + m_xFeatureInvalidation; mutable ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > - m_xParser; + m_xParser; bool m_bInitializedParser; bool m_bActiveControlModified; @@ -132,7 +132,7 @@ namespace frm // XFormOperations virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getCursor() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > SAL_CALL getUpdateCursor() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > SAL_CALL getController() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getController() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > SAL_CALL getFeatureInvalidation() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setFeatureInvalidation(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > & the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::form::runtime::FeatureState SAL_CALL getState(::sal_Int16 Feature) throw (::com::sun::star::uno::RuntimeException); @@ -163,7 +163,7 @@ namespace frm private: // service constructors - void createWithFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void createWithFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); void createWithForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); /** determines whether or not we're already disposed diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index dac97eda2..e4d93d8c6 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -34,17 +34,23 @@ #include "navbarcontrol.hxx" #include "frm_strings.hxx" #include "frm_module.hxx" -#include "navtoolbar.hxx" #include "FormComponent.hxx" +#include "componenttools.hxx" +#include "navtoolbar.hxx" +#include "commandimageprovider.hxx" +#include "commanddescriptionprovider.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/XView.hpp> #include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/form/runtime/FormFeature.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> /** === end UNO includes === **/ #include <tools/debug.hxx> +#include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> -#include <svx/svxids.hrc> //-------------------------------------------------------------------------- extern "C" void SAL_CALL createRegistryInfo_ONavigationBarControl() @@ -62,6 +68,8 @@ namespace frm using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; + using namespace ::com::sun::star::graphic; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; #define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \ Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ @@ -129,7 +137,8 @@ namespace frm //------------------------------------------------------------------ namespace { - static WinBits getWinBits( const Reference< XControlModel >& _rxModel ) + //.............................................................. + static WinBits lcl_getWinBits_nothrow( const Reference< XControlModel >& _rxModel ) { WinBits nBits = 0; try @@ -149,7 +158,7 @@ namespace frm } catch( const Exception& ) { - DBG_ERROR( "::getWinBits: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return nBits; } @@ -175,7 +184,7 @@ namespace frm } // create the peer - ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getWinBits( getModel() ) ); + ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getModel() ); DBG_ASSERT( pPeer, "ONavigationBarControl::createPeer: invalid peer returned!" ); if ( pPeer ) // by definition, the returned component is aquired once @@ -267,7 +276,7 @@ namespace frm DBG_NAME( ONavigationBarPeer ) //------------------------------------------------------------------ ONavigationBarPeer* ONavigationBarPeer::Create( const Reference< XMultiServiceFactory >& _rxORB, - Window* _pParentWindow, WinBits _nStyle ) + Window* _pParentWindow, const Reference< XControlModel >& _rxModel ) { DBG_TESTSOLARMUTEX(); @@ -276,7 +285,13 @@ namespace frm pPeer->acquire(); // by definition, the returned object is aquired once // the VCL control for the peer - NavigationToolBar* pNavBar = new NavigationToolBar( _pParentWindow, _nStyle ); + Reference< XModel > xContextDocument( getXModel( _rxModel ) ); + NavigationToolBar* pNavBar = new NavigationToolBar( + _pParentWindow, + lcl_getWinBits_nothrow( _rxModel ), + createDocumentCommandImageProvider( _rxORB, xContextDocument ), + createDocumentCommandDescriptionProvider( _rxORB, xContextDocument ) + ); // some knittings pNavBar->setDispatcher( pPeer ); @@ -456,7 +471,7 @@ namespace frm } //------------------------------------------------------------------ - void ONavigationBarPeer::featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ) + void ONavigationBarPeer::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ) { // enable this button on the toolbox NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() ); @@ -465,15 +480,15 @@ namespace frm pNavBar->enableFeature( _nFeatureId, _bEnabled ); // is it a feature with additional state information? - if ( _nFeatureId == SID_FM_FORM_FILTERED ) + if ( _nFeatureId == FormFeature::ToggleApplyFilter ) { // additional boolean state pNavBar->checkFeature( _nFeatureId, getBooleanState( _nFeatureId ) ); } - else if ( _nFeatureId == SID_FM_RECORD_TOTAL ) + else if ( _nFeatureId == FormFeature::TotalRecords ) { pNavBar->setFeatureText( _nFeatureId, getStringState( _nFeatureId ) ); } - else if ( _nFeatureId == SID_FM_RECORD_ABSOLUTE ) + else if ( _nFeatureId == FormFeature::MoveAbsolute ) { pNavBar->setFeatureText( _nFeatureId, String::CreateFromInt32( getIntegerState( _nFeatureId ) ) ); } @@ -496,7 +511,7 @@ namespace frm } //------------------------------------------------------------------ - bool ONavigationBarPeer::isEnabled( sal_Int32 _nFeatureId ) const + bool ONavigationBarPeer::isEnabled( sal_Int16 _nFeatureId ) const { if ( const_cast< ONavigationBarPeer* >( this )->isDesignMode() ) return false; @@ -524,27 +539,27 @@ namespace frm } //------------------------------------------------------------------ - void ONavigationBarPeer::getSupportedFeatures( ::std::vector< sal_Int32 >& _rFeatureIds ) + void ONavigationBarPeer::getSupportedFeatures( ::std::vector< sal_Int16 >& _rFeatureIds ) { - _rFeatureIds.push_back( SID_FM_RECORD_ABSOLUTE ); - _rFeatureIds.push_back( SID_FM_RECORD_TOTAL ); - _rFeatureIds.push_back( SID_FM_RECORD_FIRST ); - _rFeatureIds.push_back( SID_FM_RECORD_PREV ); - _rFeatureIds.push_back( SID_FM_RECORD_NEXT ); - _rFeatureIds.push_back( SID_FM_RECORD_LAST ); - _rFeatureIds.push_back( SID_FM_RECORD_SAVE ); - _rFeatureIds.push_back( SID_FM_RECORD_UNDO ); - _rFeatureIds.push_back( SID_FM_RECORD_NEW ); - _rFeatureIds.push_back( SID_FM_RECORD_DELETE ); - _rFeatureIds.push_back( SID_FM_REFRESH ); - _rFeatureIds.push_back( SID_FM_REFRESH_FORM_CONTROL ); - _rFeatureIds.push_back( SID_FM_SORTUP ); - _rFeatureIds.push_back( SID_FM_SORTDOWN ); - _rFeatureIds.push_back( SID_FM_ORDERCRIT ); - _rFeatureIds.push_back( SID_FM_AUTOFILTER ); - _rFeatureIds.push_back( SID_FM_FILTERCRIT ); - _rFeatureIds.push_back( SID_FM_FORM_FILTERED ); - _rFeatureIds.push_back( SID_FM_REMOVE_FILTER_SORT ); + _rFeatureIds.push_back( FormFeature::MoveAbsolute ); + _rFeatureIds.push_back( FormFeature::TotalRecords ); + _rFeatureIds.push_back( FormFeature::MoveToFirst ); + _rFeatureIds.push_back( FormFeature::MoveToPrevious ); + _rFeatureIds.push_back( FormFeature::MoveToNext ); + _rFeatureIds.push_back( FormFeature::MoveToLast ); + _rFeatureIds.push_back( FormFeature::SaveRecordChanges ); + _rFeatureIds.push_back( FormFeature::UndoRecordChanges ); + _rFeatureIds.push_back( FormFeature::MoveToInsertRow ); + _rFeatureIds.push_back( FormFeature::DeleteRecord ); + _rFeatureIds.push_back( FormFeature::ReloadForm ); + _rFeatureIds.push_back( FormFeature::RefreshCurrentControl ); + _rFeatureIds.push_back( FormFeature::SortAscending ); + _rFeatureIds.push_back( FormFeature::SortDescending ); + _rFeatureIds.push_back( FormFeature::InteractiveSort ); + _rFeatureIds.push_back( FormFeature::AutoFilter ); + _rFeatureIds.push_back( FormFeature::InteractiveFilter ); + _rFeatureIds.push_back( FormFeature::ToggleApplyFilter ); + _rFeatureIds.push_back( FormFeature::RemoveFilterAndSort ); } //......................................................................... diff --git a/forms/source/solar/component/navbarcontrol.hxx b/forms/source/solar/component/navbarcontrol.hxx index 116684e6a..cda9b2571 100644 --- a/forms/source/solar/component/navbarcontrol.hxx +++ b/forms/source/solar/component/navbarcontrol.hxx @@ -31,14 +31,18 @@ #ifndef FORMS_NAVBARCONTROL_HXX #define FORMS_NAVBARCONTROL_HXX +#include "formnavigation.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +/** === end UNO includes === **/ + #include <toolkit/controls/unocontrol.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <comphelper/uno3.hxx> #include <cppuhelper/implbase1.hxx> #include <vcl/wintypes.hxx> -#include <com/sun/star/frame/XDispatchProviderInterception.hpp> -#include <com/sun/star/frame/XStatusListener.hpp> -#include "formnavigation.hxx" //......................................................................... namespace frm @@ -111,11 +115,13 @@ namespace frm static ONavigationBarPeer* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, Window* _pParentWindow, - WinBits _nStyle + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ); protected: - ONavigationBarPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ); + ONavigationBarPeer( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + ); ~ONavigationBarPeer(); public: @@ -144,12 +150,12 @@ namespace frm // OFormNavigationHelper overriables virtual void interceptorsChanged( ); - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); virtual void allFeatureStatesChanged( ); - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ); + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ); // IFeatureDispatcher overriables - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; }; //......................................................................... diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index a79c8af55..a50b17665 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -30,39 +30,41 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" + #include "navtoolbar.hxx" #include "frm_resource.hxx" -#ifndef _FRM_RESOURCE_HRC_ -#include "frm_resource.hrc" -#endif -#include <vcl/fixed.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#include <sfx2/msgpool.hxx> -#include <sfx2/imgmgr.hxx> #include "featuredispatcher.hxx" +#include "frm_resource.hrc" +#include "commandimageprovider.hxx" +#include "commanddescriptionprovider.hxx" + #include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/form/runtime/FormFeature.hpp> + +#include <sfx2/imgmgr.hxx> +#include <vcl/fixed.hxx> #include <memory> -#define LID_RECORD_LABEL 1 -#define LID_RECORD_FILLER 2 +#define LID_RECORD_LABEL 1000 +#define LID_RECORD_FILLER 1001 //......................................................................... namespace frm { //......................................................................... + using ::com::sun::star::uno::makeAny; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; + //===================================================================== //..................................................................... namespace { - static bool isSfxSlot( sal_Int32 _nFeatureId ) + static bool isArtificialItem( sal_Int16 _nFeatureId ) { - // everything we use in this class is an SFX-slot - except the LID_* ids - return ( _nFeatureId != LID_RECORD_LABEL ) - && ( _nFeatureId != LID_RECORD_FILLER ); + return ( _nFeatureId == LID_RECORD_LABEL ) + || ( _nFeatureId == LID_RECORD_FILLER ); } static String getLabelString( USHORT _nResId ) @@ -72,6 +74,38 @@ namespace frm sLabel += String::CreateFromAscii( " " ); return sLabel; } + + ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature ) + { + const sal_Char* pAsciiCommandName = NULL; + switch ( _nFormFeature ) + { + case FormFeature::MoveAbsolute : pAsciiCommandName = "AbsoluteRecord"; break; + case FormFeature::TotalRecords : pAsciiCommandName = "RecTotal"; break; + case FormFeature::MoveToFirst : pAsciiCommandName = "FirstRecord"; break; + case FormFeature::MoveToPrevious : pAsciiCommandName = "PrevRecord"; break; + case FormFeature::MoveToNext : pAsciiCommandName = "NextRecord"; break; + case FormFeature::MoveToLast : pAsciiCommandName = "LastRecord"; break; + case FormFeature::SaveRecordChanges : pAsciiCommandName = "RecSave"; break; + case FormFeature::UndoRecordChanges : pAsciiCommandName = "RecUndo"; break; + case FormFeature::MoveToInsertRow : pAsciiCommandName = "NewRecord"; break; + case FormFeature::DeleteRecord : pAsciiCommandName = "DeleteRecord"; break; + case FormFeature::ReloadForm : pAsciiCommandName = "Refresh"; break; + case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break; + case FormFeature::SortAscending : pAsciiCommandName = "Sortup"; break; + case FormFeature::SortDescending : pAsciiCommandName = "SortDown"; break; + case FormFeature::InteractiveSort : pAsciiCommandName = "OrderCrit"; break; + case FormFeature::AutoFilter : pAsciiCommandName = "AutoFilter"; break; + case FormFeature::InteractiveFilter : pAsciiCommandName = "FilterCrit"; break; + case FormFeature::ToggleApplyFilter : pAsciiCommandName = "FormFiltered"; break; + case FormFeature::RemoveFilterAndSort : pAsciiCommandName = "RemoveFilterSort"; break; + } + if ( pAsciiCommandName != NULL ) + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName ); + + OSL_ENSURE( false, "lcl_getCommandURL: unknown FormFeature!" ); + return ::rtl::OUString(); + } } //===================================================================== @@ -119,9 +153,12 @@ namespace frm //===================================================================== DBG_NAME( NavigationToolBar ) //--------------------------------------------------------------------- - NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle ) + NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider, + const PCommandDescriptionProvider& _pDescriptionProvider ) :Window( _pParent, _nStyle ) ,m_pDispatcher( NULL ) + ,m_pImageProvider( _pImageProvider ) + ,m_pDescriptionProvider( _pDescriptionProvider ) ,m_eImageSize( eSmall ) ,m_pToolbar( NULL ) { @@ -150,7 +187,7 @@ namespace frm m_pToolbar->setDispatcher( _pDispatcher ); - RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( SID_FM_RECORD_ABSOLUTE ) ); + RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) ); OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" ); if ( pPositionWindow ) pPositionWindow->setDispatcher( _pDispatcher ); @@ -179,15 +216,15 @@ namespace frm { m_pToolbar->EnableItem( _nItemId, _bEnabled ); - if ( _nItemId == SID_FM_RECORD_ABSOLUTE ) + if ( _nItemId == FormFeature::MoveAbsolute ) m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled ); - if ( _nItemId == SID_FM_RECORD_TOTAL ) + if ( _nItemId == FormFeature::TotalRecords ) m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled ); } //--------------------------------------------------------------------- - void NavigationToolBar::enableFeature( sal_Int32 _nFeatureId, bool _bEnabled ) + void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::enableFeature: invalid id!" ); @@ -196,7 +233,7 @@ namespace frm } //--------------------------------------------------------------------- - void NavigationToolBar::checkFeature( sal_Int32 _nFeatureId, bool _bEnabled ) + void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::checkFeature: invalid id!" ); @@ -205,7 +242,7 @@ namespace frm } //--------------------------------------------------------------------- - void NavigationToolBar::setFeatureText( sal_Int32 _nFeatureId, const ::rtl::OUString& _rText ) + void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::checkFeature: invalid id!" ); @@ -228,71 +265,67 @@ namespace frm // items. We could duplicate all the information here in our lib // (such as the item text and the image), but why should we? - struct SlotDescription + struct FeatureDescription { USHORT nId; bool bRepeat; bool bItemWindow; - } aSupportedSlots[] = + } aSupportedFeatures[] = { - { LID_RECORD_LABEL, false, true }, - { SID_FM_RECORD_ABSOLUTE, false, true }, - { LID_RECORD_FILLER, false, true }, - { SID_FM_RECORD_TOTAL, false, true }, - - { SID_FM_RECORD_FIRST, true, false }, - { SID_FM_RECORD_PREV, true, false }, - { SID_FM_RECORD_NEXT, true, false }, - { SID_FM_RECORD_LAST, true, false }, + { LID_RECORD_LABEL, false, true }, + { FormFeature::MoveAbsolute, false, true }, + { LID_RECORD_FILLER, false, true }, + { FormFeature::TotalRecords, false, true }, + { FormFeature::MoveToFirst, true, false }, + { FormFeature::MoveToPrevious, true, false }, + { FormFeature::MoveToNext, true, false }, + { FormFeature::MoveToLast, true, false }, + { FormFeature::MoveToInsertRow, false, false }, { 0, false, false }, - { SID_FM_RECORD_SAVE, false, false }, - { SID_FM_RECORD_UNDO, false, false }, - { SID_FM_RECORD_NEW, false, false }, - { SID_FM_RECORD_DELETE, false, false }, - { SID_FM_REFRESH, false, false }, - { SID_FM_REFRESH_FORM_CONTROL, false, false }, + { FormFeature::SaveRecordChanges, false, false }, + { FormFeature::UndoRecordChanges, false, false }, + { FormFeature::DeleteRecord, false, false }, + { FormFeature::ReloadForm, false, false }, + { FormFeature::RefreshCurrentControl, false, false }, { 0, false, false }, - { SID_FM_SORTUP, false, false }, - { SID_FM_SORTDOWN, false, false }, - { SID_FM_ORDERCRIT, false, false }, - { SID_FM_AUTOFILTER, false, false }, - { SID_FM_FILTERCRIT, false, false }, - { SID_FM_FORM_FILTERED, false, false }, - { SID_FM_REMOVE_FILTER_SORT, false, false }, + { FormFeature::SortAscending, false, false }, + { FormFeature::SortDescending, false, false }, + { FormFeature::InteractiveSort, false, false }, + { FormFeature::AutoFilter, false, false }, + { FormFeature::InteractiveFilter, false, false }, + { FormFeature::ToggleApplyFilter, false, false }, + { FormFeature::RemoveFilterAndSort, false, false }, }; - size_t nSupportedSlots = sizeof( aSupportedSlots ) / sizeof( aSupportedSlots[0] ); - SlotDescription* pSupportedSlots = aSupportedSlots; - SlotDescription* pSupportedSlotsEnd = aSupportedSlots + nSupportedSlots; - for ( ; pSupportedSlots < pSupportedSlotsEnd; ++pSupportedSlots ) + size_t nSupportedFeatures = sizeof( aSupportedFeatures ) / sizeof( aSupportedFeatures[0] ); + FeatureDescription* pSupportedFeatures = aSupportedFeatures; + FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures; + for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures ) { - if ( pSupportedSlots->nId ) + if ( pSupportedFeatures->nId ) { // it's _not_ a separator - // the text(s) of the item - String sItemText; - String sItemHelpText; - - // TODO/CLEANUP: this code does nothing(!) nowadays - //SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL ); - //sItemText = rSlotPool.GetSlotName( pSupportedSlots->nId, &sItemHelpText ); - // insert the entry - m_pToolbar->InsertItem( pSupportedSlots->nId, sItemText, pSupportedSlots->bRepeat ? TIB_REPEAT : 0 ); - m_pToolbar->SetQuickHelpText( pSupportedSlots->nId, sItemHelpText ); - if ( isSfxSlot( pSupportedSlots->nId ) ) - m_pToolbar->SetHelpId( pSupportedSlots->nId, pSupportedSlots->nId ); + m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 ); + m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() ); // TODO + if ( !isArtificialItem( pSupportedFeatures->nId ) ) + { + ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) ); + m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL ); + if ( m_pDescriptionProvider ) + m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) ); + } - if ( pSupportedSlots->bItemWindow ) + if ( pSupportedFeatures->bItemWindow ) { Window* pItemWindow = NULL; - if ( SID_FM_RECORD_ABSOLUTE == pSupportedSlots->nId ) + if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId ) { pItemWindow = new RecordPositionInput( m_pToolbar ); static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher ); } - else if ( LID_RECORD_FILLER == pSupportedSlots->nId ) + else if ( LID_RECORD_FILLER == pSupportedFeatures->nId ) { pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER ); pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT))); @@ -305,7 +338,7 @@ namespace frm } m_aChildWins.push_back( pItemWindow ); - switch ( pSupportedSlots->nId ) + switch ( pSupportedFeatures->nId ) { case LID_RECORD_LABEL: pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) ); @@ -316,7 +349,7 @@ namespace frm break; } - m_pToolbar->SetItemWindow( pSupportedSlots->nId, pItemWindow ); + m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow ); } } else @@ -327,25 +360,66 @@ namespace frm forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL ); - // the image of the item - ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) ); - pImageManager->SetImagesForceSize( *m_pToolbar, FALSE, m_eImageSize == eLarge ); + implUpdateImages(); + } + + //--------------------------------------------------------------------- + void NavigationToolBar::implUpdateImages() + { + OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" ); + if ( !m_pImageProvider ) + return; + + const bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + + const USHORT nItemCount = m_pToolbar->GetItemCount(); + + // collect the FormFeatures in the toolbar + typedef ::std::vector< sal_Int16 > FormFeatures; + FormFeatures aFormFeatures; + aFormFeatures.reserve( nItemCount ); + + for ( USHORT i=0; i<nItemCount; ++i ) + { + USHORT nId = m_pToolbar->GetItemId( i ); + if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) ) + aFormFeatures.push_back( nId ); + } + + // translate them into command URLs + CommandURLs aCommandURLs( aFormFeatures.size() ); + for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin(); + formFeature != aFormFeatures.end(); + ++formFeature + ) + { + aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature ); + } + + // retrieve the images for the command URLs + CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge, bIsHighContrast ); + + // and set them at the toolbar + CommandImages::const_iterator commandImage = aCommandImages.begin(); + for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin(); + formFeature != aFormFeatures.end(); + ++formFeature, ++commandImage + ) + { + m_pToolbar->SetItemImage( *formFeature, *commandImage ); + } // parts of our layout is dependent on the size of our icons Resize(); } //--------------------------------------------------------------------- - void NavigationToolBar::implSetImageSize( ImageSize _eSize, bool _bForce ) + void NavigationToolBar::implSetImageSize( ImageSize _eSize ) { - if ( ( _eSize != m_eImageSize ) || _bForce ) + if ( _eSize != m_eImageSize ) { m_eImageSize = _eSize; - ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) ); - pImageManager->SetImagesForceSize( *m_pToolbar, GetSettings().GetStyleSettings().GetHighContrastMode(), m_eImageSize == eLarge ); - - // parts of our layout is dependent on the size of our icons - Resize(); + implUpdateImages(); } } @@ -365,7 +439,7 @@ namespace frm case ePosition: { static const USHORT aPositionIds[] = { - LID_RECORD_LABEL, SID_FM_RECORD_ABSOLUTE, LID_RECORD_FILLER, SID_FM_RECORD_TOTAL, 0 + LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0 }; pGroupIds = aPositionIds; } @@ -373,7 +447,7 @@ namespace frm case eNavigation: { static const USHORT aNavigationIds[] = { - SID_FM_RECORD_FIRST, SID_FM_RECORD_PREV, SID_FM_RECORD_NEXT, SID_FM_RECORD_LAST, 0 + FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0 }; pGroupIds = aNavigationIds; } @@ -381,7 +455,7 @@ namespace frm case eRecordActions: { static const USHORT aActionIds[] = { - SID_FM_RECORD_SAVE, SID_FM_RECORD_UNDO, SID_FM_RECORD_NEW, SID_FM_RECORD_DELETE, SID_FM_REFRESH, SID_FM_REFRESH_FORM_CONTROL, 0 + FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0 }; pGroupIds = aActionIds; } @@ -389,7 +463,7 @@ namespace frm case eFilterSort: { static const USHORT aFilterSortIds[] = { - SID_FM_SORTUP, SID_FM_SORTDOWN, SID_FM_ORDERCRIT, SID_FM_AUTOFILTER, SID_FM_FILTERCRIT, SID_FM_FORM_FILTERED, SID_FM_REMOVE_FILTER_SORT, 0 + FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0 }; pGroupIds = aFilterSortIds; } @@ -410,9 +484,9 @@ namespace frm switch ( _eGroup ) { case ePosition : nIndicatorItem = LID_RECORD_LABEL; break; - case eNavigation : nIndicatorItem = SID_FM_RECORD_FIRST; break; - case eRecordActions : nIndicatorItem = SID_FM_RECORD_SAVE; break; - case eFilterSort : nIndicatorItem = SID_FM_SORTUP; break; + case eNavigation : nIndicatorItem = FormFeature::MoveToFirst; break; + case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges; break; + case eFilterSort : nIndicatorItem = FormFeature::SortAscending; break; default: OSL_ENSURE( sal_False, "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" ); } @@ -477,7 +551,7 @@ namespace frm // the contrast of the background color may have changed, so force // the images to be rebuild (high contrast requires a possibly different // image set) - implSetImageSize( m_eImageSize, true ); + implUpdateImages(); } //--------------------------------------------------------------------- @@ -490,7 +564,7 @@ namespace frm // the contrast of the background color may have changed, so force // the images to be rebuild (high contrast requires a possibly different // image set) - implSetImageSize( m_eImageSize, true ); + implUpdateImages(); } //--------------------------------------------------------------------- @@ -579,11 +653,11 @@ namespace frm sItemText = getLabelString( RID_STR_LABEL_OF ); break; - case SID_FM_RECORD_ABSOLUTE: + case FormFeature::MoveAbsolute: sItemText = String::CreateFromAscii( "12345678" ); break; - case SID_FM_RECORD_TOTAL: + case FormFeature::TotalRecords: sItemText = String::CreateFromAscii( "123456" ); break; } @@ -638,7 +712,7 @@ namespace frm return; if ( m_pDispatcher ) - m_pDispatcher->dispatchWithArgument( SID_FM_RECORD_ABSOLUTE, "Position", ::com::sun::star::uno::makeAny( (sal_Int32)nRecord ) ); + m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) ); SaveValue(); } diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx index 3f55773fd..6e1caea56 100644 --- a/forms/source/solar/inc/navtoolbar.hxx +++ b/forms/source/solar/inc/navtoolbar.hxx @@ -34,14 +34,19 @@ #include <vcl/toolbox.hxx> #include <vcl/field.hxx> +#include <boost/shared_ptr.hpp> + //......................................................................... namespace frm { //......................................................................... class IFeatureDispatcher; + class ICommandImageProvider; + class ICommandDescriptionProvider; class ImplNavToolBar; + //===================================================================== //= NavigationToolBar //===================================================================== @@ -63,13 +68,22 @@ namespace frm }; private: - const IFeatureDispatcher* m_pDispatcher; - ImageSize m_eImageSize; - ImplNavToolBar* m_pToolbar; - ::std::vector< Window* > m_aChildWins; + const IFeatureDispatcher* m_pDispatcher; + const ::boost::shared_ptr< const ICommandImageProvider > + m_pImageProvider; + const ::boost::shared_ptr< const ICommandDescriptionProvider > + m_pDescriptionProvider; + ImageSize m_eImageSize; + ImplNavToolBar* m_pToolbar; + ::std::vector< Window* > m_aChildWins; public: - NavigationToolBar( Window* _pParent, WinBits _nStyle ); + NavigationToolBar( + Window* _pParent, + WinBits _nStyle, + const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider, + const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider + ); ~NavigationToolBar( ); /** sets the dispatcher which is to be used for the features @@ -82,19 +96,16 @@ namespace frm ensuring the life time of the object does exceed the life time of the tool bar instance. */ - void setDispatcher( const IFeatureDispatcher* _pDispatcher ); + void setDispatcher( const IFeatureDispatcher* _pDispatcher ); - /** enables or disables a given feature - */ - void enableFeature( sal_Int32 _nFeatureId, bool _bEnabled ); + /// enables or disables a given feature + void enableFeature( sal_Int16 _nFeatureId, bool _bEnabled ); - /** checks or unchecks a given feature - */ - void checkFeature( sal_Int32 _nFeatureId, bool _bEnabled ); + /// checks or unchecks a given feature + void checkFeature( sal_Int16 _nFeatureId, bool _bEnabled ); - /** sets the text of a given feature - */ - void setFeatureText( sal_Int32 _nFeatureId, const ::rtl::OUString& _rText ); + /// sets the text of a given feature + void setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText ); /** retrieves the current image size */ @@ -127,7 +138,10 @@ namespace frm void implInit( ); /// impl version of SetImageSize - void implSetImageSize( ImageSize _eSize, bool _bForce = false ); + void implSetImageSize( ImageSize _eSize ); + + /// updates the images of our items + void implUpdateImages(); /// enables or disables an item, plus possible dependent items void implEnableItem( USHORT _nItemId, bool _bEnabled ); |