diff options
author | Noel Power <noel.power@novell.com> | 2011-12-05 09:56:17 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-12-05 09:57:12 +0000 |
commit | 9cff030fa15f89fa1009fbb3827ab11c43c20b04 (patch) | |
tree | 7a2cc323b2df30d253b8911d25aeaadd78c9d6cb /basctl/source | |
parent | c2f62c8cb30975e3cd46c4800e738f3f010ecb3e (diff) |
add some form control support for basic dialogs
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 52 | ||||
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 10 | ||||
-rw-r--r-- | basctl/source/basicide/idetemp.hxx | 2 | ||||
-rw-r--r-- | basctl/source/dlged/dlged.cxx | 2 | ||||
-rw-r--r-- | basctl/source/dlged/dlgedfac.cxx | 67 | ||||
-rw-r--r-- | basctl/source/dlged/dlgedobj.cxx | 31 | ||||
-rw-r--r-- | basctl/source/inc/dlgeddef.hxx | 8 | ||||
-rw-r--r-- | basctl/source/inc/dlgedfac.hxx | 4 | ||||
-rw-r--r-- | basctl/source/inc/dlgedobj.hxx | 2 |
9 files changed, 165 insertions, 13 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index b5c287d431f8..2f7ccfb744ba 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -272,6 +272,18 @@ void DialogWindow::DoScroll( ScrollBar* pCurScrollBar ) void DialogWindow::GetState( SfxItemSet& rSet ) { SfxWhichIter aIter(rSet); + bool bIsCalc = false; + if ( GetDocument().isDocument() ) + { + Reference< frame::XModel > xModel= GetDocument().getDocument(); + if ( xModel.is() ) + { + Reference< lang::XServiceInfo > xServiceInfo ( xModel, UNO_QUERY ); + if ( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") ) ) ) + bIsCalc = true; + } + } + for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() ) { switch ( nWh ) @@ -390,6 +402,18 @@ void DialogWindow::GetState( SfxItemSet& rSet ) rSet.DisableItem( nWh ); } break; + case SID_INSERT_RADIO: + case SID_INSERT_CHECK: + case SID_INSERT_LIST: + case SID_INSERT_COMBO: + case SID_INSERT_VSCROLL: + case SID_INSERT_HSCROLL: + case SID_INSERT_SPIN: + { + if ( !bIsCalc || IsReadOnly() ) + rSet.DisableItem( nWh ); + } + break; } } } @@ -430,6 +454,34 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq ) pBindings->Invalidate( SID_DOC_MODIFIED ); } break; + case SID_INSERT_RADIO: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMRADIO ); + break; + case SID_INSERT_CHECK: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMCHECK ); + break; + case SID_INSERT_LIST: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMLIST ); + break; + case SID_INSERT_COMBO: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMCOMBO ); + break; + case SID_INSERT_SPIN: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMSPIN ); + break; + case SID_INSERT_VSCROLL: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMVSCROLL ); + break; + case SID_INSERT_HSCROLL: + GetEditor()->SetMode( DLGED_INSERT ); + GetEditor()->SetInsertObj( OBJ_DLG_FORMHSCROLL ); + break; case SID_CHOOSE_CONTROLS: { const SfxItemSet* pArgs = rReq.GetArgs(); diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 62cb0c6ec0dd..ab9fd013c9f8 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -917,6 +917,13 @@ void BasicIDEShell::GetState(SfxItemSet &rSet) break; case SID_CHOOSE_CONTROLS: case SID_DIALOG_TESTMODE: + case SID_INSERT_RADIO: + case SID_INSERT_CHECK: + case SID_INSERT_LIST: + case SID_INSERT_COMBO: + case SID_INSERT_VSCROLL: + case SID_INSERT_HSCROLL: + case SID_INSERT_SPIN: { if( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) ) rSet.DisableItem( nWh ); @@ -1201,6 +1208,7 @@ void BasicIDEShell::ManageToolbars() static ::rtl::OUString aMacroBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/macrobar" )); static ::rtl::OUString aDialogBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/dialogbar" )); static ::rtl::OUString aInsertControlsBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" )); + static ::rtl::OUString aFormControlsBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formcontrolsbar" )); (void)aInsertControlsBarResName; if( !pCurWin ) @@ -1222,11 +1230,13 @@ void BasicIDEShell::ManageToolbars() xLayoutManager->requestElement( aDialogBarResName ); xLayoutManager->requestElement( aInsertControlsBarResName ); + xLayoutManager->requestElement( aFormControlsBarResName ); } else { xLayoutManager->destroyElement( aDialogBarResName ); xLayoutManager->destroyElement( aInsertControlsBarResName ); + xLayoutManager->destroyElement( aFormControlsBarResName ); xLayoutManager->requestElement( aMacroBarResName ); } diff --git a/basctl/source/basicide/idetemp.hxx b/basctl/source/basicide/idetemp.hxx index 7700d94f0748..cb2d8693acc9 100644 --- a/basctl/source/basicide/idetemp.hxx +++ b/basctl/source/basicide/idetemp.hxx @@ -57,7 +57,7 @@ enum SvxChooseControlEnum SVX_SNAP_FORMATTEDFIELD, SVX_SNAP_PATTERNFIELD, SVX_SNAP_FILECONTROL, - SVX_SNAP_TREECONTROL + SVX_SNAP_TREECONTROL, }; #define SvxChooseControlItem SfxAllEnumItem diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 6d3c5bf69d6b..2769145074cb 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -218,7 +218,7 @@ DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star:: pDlgEdPage = new DlgEdPage( *pDlgEdModel ); pDlgEdModel->InsertPage( pDlgEdPage ); - pObjFac = new DlgEdFactory(); + pObjFac = new DlgEdFactory(xModel); pFunc = new DlgEdFuncSelect( this ); diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx index 92c0da48ff13..ecbb9bda00ab 100644 --- a/basctl/source/dlged/dlgedfac.cxx +++ b/basctl/source/dlged/dlgedfac.cxx @@ -39,7 +39,7 @@ using namespace ::com::sun::star; -DlgEdFactory::DlgEdFactory() +DlgEdFactory::DlgEdFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) : mxModel( xModel ) { SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) ); } @@ -70,25 +70,52 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) if( (pObjFactory->nInventor == DlgInventor) && (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) && - (pObjFactory->nIdentifier <= OBJ_DLG_SPINBUTTON) ) + (pObjFactory->nIdentifier <= OBJ_DLG_FORMHSCROLL) ) { switch( pObjFactory->nIdentifier ) { case OBJ_DLG_PUSHBUTTON: pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" )) , xDialogSFact ); break; + case OBJ_DLG_FORMRADIO: case OBJ_DLG_RADIOBUTTON: - pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" )) , xDialogSFact ); + if ( pObjFactory->nIdentifier == OBJ_DLG_RADIOBUTTON ) + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" )) , xDialogSFact ); + else + { + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.RadioButton" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); + } break; + case OBJ_DLG_FORMCHECK: case OBJ_DLG_CHECKBOX: - pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" )) , xDialogSFact ); + if ( pObjFactory->nIdentifier == OBJ_DLG_CHECKBOX ) + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" )) , xDialogSFact ); + else + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.CheckBox" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); break; + case OBJ_DLG_FORMLIST: case OBJ_DLG_LISTBOX: - pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" )) , xDialogSFact ); + if ( pObjFactory->nIdentifier == OBJ_DLG_LISTBOX ) + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" )) , xDialogSFact ); + else + { + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ListBox" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); + } break; + case OBJ_DLG_FORMCOMBO: case OBJ_DLG_COMBOBOX: { - DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" )) , xDialogSFact ); + DlgEdObj* pNew = NULL; + if ( pObjFactory->nIdentifier == OBJ_DLG_COMBOBOX ) + pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" )) , xDialogSFact ); + else + { + pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ComboBox" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel ); + } pObjFactory->pNewObj = pNew; try { @@ -118,12 +145,27 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) case OBJ_DLG_PROGRESSBAR: pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" )) , xDialogSFact ); break; + case OBJ_DLG_FORMHSCROLL: case OBJ_DLG_HSCROLLBAR: - pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact ); + if ( pObjFactory->nIdentifier == OBJ_DLG_HSCROLLBAR ) + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact ); + else + { + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ScrollBar" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); + } break; + case OBJ_DLG_FORMVSCROLL: case OBJ_DLG_VSCROLLBAR: { - DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact ); + DlgEdObj* pNew = NULL; + if ( pObjFactory->nIdentifier == OBJ_DLG_VSCROLLBAR ) + pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact ); + else + { + pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ScrollBar" )) , xDialogSFact ); + static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel ); + } pObjFactory->pNewObj = pNew; // set vertical orientation try @@ -183,8 +225,15 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) case OBJ_DLG_FILECONTROL: pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" )) , xDialogSFact ); break; + case OBJ_DLG_FORMSPIN: case OBJ_DLG_SPINBUTTON: - pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlSpinButtonModel") , xDialogSFact ); + if ( pObjFactory->nIdentifier == OBJ_DLG_SPINBUTTON ) + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlSpinButtonModel") , xDialogSFact ); + else + { + pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.form.component.SpinButton") , xDialogSFact ); + static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); + } break; case OBJ_DLG_TREECONTROL: DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" )) , xDialogSFact ); diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 2e2d8dfaba1c..aa79ef1f5de8 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -38,6 +38,9 @@ #include "dlgresid.hrc" +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/binding/XValueBinding.hpp> +#include <com/sun/star/form/binding/XListEntrySink.hpp> #include <com/sun/star/awt/XUnoControlContainer.hpp> #include <com/sun/star/awt/XVclContainerPeer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -1856,7 +1859,33 @@ awt::DeviceInfo DlgEdForm::getDeviceInfo() const return aDeviceInfo; } - +bool DlgEdObj::MakeDataAware( const Reference< frame::XModel >& xModel ) +{ + bool bRes = false; + // Need to flesh this out, currently we will only support data-aware controls for calc + // and only handle a subset of functionality e.g. linked-cell and cell range data source. Of course later + // we need to disambiguate for writer ( and others ? ) and also support the generic form (db) bindings + // we need some more work in xmlscript to be able to handle that + Reference< lang::XMultiServiceFactory > xFac( xModel, UNO_QUERY ); + Reference< form::binding::XBindableValue > xBindable( GetUnoControlModel(), UNO_QUERY ); + Reference< form::binding::XListEntrySink > xListEntrySink( GetUnoControlModel(), UNO_QUERY ); + if ( xFac.is() ) + { + if ( xBindable.is() ) + { + Reference< form::binding::XValueBinding > xBinding( xFac->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.CellValueBinding" ) ) ), UNO_QUERY ); + xBindable->setValueBinding( xBinding ); + } + if ( xListEntrySink.is() ) + { + Reference< form::binding::XListEntrySource > xSource( xFac->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.CellRangeListSource" ) ) ), UNO_QUERY ); + xListEntrySink->setListEntrySource( xSource ); + } + if ( xListEntrySink.is() || xBindable.is() ) + bRes = true; + } + return bRes; +} //---------------------------------------------------------------------------- diff --git a/basctl/source/inc/dlgeddef.hxx b/basctl/source/inc/dlgeddef.hxx index a7be1fa232c5..f3104a198667 100644 --- a/basctl/source/inc/dlgeddef.hxx +++ b/basctl/source/inc/dlgeddef.hxx @@ -63,6 +63,14 @@ const sal_uInt32 DlgInventor = sal_uInt32('D')*0x00000001+ #define OBJ_DLG_TREECONTROL ((sal_uInt16)24) #define OBJ_DLG_SPINBUTTON ((sal_uInt16)25) +#define OBJ_DLG_FORMRADIO ((sal_uInt16)26) +#define OBJ_DLG_FORMCHECK ((sal_uInt16)27) +#define OBJ_DLG_FORMLIST ((sal_uInt16)28) +#define OBJ_DLG_FORMCOMBO ((sal_uInt16)29) +#define OBJ_DLG_FORMSPIN ((sal_uInt16)30) +#define OBJ_DLG_FORMVSCROLL ((sal_uInt16)31) +#define OBJ_DLG_FORMHSCROLL ((sal_uInt16)32) + // control properties #define DLGED_PROP_BACKGROUNDCOLOR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" ) ) #define DLGED_PROP_DROPDOWN ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ) diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx index 9908b3f5798d..dffbefe024a7 100644 --- a/basctl/source/inc/dlgedfac.hxx +++ b/basctl/source/inc/dlgedfac.hxx @@ -31,6 +31,7 @@ #define _BASCTL_DLGEDFAC_HXX #include <svx/svdobj.hxx> +#include <com/sun/star/frame/XModel.hpp> //============================================================================ // DlgEdFactory @@ -38,8 +39,9 @@ class DlgEdFactory { + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel; public: - DlgEdFactory(); + DlgEdFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); ~DlgEdFactory(); DECL_LINK( MakeObject, SdrObjFactory * ); diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index d68c9407bb15..ebe1186dd43b 100644 --- a/basctl/source/inc/dlgedobj.hxx +++ b/basctl/source/inc/dlgedobj.hxx @@ -29,6 +29,7 @@ #ifndef _BASCTL_DLGEDOBJ_HXX #define _BASCTL_DLGEDOBJ_HXX +#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/beans/XPropertyChangeListener.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <comphelper/processfactory.hxx> @@ -131,6 +132,7 @@ public: virtual void SAL_CALL _elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); virtual void SetLayer(SdrLayerID nLayer); + bool MakeDataAware( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); }; |