diff options
31 files changed, 393 insertions, 137 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index f4a3c1d48fc7..43bfbb7559dc 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -82,6 +82,7 @@ #include <com/sun/star/resource/XStringResourceResolver.hpp> #include <com/sun/star/resource/StringResourceWithLocation.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> using namespace comphelper; using namespace ::com::sun::star; @@ -112,8 +113,16 @@ DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, St { InitSettings( TRUE, TRUE, TRUE ); - pEditor = new DlgEditor(); + pEditor = new DlgEditor( rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); pEditor->SetWindow( this ); + // set vba mode on DialogModel ( allows it to work in 100thmm instead of MAP_APPFONT ) + if ( rDocument.isDocument() && rDocument.getDocument().is() ) + { + uno::Reference< script::vba::XVBACompatibility > xDocVBAMode( rDocument.getLibraryContainer( E_SCRIPTS ), uno::UNO_QUERY ); + uno::Reference< script::vba::XVBACompatibility > xDialogModelVBAMode( xDialogModel, uno::UNO_QUERY ); + if ( xDocVBAMode.is() && xDialogModelVBAMode.is() ) + xDialogModelVBAMode->setVBACompatibilityMode( xDocVBAMode->getVBACompatibilityMode() ); + } pEditor->SetDialog( xDialogModel ); // Undo einrichten @@ -728,7 +737,7 @@ BOOL DialogWindow::SaveDialog() Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); Reference< XInputStream > xInput( xISP->createInputStream() ); Reference< XSimpleFileAccess > xSFI( xMSF->createInstance @@ -1010,7 +1019,7 @@ BOOL implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocumen Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); String aXmlDlgName; Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY ); @@ -1236,7 +1245,7 @@ BOOL implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocumen } } - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP ); if( bSuccess ) { @@ -1346,7 +1355,7 @@ void DialogWindow::StoreData() Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); xLib->replaceByName( ::rtl::OUString( GetName() ), makeAny( xISP ) ); } } diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index 22fbdc4a9c7b..322faa0bcc11 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -96,7 +96,7 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel ); // new dialog window diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 0f66a6ebe120..c45fa00d1641 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -312,7 +312,7 @@ void BasicIDEShell::CopyDialogResources( Reference< io::XInputStreamProvider >& Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() ); if( xDialogModel.is() ) { @@ -329,7 +329,7 @@ void BasicIDEShell::CopyDialogResources( Reference< io::XInputStreamProvider >& { LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); } - io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); + io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); } } diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 6b16316d889c..98cd27c55668 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -453,14 +453,12 @@ namespace basctl bool ScriptDocument_Impl::isInVBAMode() const { bool bResult = false; -#ifdef FUTURE_VBA_CWS if ( !isApplication() ) { Reference< XVBACompatibility > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); if ( xVBACompat.is() ) bResult = xVBACompat->getVBACompatibilityMode(); } -#endif return bResult; } @@ -678,7 +676,7 @@ namespace basctl if ( !_rxExistingDialogModel.is() ) { Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW ); - ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext() ); + ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() ); } // set new name as property @@ -686,12 +684,12 @@ namespace basctl xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rNewName ) ); // export dialog model - xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext() ); + xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() ); aElement <<= xISP; } // insert element by new name in container - else if ( _eType == E_SCRIPTS ) + if ( _eType == E_SCRIPTS ) { Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) ) @@ -798,7 +796,7 @@ namespace basctl xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) ); // export dialog model - _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext() ); + _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() ); // insert dialog into library xLib->insertByName( _rDialogName, makeAny( _out_rDialogProvider ) ); diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 326098976d87..6f031ae601f2 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -205,7 +205,7 @@ BOOL DlgEditor::RemarkDialog() //---------------------------------------------------------------------------- -DlgEditor::DlgEditor() +DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) :pHScroll(NULL) ,pVScroll(NULL) ,pDlgEdModel(NULL) @@ -227,6 +227,7 @@ DlgEditor::DlgEditor() ,bCreateOK(TRUE) ,bDialogModelChanged(FALSE) ,mnPaintGuard(0) + ,m_xDocument( xModel ) { pDlgEdModel = new DlgEdModel(); pDlgEdModel->GetItemPool().FreezeIdRanges(); @@ -835,7 +836,7 @@ void DlgEditor::Copy() Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument ); Reference< XInputStream > xStream( xISP->createInputStream() ); Sequence< sal_Int8 > DialogModelBytes; implCopyStreamToByteSequence( xStream, DialogModelBytes ); @@ -868,7 +869,7 @@ void DlgEditor::Copy() uno::Reference< resource::XStringResourceManager > xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY ); LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager ); - Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext ); + Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument ); Reference< XInputStream > xStream2( xISP2->createInputStream() ); Sequence< sal_Int8 > NoResourceDialogModelBytes; implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes ); @@ -1014,7 +1015,7 @@ void DlgEditor::Paste() Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - ::xmlscript::importDialogModel( ::xmlscript::createInputStream( *((::rtl::ByteSequence*)(&DialogModelBytes)) ) , xClipDialogModel, xContext ); + ::xmlscript::importDialogModel( ::xmlscript::createInputStream( *((::rtl::ByteSequence*)(&DialogModelBytes)) ) , xClipDialogModel, xContext, m_xDocument ); } // get control models from clipboard dialog model diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 5af7519f85f0..fcade49d1c8b 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -74,6 +74,22 @@ TYPEINIT1(DlgEdObj, SdrUnoObj); DBG_NAME(DlgEdObj); //---------------------------------------------------------------------------- +MapMode lcl_getMapModeForForm( DlgEdForm* pForm ) +{ + MapMode aMode( MAP_APPFONT ); //Default + try + { + uno::Reference< beans::XPropertySet > xProps( pForm ? pForm->GetUnoControlModel() : NULL, uno::UNO_QUERY_THROW ); + sal_Bool bVBAForm = sal_False; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBAForm; + if ( bVBAForm ) + aMode = MapMode( MAP_100TH_MM ); + } + catch ( Exception& ) + { + } + return aMode; +} DlgEdObj::DlgEdObj() :SdrUnoObj(String(), sal_False) @@ -194,8 +210,9 @@ bool DlgEdObj::TransformSdrToControlCoordinates( } // convert pixel to logic units - aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->PixelToLogic( aPos, aConvMode ); + aSize = pDevice->PixelToLogic( aSize, aConvMode ); // set out parameters nXOut = aPos.Width(); @@ -242,10 +259,10 @@ bool DlgEdObj::TransformSdrToFormCoordinates( aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; } - + MapMode aConvMode = lcl_getMapModeForForm( pForm ); // convert pixel to logic units - aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); + aPos = pDevice->PixelToLogic( aPos, aConvMode ); + aSize = pDevice->PixelToLogic( aSize, aConvMode ); // set out parameters nXOut = aPos.Width(); @@ -287,9 +304,10 @@ bool DlgEdObj::TransformControlToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; - aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); - aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_APPFONT ) ); + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->LogicToPixel( aPos, aConvMode ); + aSize = pDevice->LogicToPixel( aSize, aConvMode ); + aFormPos = pDevice->LogicToPixel( aFormPos, aConvMode ); // add form position aPos.Width() += aFormPos.Width(); @@ -333,14 +351,16 @@ bool DlgEdObj::TransformFormToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; - aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); // take window borders into account DlgEdForm* pForm = NULL; if ( !lcl_getDlgEdForm( this, pForm ) ) return false; + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->LogicToPixel( aPos, aConvMode ); + aSize = pDevice->LogicToPixel( aSize, aConvMode ); + // take window borders into account Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY ); DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" ); diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index 1444bab59c65..f49d684cbe80 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/datatransfer/DataFlavor.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <tools/link.hxx> #include <tools/gen.hxx> #include <vcl/timer.hxx> @@ -128,9 +129,11 @@ protected: BOOL bDialogModelChanged; Timer aMarkTimer; long mnPaintGuard; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument; + DlgEditor(); // not implemented public: - DlgEditor(); + DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); ~DlgEditor(); void SetWindow( Window* pWindow ); diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 022cc1cfb72c..a53c8ae8b6c4 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -5725,7 +5725,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem( if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) ) { BitmapEx aBitmap = aImage.GetBitmapEx(); - BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize); + BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize); aImage = Image( aBitmapex); } aTbSymbol.InsertItem( nId,aImage, aURL, 0, 0 ); //modify @@ -5889,7 +5889,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL ) if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) ) { BitmapEx aBitmap = aImage.GetBitmapEx(); - BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize); + BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize); aImage = Image( aBitmapex); } if ( bOK && !!aImage ) diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx index 637230587e6b..7ea2620471b6 100644 --- a/cui/source/options/optfltr.cxx +++ b/cui/source/options/optfltr.cxx @@ -54,6 +54,7 @@ OfaMSFilterTabPage::OfaMSFilterTabPage(Window* pParent, const SfxItemSet& rSet) : SfxTabPage( pParent, CUI_RES( RID_OFAPAGE_MSFILTEROPT ), rSet ), aMSWordGB ( this, CUI_RES( GB_WORD ) ), aWBasicCodeCB ( this, CUI_RES( CB_WBAS_CODE ) ), + aWBasicWbctblCB ( this, CUI_RES( CB_WBAS_WBCTBL ) ), aWBasicStgCB ( this, CUI_RES( CB_WBAS_STG ) ), aMSExcelGB ( this, CUI_RES( GB_EXCEL ) ), aEBasicCodeCB ( this, CUI_RES( CB_EBAS_CODE ) ), @@ -65,6 +66,7 @@ OfaMSFilterTabPage::OfaMSFilterTabPage(Window* pParent, const SfxItemSet& rSet) { FreeResource(); + aWBasicCodeCB.SetClickHdl( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) ); aEBasicCodeCB.SetClickHdl( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) ); } @@ -72,6 +74,12 @@ OfaMSFilterTabPage::~OfaMSFilterTabPage() { } +IMPL_LINK( OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, CheckBox*, EMPTYARG ) +{ + aWBasicWbctblCB.Enable( aWBasicCodeCB.IsChecked() ); + return 0; +} + IMPL_LINK( OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, CheckBox*, EMPTYARG ) { aEBasicExectblCB.Enable( aEBasicCodeCB.IsChecked() ); @@ -91,6 +99,8 @@ BOOL OfaMSFilterTabPage::FillItemSet( SfxItemSet& ) BOOL bFlag; if( aWBasicCodeCB.GetSavedValue() != (bFlag = aWBasicCodeCB.IsChecked())) pOpt->SetLoadWordBasicCode( bFlag ); + if( aWBasicWbctblCB.GetSavedValue() != (bFlag = aWBasicWbctblCB.IsChecked())) + pOpt->SetLoadWordBasicExecutable( bFlag ); if( aWBasicStgCB.GetSavedValue() != (bFlag = aWBasicStgCB.IsChecked())) pOpt->SetLoadWordBasicStorage( bFlag ); @@ -119,8 +129,11 @@ void OfaMSFilterTabPage::Reset( const SfxItemSet& ) aWBasicCodeCB.Check( pOpt->IsLoadWordBasicCode() ); aWBasicCodeCB.SaveValue(); + aWBasicWbctblCB.Check( pOpt->IsLoadWordBasicExecutable() ); + aWBasicWbctblCB.SaveValue(); aWBasicStgCB.Check( pOpt->IsLoadWordBasicStorage() ); aWBasicStgCB.SaveValue(); + LoadWordBasicCheckHdl_Impl( &aWBasicCodeCB ); aEBasicCodeCB.Check( pOpt->IsLoadExcelBasicCode() ); aEBasicCodeCB.SaveValue(); diff --git a/cui/source/options/optfltr.hrc b/cui/source/options/optfltr.hrc index 948da2c47542..a9411b576674 100644 --- a/cui/source/options/optfltr.hrc +++ b/cui/source/options/optfltr.hrc @@ -40,6 +40,7 @@ #define CB_EBAS_STG 5 #define CB_PBAS_CODE 6 #define CB_PBAS_STG 7 +#define CB_WBAS_WBCTBL 8 #define CLB_SETTINGS 1 #define ST_CHG_MATH 1 diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx index e2572e901124..e4fa2d103472 100644 --- a/cui/source/options/optfltr.hxx +++ b/cui/source/options/optfltr.hxx @@ -43,6 +43,7 @@ class OfaMSFilterTabPage : public SfxTabPage { FixedLine aMSWordGB; CheckBox aWBasicCodeCB; + CheckBox aWBasicWbctblCB; CheckBox aWBasicStgCB; FixedLine aMSExcelGB; CheckBox aEBasicCodeCB; @@ -55,6 +56,7 @@ class OfaMSFilterTabPage : public SfxTabPage OfaMSFilterTabPage( Window* pParent, const SfxItemSet& rSet ); virtual ~OfaMSFilterTabPage(); + DECL_LINK( LoadWordBasicCheckHdl_Impl, CheckBox* ); DECL_LINK( LoadExcelBasicCheckHdl_Impl, CheckBox* ); public: diff --git a/cui/source/options/optfltr.src b/cui/source/options/optfltr.src index 35659dd71f5b..b6e8932136de 100644 --- a/cui/source/options/optfltr.src +++ b/cui/source/options/optfltr.src @@ -51,9 +51,16 @@ TabPage RID_OFAPAGE_MSFILTEROPT TabStop = TRUE ; Text [ en-US ] = "Load Basic ~code"; }; + CheckBox CB_WBAS_WBCTBL + { + Pos = MAP_APPFONT ( 22 , 28 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "E~xecutable code"; + }; CheckBox CB_WBAS_STG { - Pos = MAP_APPFONT ( 12 , 28 ) ; + Pos = MAP_APPFONT ( 12 , 42 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Save ~original Basic code"; @@ -61,27 +68,27 @@ TabPage RID_OFAPAGE_MSFILTEROPT FixedLine GB_EXCEL { - Pos = MAP_APPFONT ( 6 , 44 ) ; + Pos = MAP_APPFONT ( 6 , 58 ) ; Size = MAP_APPFONT ( 248 , 8 ) ; Text [ en-US ] = "Microsoft Excel 97/2000/XP"; }; CheckBox CB_EBAS_CODE { - Pos = MAP_APPFONT ( 12 , 55 ) ; + Pos = MAP_APPFONT ( 12 , 69 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Lo~ad Basic code"; }; CheckBox CB_EBAS_EXECTBL { - Pos = MAP_APPFONT ( 22 , 69 ) ; + Pos = MAP_APPFONT ( 22 , 83 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "E~xecutable code"; }; CheckBox CB_EBAS_STG { - Pos = MAP_APPFONT ( 12 , 83 ) ; + Pos = MAP_APPFONT ( 12 , 97 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Sa~ve original Basic code"; diff --git a/extensions/inc/propctrlr.hrc b/extensions/inc/propctrlr.hrc index 6961319f4dda..477f512797ec 100644 --- a/extensions/inc/propctrlr.hrc +++ b/extensions/inc/propctrlr.hrc @@ -326,9 +326,10 @@ #define HID_FM_PROPDLG_TAB_GENERAL ( HID_PROPC_START + 294) #define HID_FM_PROPDLG_TAB_DATA ( HID_PROPC_START + 295) #define HID_FM_PROPDLG_TAB_EVT ( HID_PROPC_START + 296) +#define HID_PROP_GROUP_NAME ( HID_PROPC_START + 297) // please adjust HID_LAST_PROPC_ID if you add new ids here! -#define HID_LAST_PROPC_ID HID_FM_PROPDLG_TAB_EVT +#define HID_LAST_PROPC_ID HID_PROP_GROUP_NAME #if HID_LAST_PROPC_ID > HID_PROPC_END #error help id overflow (PROPC) diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index 89cb5625bca3..9a95c30ec645 100755 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/script/XEngine.hpp> #include <com/sun/star/script/InterruptEngineEvent.hpp> #include <com/sun/star/script/XLibraryAccess.hpp> +#include <com/sun/star/script/BasicErrorException.hpp> #include <com/sun/star/bridge/ModelDependent.hpp> #include "com/sun/star/bridge/oleautomation/NamedArgument.hpp" @@ -152,10 +153,10 @@ Any IUnknownWrapper_Impl::queryInterface(const Type& t) return Any(); if (t == getCppuType(static_cast<Reference<XDefaultProperty>*>( 0)) && !m_bHasDfltProperty ) return Any(); - if (t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) && !m_spDispatch) + if ( ( t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) || t == getCppuType(static_cast<Reference<XAutomationInvocation>*>( 0)) ) && !m_spDispatch) return Any(); - return WeakImplHelper6<XInvocation, XBridgeSupplier2, + return WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>::queryInterface(t); } @@ -167,6 +168,61 @@ Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection( return ret; } +Any SAL_CALL IUnknownWrapper_Impl::invokeGetProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) +{ + Any aResult; + try + { + o2u_attachCurrentThread(); + ITypeInfo * pInfo = getTypeInfo(); + FuncDesc aDescGet(pInfo); + FuncDesc aDescPut(pInfo); + VarDesc aVarDesc(pInfo); + getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc); + if ( !aDescGet ) + { + OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName + + OUSTR("\" is not supported")); + throw UnknownPropertyException(msg, Reference<XInterface>()); + } + aResult = invokeWithDispIdComTlb( aDescGet, aPropertyName, aParams, aOutParamIndex, aOutParam ); + } + catch ( Exception& e ) + { + throw RuntimeException(OUSTR("[automation bridge] unexpected exception in " + "IUnknownWrapper_Impl::invokeGetProperty ! Message : \n") + + e.Message, Reference<XInterface>()); + } + return aResult; +} + +Any SAL_CALL IUnknownWrapper_Impl::invokePutProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) +{ + Any aResult; + try + { + o2u_attachCurrentThread(); + ITypeInfo * pInfo = getTypeInfo(); + FuncDesc aDescGet(pInfo); + FuncDesc aDescPut(pInfo); + VarDesc aVarDesc(pInfo); + getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc); + if ( !aDescPut ) + { + OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName + + OUSTR("\" is not supported")); + throw UnknownPropertyException(msg, Reference<XInterface>()); + } + aResult = invokeWithDispIdComTlb( aDescPut, aPropertyName, aParams, aOutParamIndex, aOutParam ); + } + catch ( Exception& e ) + { + throw RuntimeException(OUSTR("[automation bridge] unexpected exception in " + "IUnknownWrapper_Impl::invokePutProperty ! Message : \n") + + e.Message, Reference<XInterface>()); + } + return aResult; +} Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName, @@ -213,6 +269,10 @@ Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName, { throw; } + catch (InvocationTargetException &) + { + throw; + } catch (BridgeRuntimeError & e) { throw RuntimeException(e.message, Reference<XInterface>()); @@ -658,12 +718,16 @@ sal_Bool SAL_CALL IUnknownWrapper_Impl::hasProperty( const OUString& aName ) FuncDesc aDescPut(pInfo); VarDesc aVarDesc(pInfo); getPropDesc(aName, & aDescGet, & aDescPut, & aVarDesc); - // Automation properties can have parameters. If so, we access them through - // XInvocation::invoke. Thas is, hasProperty must return false for such a - // property + + // we should probably just check the funckind + // basic has been modified to handle properties ( 'get' ) props at + // least with paramaters + // additionally you can call invoke(Get|Set)Property on the bridge + // you can determine if a property has parameter is hasMethod + // returns true for the name if (aVarDesc - || aDescPut && aDescPut->cParams == 0 - || aDescGet && aDescGet->cParams == 0) + || aDescPut + || aDescGet ) { ret = sal_True; } @@ -1392,6 +1456,19 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) { + // Get type info for the call. It can be a method call or property put or + // property get operation. + FuncDesc aFuncDesc(getTypeInfo()); + getFuncDescForInvoke(sFuncName, Params, & aFuncDesc); + return invokeWithDispIdComTlb( aFuncDesc, sFuncName, Params, OutParamIndex, OutParam ); +} + +Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, + const OUString& sFuncName, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) +{ Any ret; HRESULT result; @@ -1410,10 +1487,6 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, sal_Int32 revIndex = 0; bool bVarargParam = false; - // Get type info for the call. It can be a method call or property put or - // property get operation. - FuncDesc aFuncDesc(getTypeInfo()); - getFuncDescForInvoke(sFuncName, Params, & aFuncDesc); //Set the array of DISPIDs for named args if it is a property put operation. //If there are other named arguments another array is set later on. @@ -1832,11 +1905,24 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, "DISP_E_BADVARTYPE."), 0); break; case DISP_E_EXCEPTION: + { message = OUSTR("[automation bridge]: "); message += OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); - throw InvocationTargetException(message, Reference<XInterface>(), Any()); + + // Add for VBA, to throw an exception with the correct error code and message. + sal_Int32 nErrorCode = excepinfo.wCode; + if ( nErrorCode == 0 ) + { + // The low 16-bit of scode describing the error or warning. + nErrorCode = ( excepinfo.scode & 0xFFFF ); + } + BasicErrorException aBasicErrExp(message, Reference<XInterface>(), nErrorCode, message); + throw InvocationTargetException(message, Reference<XInterface>(), makeAny(aBasicErrExp)); + // End add + break; + } case DISP_E_MEMBERNOTFOUND: message = OUSTR("[automation bridge]: A function with the name \"") + sFuncName + OUSTR("\" is not supported. Object returned " @@ -1969,11 +2055,17 @@ void IUnknownWrapper_Impl::getFuncDesc(const OUString & sFuncName, FUNCDESC ** p //get the associated index and add an entry to the map //with the name sFuncName which differs in the casing of the letters to //the actual name as obtained from ITypeInfo - cit itOrg = m_mapComFunc.find(OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)))); + OUString sRealName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))); + cit itOrg = m_mapComFunc.find(sRealName); OSL_ASSERT(itOrg != m_mapComFunc.end()); + // maybe this is a property, if so we need + // to store either both id's ( put/get ) or + // just the get. Storing both is more consistent + pair<cit, cit> pItems = m_mapComFunc.equal_range( sRealName ); + for ( ;pItems.first != pItems.second; ++pItems.first ) + m_mapComFunc.insert( TLBFuncIndexMap::value_type ( make_pair(sFuncName, pItems.first->second ) )); itIndex = - m_mapComFunc.insert( TLBFuncIndexMap::value_type - ( make_pair(sFuncName, itOrg->second ) )); + m_mapComFunc.find( sFuncName ); } } } @@ -2080,56 +2172,69 @@ void IUnknownWrapper_Impl::getPropDesc(const OUString & sFuncName, FUNCDESC ** p //else no entry for sFuncName, pFuncDesc will not be filled in } -VARTYPE IUnknownWrapper_Impl::getElementTypeDesc(const TYPEDESC *desc) +VARTYPE IUnknownWrapper_Impl::getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType ) { VARTYPE _type( VT_NULL ); - - if (desc->vt == VT_PTR) - { - _type = getElementTypeDesc(desc->lptdesc); - _type |= VT_BYREF; - } - else if (desc->vt == VT_SAFEARRAY) - { - _type = getElementTypeDesc(desc->lptdesc); - _type |= VT_ARRAY; - } - else if (desc->vt == VT_USERDEFINED) + if ( pTypeInfo ) { - ITypeInfo* thisInfo = getTypeInfo(); //kept by this instance - CComPtr<ITypeInfo> spRefInfo; - thisInfo->GetRefTypeInfo(desc->hreftype, & spRefInfo.p); - if (spRefInfo) + CComPtr<ITypeInfo> spRefInfo; + pTypeInfo->GetRefTypeInfo( nHrefType, &spRefInfo.p ); + if ( spRefInfo ) { - TypeAttr attr(spRefInfo); - spRefInfo->GetTypeAttr( & attr); - if (attr->typekind == TKIND_ENUM) + TypeAttr attr( spRefInfo ); + spRefInfo->GetTypeAttr( &attr ); + if ( attr->typekind == TKIND_ENUM ) { - //We use the type of the first enum value. - if (attr->cVars == 0) + // We use the type of the first enum value. + if ( attr->cVars == 0 ) { - throw BridgeRuntimeError(OUSTR("[automation bridge] Could " - "not obtain type description")); + throw BridgeRuntimeError(OUSTR("[automation bridge] Could not obtain type description")); } - VarDesc var(spRefInfo); - spRefInfo->GetVarDesc(0, & var); + VarDesc var( spRefInfo ); + spRefInfo->GetVarDesc( 0, &var ); _type = var->lpvarValue->vt; } - else if (attr->typekind == TKIND_INTERFACE) + else if ( attr->typekind == TKIND_INTERFACE ) { _type = VT_UNKNOWN; } - else if (attr->typekind == TKIND_DISPATCH) + else if ( attr->typekind == TKIND_DISPATCH ) { _type = VT_DISPATCH; } + else if ( attr->typekind == TKIND_ALIAS ) + { + // TKIND_ALIAS is a type that is an alias for another type. So get that alias type. + _type = getUserDefinedElementType( pTypeInfo, attr->tdescAlias.hreftype ); + } else { - throw BridgeRuntimeError(OUSTR("[automation bridge] " - "Unhandled user defined type.")); + throw BridgeRuntimeError( OUSTR("[automation bridge] Unhandled user defined type.") ); } } } + return _type; +} + +VARTYPE IUnknownWrapper_Impl::getElementTypeDesc(const TYPEDESC *desc) +{ + VARTYPE _type( VT_NULL ); + + if (desc->vt == VT_PTR) + { + _type = getElementTypeDesc(desc->lptdesc); + _type |= VT_BYREF; + } + else if (desc->vt == VT_SAFEARRAY) + { + _type = getElementTypeDesc(desc->lptdesc); + _type |= VT_ARRAY; + } + else if (desc->vt == VT_USERDEFINED) + { + ITypeInfo* thisInfo = getTypeInfo(); //kept by this instance + _type = getUserDefinedElementType( thisInfo, desc->hreftype ); + } else { _type = desc->vt; diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx index b990ac3af17d..3c184472c20f 100644 --- a/extensions/source/ole/oleobjw.hxx +++ b/extensions/source/ole/oleobjw.hxx @@ -54,6 +54,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp> +#include <com/sun/star/script//XAutomationInvocation.hpp> #include <rtl/ustring.hxx> #include <com/sun/star/script/XDefaultProperty.hpp> @@ -81,7 +82,7 @@ typedef hash_multimap<OUString, unsigned int, hashOUString_Impl, equalOUString_I // This class wraps an IDispatch and maps XInvocation calls to IDispatch calls on the wrapped object. // If m_TypeDescription is set then this class represents an UNO interface implemented in a COM component. // The interface is not a real interface in terms of an abstract class but is realized through IDispatch. -class IUnknownWrapper_Impl : public WeakImplHelper6<XInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>, +class IUnknownWrapper_Impl : public WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>, public UnoConversionUtilities<IUnknownWrapper_Impl> @@ -134,6 +135,9 @@ public: protected: virtual ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; } + virtual ::com::sun::star::uno::Any SAL_CALL invokeGetProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL invokePutProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); + // ---------------------------------------------------------------------------- virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName, const Sequence< Any >& Params, @@ -145,6 +149,12 @@ protected: Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam); + Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, + const OUString& sFuncName, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam); + // virtual void setValueWithDispId(DISPID dispID, const Any& Value); // virtual Any getValueWithDispId(const OUString& sName, DISPID dispID); @@ -188,8 +198,11 @@ protected: /** Returns the DISPID for a function or property name. If true is returned then id contains a valid DISPID. */ + bool getDispid(const OUString& sFuncName, DISPID * id); + VARTYPE getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType ); + /** Gets the element type in a VARIANT like style. E.g. if desc->lptdesc contains a VT_PTR than it is replaced by VT_BYREF and VT_SAFEARRAY is replaced by VT_ARRAY If the TYPEDESC describes an SAFEARRAY then varType is a combination of VT_ARRAY diff --git a/extensions/source/propctrlr/defaultforminspection.cxx b/extensions/source/propctrlr/defaultforminspection.cxx index f477c4deaa1e..2fffb43951ce 100644 --- a/extensions/source/propctrlr/defaultforminspection.cxx +++ b/extensions/source/propctrlr/defaultforminspection.cxx @@ -149,7 +149,7 @@ namespace pcr { "com.sun.star.form.inspection.EventHandler", false }, // a handler which introduces virtual properties for binding controls to spreadsheet cells - { "com.sun.star.form.inspection.CellBindingPropertyHandler", true }, + { "com.sun.star.form.inspection.CellBindingPropertyHandler", false }, // properties related to binding to an XForms DOM node { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true }, diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx index 9d8becfbd923..0e63f360f9a0 100644 --- a/extensions/source/propctrlr/formmetadata.cxx +++ b/extensions/source/propctrlr/formmetadata.cxx @@ -138,6 +138,7 @@ namespace pcr DEF_INFO_3( LABEL, LABEL, LABEL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_2( CONTROLLABEL, LABELCONTROL, CONTROLLABEL, FORM_VISIBLE, COMPOSEABLE ), DEF_INFO_3( WRITING_MODE, WRITING_MODE, WRITING_MODE, FORM_VISIBLE, ENUM, COMPOSEABLE ), + DEF_INFO_3( GROUP_NAME, GROUP_NAME, GROUP_NAME, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_2( TEXT, TEXT, TEXT, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_3( MAXTEXTLEN, MAXTEXTLEN, MAXTEXTLEN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_3( EDITMASK, EDITMASK, EDITMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), diff --git a/extensions/source/propctrlr/formmetadata.hxx b/extensions/source/propctrlr/formmetadata.hxx index 294a43e4a9e7..3eb7f0e29d56 100644 --- a/extensions/source/propctrlr/formmetadata.hxx +++ b/extensions/source/propctrlr/formmetadata.hxx @@ -163,6 +163,7 @@ namespace pcr #define PROPERTY_ID_ALLOWADDITIONS 20 #define PROPERTY_ID_ALLOWEDITS 21 #define PROPERTY_ID_ALLOWDELETIONS 22 + #define PROPERTY_ID_GROUP_NAME 23 #define PROPERTY_ID_NAVIGATION 24 #define PROPERTY_ID_CYCLE 25 #define PROPERTY_ID_HIDDEN_VALUE 26 diff --git a/extensions/source/propctrlr/formres.src b/extensions/source/propctrlr/formres.src index 1daadd6e0f01..a1ac9fe2c0c4 100644 --- a/extensions/source/propctrlr/formres.src +++ b/extensions/source/propctrlr/formres.src @@ -231,6 +231,10 @@ String RID_STR_NAME { Text [ en-US ] = "Name" ; }; +String RID_STR_GROUP_NAME +{ + Text [ en-US ] = "Group name" ; +}; String RID_STR_TABINDEX { Text [ en-US ] = "Tab order" ; diff --git a/extensions/source/propctrlr/formresid.hrc b/extensions/source/propctrlr/formresid.hrc index f2de0c252d8b..0aeab5306da9 100644 --- a/extensions/source/propctrlr/formresid.hrc +++ b/extensions/source/propctrlr/formresid.hrc @@ -149,6 +149,7 @@ #define RID_STR_CURSOR_TYPE ( RID_FORMBROWSER_START + 121 ) #define RID_STR_ENABLE_VISIBLE ( RID_FORMBROWSER_START + 122 ) #define RID_STR_WHEEL_BEHAVIOR ( RID_FORMBROWSER_START + 123 ) +#define RID_STR_GROUP_NAME ( RID_FORMBROWSER_START + 124 ) // FREE // FREE // FREE diff --git a/extensions/source/propctrlr/formstrings.hxx b/extensions/source/propctrlr/formstrings.hxx index 20b0dd34b2cd..aed09d4fcbf0 100644 --- a/extensions/source/propctrlr/formstrings.hxx +++ b/extensions/source/propctrlr/formstrings.hxx @@ -48,6 +48,7 @@ namespace pcr PCR_CONSTASCII_STRING( PROPERTY_WHEEL_BEHAVIOR, "MouseWheelBehavior"); PCR_CONSTASCII_STRING( PROPERTY_TAG, "Tag"); PCR_CONSTASCII_STRING( PROPERTY_NAME, "Name"); + PCR_CONSTASCII_STRING( PROPERTY_GROUP_NAME, "GroupName"); PCR_CONSTASCII_STRING( PROPERTY_VALUE, "Value"); PCR_CONSTASCII_STRING( PROPERTY_TEXT, "Text"); PCR_CONSTASCII_STRING( PROPERTY_NAVIGATION, "NavigationBarMode"); diff --git a/extensions/util/hidother.src b/extensions/util/hidother.src index 4700d3380e3f..e890400d6ad8 100644 --- a/extensions/util/hidother.src +++ b/extensions/util/hidother.src @@ -207,6 +207,7 @@ hidspecial HID_PROP_FOCUSONCLICK { HelpId = HID_PROP_FOCUSONCLICK hidspecial HID_PROP_FONT { HelpId = HID_PROP_FONT; } hidspecial HID_PROP_FORMATKEY { HelpId = HID_PROP_FORMATKEY; } hidspecial HID_PROP_GROUPBOX { HelpId = HID_PROP_GROUPBOX; } +hidspecial HID_PROP_GROUP_NAME { HelpId = HID_PROP_GROUP_NAME; } hidspecial HID_PROP_HEIGHT { HelpId = HID_PROP_HEIGHT; } hidspecial HID_PROP_HELPTEXT { HelpId = HID_PROP_HELPTEXT; } hidspecial HID_PROP_HELPURL { HelpId = HID_PROP_HELPURL; } diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 148e4c9aa298..e025d5e55cb4 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -2751,8 +2751,8 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin OSL_PRECOND( m_bSupportsExternalBinding, "OBoundControlModel::setValueBinding: How did you reach this method?" ); // the interface for this method should not have been exposed if we do not // support binding to external data - - if ( !impl_approveValueBinding_nolock( _rxBinding ) ) + // allow reset + if ( _rxBinding.is() && !impl_approveValueBinding_nolock( _rxBinding ) ) { throw IncompatibleTypesException( FRM_RES_STRING( RID_STR_INCOMPATIBLE_TYPES ), diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index fde6aa1a23ca..858a7869c864 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -124,14 +124,13 @@ OGroupComp::OGroupComp(const Reference<XPropertySet>& rxSet, sal_Int32 nInsertPo ,m_xControlModel(rxSet,UNO_QUERY) ,m_nPos( nInsertPos ) ,m_nTabIndex(0) + ,m_aName( OGroupManager::GetGroupName( rxSet ) ) { if (m_xComponent.is()) { if (hasProperty( PROPERTY_TABINDEX, m_xComponent ) ) // Indices kleiner 0 werden wie 0 behandelt m_nTabIndex = Max(getINT16(m_xComponent->getPropertyValue( PROPERTY_TABINDEX )) , sal_Int16(0)); - - m_xComponent->getPropertyValue( PROPERTY_NAME ) >>= m_aName; } } @@ -318,7 +317,8 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const aFind->second.RemoveComponent( _xSet ); // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren - if ( aFind->second.Count() == 1 ) + sal_Int32 nCount = aFind->second.Count(); + if ( nCount == 1 || nCount == 0 ) { OActiveGroups::iterator aActiveFind = ::std::find( m_aActiveGroupMap.begin(), @@ -329,7 +329,7 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const { // the group is active. Deactivate it if the remaining component // is *no* radio button - if ( !isRadioButton( aFind->second.GetObject( 0 ) ) ) + if ( nCount == 0 || !isRadioButton( aFind->second.GetObject( 0 ) ) ) m_aActiveGroupMap.erase( aActiveFind ); } } @@ -338,6 +338,8 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const // Bei Component als PropertyChangeListener abmelden _xSet->removePropertyChangeListener( PROPERTY_NAME, this ); + if (hasProperty(PROPERTY_GROUP_NAME, _xSet)) + _xSet->removePropertyChangeListener( PROPERTY_GROUP_NAME, this ); if (hasProperty(PROPERTY_TABINDEX, _xSet)) _xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this ); } @@ -348,10 +350,23 @@ void SAL_CALL OGroupManager::propertyChange(const PropertyChangeEvent& evt) thro // Component aus Gruppe entfernen ::rtl::OUString sGroupName; - if (evt.PropertyName == PROPERTY_NAME) + if (hasProperty( PROPERTY_GROUP_NAME, xSet )) + xSet->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName; + if (evt.PropertyName == PROPERTY_NAME) { + if (sGroupName.getLength() > 0) + return; // group hasn't changed; ignore this name change. + // no GroupName; use Name as GroupNme + evt.OldValue >>= sGroupName; + } + else if (evt.PropertyName == PROPERTY_GROUP_NAME) { evt.OldValue >>= sGroupName; + if (sGroupName.getLength() == 0) { + // No prior GroupName; fallback to Nme + xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + } + } else - xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + sGroupName = GetGroupName( xSet ); removeFromGroupMap(sGroupName,xSet); @@ -434,8 +449,7 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet ) m_pCompGroup->InsertComponent( xSet ); // Component in Gruppe aufnehmen - ::rtl::OUString sGroupName; - xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + ::rtl::OUString sGroupName( GetGroupName( xSet ) ); OGroupArr::iterator aFind = m_aGroupArr.find(sGroupName); @@ -473,6 +487,8 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet ) // Bei Component als PropertyChangeListener anmelden xSet->addPropertyChangeListener( PROPERTY_NAME, this ); + if (hasProperty(PROPERTY_GROUP_NAME, xSet)) + xSet->addPropertyChangeListener( PROPERTY_GROUP_NAME, this ); // Tabindex muss nicht jeder unterstuetzen if (hasProperty(PROPERTY_TABINDEX, xSet)) @@ -489,12 +505,26 @@ void OGroupManager::RemoveElement( const Reference<XPropertySet>& xSet ) return; // Component aus Gruppe entfernen - ::rtl::OUString sGroupName; - xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + ::rtl::OUString sGroupName( GetGroupName( xSet ) ); removeFromGroupMap(sGroupName,xSet); } +::rtl::OUString OGroupManager::GetGroupName( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xComponent ) +{ + if (!xComponent.is()) + return ::rtl::OUString(); + ::rtl::OUString sGroupName; + if (hasProperty( PROPERTY_GROUP_NAME, xComponent )) { + xComponent->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName; + if (sGroupName.getLength() == 0) + xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + } + else + xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + return sGroupName; +} + //......................................................................... } // namespace frm //......................................................................... diff --git a/forms/source/component/GroupManager.hxx b/forms/source/component/GroupManager.hxx index fc9d8ce82c61..5c3f2966ef9c 100644 --- a/forms/source/component/GroupManager.hxx +++ b/forms/source/component/GroupManager.hxx @@ -217,6 +217,8 @@ public: void getGroup(sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> >& _rGroup, ::rtl::OUString& Name); void getGroupByName(const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> >& _rGroup); ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> > getControlModels(); + + static ::rtl::OUString GetGroupName( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xComponent ); }; diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index d2de4882dead..55624b44e1c7 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -1555,6 +1555,8 @@ namespace frm void SAL_CALL OListBoxControl::itemStateChanged(const ItemEvent& _rEvent) throw(RuntimeException) { // forward this to our listeners + Reference< XChild > xChild( getModel(), UNO_QUERY ); + if ( xChild.is() && xChild->getParent().is() ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( m_aItemListeners.getLength() ) @@ -1567,6 +1569,8 @@ namespace frm m_pItemBroadcaster->addEvent( new ItemEventDescription( _rEvent ), this ); } } + else + m_aItemListeners.notifyEach( &XItemListener::itemStateChanged, _rEvent ); // and do the handling for the ChangeListeners ::osl::ClearableMutexGuard aGuard(m_aMutex); diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index c4a1216ad76c..2646ec90099a 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" #include "RadioButton.hxx" +#include "GroupManager.hxx" #include "property.hxx" #ifndef _FRM_PROPERTY_HRC_ #include "property.hrc" @@ -119,6 +120,7 @@ ORadioButtonModel::ORadioButtonModel(const Reference<XMultiServiceFactory>& _rxF m_nClassId = FormComponentType::RADIOBUTTON; m_aLabelServiceName = FRM_SUN_COMPONENT_GROUPBOX; initValueProperty( PROPERTY_STATE, PROPERTY_ID_STATE ); + startAggregatePropertyListening( PROPERTY_GROUP_NAME ); } //------------------------------------------------------------------ @@ -166,7 +168,11 @@ StringSequence SAL_CALL ORadioButtonModel::getSupportedServiceNames() throw(Runt void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, const Any& rValue) { // mein Name - ::rtl::OUString sMyName(m_aName); + ::rtl::OUString sMyGroup; + if (hasProperty(PROPERTY_GROUP_NAME, this)) + this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sMyGroup; + if (sMyGroup.getLength() == 0) + sMyGroup = m_aName; // meine Siblings durchiterieren Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); @@ -174,8 +180,9 @@ void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, cons { Reference<XPropertySet> xMyProps; query_interface(static_cast<XWeak*>(this), xMyProps); - ::rtl::OUString sCurrentName; - for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) + ::rtl::OUString sCurrentGroup; + sal_Int32 nNumSiblings = xIndexAccess->getCount(); + for (sal_Int32 i=0; i<nNumSiblings; ++i) { Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY); if (!xSiblingProperties.is()) @@ -192,8 +199,8 @@ void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, cons continue; // das 'zur selben Gruppe gehoeren' wird am Namen festgemacht - xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sCurrentName; - if (sCurrentName == sMyName) + sCurrentGroup = OGroupManager::GetGroupName( xSiblingProperties ); + if (sCurrentGroup == sMyGroup) xSiblingProperties->setPropertyValue(rPropName, rValue); } } @@ -220,40 +227,7 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons // die andere Richtung : wenn sich mein Name aendert ... if (nHandle == PROPERTY_ID_NAME) { - // ... muss ich testen, ob ich Siblings mit dem selben Namen habe, damit ich deren ControlSource uebernehmen kann - Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); - if (xIndexAccess.is()) - { - ::rtl::OUString sName; - ::rtl::OUString sControlSource; - - Reference<XPropertySet> xMyProps; - query_interface(static_cast<XWeak*>(this), xMyProps); - for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) - { - Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY); - if (!xSiblingProperties.is()) - continue; - - if (xMyProps == xSiblingProperties) - // nur wenn ich nicht mich selber gefunden habe - continue; - - sal_Int16 nType = 0; - xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; - if (nType != FormComponentType::RADIOBUTTON) - // nur Radio-Buttons - continue; - - xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sName; - // Control, das zur gleichen Gruppe gehoert ? - if (rValue == sName) - { - setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE)); - break; - } - } - } + setControlSource(); } if (nHandle == PROPERTY_ID_DEFAULT_STATE) @@ -271,6 +245,52 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons } } +void ORadioButtonModel::setControlSource() +{ + Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); + if (xIndexAccess.is()) + { + ::rtl::OUString sName, sGroupName; + + if (hasProperty(PROPERTY_GROUP_NAME, this)) + this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName; + this->getPropertyValue(PROPERTY_NAME) >>= sName; + + Reference<XPropertySet> xMyProps; + query_interface(static_cast<XWeak*>(this), xMyProps); + for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) + { + Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY); + if (!xSiblingProperties.is()) + continue; + + if (xMyProps == xSiblingProperties) + // nur wenn ich nicht mich selber gefunden habe + continue; + + sal_Int16 nType = 0; + xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; + if (nType != FormComponentType::RADIOBUTTON) + // nur Radio-Buttons + continue; + + ::rtl::OUString sSiblingName, sSiblingGroupName; + if (hasProperty(PROPERTY_GROUP_NAME, xSiblingProperties)) + xSiblingProperties->getPropertyValue(PROPERTY_GROUP_NAME) >>= sSiblingGroupName; + xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sSiblingName; + + if ((sGroupName.getLength() == 0 && sSiblingGroupName.getLength() == 0 && // (no group name + sName == sSiblingName) || // names match) or + (sGroupName.getLength() != 0 && sSiblingGroupName.getLength() != 0 && // (have group name + sGroupName == sSiblingGroupName)) // they match) + { + setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE)); + break; + } + } + } +} + //------------------------------------------------------------------------------ void ORadioButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { @@ -360,6 +380,13 @@ void ORadioButtonModel::_propertyChanged(const PropertyChangeEvent& _rEvent) thr SetSiblingPropsTo( PROPERTY_STATE, aZero ); } } + else if ( _rEvent.PropertyName.equals( PROPERTY_GROUP_NAME ) ) + { + setControlSource(); + // Can't call OReferenceValueComponent::_propertyChanged(), as it + // doesn't know what to do with the GroupName property. + return; + } OReferenceValueComponent::_propertyChanged( _rEvent ); } diff --git a/forms/source/component/RadioButton.hxx b/forms/source/component/RadioButton.hxx index 3f122fe7b27c..37d129d0befc 100644 --- a/forms/source/component/RadioButton.hxx +++ b/forms/source/component/RadioButton.hxx @@ -84,6 +84,8 @@ private: our mutex is aquired exactly once */ void setNewAggregateState( const ::com::sun::star::uno::Any& _rValue ); + + void setControlSource(); }; //================================================================== diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index 8a8105d2e1a7..51ce3374592d 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -97,6 +97,7 @@ namespace frm FORMS_CONSTASCII_STRING( PROPERTY_TABINDEX, "TabIndex" ); FORMS_CONSTASCII_STRING( PROPERTY_TAG, "Tag" ); FORMS_CONSTASCII_STRING( PROPERTY_NAME, "Name" ); + FORMS_CONSTASCII_STRING( PROPERTY_GROUP_NAME, "GroupName" ); FORMS_CONSTASCII_STRING( PROPERTY_CLASSID, "ClassId" ); FORMS_CONSTASCII_STRING( PROPERTY_FETCHSIZE, "FetchSize" ); FORMS_CONSTASCII_STRING( PROPERTY_VALUE, "Value" ); diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index c1064e6d56b9..2043fdef2ed3 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -60,7 +60,8 @@ 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) -#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) +#define PROPERTY_ID_GROUP_NAME (PROPERTY_ID_START + 22) +#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 23) // free // free // free diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index e494406f87ef..713dc8fb8909 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -154,9 +154,16 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIn xProps->getPropertyValue( rtl::OUString::createFromAscii("DefaultControl" ) ) >>= sServiceName; Reference< ooo::vba::XVBAToOOEventDescGen > xDescSupplier( m_xServiceFactory->createInstance( rtl::OUString::createFromAscii( "ooo.vba.VBAToOOEventDesc" ) ), UNO_QUERY_THROW ); - Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( m_xServiceFactory->createInstance( sServiceName ), sCodeName ); + Reference< XInterface > xInterface = m_xServiceFactory->createInstance( sServiceName ); + Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( xInterface, sCodeName ); // register the vba script events m_xEventAttacher->registerScriptEvents( i_nIndex, vbaEvents ); + + Reference< XComponent > xComponent( xInterface, UNO_QUERY ); + if ( xComponent.is() ) + { + xComponent->dispose(); + } } while ( false ); } |