From 9f5745c1bca373fa6ea1c8daa57cd01f50b20968 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 30 Sep 2010 18:04:12 +0200 Subject: [PATCH 01/85] obo56: #163781# BuildAllDimensionMembers: from external source, after adding dimensions obo56: #163805# Authors: Niklas Nebel User Frank Peters --- readlicense_oo/docs/readme.xsl | 58 ++++++++++++++++------------------ 1 file changed, 28 insertions(+), 30 deletions(-) mode change 100644 => 100755 readlicense_oo/docs/readme.xsl diff --git a/readlicense_oo/docs/readme.xsl b/readlicense_oo/docs/readme.xsl old mode 100644 new mode 100755 index 4e77fa522c3d..e63e319cf502 --- a/readlicense_oo/docs/readme.xsl +++ b/readlicense_oo/docs/readme.xsl @@ -34,6 +34,13 @@ + + + + + + + @@ -115,59 +122,50 @@ - -* + * - - + - - + - - - + + - - -====================================================================== - + + ====================================================================== + - -====================================================================== + + ====================================================================== + - - ----------------------------------------------------------------------- - + + + ---------------------------------------------------------------------- + - ----------------------------------------------------------------------- - + + ---------------------------------------------------------------------- - - - + + - ----------------------------------------------------------------------- - + + ---------------------------------------------------------------------- - - From 94c8d24c100c876de416ea51a9330d5b21c1c16b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 1 Dec 2010 09:57:04 +0100 Subject: [PATCH 02/85] dba34b: removed unused includes --- svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index d7df0a932f9c..8f7e36769318 100755 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -57,8 +57,6 @@ #include /** === end UNO includes === **/ -#include -#include #include #include #include @@ -69,7 +67,6 @@ #include #include -#include #include /* From 947f23d3b3890efbc931030bc792ab9c8d5bde87 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 1 Dec 2010 09:57:05 +0100 Subject: [PATCH 03/85] dba34b: #i113555# when a button's URL points to a document-local target, properly export this to PDF --- drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 0d2be85f9872..7e53a5dfa5c4 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -865,7 +865,7 @@ namespace drawinglayer // I have now moved describePDFControl to toolkit, thus i can implement the PDF // form control support now as follows ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget > pPDFControl; - ::toolkitform::describePDFControl(rXControl, pPDFControl); + ::toolkitform::describePDFControl( rXControl, pPDFControl, *mpPDFExtOutDevData ); if(pPDFControl.get()) { From 39345c3f8efa8c33b7f3655bc9a854daf9cc6928 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 1 Dec 2010 12:39:33 +0100 Subject: [PATCH 04/85] dba34c: #i114595# don't ask for the Selection control if it doesn't exist --- sfx2/source/dialog/filedlghelper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 02b9003f59d2..91f1afacf1a4 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1564,7 +1564,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the item should remain only if it was set by the dialog rpSet->ClearItem( SID_SELECTION ); - if( mbExport ) + if( mbExport && mbHasSelectionBox ) { try { From 2e082fe92cc64f6abee53440be67ff39bc83e433 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 2 Dec 2010 14:16:42 +0100 Subject: [PATCH 05/85] dba34c: #i115876# --- svx/source/form/fmobj.cxx | 4 +++- svx/source/form/fmpgeimp.cxx | 33 ++++++++++++++++++++++++++++----- svx/source/inc/fmpgeimp.hxx | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index e679779887a2..ba2fba4f40f3 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -650,7 +650,9 @@ void FmFormObj::SetUnoControlModel( const Reference< com::sun::star::awt::XContr { SdrUnoObj::SetUnoControlModel( _rxModel ); - // TODO: call something like formObjectInserted at the form page, to tell it the new model + FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetPage() ); + if ( pFormPage ) + pFormPage->GetImpl().formModelAssigned( *this ); impl_checkRefDevice_nothrow( true ); } diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index 3ade4bdd3091..ceafd55566e2 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -275,7 +275,7 @@ namespace _map->put( makeAny( xControlModel ), makeAny( xControlShape ) ); } - static void lcl_removeFormObject( const FmFormObj& _object, const Reference< XMap >& _map ) + static void lcl_removeFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map, bool i_ignoreNonExistence = false ) { // the control model Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); @@ -287,8 +287,11 @@ namespace Any aOldAssignment = #endif _map->remove( makeAny( xControlModel ) ); - OSL_ENSURE( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ), - "lcl_removeFormObject: map was inconsistent!" ); + (void)aOldAssignment; + OSL_ENSURE( !i_ignoreNonExistence || + ( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ) ), + "lcl_removeFormObject: map was inconsistent!" ); + (void)i_ignoreNonExistence; } } @@ -703,7 +706,26 @@ Reference< XForm > FmFormPageImpl::findFormForDataSource( return sName; } -//------------------------------------------------------------------ +//---------------------------------------------------------------------------------------------------------------------- +void FmFormPageImpl::formModelAssigned( const FmFormObj& _object ) +{ + Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); + if ( !xControlShapeMap.is() ) + // our map does not exist -> not interested in this event + return; + + try + { + lcl_removeFormObject_throw( _object, xControlShapeMap, false ); + lcl_insertFormObject_throw( _object, xControlShapeMap ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//---------------------------------------------------------------------------------------------------------------------- void FmFormPageImpl::formObjectInserted( const FmFormObj& _object ) { Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); @@ -721,6 +743,7 @@ void FmFormPageImpl::formObjectInserted( const FmFormObj& _object ) } } +//---------------------------------------------------------------------------------------------------------------------- void FmFormPageImpl::formObjectRemoved( const FmFormObj& _object ) { Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); @@ -730,7 +753,7 @@ void FmFormPageImpl::formObjectRemoved( const FmFormObj& _object ) try { - lcl_removeFormObject( _object, xControlShapeMap ); + lcl_removeFormObject_throw( _object, xControlShapeMap ); } catch( const Exception& ) { diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx index 755c754853dc..d5061af70bdf 100644 --- a/svx/source/inc/fmpgeimp.hxx +++ b/svx/source/inc/fmpgeimp.hxx @@ -135,6 +135,7 @@ public: void formObjectInserted( const FmFormObj& _object ); void formObjectRemoved( const FmFormObj& _object ); + void formModelAssigned( const FmFormObj& _object ); /** returns an object mapping from control models to drawing shapes. */ From b8cfdece629a509bd668a9b6196a839518551cfd Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Thu, 2 Dec 2010 14:18:45 +0100 Subject: [PATCH 06/85] dba34c: #i99979# check if international --- connectivity/source/parse/sqlnode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index b8bcd5334787..f9f348592a6f 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2467,7 +2467,7 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode if (rString.getLength()) rString.appendAscii(" "); - const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, &rParam.m_rContext); + const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, rParam.bInternational ? &rParam.m_rContext : NULL); rString.append(::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8)); } break; case SQL_NODE_STRING: From f43f0131fae5fc74680fceeef1ef26a3dd631201 Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Thu, 2 Dec 2010 14:39:01 +0100 Subject: [PATCH 07/85] dba34c: #i103425# allow datediff with 2 args as well --- connectivity/source/parse/sqlbison.y | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 9709d33fdf76..947da78b8f62 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -271,7 +271,7 @@ using namespace connectivity; %type form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist %type /*bit_concatenation*/ bit_value_exp bit_factor bit_primary collate_clause char_value_fct unique_spec value_exp_commalist in_predicate_value unique_test update_source %type function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument -%type date_function_0Argument date_function_1Argument function_name12 function_name23 function_name1 function_name2 function_name3 function_name0 numeric_function_0Argument numeric_function_1Argument numeric_function_2Argument date_function_3Argument +%type date_function_0Argument date_function_1Argument function_name12 function_name23 function_name1 function_name2 function_name3 function_name0 numeric_function_0Argument numeric_function_1Argument numeric_function_2Argument %type all query_primary sql_not for_length upper_lower comparison column_val cross_union /*opt_schema_element_list*/ %type /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist %type column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement @@ -1851,10 +1851,10 @@ function_name12: ; function_name23: SQL_TOKEN_LOCATE + | SQL_TOKEN_DATEDIFF ; function_name3: string_function_3Argument - | date_function_3Argument ; function_name: string_function @@ -1912,8 +1912,6 @@ date_function_1Argument: | SQL_TOKEN_TIMEVALUE | SQL_TOKEN_DATEVALUE ; -date_function_3Argument: - SQL_TOKEN_DATEDIFF date_function: SQL_TOKEN_TIMESTAMPADD From 3ae1e51873cf2cd2a56edceda14e702a806f68c8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 2 Dec 2010 15:29:46 +0100 Subject: [PATCH 08/85] dba34c: spelling --- sfx2/source/control/unoctitm.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index e53f1766b7b9..90aaeca680cc 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -131,7 +131,7 @@ void SfxUnoControllerItem::UnBind() void SAL_CALL SfxUnoControllerItem::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException ) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); - DBG_ASSERT( pCtrlItem, "Dispatch hat den StatusListener nicht entfern!" ); + DBG_ASSERT( pCtrlItem, "dispatch implementation didn't respect our previous removeStatusListener call!" ); if ( rEvent.Requery ) { From ea6c7c0d73e7d898d6e4759cb33997b7a48d2bd7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 2 Dec 2010 15:29:46 +0100 Subject: [PATCH 09/85] dba34c: FmFormPageImpl needs late init, else the 'copy-ctor' crashs after the previous change --- svx/source/form/fmpage.cxx | 5 ++++- svx/source/form/fmpgeimp.cxx | 13 +++++-------- svx/source/inc/fmpgeimp.hxx | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index 0a5c7da9ea3c..94c6e80dcc07 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -105,12 +105,15 @@ FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, FASTBOOL bMaster FmFormPage::FmFormPage(const FmFormPage& rPage) :SdrPage(rPage) #ifndef SVX_LIGHT - ,m_pImpl(new FmFormPageImpl( *this, rPage.GetImpl() ) ) + ,m_pImpl(new FmFormPageImpl( *this ) ) #else ,m_pImpl(NULL) #endif ,m_pBasic(0) { +#ifndef SVX_LIGHT + m_pImpl->initFrom( rPage.GetImpl() ); +#endif RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" ); m_sPageName = rPage.m_sPageName; } diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index ceafd55566e2..ec612e2ea782 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -167,19 +167,16 @@ namespace } //------------------------------------------------------------------------------ -FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl ) - :m_rPage( _rPage ) - ,m_bFirstActivation( sal_True ) - ,m_bAttemptedFormCreation( false ) +void FmFormPageImpl::initFrom( FmFormPageImpl& i_foreignImpl ) { DBG_CTOR(FmFormPageImpl,NULL); // clone the Forms collection - Reference< XCloneable > xCloneable( const_cast< FmFormPageImpl& >( rImpl ).getForms( false ), UNO_QUERY ); + Reference< XCloneable > xCloneable( const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ), UNO_QUERY ); if ( !xCloneable.is() ) { // great, nothing to do - OSL_ENSURE( !const_cast< FmFormPageImpl& >( rImpl ).getForms( false ).is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" ); + OSL_ENSURE( !const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ).is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" ); return; } try @@ -196,7 +193,7 @@ FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl aVisitor.process( FormComponentPair( xCloneable, m_xForms ), aAssignmentProcessor ); // assign the cloned models to their SdrObjects - SdrObjListIter aForeignIter( rImpl.m_rPage ); + SdrObjListIter aForeignIter( i_foreignImpl.m_rPage ); SdrObjListIter aOwnIter( m_rPage ); OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (1)!" ); @@ -230,7 +227,7 @@ FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl MapControlModels::const_iterator assignment = aModelAssignment.find( xForeignModel ); OSL_ENSURE( assignment != aModelAssignment.end(), "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" ); if ( assignment == aModelAssignment.end() ) - // the source SdrObject has a model, but it is not part of the model hierarchy in rImpl.getForms(). + // the source SdrObject has a model, but it is not part of the model hierarchy in i_foreignImpl.getForms(). // Pathological, too ... continue; diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx index d5061af70bdf..9eb91c809d66 100644 --- a/svx/source/inc/fmpgeimp.hxx +++ b/svx/source/inc/fmpgeimp.hxx @@ -81,9 +81,10 @@ protected: public: FmFormPageImpl( FmFormPage& _rPage ); - FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl ); ~FmFormPageImpl(); + void initFrom( FmFormPageImpl& i_foreignImpl ); + // nur wichtig fuer den DesignMode void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm); ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm(); From 455c3c0ca387adde8aeafe598cb49f730d655bd9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 3 Dec 2010 10:20:34 +0100 Subject: [PATCH 10/85] dba34c: #i115880# removed assertion - it does not really indicate a problem, and preventing it otherwise would be unreasonably expensive --- svx/source/form/fmpgeimp.cxx | 34 +++++++---------- svx/source/svdraw/svdouno.cxx | 71 +++++++---------------------------- 2 files changed, 27 insertions(+), 78 deletions(-) diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index ec612e2ea782..a582d97d8d15 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -169,16 +169,16 @@ namespace //------------------------------------------------------------------------------ void FmFormPageImpl::initFrom( FmFormPageImpl& i_foreignImpl ) { - DBG_CTOR(FmFormPageImpl,NULL); - // clone the Forms collection - Reference< XCloneable > xCloneable( const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ), UNO_QUERY ); + const Reference< XNameContainer > xForeignForms( const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ) ); + const Reference< XCloneable > xCloneable( xForeignForms, UNO_QUERY ); if ( !xCloneable.is() ) { // great, nothing to do - OSL_ENSURE( !const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ).is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" ); + OSL_ENSURE( !xForeignForms.is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" ); return; } + try { m_xForms.set( xCloneable->createClone(), UNO_QUERY_THROW ); @@ -205,31 +205,23 @@ void FmFormPageImpl::initFrom( FmFormPageImpl& i_foreignImpl ) bool bForeignIsForm = pForeignObj && ( pForeignObj->GetObjInventor() == FmFormInventor ); bool bOwnIsForm = pOwnObj && ( pOwnObj->GetObjInventor() == FmFormInventor ); - if ( bForeignIsForm != bOwnIsForm ) - { - OSL_ENSURE( false, "FmFormPageImpl::FmFormPageImpl: inconsistent ordering of objects!" ); - // don't attempt to do further assignments, something's completely messed up - break; - } + ENSURE_OR_BREAK( bForeignIsForm == bOwnIsForm, "FmFormPageImpl::FmFormPageImpl: inconsistent ordering of objects!" ); + // if this fires, don't attempt to do further assignments, something's completely messed up + if ( !bForeignIsForm ) // no form control -> next round continue; Reference< XControlModel > xForeignModel( pForeignObj->GetUnoControlModel() ); - OSL_ENSURE( xForeignModel.is(), "FmFormPageImpl::FmFormPageImpl: control shape without control!" ); - if ( !xForeignModel.is() ) - // the SdrObject does not have a UNO Control Model. This is pathological, but well ... So the cloned - // SdrObject will also not have a UNO Control Model. - continue; - - OSL_ENSURE( !pOwnObj->GetUnoControlModel().is(), "FmFormPageImpl::FmFormPageImpl: there already is a control model for the target object!" ); + ENSURE_OR_CONTINUE( xForeignModel.is(), "FmFormPageImpl::FmFormPageImpl: control shape without control!" ); + // if this fires, the SdrObject does not have a UNO Control Model. This is pathological, but well ... + // So the cloned SdrObject will also not have a UNO Control Model. MapControlModels::const_iterator assignment = aModelAssignment.find( xForeignModel ); - OSL_ENSURE( assignment != aModelAssignment.end(), "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" ); - if ( assignment == aModelAssignment.end() ) - // the source SdrObject has a model, but it is not part of the model hierarchy in i_foreignImpl.getForms(). + ENSURE_OR_CONTINUE( assignment != aModelAssignment.end(), "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" ); + // if this fires, the source SdrObject has a model, but it is not part of the model hierarchy in + // i_foreignImpl.getForms(). // Pathological, too ... - continue; pOwnObj->SetUnoControlModel( assignment->second ); } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index b98e5ba5c1c6..eeae4d8079a8 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -318,68 +318,25 @@ void SdrUnoObj::operator = (const SdrObject& rObj) SdrRectObj::operator = (rObj); // release the reference to the current control model - SetUnoControlModel(uno::Reference< awt::XControlModel >()); + SetUnoControlModel( NULL ); - aUnoControlModelTypeName = ((SdrUnoObj&) rObj).aUnoControlModelTypeName; - aUnoControlTypeName = ((SdrUnoObj&) rObj).aUnoControlTypeName; + const SdrUnoObj& rUnoObj = dynamic_cast< const SdrUnoObj& >( rObj ); + + aUnoControlModelTypeName = rUnoObj.aUnoControlModelTypeName; + aUnoControlTypeName = rUnoObj.aUnoControlTypeName; // copy the uno control model - uno::Reference< awt::XControlModel > xCtrl( ((SdrUnoObj&) rObj).GetUnoControlModel(), uno::UNO_QUERY ); - uno::Reference< util::XCloneable > xClone( xCtrl, uno::UNO_QUERY ); - - if ( xClone.is() ) + const uno::Reference< awt::XControlModel > xSourceControlModel( rUnoObj.GetUnoControlModel(), uno::UNO_QUERY ); + if ( xSourceControlModel.is() ) { - // copy the model by cloning - uno::Reference< awt::XControlModel > xNewModel( xClone->createClone(), uno::UNO_QUERY ); - DBG_ASSERT( xNewModel.is(), "SdrUnoObj::operator =, no control model!"); - xUnoControlModel = xNewModel; - } - else - { - // copy the model by streaming - uno::Reference< io::XPersistObject > xObj( xCtrl, uno::UNO_QUERY ); - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - if ( xObj.is() && xFactory.is() ) + try { - // creating a pipe - uno::Reference< io::XOutputStream > xOutPipe(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.Pipe")), uno::UNO_QUERY); - uno::Reference< io::XInputStream > xInPipe(xOutPipe, uno::UNO_QUERY); - - // creating the mark streams - uno::Reference< io::XInputStream > xMarkIn(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")), uno::UNO_QUERY); - uno::Reference< io::XActiveDataSink > xMarkSink(xMarkIn, uno::UNO_QUERY); - - uno::Reference< io::XOutputStream > xMarkOut(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")), uno::UNO_QUERY); - uno::Reference< io::XActiveDataSource > xMarkSource(xMarkOut, uno::UNO_QUERY); - - // connect mark and sink - uno::Reference< io::XActiveDataSink > xSink(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")), uno::UNO_QUERY); - - // connect mark and source - uno::Reference< io::XActiveDataSource > xSource(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")), uno::UNO_QUERY); - - uno::Reference< io::XObjectOutputStream > xOutStrm(xSource, uno::UNO_QUERY); - uno::Reference< io::XObjectInputStream > xInStrm(xSink, uno::UNO_QUERY); - - if (xMarkSink.is() && xMarkSource.is() && xSink.is() && xSource.is()) - { - xMarkSink->setInputStream(xInPipe); - xMarkSource->setOutputStream(xOutPipe); - xSink->setInputStream(xMarkIn); - xSource->setOutputStream(xMarkOut); - - // write the object to source - xOutStrm->writeObject(xObj); - xOutStrm->closeOutput(); - // read the object - uno::Reference< awt::XControlModel > xModel(xInStrm->readObject(), uno::UNO_QUERY); - xInStrm->closeInput(); - - DBG_ASSERT(xModel.is(), "SdrUnoObj::operator =, keine Model erzeugt"); - - xUnoControlModel = xModel; - } + uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW ); + xUnoControlModel.set( xClone->createClone(), uno::UNO_QUERY_THROW ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } From 1e3e411b54b2d556ee1df8b903d8ff311419dc99 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 3 Dec 2010 17:47:13 +0100 Subject: [PATCH 11/85] dr78: #i111413# new ODFF interpreter functions SEC, SECH, CSC, CSCH; patch from , slightly reworked --- formula/inc/formula/compiler.hrc | 126 +++++++++--------- formula/inc/formula/opcode.hxx | 4 + .../source/core/resource/core_resource.src | 24 ++++ 3 files changed, 93 insertions(+), 61 deletions(-) diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc index e4dc05aca4e9..5c58d9d3e068 100644 --- a/formula/inc/formula/compiler.hrc +++ b/formula/inc/formula/compiler.hrc @@ -130,67 +130,71 @@ #define SC_OPCODE_ARC_COS_HYP 95 #define SC_OPCODE_ARC_TAN_HYP 96 #define SC_OPCODE_ARC_COT_HYP 97 -#define SC_OPCODE_EXP 98 -#define SC_OPCODE_LN 99 -#define SC_OPCODE_SQRT 100 -#define SC_OPCODE_FACT 101 -#define SC_OPCODE_GET_YEAR 102 /* date and time */ -#define SC_OPCODE_GET_MONTH 103 -#define SC_OPCODE_GET_DAY 104 -#define SC_OPCODE_GET_HOUR 105 -#define SC_OPCODE_GET_MIN 106 -#define SC_OPCODE_GET_SEC 107 -#define SC_OPCODE_PLUS_MINUS 108 /* miscellaneous */ -#define SC_OPCODE_ABS 109 -#define SC_OPCODE_INT 110 -#define SC_OPCODE_PHI 111 -#define SC_OPCODE_GAUSS 112 -#define SC_OPCODE_IS_EMPTY 113 /* obtain type */ -#define SC_OPCODE_IS_STRING 114 -#define SC_OPCODE_IS_NON_STRING 115 -#define SC_OPCODE_IS_LOGICAL 116 -#define SC_OPCODE_TYPE 117 -#define SC_OPCODE_IS_REF 118 -#define SC_OPCODE_IS_VALUE 119 -#define SC_OPCODE_IS_FORMULA 120 -#define SC_OPCODE_IS_NV 121 -#define SC_OPCODE_IS_ERR 122 -#define SC_OPCODE_IS_ERROR 123 -#define SC_OPCODE_IS_EVEN 124 -#define SC_OPCODE_IS_ODD 125 -#define SC_OPCODE_N 126 -#define SC_OPCODE_GET_DATE_VALUE 127 /* string functions */ -#define SC_OPCODE_GET_TIME_VALUE 128 -#define SC_OPCODE_CODE 129 -#define SC_OPCODE_TRIM 130 -#define SC_OPCODE_UPPER 131 -#define SC_OPCODE_PROPPER 132 -#define SC_OPCODE_LOWER 133 -#define SC_OPCODE_LEN 134 -#define SC_OPCODE_T 135 /* miscellaneous, part 21 */ -#define SC_OPCODE_VALUE 136 -#define SC_OPCODE_CLEAN 137 -#define SC_OPCODE_CHAR 138 -#define SC_OPCODE_LOG10 139 -#define SC_OPCODE_EVEN 140 -#define SC_OPCODE_ODD 141 -#define SC_OPCODE_STD_NORM_DIST 142 -#define SC_OPCODE_FISHER 143 -#define SC_OPCODE_FISHER_INV 144 -#define SC_OPCODE_S_NORM_INV 145 -#define SC_OPCODE_GAMMA_LN 146 -#define SC_OPCODE_ERROR_TYPE 147 -#define SC_OPCODE_ERR_CELL 148 -#define SC_OPCODE_FORMULA 149 -#define SC_OPCODE_ARABIC 150 -#define SC_OPCODE_INFO 151 -#define SC_OPCODE_BAHTTEXT 152 -#define SC_OPCODE_JIS 153 -#define SC_OPCODE_ASC 154 -#define SC_OPCODE_UNICODE 155 -#define SC_OPCODE_UNICHAR 156 -#define SC_OPCODE_GAMMA 157 -#define SC_OPCODE_STOP_1_PAR 158 +#define SC_OPCODE_COSECANT 98 +#define SC_OPCODE_SECANT 99 +#define SC_OPCODE_COSECANT_HYP 100 +#define SC_OPCODE_SECANT_HYP 101 +#define SC_OPCODE_EXP 102 +#define SC_OPCODE_LN 103 +#define SC_OPCODE_SQRT 104 +#define SC_OPCODE_FACT 105 +#define SC_OPCODE_GET_YEAR 106 /* date and time */ +#define SC_OPCODE_GET_MONTH 107 +#define SC_OPCODE_GET_DAY 108 +#define SC_OPCODE_GET_HOUR 109 +#define SC_OPCODE_GET_MIN 110 +#define SC_OPCODE_GET_SEC 111 +#define SC_OPCODE_PLUS_MINUS 112 /* miscellaneous */ +#define SC_OPCODE_ABS 113 +#define SC_OPCODE_INT 114 +#define SC_OPCODE_PHI 115 +#define SC_OPCODE_GAUSS 116 +#define SC_OPCODE_IS_EMPTY 117 /* obtain type */ +#define SC_OPCODE_IS_STRING 118 +#define SC_OPCODE_IS_NON_STRING 119 +#define SC_OPCODE_IS_LOGICAL 120 +#define SC_OPCODE_TYPE 121 +#define SC_OPCODE_IS_REF 122 +#define SC_OPCODE_IS_VALUE 123 +#define SC_OPCODE_IS_FORMULA 124 +#define SC_OPCODE_IS_NV 125 +#define SC_OPCODE_IS_ERR 126 +#define SC_OPCODE_IS_ERROR 127 +#define SC_OPCODE_IS_EVEN 128 +#define SC_OPCODE_IS_ODD 129 +#define SC_OPCODE_N 130 +#define SC_OPCODE_GET_DATE_VALUE 131 /* string functions */ +#define SC_OPCODE_GET_TIME_VALUE 132 +#define SC_OPCODE_CODE 133 +#define SC_OPCODE_TRIM 134 +#define SC_OPCODE_UPPER 135 +#define SC_OPCODE_PROPPER 136 +#define SC_OPCODE_LOWER 137 +#define SC_OPCODE_LEN 138 +#define SC_OPCODE_T 139 /* miscellaneous, part 21 */ +#define SC_OPCODE_VALUE 140 +#define SC_OPCODE_CLEAN 141 +#define SC_OPCODE_CHAR 142 +#define SC_OPCODE_LOG10 143 +#define SC_OPCODE_EVEN 144 +#define SC_OPCODE_ODD 145 +#define SC_OPCODE_STD_NORM_DIST 146 +#define SC_OPCODE_FISHER 147 +#define SC_OPCODE_FISHER_INV 148 +#define SC_OPCODE_S_NORM_INV 149 +#define SC_OPCODE_GAMMA_LN 150 +#define SC_OPCODE_ERROR_TYPE 151 +#define SC_OPCODE_ERR_CELL 152 +#define SC_OPCODE_FORMULA 153 +#define SC_OPCODE_ARABIC 154 +#define SC_OPCODE_INFO 155 +#define SC_OPCODE_BAHTTEXT 156 +#define SC_OPCODE_JIS 157 +#define SC_OPCODE_ASC 158 +#define SC_OPCODE_UNICODE 159 +#define SC_OPCODE_UNICHAR 160 +#define SC_OPCODE_GAMMA 161 +#define SC_OPCODE_STOP_1_PAR 162 /*** Functions with more than one parameters ***/ #define SC_OPCODE_START_2_PAR 201 diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx index 390ab21048d3..09c621df1ef1 100644 --- a/formula/inc/formula/opcode.hxx +++ b/formula/inc/formula/opcode.hxx @@ -121,6 +121,10 @@ enum OpCodeEnum ocArcCosHyp = SC_OPCODE_ARC_COS_HYP, ocArcTanHyp = SC_OPCODE_ARC_TAN_HYP, ocArcCotHyp = SC_OPCODE_ARC_COT_HYP, + ocCosecant = SC_OPCODE_COSECANT, + ocSecant = SC_OPCODE_SECANT, + ocCosecantHyp = SC_OPCODE_COSECANT_HYP, + ocSecantHyp = SC_OPCODE_SECANT_HYP, ocExp = SC_OPCODE_EXP, ocLn = SC_OPCODE_LN, ocSqrt = SC_OPCODE_SQRT, diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index d2996e78fba7..f7cd137d08a5 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -88,6 +88,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; + String SC_OPCODE_COSECANT { Text = "CSC" ; }; + String SC_OPCODE_SECANT { Text = "SEC" ; }; + String SC_OPCODE_COSECANT_HYP { Text = "CSCH" ; }; + String SC_OPCODE_SECANT_HYP { Text = "SECH" ; }; String SC_OPCODE_EXP { Text = "EXP" ; }; String SC_OPCODE_LN { Text = "LN" ; }; String SC_OPCODE_SQRT { Text = "SQRT" ; }; @@ -412,6 +416,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; + String SC_OPCODE_COSECANT { Text = "CSC" ; }; + String SC_OPCODE_SECANT { Text = "SEC" ; }; + String SC_OPCODE_COSECANT_HYP { Text = "CSCH" ; }; + String SC_OPCODE_SECANT_HYP { Text = "SECH" ; }; String SC_OPCODE_EXP { Text = "EXP" ; }; String SC_OPCODE_LN { Text = "LN" ; }; String SC_OPCODE_SQRT { Text = "SQRT" ; }; @@ -830,6 +838,22 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "ACOTH" ; }; + String SC_OPCODE_COSECANT + { + Text [ en-US ] = "CSC" ; + }; + String SC_OPCODE_SECANT + { + Text [ en-US ] = "SEC" ; + }; + String SC_OPCODE_COSECANT_HYP + { + Text [ en-US ] = "CSCH" ; + }; + String SC_OPCODE_SECANT_HYP + { + Text [ en-US ] = "SECH" ; + }; String SC_OPCODE_EXP { Text [ en-US ] = "EXP"; From 794b301edcb9e8b52925c35ddeed71d1576dc72a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 7 Dec 2010 12:19:33 +0100 Subject: [PATCH 12/85] dba34c: some slots can be enabled in alive mode as well --- svx/source/form/fmshell.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 96bdd27d62e1..cb376a1b4acd 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -905,19 +905,19 @@ void FmFormShell::GetState(SfxItemSet &rSet) case SID_FM_USE_WIZARDS: if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) ) rSet.Put( SfxVisibilityItem( nWhich, sal_False ) ); - else if (!m_bDesignMode || !GetFormModel()) + else if (!GetFormModel()) rSet.DisableItem( nWhich ); else rSet.Put( SfxBoolItem(nWhich, GetImpl()->GetWizardUsing() ) ); break; case SID_FM_AUTOCONTROLFOCUS: - if (!m_bDesignMode || !GetFormModel()) + if (!GetFormModel()) rSet.DisableItem( nWhich ); else rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetAutoControlFocus() ) ); break; case SID_FM_OPEN_READONLY: - if (!m_bDesignMode || !GetFormModel()) + if (!GetFormModel()) rSet.DisableItem( nWhich ); else rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetOpenInDesignMode() ) ); From 00d0b523b7913b534a6f7fef4f2a86e9472d0208 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 21 Dec 2010 11:28:35 +0100 Subject: [PATCH 13/85] dba34c: #i110039# 'Form Design' now known as 'Database Form' --- officecfg/registry/data/org/openoffice/Setup.xcu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Setup.xcu b/officecfg/registry/data/org/openoffice/Setup.xcu index e8b483b8622d..27054b8a3417 100644 --- a/officecfg/registry/data/org/openoffice/Setup.xcu +++ b/officecfg/registry/data/org/openoffice/Setup.xcu @@ -348,7 +348,7 @@ swform - Base: Form Design + Base: Database Form WriterFormWindowState From 3ff6379e53a0f47f56417a41937fe92996980cb8 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 3 Jan 2011 13:56:33 +0100 Subject: [PATCH 14/85] dba34c: fix for cast and char compare --- connectivity/inc/connectivity/sqlnode.hxx | 1 + connectivity/source/drivers/ado/AColumn.cxx | 5 ++++- connectivity/source/drivers/ado/AConnection.cxx | 5 +++++ connectivity/source/drivers/macab/MacabRecord.cxx | 2 +- connectivity/source/parse/sqlnode.cxx | 11 ++++++++++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index fa283cb5cf04..04ec8dc153df 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -231,6 +231,7 @@ namespace connectivity character_string_type, other_like_predicate_part_2, between_predicate_part_2, + cast_spec, rule_count, // letzter_wert UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID) }; diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index aa287c185b26..510c2790e777 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -165,7 +165,8 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r { sal_Int32 nVal=0; rValue >>= nVal; - m_aColumn.put_NumericScale((sal_Int8)nVal); + if ( !m_IsCurrency ) + m_aColumn.put_NumericScale((sal_Int8)nVal); } break; case PROPERTY_ID_ISNULLABLE: @@ -212,6 +213,8 @@ void OAdoColumn::fillPropertyValues() DataTypeEnum eType = m_aColumn.get_Type(); m_IsCurrency = (eType == adCurrency); + if ( m_IsCurrency && !m_Scale) + m_Scale = 4; m_Type = ADOS::MapADOType2Jdbc(eType); sal_Bool bForceTo = sal_True; diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index a7e2ec4df490..6596b9b8d946 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -466,6 +466,11 @@ void OConnection::buildTypeInfo() throw( SQLException) aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value(); aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value(); aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value(); + if ( adCurrency == aInfo->eType && !aInfo->aSimpleType.nMaximumScale) + { + aInfo->aSimpleType.nMinimumScale = 4; + aInfo->aSimpleType.nMaximumScale = 4; + } aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value(); // Now that we have the type info, save it // in the Hashtable if we don't already have an diff --git a/connectivity/source/drivers/macab/MacabRecord.cxx b/connectivity/source/drivers/macab/MacabRecord.cxx index 35817526ff17..e161ece74522 100755 --- a/connectivity/source/drivers/macab/MacabRecord.cxx +++ b/connectivity/source/drivers/macab/MacabRecord.cxx @@ -202,7 +202,7 @@ sal_Int32 MacabRecord::compareFields(const macabfield *_field1, const macabfield result = CFStringCompare( (CFStringRef) _field1->value, (CFStringRef) _field2->value, - 0); // 0 = no options (like ignore case) + kCFCompareLocalized); // Specifies that the comparison should take into account differences related to locale, such as the thousands separator character. break; case kABDateProperty: diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index f9f348592a6f..77c7118a1d38 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1425,7 +1425,8 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::parenthesized_boolean_value_expression, "parenthesized_boolean_value_expression" }, { OSQLParseNode::character_string_type, "character_string_type" }, { OSQLParseNode::other_like_predicate_part_2, "other_like_predicate_part_2" }, - { OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" } + { OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" }, + { OSQLParseNode::cast_spec, "cast_spec" } }; size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" ); @@ -2511,6 +2512,7 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode rString.append(m_aNodeValue); rString.appendAscii("#"); break; + case SQL_NODE_INTNUM: case SQL_NODE_APPROXNUM: { @@ -2523,6 +2525,13 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode rString.append(aTmp); } break; + + case SQL_NODE_PUNCTUATION: + if ( getParent() && SQL_ISRULE(getParent(),cast_spec) && m_aNodeValue.toChar() == '(' ) // no spaces in front of '(' or after ')' + { + rString.append(m_aNodeValue); + break; + } // fall through default: if (rString.getLength() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' ) From 33b9b857ea6cb5a6f731de68f58e532242c43d30 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Tue, 4 Jan 2011 13:12:33 +0100 Subject: [PATCH 15/85] dba34c: #i20306# support for window function and limit fetch first, ... added --- connectivity/inc/connectivity/sqlnode.hxx | 2 + connectivity/source/drivers/file/fcomp.cxx | 4 +- connectivity/source/parse/sqlbison.y | 459 ++++++++++++++++++++- connectivity/source/parse/sqlflex.l | 27 ++ connectivity/source/parse/sqliterator.cxx | 16 +- 5 files changed, 491 insertions(+), 17 deletions(-) diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 04ec8dc153df..2fe688574a0a 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -65,6 +65,8 @@ namespace rtl { class OUStringBuffer; } +#define ORDER_BY_CHILD_POS 5 +#define TABLE_EXPRESSION_CHILD_COUNT 9 namespace connectivity { diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index eeaec1ff40f1..c5b287164e16 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -99,7 +99,7 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) OSQLParseNode * pTableExp = pSQLParseNode->getChild(3); DBG_ASSERT(pTableExp != NULL,"Fehler im Parse Tree"); DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Fehler im Parse Tree"); - DBG_ASSERT(pTableExp->count() == 5,"Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"Fehler im Parse Tree"); // check that we don't use anything other than count(*) as function OSQLParseNode* pSelection = pSQLParseNode->getChild(2); @@ -117,7 +117,7 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) pWhereClause = pTableExp->getChild(1); - pOrderbyClause = pTableExp->getChild(4); + pOrderbyClause = pTableExp->getChild(ORDER_BY_CHILD_POS); } else if (SQL_ISRULE(pSQLParseNode,update_statement_searched)) { diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 947da78b8f62..bfea82a25c7c 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -217,6 +217,14 @@ using namespace connectivity; %token SQL_TOKEN_VALUE SQL_TOKEN_CURRENT_CATALOG SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP SQL_TOKEN_CURRENT_PATH SQL_TOKEN_CURRENT_ROLE SQL_TOKEN_CURRENT_SCHEMA SQL_TOKEN_CURRENT_USER %token SQL_TOKEN_SESSION_USER SQL_TOKEN_SYSTEM_USER SQL_TOKEN_VARCHAR SQL_TOKEN_VARBINARY SQL_TOKEN_VARYING SQL_TOKEN_OBJECT SQL_TOKEN_NCLOB SQL_TOKEN_NATIONAL %token SQL_TOKEN_LARGE SQL_TOKEN_CLOB SQL_TOKEN_BLOB SQL_TOKEN_BIGINT SQL_TOKEN_BINARY SQL_TOKEN_WITHOUT SQL_TOKEN_BOOLEAN SQL_TOKEN_INTERVAL +// window function +%token SQL_TOKEN_OVER SQL_TOKEN_ROW_NUMBER SQL_TOKEN_NTILE SQL_TOKEN_LEAD SQL_TOKEN_LAG SQL_TOKEN_RESPECT SQL_TOKEN_IGNORE SQL_TOKEN_NULLS +%token SQL_TOKEN_FIRST_VALUE SQL_TOKEN_LAST_VALUE SQL_TOKEN_NTH_VALUE SQL_TOKEN_FIRST SQL_TOKEN_LAST +%token SQL_TOKEN_EXCLUDE SQL_TOKEN_OTHERS SQL_TOKEN_TIES SQL_TOKEN_FOLLOWING SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING SQL_TOKEN_RANGE SQL_TOKEN_ROWS +%token SQL_TOKEN_PARTITION SQL_TOKEN_WINDOW SQL_TOKEN_NO +// LIMIT and OFFSEt +%token SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY + /* operators */ %left SQL_TOKEN_NAME %left SQL_TOKEN_OR @@ -286,6 +294,16 @@ using namespace connectivity; %type binary_string_type numeric_type boolean_type datetime_type interval_type opt_paren_precision paren_char_length opt_paren_char_large_length paren_character_large_object_length %type large_object_length opt_multiplier character_large_object_type national_character_large_object_type binary_large_object_string_type opt_with_or_without_time_zone %type approximate_numeric_type exact_numeric_type opt_paren_precision_scale +/* window function rules */ +%type window_function window_function_type ntile_function number_of_tiles lead_or_lag_function lead_or_lag lead_or_lag_extent offset default_expression null_treatment +%type first_or_last_value_function first_or_last_value nth_value_function nth_row from_first_or_last window_name_or_specification in_line_window_specification opt_lead_or_lag_function +%type opt_null_treatment opt_from_first_or_last simple_value_specification dynamic_parameter_specification window_name window_clause window_definition_list window_definition +%type new_window_name window_specification_details existing_window_name window_partition_clause window_partition_column_reference_list window_partition_column_reference window_frame_clause +%type window_frame_units window_frame_extent window_frame_start window_frame_preceding window_frame_between window_frame_bound_1 window_frame_bound_2 window_frame_bound window_frame_following window_frame_exclusion +%type opt_window_frame_clause opt_window_partition_clause opt_existing_window_name window_specification opt_window_frame_exclusion opt_window_clause opt_offset +%type opt_fetch_first_row_count fetch_first_clause offset_row_count fetch_first_row_count first_or_next row_or_rows opt_result_offset_clause result_offset_clause +/* LIMIT and OFFSET */ +%type opt_limit_offset_clause limit_offset_clause opt_fetch_first_clause %% /* Parse Tree an OSQLParser zurueckliefern @@ -920,19 +938,89 @@ selection: } | scalar_exp_commalist ; +opt_result_offset_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | result_offset_clause + ; +result_offset_clause: + SQL_TOKEN_OFFSET offset_row_count row_or_rows + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +opt_fetch_first_row_count: + /* empty */ {$$ = SQL_NEW_RULE;} + | fetch_first_row_count + ; +first_or_next: + SQL_TOKEN_FIRST + | SQL_TOKEN_NEXT + ; +row_or_rows: + SQL_TOKEN_ROW + | SQL_TOKEN_ROWS + ; +opt_fetch_first_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | fetch_first_clause + ; +fetch_first_clause: + SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + ; +offset_row_count: + literal + ; +fetch_first_row_count: + literal + ; +opt_limit_offset_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | limit_offset_clause + ; +opt_offset: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +limit_offset_clause: + SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; table_exp: - from_clause - opt_where_clause - opt_group_by_clause - opt_having_clause - opt_order_by_clause - {$$ = SQL_NEW_RULE; + from_clause opt_where_clause opt_group_by_clause opt_having_clause opt_window_clause opt_order_by_clause opt_limit_offset_clause opt_result_offset_clause opt_fetch_first_clause + { + $$ = SQL_NEW_RULE; $$->append($1); $$->append($2); $$->append($3); $$->append($4); - $$->append($5);} + $$->append($5); + $$->append($6); + $$->append($7); + $$->append($8); + $$->append($9); + } ; from_clause: @@ -1949,6 +2037,362 @@ numeric_function: SQL_TOKEN_RAND | SQL_TOKEN_TRUNCATE ; + +window_function: + window_function_type SQL_TOKEN_OVER window_name_or_specification + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_function_type : + rank_function_type '(' ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_ROW_NUMBER '(' ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | general_set_fct + | ntile_function + | lead_or_lag_function + | first_or_last_value_function + | nth_value_function +; +ntile_function : + SQL_TOKEN_NTILE '(' number_of_tiles ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +dynamic_parameter_specification: + parameter + ; +simple_value_specification: + literal + ; +number_of_tiles : + simple_value_specification + | dynamic_parameter_specification + ; +opt_lead_or_lag_function: + /* empty */ {$$ = SQL_NEW_RULE;} + | ',' offset + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($2); + } + | ',' offset ',' default_expression + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($4); + } + ; +opt_null_treatment: + /* empty */ {$$ = SQL_NEW_RULE;} + | null_treatment + ; + +lead_or_lag_function: + lead_or_lag '(' lead_or_lag_extent opt_lead_or_lag_function ')' opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($6); + } + ; +lead_or_lag: + SQL_TOKEN_LEAD + | SQL_TOKEN_LAG + ; +lead_or_lag_extent: + value_exp + ; +offset: + SQL_TOKEN_INTNUM + ; +default_expression: + value_exp + ; +null_treatment: + SQL_TOKEN_RESPECT SQL_TOKEN_NULLS + | SQL_TOKEN_IGNORE SQL_TOKEN_NULLS + ; +first_or_last_value_function: + first_or_last_value '(' value_exp ')' opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($5); + } + ; +first_or_last_value : + SQL_TOKEN_FIRST_VALUE + | SQL_TOKEN_LAST_VALUE + ; +opt_from_first_or_last: + /* empty */ {$$ = SQL_NEW_RULE;} + | from_first_or_last + ; +nth_value_function: + SQL_TOKEN_NTH_VALUE '(' value_exp ',' nth_row ')' opt_from_first_or_last opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($7); + $$->append($8); + } + ; +nth_row: + simple_value_specification + | dynamic_parameter_specification + ; +from_first_or_last: + SQL_TOKEN_FROM SQL_TOKEN_FIRST + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_FROM SQL_TOKEN_LAST + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_name: + SQL_TOKEN_NAME + ; +window_name_or_specification: + window_name + | in_line_window_specification + ; +in_line_window_specification: + window_specification + ; +opt_window_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_clause + ; +window_clause: + SQL_TOKEN_WINDOW window_definition_list + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_definition_list: + window_definition_list ',' window_definition + {$1->append($3); + $$ = $1;} + | window_definition + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + ; +window_definition: + new_window_name SQL_TOKEN_AS window_specification + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +new_window_name: + window_name + ; +window_specification: + '(' window_specification_details ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +opt_existing_window_name: + /* empty */ {$$ = SQL_NEW_RULE;} + | existing_window_name + ; +opt_window_partition_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_partition_clause + ; +opt_window_frame_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_frame_clause + ; +window_specification_details: + opt_existing_window_name + opt_window_partition_clause + opt_order_by_clause + opt_window_frame_clause + ; +existing_window_name: + window_name + ; +window_partition_clause: + SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_partition_column_reference_list: + window_partition_column_reference_list ',' window_partition_column_reference + {$1->append($3); + $$ = $1;} + | window_partition_column_reference + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + ; +window_partition_column_reference: + column_ref opt_collate_clause + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +opt_window_frame_exclusion: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_frame_exclusion + ; +window_frame_clause: + window_frame_units window_frame_extent opt_window_frame_exclusion + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_frame_units: + SQL_TOKEN_ROWS + | SQL_TOKEN_RANGE + ; +window_frame_extent: + window_frame_start + | window_frame_between + ; +window_frame_start: + SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | window_frame_preceding + | SQL_TOKEN_CURRENT SQL_TOKEN_ROW + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_preceding: + unsigned_value_spec SQL_TOKEN_PRECEDING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_between: + SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2 + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; +window_frame_bound_1: + window_frame_bound + ; +window_frame_bound_2: + window_frame_bound + ; +window_frame_bound: + window_frame_start + | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | window_frame_following + ; +window_frame_following: + unsigned_value_spec SQL_TOKEN_FOLLOWING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_exclusion: + SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; op_parameter: {$$ = SQL_NEW_RULE;} | '?' SQL_EQUAL @@ -2313,6 +2757,7 @@ value_exp_primary: | set_fct_spec | scalar_subquery | case_expression + | window_function | '(' value_exp ')' { $$ = SQL_NEW_RULE; diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index c6723dfd6869..35a9278a8e49 100644 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -212,15 +212,19 @@ END {SQL_NEW_KEYWORD(SQL_TOKEN_END); } EVERY {SQL_NEW_KEYWORD(SQL_TOKEN_EVERY); } ESCAPE {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE); } EXCEPT {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT); } +EXCLUDE {SQL_NEW_KEYWORD(SQL_TOKEN_EXCLUDE); } EXISTS {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS); } EXP {SQL_NEW_KEYWORD(SQL_TOKEN_EXP); } EXTRACT {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); } FALSE {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE); } FETCH {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH); } +FIRST {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST); } +FIRST_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST_VALUE); } FLOAT {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT); } FLOOR {SQL_NEW_KEYWORD(SQL_TOKEN_FLOOR); } FN {SQL_NEW_KEYWORD(SQL_TOKEN_FN); } +FOLLOWING {SQL_NEW_KEYWORD(SQL_TOKEN_FOLLOWING); } FOR {SQL_NEW_KEYWORD(SQL_TOKEN_FOR); } FOREIGN {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN); } FOUND {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND); } @@ -234,6 +238,7 @@ GROUP {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP); } HAVING {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING); } HOUR {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR); } +IGNORE {SQL_NEW_KEYWORD(SQL_TOKEN_IGNORE); } IN {SQL_NEW_KEYWORD(SQL_TOKEN_IN); } INNER {SQL_NEW_KEYWORD(SQL_TOKEN_INNER); } INSERT {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT); } @@ -249,12 +254,17 @@ JOIN {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN); } KEY {SQL_NEW_KEYWORD(SQL_TOKEN_KEY); } +LAG {SQL_NEW_KEYWORD(SQL_TOKEN_LAG); } LARGE {SQL_NEW_KEYWORD(SQL_TOKEN_LARGE); } +LAST {SQL_NEW_KEYWORD(SQL_TOKEN_LAST); } +LAST_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_LAST_VALUE); } LCASE {SQL_NEW_KEYWORD(SQL_TOKEN_LCASE); } +LEAD {SQL_NEW_KEYWORD(SQL_TOKEN_LEAD); } LEADING {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING); } LEFT {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT); } LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_LENGTH); } LIKE {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE); } +LIMIT {SQL_NEW_KEYWORD(SQL_TOKEN_LIMIT); } LN {SQL_NEW_KEYWORD(SQL_TOKEN_LN); } LOCAL {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL); } LOCATE {SQL_NEW_KEYWORD(SQL_TOKEN_LOCATE); } @@ -276,29 +286,40 @@ NATURAL {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL); } NCHAR {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR); } NCLOB {SQL_NEW_KEYWORD(SQL_TOKEN_NCLOB); } NEW {SQL_NEW_KEYWORD(SQL_TOKEN_NEW); } +NEXT {SQL_NEW_KEYWORD(SQL_TOKEN_NEXT); } +NO {SQL_NEW_KEYWORD(SQL_TOKEN_NO); } NOT {SQL_NEW_KEYWORD(SQL_TOKEN_NOT); } NOW {SQL_NEW_KEYWORD(SQL_TOKEN_NOW); } +NTH_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_NTH_VALUE); } +NTILE {SQL_NEW_KEYWORD(SQL_TOKEN_NTILE); } NULL {SQL_NEW_KEYWORD(SQL_TOKEN_NULL); } NULLIF {SQL_NEW_KEYWORD(SQL_TOKEN_NULLIF); } +NULLS {SQL_NEW_KEYWORD(SQL_TOKEN_NULLS); } NUMERIC {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC); } OBJECT {SQL_NEW_KEYWORD(SQL_TOKEN_OBJECT); } OCTET_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_OCTET_LENGTH); } OF {SQL_NEW_KEYWORD(SQL_TOKEN_OF); } +OFFSET {SQL_NEW_KEYWORD(SQL_TOKEN_OFFSET); } OJ {SQL_NEW_KEYWORD(SQL_TOKEN_OJ); } OLD {SQL_NEW_KEYWORD(SQL_TOKEN_OLD); } ON {SQL_NEW_KEYWORD(SQL_TOKEN_ON); } +ONLY {SQL_NEW_KEYWORD(SQL_TOKEN_ONLY); } OPTION {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION); } OR {SQL_NEW_KEYWORD(SQL_TOKEN_OR); } ORDER {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER); } +OTHERS {SQL_NEW_KEYWORD(SQL_TOKEN_OTHERS); } OUTER {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER); } +OVER {SQL_NEW_KEYWORD(SQL_TOKEN_OVER); } +PARTITION {SQL_NEW_KEYWORD(SQL_TOKEN_PARTITION); } PERCENT_RANK {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENT_RANK); } PERCENTILE_CONT {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_CONT); } PERCENTILE_DISC {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_DISC); } PI {SQL_NEW_KEYWORD(SQL_TOKEN_PI); } POSITION {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION); } POWER {SQL_NEW_KEYWORD(SQL_TOKEN_POWER); } +PRECEDING {SQL_NEW_KEYWORD(SQL_TOKEN_PRECEDING); } PRECISION {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION); } PRIMARY {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY); } PRIVILEGES {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES); } @@ -309,16 +330,20 @@ QUARTER {SQL_NEW_KEYWORD(SQL_TOKEN_QUARTER); } RADIANS {SQL_NEW_KEYWORD(SQL_TOKEN_RADIANS); } RAND {SQL_NEW_KEYWORD(SQL_TOKEN_RAND); } +RANGE {SQL_NEW_KEYWORD(SQL_TOKEN_RANGE); } RANK {SQL_NEW_KEYWORD(SQL_TOKEN_RANK); } REAL {SQL_NEW_KEYWORD(SQL_TOKEN_REAL); } REFERENCES {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES); } REFERENCING {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCING); } REPEAT {SQL_NEW_KEYWORD(SQL_TOKEN_REPEAT); } REPLACE {SQL_NEW_KEYWORD(SQL_TOKEN_REPLACE); } +RESPECT {SQL_NEW_KEYWORD(SQL_TOKEN_RESPECT); } ROLLBACK {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK); } ROUND {SQL_NEW_KEYWORD(SQL_TOKEN_ROUND); } ROUNDMAGIC {SQL_NEW_KEYWORD(SQL_TOKEN_ROUNDMAGIC); } ROW {SQL_NEW_KEYWORD(SQL_TOKEN_ROW); } +ROWS {SQL_NEW_KEYWORD(SQL_TOKEN_ROWS); } +ROW_NUMBER {SQL_NEW_KEYWORD(SQL_TOKEN_ROW_NUMBER); } RIGHT {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT); } RTRIM {SQL_NEW_KEYWORD(SQL_TOKEN_RTRIM); } @@ -345,6 +370,7 @@ SYSTEM_USER {SQL_NEW_KEYWORD(SQL_TOKEN_SYSTEM_USER); } TABLE {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE); } TAN {SQL_NEW_KEYWORD(SQL_TOKEN_TAN); } THEN {SQL_NEW_KEYWORD(SQL_TOKEN_THEN); } +TIES {SQL_NEW_KEYWORD(SQL_TOKEN_TIES); } TIME {SQL_NEW_KEYWORD(SQL_TOKEN_TIME); } TIMESTAMP {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP); } TIMESTAMPADD {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPADD); } @@ -363,6 +389,7 @@ TS {SQL_NEW_KEYWORD(SQL_TOKEN_TS); } T {SQL_NEW_KEYWORD(SQL_TOKEN_T); } UCASE {SQL_NEW_KEYWORD(SQL_TOKEN_UCASE); } +UNBOUNDED {SQL_NEW_KEYWORD(SQL_TOKEN_UNBOUNDED); } UNION {SQL_NEW_KEYWORD(SQL_TOKEN_UNION); } UNIQUE {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE); } UNKNOWN {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 34ba49566383..58d0330a2f29 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1068,9 +1068,9 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo OSQLParseNode * pTableExp = pSelectNode->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); - sal_uInt32 nPos = ( _bOrder ? 4 : 2 ); + sal_uInt32 nPos = ( _bOrder ? ORDER_BY_CHILD_POS : 2 ); OSQLParseNode * pOptByClause = pTableExp->getChild(nPos); OSL_ENSURE(pOptByClause != NULL,"OSQLParseTreeIterator: error in parse tree!"); @@ -1233,7 +1233,7 @@ bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSele OSQLParseNode * pTableExp = pSelectNode->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pWhereClause = pTableExp->getChild(1); } else if (SQL_ISRULE(pSelectNode,update_statement_searched)) { @@ -1967,7 +1967,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pWhereClause = pTableExp->getChild(1); } @@ -1997,9 +1997,9 @@ const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); - pOrderClause = pTableExp->getChild(4); + pOrderClause = pTableExp->getChild(ORDER_BY_CHILD_POS); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: if(pOrderClause->count() != 3) pOrderClause = NULL; @@ -2019,7 +2019,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pGroupClause = pTableExp->getChild(2); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: @@ -2040,7 +2040,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pHavingClause = pTableExp->getChild(3); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: From b926321f4b3e4386e0d1ed4a2795477bd0f2e727 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Tue, 4 Jan 2011 13:42:04 +0100 Subject: [PATCH 16/85] dba34c: #i108229# check for correct token id --- connectivity/source/parse/sqliterator.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 58d0330a2f29..e0ea97f1f7aa 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1451,7 +1451,7 @@ void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition } //----------------------------------------------------------------------------- void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode - ,const OSQLParseNode* _pColumnRef + ,const OSQLParseNode* _pParentNode ,const ::rtl::OUString& _aColumnName ,const ::rtl::OUString& _aTableRange ,const ::rtl::OUString& _rColumnAlias) @@ -1490,18 +1490,18 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode } // found a parameter - if ( _pColumnRef && (SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec)) ) + if ( _pParentNode && (SQL_ISRULE(_pParentNode,general_set_fct) || SQL_ISRULE(_pParentNode,set_fct_spec)) ) {// found a function as column_ref ::rtl::OUString sFunctionName; - _pColumnRef->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - const sal_uInt32 nCount = _pColumnRef->count(); + _pParentNode->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const sal_uInt32 nCount = _pParentNode->count(); sal_uInt32 i = 0; for(; i < nCount;++i) { - if ( _pColumnRef->getChild(i) == _pParseNode ) + if ( _pParentNode->getChild(i) == _pParseNode ) break; } - sal_Int32 nType = ::connectivity::OSQLParser::getFunctionParameterType( _pColumnRef->getParent()->getChild(0)->getTokenID(), i+1); + sal_Int32 nType = ::connectivity::OSQLParser::getFunctionParameterType( _pParentNode->getChild(0)->getTokenID(), i-1); OParseColumn* pColumn = new OParseColumn( sParameterName, ::rtl::OUString(), @@ -1552,14 +1552,14 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode if ( bNotFound ) { sal_Int32 nType = DataType::VARCHAR; - OSQLParseNode* pParent = _pColumnRef ? _pColumnRef->getParent() : NULL; + OSQLParseNode* pParent = _pParentNode ? _pParentNode->getParent() : NULL; if ( pParent && (SQL_ISRULE(pParent,general_set_fct) || SQL_ISRULE(pParent,set_fct_spec)) ) { - const sal_uInt32 nCount = _pColumnRef->count(); + const sal_uInt32 nCount = _pParentNode->count(); sal_uInt32 i = 0; for(; i < nCount;++i) { - if ( _pColumnRef->getChild(i) == _pParseNode ) + if ( _pParentNode->getChild(i) == _pParseNode ) break; } nType = ::connectivity::OSQLParser::getFunctionParameterType( pParent->getChild(0)->getTokenID(), i+1); From 3e727eeb92ec7d0b03933c9f66d96e72d91f3f24 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 5 Jan 2011 10:27:09 +0100 Subject: [PATCH 17/85] dba34c: #i110584# fix for FN escape function and check if table name is empty --- .../source/commontools/predicateinput.cxx | 23 ++++++------------- connectivity/source/parse/PColumn.cxx | 16 +++++++------ connectivity/source/parse/sqlbison.y | 9 ++++++-- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 8ffebb0cfbda..73cb88b90dbf 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -332,26 +332,17 @@ namespace dbtools OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); if ( pOdbcSpec ) { - if ( !_bForStatementUse ) - { - if ( ( pOdbcSpec->count() >= 2 ) - && ( SQL_NODE_STRING == pOdbcSpec->getChild(1)->getNodeType() ) - ) - { - - sReturn = pOdbcSpec->getChild(1)->getTokenValue(); - } - else - OSL_ENSURE( sal_False, "OPredicateInputController::getPredicateValue: unknown/invalid structure (odbc + param use)!" ); - } - else + if ( _bForStatementUse ) { OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent(); OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" ); if ( pFuncSpecParent ) - pFuncSpecParent->parseNodeToStr( - sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True - ); + pFuncSpecParent->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); + } + else + { + pOdbcSpec->getChild(1)->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); + // sReturn = pOdbcSpec->getChild(1)->getTokenValue(); } } else diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index 10f4b5b4bdcf..8f3014908b10 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -155,13 +155,15 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe _rxResMetaData->isCurrency( _nColumnPos ), _rxDBMetaData->supportsMixedCaseQuotedIdentifiers() ); - pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData, - _rxResMetaData->getCatalogName( _nColumnPos ), - _rxResMetaData->getSchemaName( _nColumnPos ), - _rxResMetaData->getTableName( _nColumnPos ), - sal_False, - eComplete - ) ); + const ::rtl::OUString sTableName = _rxResMetaData->getTableName( _nColumnPos ); + if ( sTableName.getLength() ) + pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData, + _rxResMetaData->getCatalogName( _nColumnPos ), + _rxResMetaData->getSchemaName( _nColumnPos ), + sTableName, + sal_False, + eComplete + ) ); pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) ); pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos )); pColumn->setLabel(sLabel); diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index bfea82a25c7c..ad271e855e20 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -2447,11 +2447,16 @@ odbc_fct_spec: $$->append($1); $$->append($2); } + | SQL_TOKEN_FN set_fct_spec + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } ; odbc_fct_type: - SQL_TOKEN_FN - | SQL_TOKEN_D + SQL_TOKEN_D | SQL_TOKEN_T | SQL_TOKEN_TS ; From 0ca1b7ace4da7df621d38aa9df8fab3e5984577f Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 6 Jan 2011 12:32:17 +0100 Subject: [PATCH 18/85] dba34c: #i113405# remove row from rowset when it can not be accessed anymore and adjust rowcount --- svx/source/fmcomp/gridctrl.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 1944bd47dad5..4defba88e3ef 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -2001,6 +2001,18 @@ void DbGridControl::AdjustRows() RowRemoved(GetRowCount() - nDelta, nDelta, sal_False); // es sind Zeilen weggefallen, dann ab der aktuellen Position neu zeichen Invalidate(); + + sal_Int32 nNewPos = AlignSeekCursor(); + if (m_bSynchDisplay) + DbGridControl_Base::GoToRow(nNewPos); + + SetCurrent(nNewPos); + // there are rows so go to the selected current column + if (nRecordCount) + GoToRowColumnId(nNewPos, GetColumnId(GetCurColumnId())); + if (!IsResizing() && GetRowCount()) + RecalcRows(GetTopRow(), GetVisibleRows(), sal_True); + m_aBar.InvalidateAll(m_nCurrentPos, sal_True); } else // zuwenig RowInserted(GetRowCount(), -nDelta, sal_True); From 1821b0fd528c51a2f8f963a67f2e48fe457f1f27 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Mon, 10 Jan 2011 13:41:20 +0100 Subject: [PATCH 19/85] dba34c: #i108415# handle structed filter handling --- .../inc/connectivity/predicateinput.hxx | 8 ++ .../qa/connectivity/tools/CRMDatabase.java | 5 +- .../source/commontools/predicateinput.cxx | 125 +++++++++++++----- 3 files changed, 105 insertions(+), 33 deletions(-) diff --git a/connectivity/inc/connectivity/predicateinput.hxx b/connectivity/inc/connectivity/predicateinput.hxx index 5041fd30c060..2f4dfbbd3146 100644 --- a/connectivity/inc/connectivity/predicateinput.hxx +++ b/connectivity/inc/connectivity/predicateinput.hxx @@ -104,6 +104,12 @@ namespace dbtools ::rtl::OUString* _pErrorMessage = NULL ) const; + ::rtl::OUString getPredicateValue( + const ::rtl::OUString& _sField + , const ::rtl::OUString& _rPredicateValue + , sal_Bool _bForStatementUse + , ::rtl::OUString* _pErrorMessage = NULL) const; + private: ::connectivity::OSQLParseNode* implPredicateTree( ::rtl::OUString& _rErrorMessage, @@ -116,6 +122,8 @@ namespace dbtools sal_Unicode& _rDecSep, sal_Unicode& _rThdSep ) const; + + ::rtl::OUString implParseNode(::connectivity::OSQLParseNode* pParseNode,sal_Bool _bForStatementUse) const; }; //......................................................................... diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java index a1b457884948..f9b6d52a8038 100644 --- a/connectivity/qa/connectivity/tools/CRMDatabase.java +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -224,6 +224,7 @@ public class CRMDatabase // -------------------------------------------------------------------------------------------------------- private void validateUnparseable() { + /* // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query) XSingleSelectQueryComposer composer; QueryDefinition unparseableQuery; @@ -253,6 +254,7 @@ public class CRMDatabase if ( !caughtExpected ) throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" ); + */ } // -------------------------------------------------------------------------------------------------------- @@ -284,9 +286,10 @@ public class CRMDatabase m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" ); m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false ); +/* m_database.getDataSource().createQuery( "unparseable", "SELECT {fn DAYOFMONTH ('2001-01-01')} AS \"ID_VARCHAR\" FROM \"products\"", false ); - +*/ validateUnparseable(); } } diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 73cb88b90dbf..9d088c903dcc 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -31,8 +31,10 @@ #include #include #include +#include #include #include +#include #include //......................................................................... @@ -325,54 +327,113 @@ namespace dbtools ::rtl::OUString sError; OSQLParseNode* pParseNode = implPredicateTree( sError, sValue, _rxField ); - if ( _pErrorMessage ) *_pErrorMessage = sError; + if ( _pErrorMessage ) + *_pErrorMessage = sError; - if ( pParseNode ) + sReturn = implParseNode(pParseNode,_bForStatementUse); + } + + return sReturn; + } + + ::rtl::OUString OPredicateInputController::getPredicateValue( + const ::rtl::OUString& _sField, const ::rtl::OUString& _rPredicateValue, sal_Bool _bForStatementUse, ::rtl::OUString* _pErrorMessage ) const + { + ::rtl::OUString sReturn = _rPredicateValue; + ::rtl::OUString sError; + ::rtl::OUString sField = _sField; + sal_Int32 nIndex = 0; + sField = sField.getToken(0,'(',nIndex); + if(nIndex == -1) + sField = _sField; + sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType(sField,&m_aParser.getContext()); + if ( nType == DataType::OTHER || !sField.getLength() ) + { + // first try the international version + ::rtl::OUString sSql; + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * ")); + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x WHERE ")); + sSql += sField; + sSql += _rPredicateValue; + ::std::auto_ptr pParseNode( const_cast< OSQLParser& >( m_aParser ).parseTree( sError, sSql, sal_True ) ); + nType = DataType::DOUBLE; + if ( pParseNode.get() ) { - OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); - if ( pOdbcSpec ) + OSQLParseNode* pColumnRef = pParseNode->getByRule(OSQLParseNode::column_ref); + if ( pColumnRef ) { - if ( _bForStatementUse ) - { - OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent(); - OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" ); - if ( pFuncSpecParent ) - pFuncSpecParent->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); - } - else - { - pOdbcSpec->getChild(1)->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); - // sReturn = pOdbcSpec->getChild(1)->getTokenValue(); - } + } + } + } + + Reference xMeta = m_xConnection->getMetaData(); + parse::OParseColumn* pColumn = new parse::OParseColumn( sField, + ::rtl::OUString(), + ::rtl::OUString(), + ::rtl::OUString(), + ColumnValue::NULLABLE_UNKNOWN, + 0, + 0, + nType, + sal_False, + sal_False, + xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); + Reference xColumn = pColumn; + pColumn->setFunction(sal_True); + pColumn->setRealName(sField); + + OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, xColumn ); + if ( _pErrorMessage ) + *_pErrorMessage = sError; + return pParseNode ? implParseNode(pParseNode,_bForStatementUse) : sReturn; + } + + ::rtl::OUString OPredicateInputController::implParseNode(OSQLParseNode* pParseNode,sal_Bool _bForStatementUse) const + { + ::rtl::OUString sReturn; + if ( pParseNode ) + { + ::std::auto_ptr pTemp(pParseNode); + OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); + if ( pOdbcSpec ) + { + if ( _bForStatementUse ) + { + OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent(); + OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" ); + if ( pFuncSpecParent ) + pFuncSpecParent->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); } else { - if ( pParseNode->count() >= 3 ) + pOdbcSpec->getChild(1)->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); + // sReturn = pOdbcSpec->getChild(1)->getTokenValue(); + } + } + else + { + if ( pParseNode->count() >= 3 ) + { + OSQLParseNode* pValueNode = pParseNode->getChild(2); + OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" ); + if ( !_bForStatementUse ) { - OSQLParseNode* pValueNode = pParseNode->getChild(2); - OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" ); - if ( !_bForStatementUse ) - { - if ( SQL_NODE_STRING == pValueNode->getNodeType() ) - sReturn = pValueNode->getTokenValue(); - else - pValueNode->parseNodeToStr( - sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True - ); - } + if ( SQL_NODE_STRING == pValueNode->getNodeType() ) + sReturn = pValueNode->getTokenValue(); else pValueNode->parseNodeToStr( sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True ); } else - OSL_ENSURE( sal_False, "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" ); + pValueNode->parseNodeToStr( + sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True + ); } - - delete pParseNode; + else + OSL_ENSURE( sal_False, "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" ); } } - return sReturn; } //......................................................................... From ea51944d952612269d8a5ceb3dad9e019e81e4a5 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 12 Jan 2011 14:27:13 +0100 Subject: [PATCH 20/85] dba34c: unused var when not in debug --- svx/source/form/fmpgeimp.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index 90f12f411447..9aeae3856ff6 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -276,11 +276,15 @@ namespace Any aOldAssignment = #endif _map->remove( makeAny( xControlModel ) ); + #if OSL_DEBUG_LEVEL > 0 (void)aOldAssignment; + #endif OSL_ENSURE( !i_ignoreNonExistence || ( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ) ), "lcl_removeFormObject: map was inconsistent!" ); + #if OSL_DEBUG_LEVEL > 0 (void)i_ignoreNonExistence; + #endif } } From c61e2a722864969fb5835df68c86c993934ad431 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 13 Jan 2011 14:31:54 +0100 Subject: [PATCH 21/85] dba34c: compile error --- svx/source/form/fmpgeimp.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index 9aeae3856ff6..a0d2f5a3c47a 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -282,9 +282,7 @@ namespace OSL_ENSURE( !i_ignoreNonExistence || ( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ) ), "lcl_removeFormObject: map was inconsistent!" ); - #if OSL_DEBUG_LEVEL > 0 (void)i_ignoreNonExistence; - #endif } } From 3b949fc2510279cb277f651d3b0b9976cbd1c5b6 Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Thu, 20 Jan 2011 13:12:51 +0100 Subject: [PATCH 22/85] dba34d: #i98163# import hidden value correted --- xmloff/source/forms/elementimport.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index c010b666e552..80ef4629a580 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -890,12 +890,12 @@ namespace xmloff if (!bRetrievedValues) { getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty); - ENSURE_OR_BREAK( pCurrentValueProperty && pValueProperty, "OControlImport::StartElement: illegal value property names!" ); + ENSURE_OR_BREAK( pValueProperty, "OControlImport::StartElement: illegal value property names!" ); bRetrievedValues = sal_True; } - OSL_ENSURE((PROPID_VALUE != aValueProps->Handle) || pValueProperty, + ENSURE_OR_BREAK((PROPID_VALUE != aValueProps->Handle) || pValueProperty, "OControlImport::StartElement: the control does not have a value property!"); - OSL_ENSURE((PROPID_CURRENT_VALUE != aValueProps->Handle) || pCurrentValueProperty, + ENSURE_OR_BREAK((PROPID_CURRENT_VALUE != aValueProps->Handle) || pCurrentValueProperty, "OControlImport::StartElement: the control does not have a current-value property!"); // transfer the name From d1f40e7742499d578b2079b947042e9232fcbc38 Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Fri, 21 Jan 2011 08:31:57 +0100 Subject: [PATCH 23/85] dba34d: #i112014# flush connection when ooo terminate --- connectivity/source/drivers/hsqldb/HDriver.cxx | 18 ++++++++++++++++++ .../drivers/hsqldb/HTerminateListener.cxx | 1 + connectivity/source/inc/hsqldb/HDriver.hxx | 1 + 3 files changed, 20 insertions(+) diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index a0b755c107c9..3760b914cc1d 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include "HTerminateListener.hxx" #include "hsqldb/HCatalog.hxx" #include "diagnose_ex.h" @@ -70,6 +71,7 @@ namespace connectivity using namespace ::com::sun::star::embed; using namespace ::com::sun::star::io; using namespace ::com::sun::star::task; + using namespace ::com::sun::star::util; using namespace ::com::sun::star::reflection; namespace hsqldb @@ -616,6 +618,22 @@ namespace connectivity m_bInShutDownConnections = sal_True; } //------------------------------------------------------------------ + void ODriverDelegator::flushConnections() + { + TWeakPairVector::iterator aEnd = m_aConnections.end(); + for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i) + { + try + { + Reference xCon(i->second.second.first.get(),UNO_QUERY); + xCon->flush(); + } + catch(Exception&) + { + } + } + } + //------------------------------------------------------------------ void SAL_CALL ODriverDelegator::preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx index c386334acd70..52d53fa99227 100644 --- a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx +++ b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx @@ -51,6 +51,7 @@ throw( RuntimeException ) void SAL_CALL OConnectionController::queryTermination( const EventObject& /*aEvent*/ ) throw( TerminationVetoException, RuntimeException ) { + m_pDriver->flushConnections(); } void SAL_CALL OConnectionController::notifyTermination( const EventObject& /*aEvent*/ ) diff --git a/connectivity/source/inc/hsqldb/HDriver.hxx b/connectivity/source/inc/hsqldb/HDriver.hxx index 72d21d5774e1..33be38e8de48 100644 --- a/connectivity/source/inc/hsqldb/HDriver.hxx +++ b/connectivity/source/inc/hsqldb/HDriver.hxx @@ -123,6 +123,7 @@ namespace connectivity virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); void shutdownConnections(); + void flushConnections(); protected: /// dtor virtual ~ODriverDelegator(); From fca4891942b319dfe59d1a225d0ab01601a96205 Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Wed, 26 Jan 2011 12:26:48 +0100 Subject: [PATCH 24/85] dba34d: #i108967# introduce new settings into UI and driver config: RespectDriverResultSetType --- connectivity/source/drivers/ado/ado.xcu | 5 +++++ connectivity/source/drivers/jdbc/jdbc.xcu | 5 +++++ connectivity/source/drivers/jdbc/tools.cxx | 1 + connectivity/source/drivers/odbc/odbc.xcu | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index e95e1a676c12..58bfcf8975a9 100755 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -117,6 +117,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index f4f599a701d9..2afaa54a9e90 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -147,6 +147,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 65315774a601..1be627b6d4ac 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -152,6 +152,7 @@ java_util_Properties* connectivity::createStringPropertyArray(const Sequence< Pr && pBegin->Name.compareToAscii( "Authentication" ) && pBegin->Name.compareToAscii( "PreferDosLikeLineEnds" ) && pBegin->Name.compareToAscii( "PrimaryKeySupport" ) + && pBegin->Name.compareToAscii( "RespectDriverResultSetType" ) ) { ::rtl::OUString aStr; diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index 74ba8815d021..c0d3939aa0e0 100755 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -152,6 +152,11 @@ true + + + true + + From f69f2d0e52b36f8187efbdd7b92e8703daa2c28b Mon Sep 17 00:00:00 2001 From: "Thomas Benisch [tbe]" Date: Tue, 1 Feb 2011 13:12:13 +0100 Subject: [PATCH 25/85] chart53: #i116750# RTTI for SfxViewEventHint not working --- sfx2/source/config/evntconf.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx index 59c56cc291a7..960c64cf1175 100644 --- a/sfx2/source/config/evntconf.cxx +++ b/sfx2/source/config/evntconf.cxx @@ -59,7 +59,7 @@ // ----------------------------------------------------------------------- TYPEINIT1(SfxEventHint, SfxHint); TYPEINIT1(SfxEventNamesItem, SfxPoolItem); -TYPEINIT1(SfxViewEventHint, SfxHint); +TYPEINIT1(SfxViewEventHint, SfxEventHint); using namespace com::sun::star; From 9ba098098f9cdaa688988e169dc6791f3ac735e3 Mon Sep 17 00:00:00 2001 From: "Ocke.Janssen" Date: Wed, 2 Feb 2011 08:47:25 +0100 Subject: [PATCH 26/85] dba34d: check eof --- connectivity/source/drivers/flat/ETable.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index c427675f15a0..f14f18f91342 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -159,7 +159,7 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) } ++nRowCount; } - while(nRowCount < nMaxRowsToScan && m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding)); + while(nRowCount < nMaxRowsToScan && m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding) && !m_pFileStream->IsEof()); for (xub_StrLen i = 0; i < nFieldCount; i++) { From 3bcceaa72b950f3d3874f9efee7913fc1c95a74d Mon Sep 17 00:00:00 2001 From: "Thomas Benisch [tbe]" Date: Thu, 3 Feb 2011 10:50:04 +0100 Subject: [PATCH 27/85] chart53: #164394# --- .../registry/component/dp_component.cxx | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 650a7585d929..0035b67d8ef7 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1779,17 +1779,23 @@ void BackendImpl::ComponentsPackageImpl::processPackage_( if (doRegisterPackage) { ComponentBackendDb::Data data; data.javaTypeLibrary = false; - std::vector< css::uno::Reference< css::uno::XInterface > > factories; - css::uno::Reference< css::uno::XComponentContext > context( - that->getObject(url), css::uno::UNO_QUERY); - if (!context.is()) { - context.set( - that->insertObject( - url, - raise_uno_process( - that->getComponentContext(), abortChannel)), - css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::uno::XComponentContext > context; + if (startup) { + context = that->getComponentContext(); + } else { + context.set(that->getObject(url), css::uno::UNO_QUERY); + if (!context.is()) { + context.set( + that->insertObject( + url, + raise_uno_process( + that->getComponentContext(), abortChannel)), + css::uno::UNO_QUERY_THROW); + } } + + std::vector< css::uno::Reference< css::uno::XInterface > > factories; + css::uno::Reference< css::registry::XSimpleRegistry > registry( css::uno::Reference< css::lang::XMultiComponentFactory >( that->getComponentContext()->getServiceManager(), From 3a6ae28ed1860d95d529c736396778367cd141b8 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Thu, 3 Feb 2011 16:22:52 +0100 Subject: [PATCH 28/85] tkr38: #i112307# Support for x509 v3 Subject Alternative Name extension added --- uui/source/iahndl-ssl.cxx | 63 +++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index 4df133c7c674..0703c329e9fc 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -25,12 +25,18 @@ * ************************************************************************/ + #include "com/sun/star/security/CertificateValidity.hpp" +#include "com/sun/star/security/XCertificateExtension.hpp" +#include "com/sun/star/security/XSanExtension.hpp" +#include #include "com/sun/star/task/XInteractionAbort.hpp" #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/task/XInteractionRequest.hpp" #include "com/sun/star/ucb/CertificateValidationRequest.hpp" +#include +#include #include "vos/mutex.hxx" #include "tools/datetime.hxx" #include "svl/zforlist.hxx" @@ -47,6 +53,9 @@ #define DESCRIPTION_2 2 #define TITLE 3 +#define OID_SUBJECT_ALTERNATIVE_NAME "2.5.29.17" + + using namespace com::sun::star; namespace { @@ -77,19 +86,25 @@ getContentPart( const String& _rRawString ) bool isDomainMatch( - rtl::OUString hostName, rtl::OUString certHostName) + rtl::OUString hostName, uno::Sequence< ::rtl::OUString > certHostNames) { - if (hostName.equalsIgnoreAsciiCase( certHostName )) - return true; + for ( int i = 0; i < certHostNames.getLength(); i++){ + ::rtl::OUString element = certHostNames[i]; - if ( 0 == certHostName.indexOf( rtl::OUString::createFromAscii( "*" ) ) && - hostName.getLength() >= certHostName.getLength() ) - { - rtl::OUString cmpStr = certHostName.copy( 1 ); + if (element.getLength() == 0) + continue; - if ( hostName.matchIgnoreAsciiCase( - cmpStr, hostName.getLength() - cmpStr.getLength()) ) - return true; + if (hostName.equalsIgnoreAsciiCase( element )) + return true; + + if ( 0 == element.indexOf( rtl::OUString::createFromAscii( "*" ) ) && + hostName.getLength() >= element.getLength() ) + { + rtl::OUString cmpStr = element.copy( 1 ); + if ( hostName.matchIgnoreAsciiCase( + cmpStr, hostName.getLength() - cmpStr.getLength()) ) + return true; + } } return false; @@ -278,10 +293,34 @@ handleCertificateValidationRequest_( rRequest.Certificate ); } + uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = rRequest.Certificate->getExtensions(); + uno::Sequence< security::CertAltNameEntry > altNames; + for (sal_Int32 i = 0 ; i < extensions.getLength(); i++){ + uno::Reference< security::XCertificateExtension >element = extensions[i]; + + rtl::OString aId ( (const sal_Char *)element->getExtensionId().getArray(), element->getExtensionId().getLength()); + if (aId.equals(OID_SUBJECT_ALTERNATIVE_NAME)) + { + uno::Reference< security::XSanExtension > sanExtension ( element, uno::UNO_QUERY ); + altNames = sanExtension->getAlternativeNames(); + break; + } + } + + ::rtl::OUString certHostName = getContentPart( rRequest.Certificate->getSubjectName() ); + uno::Sequence< ::rtl::OUString > certHostNames(altNames.getLength() + 1); + + certHostNames[0] = certHostName; + + for(int n = 1; n < altNames.getLength(); n++){ + if (altNames[n].Type == security::ExtAltNameType_DNS_NAME){ + altNames[n].Value >>= certHostNames[n]; + } + } + if ( (!isDomainMatch( rRequest.HostName, - getContentPart( - rRequest.Certificate->getSubjectName()) )) && + certHostNames )) && trustCert ) { trustCert = executeSSLWarnDialog( pParent, From 710128334ee6f2dd538a67d2ecaf2d7b07bb6868 Mon Sep 17 00:00:00 2001 From: ka Date: Fri, 4 Feb 2011 14:49:25 +0100 Subject: [PATCH 29/85] ka102: SVG import implementation --- .../drawinglayer_primitivetypes2d.hxx | 1 + .../processor2d/canvasprocessor.hxx | 2 + .../processor2d/vclprocessor2d.hxx | 2 + drawinglayer/prj/d.lst | 1 + .../source/primitive2d/graphicprimitive2d.cxx | 69 ++++++++++-------- drawinglayer/source/primitive2d/makefile.mk | 1 + .../primitive2d/metafileprimitive2d.cxx | 28 ++++++++ .../source/processor2d/hittestprocessor2d.cxx | 2 + .../processor2d/linegeometryextractor2d.cxx | 1 + .../processor2d/textaspolygonextractor2d.cxx | 1 + .../processor2d/vclmetafileprocessor2d.cxx | 7 ++ .../processor2d/vclpixelprocessor2d.cxx | 7 ++ .../source/processor2d/vclprocessor2d.cxx | 71 +++++++++++++++++++ .../schema/org/openoffice/Office/Common.xcs | 27 +++++++ svx/inc/svx/svdograf.hxx | 1 + svx/source/dialog/_bmpmask.cxx | 3 + svx/source/gallery2/galtheme.cxx | 1 + svx/source/svdraw/svdedtv.cxx | 6 +- svx/source/svdraw/svdfmtf.cxx | 25 ++++++- svx/source/svdraw/svdfmtf.hxx | 1 + svx/source/svdraw/svdograf.cxx | 18 +++-- svx/source/xml/xmlgrhlp.cxx | 9 +-- 22 files changed, 243 insertions(+), 41 deletions(-) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 87aae8cb768f..5b23c6fcfbc0 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -103,6 +103,7 @@ #define PRIMITIVE2D_ID_EPSPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 60) #define PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 61) #define PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 62) +#define PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 63) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx index 72ff97076a6c..d218b7737c2b 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx @@ -56,6 +56,7 @@ namespace drawinglayer { namespace primitive2d { class MetafilePrimitive2D; class TextSimplePortionPrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class TransparencePrimitive2D; class PolygonStrokePrimitive2D; class FillBitmapPrimitive2D; @@ -108,6 +109,7 @@ namespace drawinglayer void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate); void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void impRenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void impRenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive); void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D); diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 9db84f3e7e0c..9e9a827d2518 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -41,6 +41,7 @@ namespace drawinglayer { namespace primitive2d { class TextSimplePortionPrimitive2D; class PolygonHairlinePrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class FillBitmapPrimitive2D; class PolyPolygonGradientPrimitive2D; class PolyPolygonBitmapPrimitive2D; @@ -97,6 +98,7 @@ namespace drawinglayer void RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased); void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate); void RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate); void RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate); diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 54f087d317e4..10e692785a81 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -13,6 +13,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive2d ..\inc\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx ..\inc\drawinglayer\primitive2d\baseprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\baseprimitive2d.hxx ..\inc\drawinglayer\primitive2d\bitmapprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\bitmapprimitive2d.hxx +..\inc\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx ..\inc\drawinglayer\primitive2d\borderlineprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\borderlineprimitive2d.hxx ..\inc\drawinglayer\primitive2d\chartprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\chartprimitive2d.hxx ..\inc\drawinglayer\primitive2d\controlprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\controlprimitive2d.hxx diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index 1e26881c9757..3b52f2340f17 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// // includes for testing MetafilePrimitive2D::create2DDecomposition @@ -260,7 +262,9 @@ namespace drawinglayer aSuppressGraphicAttr.SetCrop(0, 0, 0, 0); aSuppressGraphicAttr.SetRotation(0); aSuppressGraphicAttr.SetMirrorFlags(0); - const Graphic aTransformedGraphic(getGraphicObject().GetTransformedGraphic(&aSuppressGraphicAttr)); + + const GraphicObject& rGraphicObject = getGraphicObject(); + const Graphic aTransformedGraphic(rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr)); switch(aTransformedGraphic.GetType()) { @@ -743,34 +747,43 @@ namespace drawinglayer { #endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE // create MetafilePrimitive2D - const Graphic aGraphic(getGraphicObject().GetGraphic()); const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); - xPrimitive = Primitive2DReference( - new MetafilePrimitive2D( - aTransform, - rMetafile)); - - // #i100357# find out if clipping is needed for this primitive. Unfortunately, - // there exist Metafiles who's content is bigger than the proposed PrefSize set - // at them. This is an error, but we need to work around this - const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); - const Size aMetaFileRealSize( - const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( - *Application::GetDefaultDevice()).GetSize()); - - if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() - || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + if( aTransformedGraphic.IsRenderGraphic() ) { - // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon - const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); - basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); - aMaskPolygon.transform(aTransform); - xPrimitive = Primitive2DReference( - new MaskPrimitive2D( - basegfx::B2DPolyPolygon(aMaskPolygon), - aChildContent)); + new RenderGraphicPrimitive2D( + static_cast< MetaRenderGraphicAction* >(rMetafile.GetAction(0))->GetRenderGraphic(), + aTransform)); + } + else + { + xPrimitive = Primitive2DReference( + new MetafilePrimitive2D( + aTransform, + rMetafile)); + + // #i100357# find out if clipping is needed for this primitive. Unfortunately, + // there exist Metafiles who's content is bigger than the proposed PrefSize set + // at them. This is an error, but we need to work around this + const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); + const Size aMetaFileRealSize( + const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( + *Application::GetDefaultDevice()).GetSize()); + + if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() + || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + { + // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon + const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); + basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); + aMaskPolygon.transform(aTransform); + + xPrimitive = Primitive2DReference( + new MaskPrimitive2D( + basegfx::B2DPolyPolygon(aMaskPolygon), + aChildContent)); + } } #ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE } @@ -808,16 +821,16 @@ namespace drawinglayer { const MapMode aMapMode100thmm(MAP_100TH_MM); - Size aBitmapSize(getGraphicObject().GetPrefSize()); + Size aBitmapSize(rGraphicObject.GetPrefSize()); // #i95968# better support PrefMapMode; special for MAP_PIXEL was missing - if(MAP_PIXEL == getGraphicObject().GetPrefMapMode().GetMapUnit()) + if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit()) { aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm); } else { - aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, getGraphicObject().GetPrefMapMode(), aMapMode100thmm); + aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm); } const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop()); diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk index 720769a0efd5..77e59dca2469 100644 --- a/drawinglayer/source/primitive2d/makefile.mk +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -42,6 +42,7 @@ SLOFILES= \ $(SLO)$/baseprimitive2d.obj \ $(SLO)$/backgroundcolorprimitive2d.obj \ $(SLO)$/bitmapprimitive2d.obj \ + $(SLO)$/rendergraphicprimitive2d.obj \ $(SLO)$/borderlineprimitive2d.obj \ $(SLO)$/chartprimitive2d.obj \ $(SLO)$/controlprimitive2d.obj \ diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 893c572a3086..9988eb884679 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include ////////////////////////////////////////////////////////////////////////////// @@ -3068,6 +3069,33 @@ namespace break; } + case META_RENDERGRAPHIC_ACTION : + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*)pAction; + const Rectangle aRectangle(pA->GetPoint(), pA->GetSize()); + + if(!aRectangle.IsEmpty()) + { + // create object transform + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aRectangle.GetWidth()); + aObjectTransform.set(1, 1, aRectangle.GetHeight()); + aObjectTransform.set(0, 2, aRectangle.Left()); + aObjectTransform.set(1, 2, aRectangle.Top()); + + // add current transformation + aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform; + + // embed using EpsPrimitive + rTargetHolders.Current().append( + new drawinglayer::primitive2d::RenderGraphicPrimitive2D( + pA->GetRenderGraphic(), + aObjectTransform ) ); + } + + break; + } case META_COMMENT_ACTION : { /** CHECKED, WORKS WELL */ diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index aaafa42ec44e..74166d4fba33 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -528,6 +528,8 @@ namespace drawinglayer case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D : case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D : case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D : + case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D: + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D: { if(!getHitTextOnly()) { diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index be3601dd0024..6eac340a7aab 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -123,6 +123,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index b9ad83373923..73b5189979ff 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -214,6 +214,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 263cdeede4f8..96ccc30a8f9a 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1287,6 +1288,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed RenderGraphic primitive; use default processing + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D : { // need to handle PolyPolygonBitmapPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 6a280fcad95e..a08f718e4283 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed BitmapEx primitive + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D : { // direct draw of fillBitmapPrimitive diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index e49e54fb751c..bcfa4b6776a3 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// // control support @@ -421,6 +423,75 @@ namespace drawinglayer } } + void VclProcessor2D::RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate) + { + // create local transform + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rRenderGraphicCandidate.getTransform()); + vcl::RenderGraphic aRenderGraphic(rRenderGraphicCandidate.getRenderGraphic()); + bool bPainted(false); + + if(maBColorModifierStack.count()) + { + // !!! TODO + // aRenderGraphic = impModifyRenderGraphic(maBColorModifierStack, aRenderGraphic); + + if(aRenderGraphic.IsEmpty()) + { + // color gets completely replaced, get it + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); + aPolygon.transform(aLocalTransform); + + mpOutputDevice->SetFillColor(Color(aModifiedColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolygon(aPolygon); + + bPainted = true; + } + } + + if(!bPainted) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + + if( basegfx::fTools::equalZero( fRotate ) ) + { + aOutlineRange.transform( aLocalTransform ); + } + else + { + // !!! TODO + // if rotated, create the unrotated output rectangle for the GraphicManager paint + /* + const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + fabs(aScale.getX()), fabs(aScale.getY()), + aTranslate.getX(), aTranslate.getY())); + + aOutlineRange.transform(aSimpleObjectMatrix); + */ + } + + // prepare dest coordinates + const Point aPoint( basegfx::fround(aOutlineRange.getMinX() ), + basegfx::fround(aOutlineRange.getMinY() ) ); + const Size aSize( basegfx::fround(aOutlineRange.getWidth() ), + basegfx::fround(aOutlineRange.getHeight() ) ); + const Size aSizePixel( mpOutputDevice->LogicToPixel( aSize ) ); + const vcl::RenderGraphicRasterizer aRasterizer( aRenderGraphic ); + const BitmapEx aBitmapEx( aRasterizer.Rasterize( aSizePixel, fRotate, fShearX ) ); + + if( !aBitmapEx.IsEmpty() ) + { + mpOutputDevice->DrawBitmapEx( aPoint, aSize, aBitmapEx ); + } + } + } + void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate) { const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap()); diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ae171230dd13..2475bd6f35ba 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -4833,6 +4833,33 @@ 1 + + + KA + Specifies default settings of SVG export dialog. + + + + KA + Specifies if SVG Tiny profile should be used for export. + + false + + + + KA + Specifies if fonts should be embedded into SVG file. + + true + + + + KA + Specifies if text decoration like underlining and strike-through be drawm by using SVG attributes (true) or by drawing SVG primitives (false). + + true + + diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index 1eba8822402a..c76c77ec325a 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -148,6 +148,7 @@ public: // Keep ATM for SD. sal_Bool IsAnimated() const; sal_Bool IsEPS() const; + sal_Bool IsRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index d010109d34b3..71b50a93f894 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -1001,6 +1001,9 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) default: { + OSL_ENSURE( pAction->GetType() != META_RENDERGRAPHIC_ACTION, + "META_RENDERGRAPHIC_ACTION currently not supported at masking" ); + pAction->Duplicate(); aMtf.AddAction( pAction ); } diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 730c1179a07e..9e34e463c805 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -901,6 +901,7 @@ BOOL GalleryTheme::InsertGraphic( const Graphic& rGraphic, ULONG nInsertPos ) case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break; case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break; case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break; + case( GFX_LINK_TYPE_NATIVE_SVG ): nExportFormat = CVT_SVG; break; default: break; } diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index d2c1e7bc52ef..05d7c7711430 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -644,8 +644,12 @@ void SdrEditView::CheckPossibilities() BOOL bGraf=HAS_BASE(SdrGrafObj,pObj); BOOL bOle2=HAS_BASE(SdrOle2Obj,pObj); - if( bGraf && ((SdrGrafObj*)pObj)->HasGDIMetaFile() && !((SdrGrafObj*)pObj)->IsEPS() ) + if( bGraf && + ((SdrGrafObj*)pObj)->HasGDIMetaFile() && + !( ((SdrGrafObj*)pObj)->IsEPS() || ((SdrGrafObj*)pObj)->IsRenderGraphic() ) ) + { bImportMtfPossible = TRUE; + } if (bOle2) bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is(); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index f10610317578..cf282aab3dc7 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -195,7 +195,7 @@ ULONG ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break; case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break; case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break; - + case META_RENDERGRAPHIC_ACTION : DoAction((MetaRenderGraphicAction &)*pAct); break; } if(pProgrInfo != NULL) @@ -272,7 +272,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText { bNoLine = FALSE; bNoFill = FALSE; FASTBOOL bLine=TRUE && !bForceTextAttr; - FASTBOOL bFill=pObj==NULL || pObj->IsClosedObj() && !bForceTextAttr; + FASTBOOL bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr ); FASTBOOL bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL); if ( bLine ) @@ -1025,4 +1025,25 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void ImpSdrGDIMetaFileImport::DoAction(MetaRenderGraphicAction& rAct) +{ + GDIMetaFile aMtf; + const ::vcl::RenderGraphic& rRenderGraphic = rAct.GetRenderGraphic(); + Rectangle aRect( rAct.GetPoint(), rAct.GetSize() ); + const Point aPos; + const Size aPrefSize( rRenderGraphic.GetPrefSize() ); + + aRect.Right()++; aRect.Bottom()++; + + aMtf.SetPrefMapMode( rRenderGraphic.GetPrefMapMode() ); + aMtf.SetPrefSize( aPrefSize ); + aMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, rRenderGraphic ) ); + aMtf.WindStart(); + + SdrGrafObj* pGraf=new SdrGrafObj( aMtf, aRect ); + InsertObj( pGraf ); +} + // eof diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index 2562b81efa8d..494e43dbadfc 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -140,6 +140,7 @@ protected: void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf); + void DoAction(MetaRenderGraphicAction& rAct); void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct ); void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=FALSE); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index b299d4c7a2ef..e95e3bf5296e 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -504,6 +504,11 @@ sal_Bool SdrGrafObj::IsEPS() const return pGraphic->IsEPS(); } +sal_Bool SdrGrafObj::IsRenderGraphic() const +{ + return pGraphic->IsRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); @@ -658,6 +663,7 @@ void SdrGrafObj::ReleaseGraphicLink() void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { FASTBOOL bAnim = pGraphic->IsAnimated(); + FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic(); FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj; rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 || @@ -665,11 +671,11 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const aGeo.nDrehWink % 27000 == 0; rInfo.bResizePropAllowed = TRUE; - rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bRotate90Allowed = bNoPresGrf && !bAnim; - rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bMirror45Allowed = bNoPresGrf && !bAnim; - rInfo.bMirror90Allowed = !bEmptyPresObj; + rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic; rInfo.bTransparenceAllowed = FALSE; rInfo.bGradientAllowed = FALSE; rInfo.bShearAllowed = FALSE; @@ -677,7 +683,7 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bCanConvToPath = FALSE; rInfo.bCanConvToPathLineToArea = FALSE; rInfo.bCanConvToPolyLineToArea = FALSE; - rInfo.bCanConvToPoly = !IsEPS(); + rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic; rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index a1a7565f314d..548224991b19 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -153,7 +153,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi { pStm->SetVersion( SOFFICE_FILEFORMAT_8 ); pStm->SetCompressMode( COMPRESSMODE_ZBITMAP ); - ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm ); + ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStm->GetError() == 0 ); } } @@ -543,7 +543,8 @@ String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) con { "gif", "image/gif" }, { "png", "image/png" }, { "jpg", "image/jpeg" }, - { "tif", "image/tiff" } + { "tif", "image/tiff" }, + { "svg", "image/svg+xml" } }; String aMimeType; @@ -648,7 +649,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt pStream->Write( rLink.GetData(), rLink.GetDataSize() ); } else - rMtf.Write( *pStream ); + rMtf.Write( *pStream, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStream->GetError() == 0 ); } @@ -728,6 +729,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break; case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break; case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break; + case( GFX_LINK_TYPE_NATIVE_SVG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); break; default: aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) ); @@ -1160,4 +1162,3 @@ Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServic } } // namespace svx - From 514ab7f3cbf2ea48cf88f1579d8fc7c0e5a5df48 Mon Sep 17 00:00:00 2001 From: ka Date: Fri, 4 Feb 2011 14:52:54 +0100 Subject: [PATCH 30/85] ka102: added/removed files for SVG import and module cleanup --- .../primitive2d/rendergraphicprimitive2d.hxx | 95 +++++++++++++++++++ .../primitive2d/rendergraphicprimitive2d.cxx | 92 ++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx create mode 100644 drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx diff --git a/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx new file mode 100644 index 000000000000..190439442917 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +#include +#include +#include +#include + +////////////////////////////////////////////////////////////////////////////// +// RenderGraphicPrimitive2D class + +namespace vcl { class RenderGraphicRasterizer; } + +namespace drawinglayer +{ + namespace primitive2d + { + /** RenderGraphicPrimitive2D class + + This class is the central primitive for RenderGraphic-based primitives. + */ + class RenderGraphicPrimitive2D : public BasePrimitive2D + { + private: + /// the RenderGraphic data + vcl::RenderGraphic maRenderGraphic; + mutable std::auto_ptr< vcl::RenderGraphicRasterizer > mapCurrentRasterizer; + + /** the object transformation from unit coordinates, defining + size, shear, rotate and position + */ + basegfx::B2DHomMatrix maTransform; + + public: + /// constructor + RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform); + + /// data read access + inline const vcl::RenderGraphic& getRenderGraphic() const { return maRenderGraphic; } + inline const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + + // access to latest used vcl::GraphicRasterizer for possibly reusing + // an already rendered vcl::RenderGraphic with the same transform + // properties during the next rendering process + void setCurrentRasterizer() const; + void setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentGraphicRasterizer ) const; + inline const vcl::RenderGraphicRasterizer* getCurrentRasterizer() const { return( mapCurrentRasterizer.get() ); } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx new file mode 100644 index 000000000000..439937f5d0f5 --- /dev/null +++ b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include +#include +#include +#include + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + RenderGraphicPrimitive2D::RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform) + : BasePrimitive2D(), + maRenderGraphic(rRenderGraphic), + maTransform(rTransform) + { + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer() const + { + mapCurrentRasterizer.reset(); + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentRasterizer ) const + { + mapCurrentRasterizer.reset( new vcl::RenderGraphicRasterizer( rCurrentRasterizer ) ); + } + + bool RenderGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const RenderGraphicPrimitive2D& rCompare = (RenderGraphicPrimitive2D&)rPrimitive; + + return (getRenderGraphic() == rCompare.getRenderGraphic() + && getTransform() == rCompare.getTransform()); + } + + return false; + } + + basegfx::B2DRange RenderGraphicPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(maTransform); + return aRetval; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(RenderGraphicPrimitive2D, PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof From 591982d2f398724a74383338dd2268d05423130c Mon Sep 17 00:00:00 2001 From: ka Date: Mon, 7 Feb 2011 03:31:27 +0100 Subject: [PATCH 31/85] ka102: disable graphic attributes in case of RenderGraphic content --- svx/inc/svx/svdograf.hxx | 2 +- svx/source/svdraw/svdograf.cxx | 5 ++ svx/source/tbxctrls/grafctrl.cxx | 146 +++++++++++++++++++------------ 3 files changed, 98 insertions(+), 55 deletions(-) diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index c76c77ec325a..fa095261c3b2 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -149,6 +149,7 @@ public: sal_Bool IsAnimated() const; sal_Bool IsEPS() const; sal_Bool IsRenderGraphic() const; + sal_Bool HasRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; @@ -226,4 +227,3 @@ public: }; #endif //_SVDOGRAF_HXX - diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index e95e3bf5296e..fd7545dea0c4 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -509,6 +509,11 @@ sal_Bool SdrGrafObj::IsRenderGraphic() const return pGraphic->IsRenderGraphic(); } +sal_Bool SdrGrafObj::HasRenderGraphic() const +{ + return pGraphic->HasRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 9f8c023c3b3d..e60e9ae27e47 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -856,10 +856,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) { SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST ); - - const bool bUndo = rView.IsUndoEnabled(); - - String aUndoStr; + String aUndoStr; + const bool bUndo = rView.IsUndoEnabled(); if( bUndo ) { @@ -1140,6 +1138,28 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) SfxItemSet aAttrSet( rPool ); SfxWhichIter aIter( rSet ); USHORT nWhich = aIter.FirstWhich(); + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + bool bEnableColors = true; + bool bEnableTransparency = true; + bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() ); + + for( int i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i ) + { + SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() ); + + if( !pGrafObj || + ( pGrafObj->GetGraphicType() == GRAPHIC_NONE ) || + ( pGrafObj->GetGraphicType() == GRAPHIC_DEFAULT ) || + pGrafObj->HasRenderGraphic() ) + { + bEnableColors = bEnableTransparency = bEnableCrop = false; + break; + } + else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) ) + { + bEnableTransparency = false; + } + } rView.GetAttributes( aAttrSet ); @@ -1153,8 +1173,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) { - rSet.Put( SfxUInt16Item( nSlotId, - sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt16Item( nSlotId, + sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_MODE ); + } } } break; @@ -1163,8 +1190,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_RED ); + } } } break; @@ -1173,8 +1207,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GREEN ); + } } } break; @@ -1183,8 +1224,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_BLUE ); + } } } break; @@ -1193,8 +1241,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE ); + } } } break; @@ -1203,8 +1258,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_CONTRAST ); + } } } break; @@ -1213,8 +1275,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) { - rSet.Put( SfxUInt32Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt32Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GAMMA ); + } } } break; @@ -1223,53 +1292,22 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - BOOL bEnable = TRUE; - - for( USHORT i = 0, nCount = (USHORT) rMarkList.GetMarkCount(); - ( i < nCount ) && bEnable; i++ ) + if( bEnableTransparency ) { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( !pObj || !pObj->ISA( SdrGrafObj ) || - ( (SdrGrafObj*) pObj )->HasGDIMetaFile() || - ( (SdrGrafObj*) pObj )->IsAnimated() ) - { - bEnable = FALSE; - } - } - - if( bEnable ) rSet.Put( SfxUInt16Item( nSlotId, ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) ); + } else + { rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); + } } } break; case( SID_ATTR_GRAF_CROP ): { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - BOOL bDisable = TRUE; - - if( 1 == rMarkList.GetMarkCount() ) - { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( pObj && pObj->ISA( SdrGrafObj ) ) - { - SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj; - - if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) && - ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) - { - bDisable = FALSE; - } - } - } - - if( bDisable ) + if( !bEnableCrop ) rSet.DisableItem( nSlotId ); } break; From 01fcebb5790e99aabf968d48d5915dbe736c3cb3 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 11 Feb 2011 19:12:45 +0100 Subject: [PATCH 32/85] dr78: #i107201# find word boundaries in ImpInsertText only if online spelling is active --- editeng/source/editeng/impedit2.cxx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index fe20464eb905..432ed35db2c8 100755 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2756,7 +2756,10 @@ EditPaM ImpEditEngine::ImpInsertText( EditSelection aCurSel, const XubString& rS // get word boundaries in order to clear possible WrongList entries // and invalidate all the necessary text (everything after and including the // start of the word) - EditSelection aCurWord( SelectWord( aCurPaM, i18n::WordType::DICTIONARY_WORD ) ); + // #i107201# do the expensive SelectWord call only if online spelling is active + EditSelection aCurWord; + if ( GetStatus().DoOnlineSpelling() ) + aCurWord = SelectWord( aCurPaM, i18n::WordType::DICTIONARY_WORD ); XubString aText( rStr ); aText.ConvertLineEnd( LINEEND_LF ); @@ -2813,12 +2816,17 @@ EditPaM ImpEditEngine::ImpInsertText( EditSelection aCurSel, const XubString& rS ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() ); DBG_ASSERT( pPortion, "Blinde Portion in InsertText" ); - // now remove the Wrongs (red spell check marks) from both words... - WrongList *pWrongs = aCurPaM.GetNode()->GetWrongList(); - if (pWrongs && pWrongs->HasWrongs()) - pWrongs->ClearWrongs( aCurWord.Min().GetIndex(), aPaM.GetIndex(), aPaM.GetNode() ); - // ... and mark both words as 'to be checked again' - pPortion->MarkInvalid( aCurWord.Min().GetIndex(), aLine.Len() ); + if ( GetStatus().DoOnlineSpelling() ) + { + // now remove the Wrongs (red spell check marks) from both words... + WrongList *pWrongs = aCurPaM.GetNode()->GetWrongList(); + if (pWrongs && pWrongs->HasWrongs()) + pWrongs->ClearWrongs( aCurWord.Min().GetIndex(), aPaM.GetIndex(), aPaM.GetNode() ); + // ... and mark both words as 'to be checked again' + pPortion->MarkInvalid( aCurWord.Min().GetIndex(), aLine.Len() ); + } + else + pPortion->MarkInvalid( aCurPaM.GetIndex(), aLine.Len() ); } if ( nEnd < aText.Len() ) aPaM = ImpInsertParaBreak( aPaM ); From 6953426767ee51c357276b8e5d496074375881e9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 17 Feb 2011 10:48:20 +0100 Subject: [PATCH 33/85] dba34d: #i116991# fix ScriptEventListenerWrapper to report failures in the delegatee creation as assertions only, instead of throwing a RuntimeException which is caught way too late --- svx/source/form/fmundo.cxx | 80 +++++++++++++------------------------- 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index eee61c5c2dee..8a72cb768d5f 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -66,6 +66,7 @@ #include #include #include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; @@ -88,7 +89,9 @@ typedef cppu::WeakImplHelper1< XScriptListener > ScriptEventListener_BASE; class ScriptEventListenerWrapper : public ScriptEventListener_BASE { public: - ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel) + ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) + :m_rModel( _rModel ) + ,m_attemptedListenerCreation( false ) { } @@ -98,7 +101,7 @@ public: // XScriptListener virtual void SAL_CALL firing(const ScriptEvent& evt) throw(RuntimeException) { - setModel(); + attemptListenerCreation(); if ( m_vbaListener.is() ) { m_vbaListener->firing( evt ); @@ -107,7 +110,7 @@ public: virtual Any SAL_CALL approveFiring(const ScriptEvent& evt) throw( com::sun::star::reflection::InvocationTargetException, RuntimeException) { - setModel(); + attemptListenerCreation(); if ( m_vbaListener.is() ) { return m_vbaListener->approveFiring( evt ); @@ -116,61 +119,32 @@ public: } private: - void setModel() + void attemptListenerCreation() { - if ( !m_vbaListener.is() ) - { - Reference < XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - if ( xProps.is() ) - { - Reference< XComponentContext > xCtx( xProps->getPropertyValue( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); - if ( xCtx.is() ) - { - Reference< XMultiComponentFactory > xMFac( - xCtx->getServiceManager(), UNO_QUERY ); + if ( m_attemptedListenerCreation ) + return; + m_attemptedListenerCreation = true; - // SfxObjectShellRef is good here since the model controls the lifetime of the shell - SfxObjectShellRef xObjSh = pModel->GetObjectShell(); - Reference< XMultiServiceFactory > xDocFac; - if ( xObjSh.Is() ) - xDocFac.set( xObjSh->GetModel(), UNO_QUERY ); - - if ( xMFac.is() ) - { - m_vbaListener.set( xMFac->createInstanceWithContext( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "ooo.vba.EventListener" ) ), xCtx ), - UNO_QUERY_THROW ); - } - } - } - } - Reference< XPropertySet > xProps( m_vbaListener, UNO_QUERY ); - if ( xProps.is() ) + try { - try - { - // SfxObjectShellRef is good here since the model controls the lifetime of the shell - SfxObjectShellRef xObjSh = pModel->GetObjectShell(); - if ( xObjSh.Is() && m_vbaListener.is() ) - { - Any aVal; - aVal <<= xObjSh->GetModel(); - xProps->setPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ), - aVal ); - } - } - catch( Exception& ) - { - //swallow any errors - } + ::comphelper::ComponentContext const aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XScriptListener > const xScriptListener( aContext.createComponent( "ooo.vba.EventListener" ), UNO_QUERY_THROW ); + Reference< XPropertySet > const xListenerProps( m_vbaListener, UNO_QUERY_THROW ); + // SfxObjectShellRef is good here since the model controls the lifetime of the shell + SfxObjectShellRef const xObjectShell = m_rModel.GetObjectShell(); + ENSURE_OR_THROW( xObjectShell.Is(), "no object shell!" ); + xListenerProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ), makeAny( xObjectShell->GetModel() ) ); + + m_vbaListener = xScriptListener; + } + catch( Exception const & ) + { + DBG_UNHANDLED_EXCEPTION(); } } - FmFormModel* pModel; - Reference< XScriptListener > m_vbaListener; + FmFormModel& m_rModel; + Reference< XScriptListener > m_vbaListener; + bool m_attemptedListenerCreation; }; From c9200e42289d06c6335fa15befb0a003f4ad0689 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 18 Feb 2011 19:43:30 +0100 Subject: [PATCH 34/85] sw34bf04: #i117001#: txtexppr.cxx: clean up some duplication --- xmloff/source/text/txtexppr.cxx | 117 +++++++++----------------------- 1 file changed, 32 insertions(+), 85 deletions(-) diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index 7b3c7e828683..1de027ec8623 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -27,8 +27,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include -#include + +#include "txtexppr.hxx" + #include #include #include @@ -37,7 +38,10 @@ #include #include #include -#include "txtexppr.hxx" + +#include + +#include #include #include "XMLSectionFootnoteConfigExport.hxx" @@ -302,6 +306,26 @@ void XMLTextExportPropertySetMapper::ContextFontHeightFilter( // helper method; implementation below bool lcl_IsOutlineStyle(const SvXMLExport&, const OUString&); +static void +lcl_checkMultiProperty(XMLPropertyState *const pState, + XMLPropertyState *const pRelState) +{ + if (pState && pRelState) + { + sal_Int32 nTemp = 0; + pRelState->maValue >>= nTemp; + if (100 == nTemp) + { + pRelState->mnIndex = -1; + pRelState->maValue.clear(); + } + else + { + pState->mnIndex = -1; + pState->maValue.clear(); + } + } +} void XMLTextExportPropertySetMapper::ContextFilter( ::std::vector< XMLPropertyState >& rProperties, @@ -605,88 +629,11 @@ void XMLTextExportPropertySetMapper::ContextFilter( } } - if( pParaLeftMarginState && pParaLeftMarginRelState ) - { - sal_Int32 nTemp = 0; - pParaLeftMarginRelState->maValue >>= nTemp; - if( nTemp == 100 ) - { - pParaLeftMarginRelState->mnIndex = -1; - pParaLeftMarginRelState->maValue.clear(); - } - else - { - pParaLeftMarginState->mnIndex = -1; - pParaLeftMarginState->maValue.clear(); - } - - } - - if( pParaRightMarginState && pParaRightMarginRelState ) - { - sal_Int32 nTemp = 0; - pParaRightMarginRelState->maValue >>= nTemp; - if( nTemp == 100 ) - { - pParaRightMarginRelState->mnIndex = -1; - pParaRightMarginRelState->maValue.clear(); - } - else - { - pParaRightMarginState->mnIndex = -1; - pParaRightMarginState->maValue.clear(); - } - } - - if( pParaFirstLineState && pParaFirstLineRelState ) - { - sal_Int32 nTemp = 0; - pParaFirstLineRelState->maValue >>= nTemp; - if( nTemp == 100 ) - { - pParaFirstLineRelState->mnIndex = -1; - pParaFirstLineRelState->maValue.clear(); - } - else - { - pParaFirstLineState->mnIndex = -1; - pParaFirstLineState->maValue.clear(); - } - } - - if( pParaTopMarginState && pParaTopMarginRelState ) - { - sal_Int32 nTemp = 0; - pParaTopMarginRelState->maValue >>= nTemp; - if( nTemp == 100 ) - { - pParaTopMarginRelState->mnIndex = -1; - pParaTopMarginRelState->maValue.clear(); - } - else - { - pParaTopMarginState->mnIndex = -1; - pParaTopMarginState->maValue.clear(); - } - - } - - if( pParaBottomMarginState && pParaBottomMarginRelState ) - { - sal_Int32 nTemp = 0; - pParaBottomMarginRelState->maValue >>= nTemp; - if( nTemp == 100 ) - { - pParaBottomMarginRelState->mnIndex = -1; - pParaBottomMarginRelState->maValue.clear(); - } - else - { - pParaBottomMarginState->mnIndex = -1; - pParaBottomMarginState->maValue.clear(); - } - - } + lcl_checkMultiProperty(pParaLeftMarginState, pParaLeftMarginRelState); + lcl_checkMultiProperty(pParaRightMarginState, pParaRightMarginRelState); + lcl_checkMultiProperty(pParaTopMarginState, pParaTopMarginRelState); + lcl_checkMultiProperty(pParaBottomMarginState, pParaBottomMarginRelState); + lcl_checkMultiProperty(pParaFirstLineState, pParaFirstLineRelState); if( pAllBorderWidthState ) { From 3c5facfce42a0dbe362d6b9fa5ac374fd76f51a1 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 18 Feb 2011 19:47:04 +0100 Subject: [PATCH 35/85] sw34bf04: #i117001#: xmloff: support fo:margin --- xmloff/inc/xmloff/PageMasterStyleMap.hxx | 17 ++++ xmloff/inc/xmloff/txtprmap.hxx | 8 ++ xmloff/inc/xmloff/xmltoken.hxx | 2 + xmloff/source/core/xmltoken.cxx | 2 + .../style/PageMasterExportPropMapper.cxx | 46 ++++++++++- .../style/PageMasterImportPropMapper.cxx | 79 +++++++++++++++++-- xmloff/source/style/PageMasterStyleMap.cxx | 28 ++++--- xmloff/source/text/txtexppr.cxx | 16 ++++ xmloff/source/text/txtimppr.cxx | 78 +++++++++++++++++- xmloff/source/text/txtprmap.cxx | 31 ++++---- 10 files changed, 265 insertions(+), 42 deletions(-) diff --git a/xmloff/inc/xmloff/PageMasterStyleMap.hxx b/xmloff/inc/xmloff/PageMasterStyleMap.hxx index 6ca1ba29f2cb..592949ca2b82 100644 --- a/xmloff/inc/xmloff/PageMasterStyleMap.hxx +++ b/xmloff/inc/xmloff/PageMasterStyleMap.hxx @@ -83,6 +83,11 @@ #define CTF_PM_PRINT_HEADERS (CTF_PM_PRINTMASK|(XML_PM_CTF_START + 0x0017)) #define CTF_PM_PRINT_OBJECTS (CTF_PM_PRINTMASK|(XML_PM_CTF_START + 0x0018)) #define CTF_PM_PRINT_ZEROVALUES (CTF_PM_PRINTMASK|(XML_PM_CTF_START + 0x0019)) +#define CTF_PM_MARGINALL (XML_PM_CTF_START + 0x001A) +#define CTF_PM_MARGINTOP (XML_PM_CTF_START + 0x001B) +#define CTF_PM_MARGINBOTTOM (XML_PM_CTF_START + 0x001C) +#define CTF_PM_MARGINLEFT (XML_PM_CTF_START + 0x001D) +#define CTF_PM_MARGINRIGHT (XML_PM_CTF_START + 0x001E) #define CTF_PM_PAGEUSAGE (XML_PM_CTF_START + 0x0031) #define CTF_PM_GRAPHICPOSITION (XML_PM_CTF_START + 0x0032) @@ -118,6 +123,12 @@ #define CTF_PM_HEADERGRAPHICPOSITION (CTF_PM_HEADERFLAG|(XML_PM_CTF_START + 0x0034)) #define CTF_PM_HEADERGRAPHICFILTER (CTF_PM_HEADERFLAG|(XML_PM_CTF_START + 0x0035)) #define CTF_PM_HEADERGRAPHICURL (CTF_PM_HEADERFLAG|(XML_PM_CTF_START + 0x0036)) +#define CTF_PM_HEADERMARGINALL (CTF_PM_HEADERFLAG|CTF_PM_MARGINALL) +#define CTF_PM_HEADERMARGINTOP (CTF_PM_HEADERFLAG|CTF_PM_MARGINTOP) +#define CTF_PM_HEADERMARGINBOTTOM (CTF_PM_HEADERFLAG|CTF_PM_MARGINBOTTOM) +#define CTF_PM_HEADERMARGINLEFT (CTF_PM_HEADERFLAG|CTF_PM_MARGINLEFT) +#define CTF_PM_HEADERMARGINRIGHT (CTF_PM_HEADERFLAG|CTF_PM_MARGINRIGHT) + // footer #define CTF_PM_FOOTERBORDERALL (CTF_PM_FOOTERFLAG|CTF_PM_BORDERALL) #define CTF_PM_FOOTERBORDERTOP (CTF_PM_FOOTERFLAG|CTF_PM_BORDERTOP) @@ -140,6 +151,12 @@ #define CTF_PM_FOOTERGRAPHICPOSITION (CTF_PM_FOOTERFLAG|(XML_PM_CTF_START + 0x0034)) #define CTF_PM_FOOTERGRAPHICFILTER (CTF_PM_FOOTERFLAG|(XML_PM_CTF_START + 0x0035)) #define CTF_PM_FOOTERGRAPHICURL (CTF_PM_FOOTERFLAG|(XML_PM_CTF_START + 0x0036)) +#define CTF_PM_FOOTERMARGINALL (CTF_PM_FOOTERFLAG|CTF_PM_MARGINALL) +#define CTF_PM_FOOTERMARGINTOP (CTF_PM_FOOTERFLAG|CTF_PM_MARGINTOP) +#define CTF_PM_FOOTERMARGINBOTTOM (CTF_PM_FOOTERFLAG|CTF_PM_MARGINBOTTOM) +#define CTF_PM_FOOTERMARGINLEFT (CTF_PM_FOOTERFLAG|CTF_PM_MARGINLEFT) +#define CTF_PM_FOOTERMARGINRIGHT (CTF_PM_FOOTERFLAG|CTF_PM_MARGINRIGHT) + #define CTF_PM_FTN_HEIGTH (XML_PM_CTF_START + 0x0060) #define CTF_PM_FTN_LINE_WEIGTH (XML_PM_CTF_START + 0x0061) #define CTF_PM_FTN_LINE_COLOR (XML_PM_CTF_START + 0x0062) diff --git a/xmloff/inc/xmloff/txtprmap.hxx b/xmloff/inc/xmloff/txtprmap.hxx index d64cc1266ef9..a02151cd0993 100644 --- a/xmloff/inc/xmloff/txtprmap.hxx +++ b/xmloff/inc/xmloff/txtprmap.hxx @@ -178,6 +178,14 @@ #define CTF_TEXT_DISPLAY (XML_TEXT_CTF_START + 143) #define CTF_TEXT_CLIP (XML_TEXT_CTF_START + 144) #define CTF_TEXT_CLIP11 (XML_TEXT_CTF_START + 145) +#define CTF_PARAMARGINALL (XML_TEXT_CTF_START + 146) +#define CTF_PARAMARGINALL_REL (XML_TEXT_CTF_START + 147) +#define CTF_MARGINALL (XML_TEXT_CTF_START + 148) +#define CTF_MARGINLEFT (XML_TEXT_CTF_START + 149) +#define CTF_MARGINRIGHT (XML_TEXT_CTF_START + 150) +#define CTF_MARGINTOP (XML_TEXT_CTF_START + 151) +#define CTF_MARGINBOTTOM (XML_TEXT_CTF_START + 152) + #define TEXT_PROP_MAP_TEXT 0 #define TEXT_PROP_MAP_PARA 1 #define TEXT_PROP_MAP_FRAME 2 diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index ecadbbdc196f..06663cc5e0f3 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3124,6 +3124,8 @@ namespace xmloff { namespace token { XML_MIN_VALUE, XML_MAX_VALUE, + XML_MARGIN, // #i117001# + XML_TOKEN_END }; diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 824d28a51a5c..97754ae1e919 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3124,6 +3124,8 @@ namespace xmloff { namespace token { TOKEN( "min-value", XML_MIN_VALUE ), TOKEN( "max-value", XML_MAX_VALUE ), + TOKEN( "margin", XML_MARGIN), + #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END } #else diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index fe14231e51c4..d803b79b50a1 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.cxx +++ b/xmloff/source/style/PageMasterExportPropMapper.cxx @@ -31,9 +31,7 @@ #include #include #include -#ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX #include -#endif #include #include #include @@ -84,6 +82,12 @@ void lcl_AddState(::std::vector< XMLPropertyState >& rPropState, sal_Int32 nInde struct XMLPropertyStateBuffer { + XMLPropertyState* pPMMarginAll; + XMLPropertyState* pPMMarginTop; + XMLPropertyState* pPMMarginBottom; + XMLPropertyState* pPMMarginLeft; + XMLPropertyState* pPMMarginRight; + XMLPropertyState* pPMBorderAll; XMLPropertyState* pPMBorderTop; XMLPropertyState* pPMBorderBottom; @@ -106,7 +110,13 @@ struct XMLPropertyStateBuffer void ContextFilter( ::std::vector< XMLPropertyState >& rPropState ); }; -XMLPropertyStateBuffer::XMLPropertyStateBuffer() : +XMLPropertyStateBuffer::XMLPropertyStateBuffer() + : pPMMarginAll( NULL ) + , pPMMarginTop( NULL ) + , pPMMarginBottom( NULL ) + , pPMMarginLeft( NULL ) + , pPMMarginRight( NULL ) + , pPMBorderAll( NULL ), pPMBorderTop( NULL ), pPMBorderBottom( NULL ), @@ -129,6 +139,31 @@ XMLPropertyStateBuffer::XMLPropertyStateBuffer() : void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& ) { + if (pPMMarginAll) + { + if (pPMMarginTop && pPMMarginBottom && pPMMarginLeft && pPMMarginRight) + { + sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0; + + pPMMarginTop->maValue >>= nTop; + pPMMarginBottom->maValue >>= nBottom; + pPMMarginLeft->maValue >>= nLeft; + pPMMarginRight->maValue >>= nRight; + + if ((nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight)) + { + lcl_RemoveState( pPMMarginTop ); + lcl_RemoveState( pPMMarginBottom ); + lcl_RemoveState( pPMMarginLeft ); + lcl_RemoveState( pPMMarginRight ); + } + else + lcl_RemoveState( pPMMarginAll ); + } + else + lcl_RemoveState( pPMMarginAll ); + } + if( pPMBorderAll ) { if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight ) @@ -348,6 +383,11 @@ void XMLPageMasterExportPropMapper::ContextFilter( switch( nSimpleId ) { + case CTF_PM_MARGINALL: pBuffer->pPMMarginAll = pProp; break; + case CTF_PM_MARGINTOP: pBuffer->pPMMarginTop = pProp; break; + case CTF_PM_MARGINBOTTOM: pBuffer->pPMMarginBottom = pProp; break; + case CTF_PM_MARGINLEFT: pBuffer->pPMMarginLeft = pProp; break; + case CTF_PM_MARGINRIGHT: pBuffer->pPMMarginRight = pProp; break; case CTF_PM_BORDERALL: pBuffer->pPMBorderAll = pProp; break; case CTF_PM_BORDERTOP: pBuffer->pPMBorderTop = pProp; break; case CTF_PM_BORDERBOTTOM: pBuffer->pPMBorderBottom = pProp; break; diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx index 59cff11d65cc..4af6e1ce16e1 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.cxx +++ b/xmloff/source/style/PageMasterImportPropMapper.cxx @@ -28,14 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" - #include "PageMasterImportPropMapper.hxx" -#ifndef _XMLOFF_PAGEMASTERPROPMAPPER_HXX #include "PageMasterPropMapper.hxx" -#endif -#ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX #include -#endif #include #include #include @@ -129,7 +124,15 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& XMLPropertyState* pFooterHeight = NULL; XMLPropertyState* pFooterMinHeight = NULL; XMLPropertyState* pFooterDynamic = NULL; - sal_uInt16 i; // for the "for" loop + XMLPropertyState* pAllMarginProperty = NULL; + XMLPropertyState* pMargins[4] = { NULL, NULL, NULL, NULL }; + ::std::auto_ptr pNewMargins[4]; + XMLPropertyState* pAllHeaderMarginProperty = NULL; + XMLPropertyState* pHeaderMargins[4] = { NULL, NULL, NULL, NULL }; + ::std::auto_ptr pNewHeaderMargins[4]; + XMLPropertyState* pAllFooterMarginProperty = NULL; + XMLPropertyState* pFooterMargins[4] = { NULL, NULL, NULL, NULL }; + ::std::auto_ptr pNewFooterMargins[4]; ::std::vector< XMLPropertyState >::iterator aEnd = rProperties.end(); for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); aIter != aEnd; ++aIter) @@ -189,12 +192,60 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& case CTF_PM_HEADERMINHEIGHT : pHeaderMinHeight = property; break; case CTF_PM_FOOTERHEIGHT : pFooterHeight = property; break; case CTF_PM_FOOTERMINHEIGHT : pFooterMinHeight = property; break; + case CTF_PM_MARGINALL : + pAllMarginProperty = property; break; + case CTF_PM_MARGINTOP : + pMargins[XML_LINE_TOP] = property; break; + case CTF_PM_MARGINBOTTOM: + pMargins[XML_LINE_BOTTOM] = property; break; + case CTF_PM_MARGINLEFT : + pMargins[XML_LINE_LEFT] = property; break; + case CTF_PM_MARGINRIGHT : + pMargins[XML_LINE_RIGHT] = property; break; + case CTF_PM_HEADERMARGINALL : + pAllHeaderMarginProperty = property; break; + case CTF_PM_HEADERMARGINTOP : + pHeaderMargins[XML_LINE_TOP] = property; break; + case CTF_PM_HEADERMARGINBOTTOM: + pHeaderMargins[XML_LINE_BOTTOM] = property; break; + case CTF_PM_HEADERMARGINLEFT : + pHeaderMargins[XML_LINE_LEFT] = property; break; + case CTF_PM_HEADERMARGINRIGHT : + pHeaderMargins[XML_LINE_RIGHT] = property; break; + case CTF_PM_FOOTERMARGINALL : + pAllFooterMarginProperty = property; break; + case CTF_PM_FOOTERMARGINTOP : + pFooterMargins[XML_LINE_TOP] = property; break; + case CTF_PM_FOOTERMARGINBOTTOM: + pFooterMargins[XML_LINE_BOTTOM] = property; break; + case CTF_PM_FOOTERMARGINLEFT : + pFooterMargins[XML_LINE_LEFT] = property; break; + case CTF_PM_FOOTERMARGINRIGHT : + pFooterMargins[XML_LINE_RIGHT] = property; break; } } } - for ( i = 0; i < 4; i++) + for (sal_uInt16 i = 0; i < 4; i++) { + if (pAllMarginProperty && !pMargins[i]) + { + pNewMargins[i].reset(new XMLPropertyState( + pAllMarginProperty->mnIndex + 1 + i, + pAllMarginProperty->maValue)); + } + if (pAllHeaderMarginProperty && !pHeaderMargins[i]) + { + pNewHeaderMargins[i].reset(new XMLPropertyState( + pAllHeaderMarginProperty->mnIndex + 1 + i, + pAllHeaderMarginProperty->maValue)); + } + if (pAllFooterMarginProperty && !pFooterMargins[i]) + { + pNewFooterMargins[i].reset(new XMLPropertyState( + pAllFooterMarginProperty->mnIndex + 1 + i, + pAllFooterMarginProperty->maValue)); + } if (pAllPaddingProperty && !pPadding[i]) pNewPadding[i] = new XMLPropertyState(pAllPaddingProperty->mnIndex + 1 + i, pAllPaddingProperty->maValue); if (pAllBorderProperty && !pBorders[i]) @@ -294,8 +345,20 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& aAny.setValue( &bValue, ::getBooleanCppuType() ); pFooterDynamic = new XMLPropertyState(pFooterMinHeight->mnIndex + 1, aAny); } - for (i = 0; i < 4; i++) + for (sal_uInt16 i = 0; i < 4; i++) { + if (pNewMargins[i].get()) + { + rProperties.push_back(*pNewMargins[i]); + } + if (pNewHeaderMargins[i].get()) + { + rProperties.push_back(*pNewHeaderMargins[i]); + } + if (pNewFooterMargins[i].get()) + { + rProperties.push_back(*pNewFooterMargins[i]); + } if (pNewPadding[i]) { rProperties.push_back(*pNewPadding[i]); diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx index 6dbda70f5125..41d2172ab4fa 100644 --- a/xmloff/source/style/PageMasterStyleMap.cxx +++ b/xmloff/source/style/PageMasterStyleMap.cxx @@ -28,10 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX #include -#endif -#include "xmloff/xmlnmspe.hxx" + +#include #include using namespace ::xmloff::token; @@ -54,10 +53,11 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = PLMAP( "NumberingType", XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, XML_PM_TYPE_NUMLETTERSYNC, 0 ), PLMAP( "PrinterPaperTray", XML_NAMESPACE_STYLE, XML_PAPER_TRAY_NAME, XML_TYPE_STRING | MID_FLAG_PROPERTY_MAY_EXCEPT, 0 ), PLMAP( "IsLandscape", XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_PM_TYPE_PRINTORIENTATION, 0 ), - PLMAP( "TopMargin", XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_MEASURE, 0 ), - PLMAP( "BottomMargin", XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, XML_TYPE_MEASURE, 0 ), - PLMAP( "LeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, 0 ), - PLMAP( "RightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, 0 ), + PLMAP( "TopMargin", XML_NAMESPACE_FO, XML_MARGIN, XML_TYPE_MEASURE, CTF_PM_MARGINALL ), + PLMAP( "TopMargin", XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_MEASURE, CTF_PM_MARGINTOP ), + PLMAP( "BottomMargin", XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, XML_TYPE_MEASURE, CTF_PM_MARGINBOTTOM ), + PLMAP( "LeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, CTF_PM_MARGINLEFT ), + PLMAP( "RightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_PM_MARGINRIGHT ), PLMAP( "TopBorder", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_BORDER, CTF_PM_BORDERALL ), PLMAP( "TopBorder", XML_NAMESPACE_FO, XML_BORDER_TOP, XML_TYPE_BORDER, CTF_PM_BORDERTOP ), PLMAP( "BottomBorder", XML_NAMESPACE_FO, XML_BORDER_BOTTOM, XML_TYPE_BORDER, CTF_PM_BORDERBOTTOM ), @@ -130,9 +130,10 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = HFMAP( "HeaderHeight", XML_NAMESPACE_SVG, XML_HEIGHT, XML_TYPE_MEASURE, CTF_PM_HEADERHEIGHT ), HFMAP( "HeaderHeight", XML_NAMESPACE_FO, XML_MIN_HEIGHT, XML_TYPE_MEASURE, CTF_PM_HEADERMINHEIGHT ), HFMAP( "HeaderIsDynamicHeight", XML_NAMESPACE_STYLE, XML__EMPTY, XML_TYPE_BOOL, CTF_PM_HEADERDYNAMIC ), - HFMAP( "HeaderLeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, CTF_PM_HEADERFLAG ), - HFMAP( "HeaderRightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_PM_HEADERFLAG ), - HFMAP( "HeaderBodyDistance", XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, XML_TYPE_MEASURE, CTF_PM_HEADERFLAG ), + HFMAP( "HeaderLeftMargin", XML_NAMESPACE_FO, XML_MARGIN, XML_TYPE_MEASURE, CTF_PM_HEADERMARGINALL ), + HFMAP( "HeaderLeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, CTF_PM_HEADERMARGINLEFT ), + HFMAP( "HeaderRightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_PM_HEADERMARGINRIGHT ), + HFMAP( "HeaderBodyDistance", XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, XML_TYPE_MEASURE, CTF_PM_HEADERMARGINBOTTOM ), HFMAP( "HeaderTopBorder", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_BORDER, CTF_PM_HEADERBORDERALL ), HFMAP( "HeaderTopBorder", XML_NAMESPACE_FO, XML_BORDER_TOP, XML_TYPE_BORDER, CTF_PM_HEADERBORDERTOP ), HFMAP( "HeaderBottomBorder", XML_NAMESPACE_FO, XML_BORDER_BOTTOM, XML_TYPE_BORDER, CTF_PM_HEADERBORDERBOTTOM ), @@ -160,9 +161,10 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = HFMAP( "FooterHeight", XML_NAMESPACE_SVG, XML_HEIGHT, XML_TYPE_MEASURE, CTF_PM_FOOTERHEIGHT ), HFMAP( "FooterHeight", XML_NAMESPACE_FO, XML_MIN_HEIGHT, XML_TYPE_MEASURE, CTF_PM_FOOTERMINHEIGHT ), HFMAP( "FooterIsDynamicHeight", XML_NAMESPACE_STYLE, XML__EMPTY, XML_TYPE_BOOL, CTF_PM_FOOTERDYNAMIC ), - HFMAP( "FooterLeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, CTF_PM_FOOTERFLAG ), - HFMAP( "FooterRightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_PM_FOOTERFLAG ), - HFMAP( "FooterBodyDistance", XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_MEASURE, CTF_PM_FOOTERFLAG ), + HFMAP( "FooterLeftMargin", XML_NAMESPACE_FO, XML_MARGIN, XML_TYPE_MEASURE, CTF_PM_FOOTERMARGINALL ), + HFMAP( "FooterLeftMargin", XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE, CTF_PM_FOOTERMARGINLEFT ), + HFMAP( "FooterRightMargin", XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_PM_FOOTERMARGINRIGHT ), + HFMAP( "FooterBodyDistance", XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_MEASURE, CTF_PM_FOOTERMARGINTOP ), HFMAP( "FooterTopBorder", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_BORDER, CTF_PM_FOOTERBORDERALL ), HFMAP( "FooterTopBorder", XML_NAMESPACE_FO, XML_BORDER_TOP, XML_TYPE_BORDER, CTF_PM_FOOTERBORDERTOP ), HFMAP( "FooterBottomBorder", XML_NAMESPACE_FO, XML_BORDER_BOTTOM, XML_TYPE_BORDER, CTF_PM_FOOTERBORDERBOTTOM ), diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index 1de027ec8623..6bca8e8f4e20 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -468,6 +468,9 @@ void XMLTextExportPropertySetMapper::ContextFilter( XMLPropertyState* pClip11State = NULL; XMLPropertyState* pClipState = NULL; + XMLPropertyState* pAllParaMargin = NULL; + XMLPropertyState* pAllMargin = NULL; + sal_Bool bNeedsAnchor = sal_False; for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); @@ -584,6 +587,8 @@ void XMLTextExportPropertySetMapper::ContextFilter( case CTF_NUMBERINGSTYLENAME: pListStyleName = propertie; break; case CTF_TEXT_CLIP11: pClip11State = propertie; break; case CTF_TEXT_CLIP: pClipState = propertie; break; + case CTF_PARAMARGINALL: pAllParaMargin = propertie; break; + case CTF_MARGINALL: pAllMargin = propertie; break; } } @@ -635,6 +640,17 @@ void XMLTextExportPropertySetMapper::ContextFilter( lcl_checkMultiProperty(pParaBottomMarginState, pParaBottomMarginRelState); lcl_checkMultiProperty(pParaFirstLineState, pParaFirstLineRelState); + if (pAllParaMargin) + { + pAllParaMargin->mnIndex = -1; // just export individual attributes... + pAllParaMargin->maValue.clear(); + } + if (pAllMargin) + { + pAllMargin->mnIndex = -1; // just export individual attributes... + pAllMargin->maValue.clear(); + } + if( pAllBorderWidthState ) { if( pLeftBorderWidthState && pRightBorderWidthState && pTopBorderWidthState && pBottomBorderWidthState ) diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index dceac7a26890..93e8750b8fb2 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -316,7 +316,12 @@ void XMLTextImportPropertyMapper::finished( XMLPropertyState* pVertOrientRelAsChar = 0; XMLPropertyState* pBackTransparency = NULL; // transparency in % XMLPropertyState* pBackTransparent = NULL; // transparency as boolean - sal_uInt16 i; // for the "for" loop + XMLPropertyState* pAllParaMargin = 0; + XMLPropertyState* pParaMargins[4] = { 0, 0, 0, 0 }; + ::std::auto_ptr pNewParaMargins[4]; + XMLPropertyState* pAllMargin = 0; + XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 }; + ::std::auto_ptr pNewMargins[4]; for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); aIter != rProperties.end(); @@ -384,7 +389,31 @@ void XMLTextImportPropertyMapper::finished( bHasAnyWidth = sal_True; break; case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break; case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break; - + case CTF_PARAMARGINALL: + case CTF_PARAMARGINALL_REL: + pAllParaMargin = property; break; + case CTF_PARALEFTMARGIN: + case CTF_PARALEFTMARGIN_REL: + pParaMargins[XML_LINE_LEFT] = property; break; + case CTF_PARARIGHTMARGIN: + case CTF_PARARIGHTMARGIN_REL: + pParaMargins[XML_LINE_RIGHT] = property; break; + case CTF_PARATOPMARGIN: + case CTF_PARATOPMARGIN_REL: + pParaMargins[XML_LINE_TOP] = property; break; + case CTF_PARABOTTOMMARGIN: + case CTF_PARABOTTOMMARGIN_REL: + pParaMargins[XML_LINE_BOTTOM] = property; break; + case CTF_MARGINALL: + pAllMargin = property; break; + case CTF_MARGINLEFT: + pMargins[XML_LINE_LEFT] = property; break; + case CTF_MARGINRIGHT: + pMargins[XML_LINE_RIGHT] = property; break; + case CTF_MARGINTOP: + pMargins[XML_LINE_TOP] = property; break; + case CTF_MARGINBOTTOM: + pMargins[XML_LINE_BOTTOM] = property; break; } } @@ -401,8 +430,31 @@ void XMLTextImportPropertyMapper::finished( FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL ); - for( i = 0; i < 4; i++ ) + for (sal_uInt16 i = 0; i < 4; i++) { + if (pAllParaMargin && !pParaMargins[i]) + { +#ifdef DBG_UTIL + sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( + pAllParaMargin->mnIndex + (2*i) + 2 ); + OSL_ENSURE( nTmp >= CTF_PARALEFTMARGIN && + nTmp <= CTF_PARABOTTOMMARGIN_REL, + "wrong property context id" ); +#endif + pNewParaMargins[i].reset(new XMLPropertyState( + pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue)); + } + if (pAllMargin && !pMargins[i]) + { +#ifdef DBG_UTIL + sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( + pAllMargin->mnIndex + i + 1 ); + OSL_ENSURE( nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM, + "wrong property context id" ); +#endif + pNewMargins[i].reset(new XMLPropertyState( + pAllMargin->mnIndex + i + 1, pAllMargin->maValue)); + } if( pAllBorderDistance && !pBorderDistances[i] ) { #ifdef DBG_UTIL @@ -506,6 +558,16 @@ void XMLTextImportPropertyMapper::finished( } #endif } + + if (pAllParaMargin) + { + pAllParaMargin->mnIndex = -1; + } + if (pAllMargin) + { + pAllMargin->mnIndex = -1; + } + if( pAllBorderDistance ) pAllBorderDistance->mnIndex = -1; @@ -649,8 +711,16 @@ void XMLTextImportPropertyMapper::finished( delete pNewFontCharSetCTL; } - for( i=0; i<4; i++ ) + for (sal_uInt16 i=0; i<4; i++) { + if (pNewParaMargins[i].get()) + { + rProperties.push_back(*pNewParaMargins[i]); + } + if (pNewMargins[i].get()) + { + rProperties.push_back(*pNewMargins[i]); + } if( pNewBorderDistances[i] ) { rProperties.push_back( *pNewBorderDistances[i] ); diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index fbc53ef3e16e..ff49ecd234f9 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -27,15 +27,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include -#include "xmloff/xmlnmspe.hxx" -#include -#ifndef _XMLOFF_TXTPRHDL_HXX -#include "txtprhdl.hxx" -#endif -#ifndef _XMLOFF_TXTPRMAP_HXX + #include -#endif + +#include + +#include +#include +#include "txtprhdl.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -91,6 +90,9 @@ XMLPropertyMapEntry aXMLParaPropMap[] = // RES_UNKNOWNATR_CONTAINER MP_E( "ParaUserDefinedAttributes", TEXT, XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM, 0 ), // RES_LR_SPACE + // !!! DO NOT REORDER THE MARGINS !!! + MP_E( "ParaLeftMargin", FO, MARGIN, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARAMARGINALL ), + MP_E( "ParaLeftMarginRelative", FO, MARGIN, XML_TYPE_PERCENT16, CTF_PARAMARGINALL_REL ), MP_E( "ParaLeftMargin", FO, MARGIN_LEFT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARALEFTMARGIN ), MP_E( "ParaLeftMarginRelative", FO, MARGIN_LEFT, XML_TYPE_PERCENT16, CTF_PARALEFTMARGIN_REL ), MP_E( "ParaRightMargin", FO, MARGIN_RIGHT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARARIGHTMARGIN ), @@ -578,11 +580,12 @@ XMLPropertyMapEntry aXMLFramePropMap[] = MG_ED( "VertOrientPosition", SVG, Y, XML_TYPE_MEASURE, 0 ), // ***** The map for automatic styles starts here ***** // RES_LR_SPACE - MG_E( "LeftMargin", FO, MARGIN_LEFT, XML_TYPE_MEASURE, 0), - MG_E( "RightMargin", FO, MARGIN_RIGHT, XML_TYPE_MEASURE, 0 ), + MG_E( "LeftMargin", FO, MARGIN, XML_TYPE_MEASURE, CTF_MARGINALL ), + MG_E( "LeftMargin", FO, MARGIN_LEFT, XML_TYPE_MEASURE, CTF_MARGINLEFT ), + MG_E( "RightMargin", FO, MARGIN_RIGHT, XML_TYPE_MEASURE, CTF_MARGINRIGHT ), // RES_UL_SPACE - MG_E( "TopMargin", FO, MARGIN_TOP, XML_TYPE_MEASURE, 0 ), - MG_E( "BottomMargin", FO, MARGIN_BOTTOM, XML_TYPE_MEASURE, 0 ), + MG_E( "TopMargin", FO, MARGIN_TOP, XML_TYPE_MEASURE, CTF_MARGINTOP ), + MG_E( "BottomMargin", FO, MARGIN_BOTTOM, XML_TYPE_MEASURE, CTF_MARGINBOTTOM ), // RES_PAGEDESC // not required // RES_BREAK @@ -852,7 +855,7 @@ XMLPropertyMapEntry *lcl_txtprmap_getMap( sal_uInt16 nType ) break; case TEXT_PROP_MAP_SHAPE_PARA: pMap = &(aXMLParaPropMap[1]); - DBG_ASSERT( pMap->meXMLName == XML_MARGIN_LEFT, "shape para map changed" ); + OSL_ENSURE( pMap->meXMLName == XML_MARGIN, "shape para map changed" ); break; case TEXT_PROP_MAP_PARA: pMap = aXMLParaPropMap; @@ -862,7 +865,7 @@ XMLPropertyMapEntry *lcl_txtprmap_getMap( sal_uInt16 nType ) break; case TEXT_PROP_MAP_AUTO_FRAME: pMap = &(aXMLFramePropMap[13]); - DBG_ASSERT( pMap->meXMLName == XML_MARGIN_LEFT, "frame map changed" ); + OSL_ENSURE( pMap->meXMLName == XML_MARGIN, "frame map changed" ); break; case TEXT_PROP_MAP_SHAPE: pMap = aXMLShapePropMap; From 7ac0c9bc14ac38a9c0d3bb3f117208464c719941 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 23 Feb 2011 09:43:22 +0100 Subject: [PATCH 36/85] dba34d: fixed attemptListenerCreation --- svx/source/form/fmundo.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 8a72cb768d5f..ecbfc8afbe1a 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -129,7 +129,7 @@ private: { ::comphelper::ComponentContext const aContext( ::comphelper::getProcessServiceFactory() ); Reference< XScriptListener > const xScriptListener( aContext.createComponent( "ooo.vba.EventListener" ), UNO_QUERY_THROW ); - Reference< XPropertySet > const xListenerProps( m_vbaListener, UNO_QUERY_THROW ); + Reference< XPropertySet > const xListenerProps( xScriptListener, UNO_QUERY_THROW ); // SfxObjectShellRef is good here since the model controls the lifetime of the shell SfxObjectShellRef const xObjectShell = m_rModel.GetObjectShell(); ENSURE_OR_THROW( xObjectShell.Is(), "no object shell!" ); From c3d9cd5435a4ff1d98fbd12482b04ccf5d322067 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 23 Feb 2011 11:36:11 +0100 Subject: [PATCH 37/85] dba34c: #i117043# fix modified state of rowset --- connectivity/source/commontools/FValue.cxx | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 95aabb821b1a..2d9ef1a219f8 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -787,11 +787,8 @@ sal_Bool operator==(const DateTime& _rLH,const DateTime& _rRH) bool ORowSetValue::operator==(const ORowSetValue& _rRH) const { - if(m_eTypeKind != _rRH.m_eTypeKind) - return false; - if ( m_bSigned != _rRH.m_bSigned ) - return false; - if(m_bNull != _rRH.isNull()) + if ( m_eTypeKind != _rRH.m_eTypeKind || + m_bNull != _rRH.isNull()) return false; if(m_bNull && _rRH.isNull()) return true; @@ -802,16 +799,29 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const { case DataType::VARCHAR: case DataType::CHAR: - case DataType::DECIMAL: - case DataType::NUMERIC: case DataType::LONGVARCHAR: { ::rtl::OUString aVal1(m_aValue.m_pString); ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); - bRet = aVal1 == aVal2; + return aVal1 == aVal2; break; } + default: + if ( m_bSigned != _rRH.m_bSigned ) + return false; + break; + } + switch(m_eTypeKind) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + ::rtl::OUString aVal1(m_aValue.m_pString); + ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); + bRet = aVal1 == aVal2; + } + break; case DataType::FLOAT: bRet = *(float*)m_aValue.m_pValue == *(float*)_rRH.m_aValue.m_pValue; break; From e80d8ed59936df66e30c8dc7501caa18b711af16 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 23 Feb 2011 13:10:19 +0100 Subject: [PATCH 38/85] dba34c: #i108415# fix for strings --- connectivity/source/commontools/predicateinput.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 9d088c903dcc..dbac44b72424 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -406,7 +406,11 @@ namespace dbtools } else { - pOdbcSpec->getChild(1)->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); + OSQLParseNode* pValueNode = pOdbcSpec->getChild(1); + if ( SQL_NODE_STRING == pValueNode->getNodeType() ) + sReturn = pValueNode->getTokenValue(); + else + pValueNode->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); // sReturn = pOdbcSpec->getChild(1)->getTokenValue(); } } From 968263e4c26dd510afbf998cbaf970de92615691 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 23 Feb 2011 16:09:08 +0100 Subject: [PATCH 39/85] dba34c: special comparison of double values --- connectivity/source/commontools/FValue.cxx | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 2d9ef1a219f8..5ea0e601a9c3 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -787,9 +787,32 @@ sal_Bool operator==(const DateTime& _rLH,const DateTime& _rRH) bool ORowSetValue::operator==(const ORowSetValue& _rRH) const { - if ( m_eTypeKind != _rRH.m_eTypeKind || - m_bNull != _rRH.isNull()) + if ( m_eTypeKind != _rRH.m_eTypeKind ) + { + switch(m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + break; + default: + switch(_rRH.m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + break; + default: + break; + } + break; + } return false; + } + if ( m_bNull != _rRH.isNull() ) + return false; if(m_bNull && _rRH.isNull()) return true; From 5e0ac176cf025f7e070d882f4bba169f6242efa7 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 24 Feb 2011 13:57:59 +0100 Subject: [PATCH 40/85] #i117013# Check restart state earlier in startup process to better support extensions with changed configuration settings --- desktop/source/app/app.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index a2f602082fe4..57adbfdad775 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1729,8 +1729,17 @@ void Desktop::Main() bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; + + { + ::comphelper::ComponentContext aContext( xSMgr ); + xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); + } + + // check whether the shutdown is caused by restart + pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + // First Start Wizard allowed ? - if ( ! pCmdLineArgs->IsNoFirstStartWizard()) + if ( ! pCmdLineArgs->IsNoFirstStartWizard() && !pExecGlobals->bRestartRequested ) { RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ FirstStartWizard" ); @@ -1782,14 +1791,6 @@ void Desktop::Main() impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} impl_checkRecoveryState" ); - { - ::comphelper::ComponentContext aContext( xSMgr ); - xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); - } - - // check whether the shutdown is caused by restart - pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); - if ( pCmdLineArgs->IsHeadless() ) { // Ensure that we use not the system file dialogs as From bedbe4e2871440b5d276e97c2894c05cc4b6fcda Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 1 Mar 2011 16:05:30 +0100 Subject: [PATCH 41/85] sw34bf04: #i103539#: always import meta.xml, to extract the BuildId: SvXMLMetaDocumentContext: refactor to not require DocumentProperties, and always set the BuildId from the meta:generator element. {Sc,Sd,Sw}XMLImport::CreateMetaContext(): always create context. sc, sd: add OrganizerMode property to ODF import. --- xmloff/inc/xmloff/xmlmetai.hxx | 10 +-- xmloff/source/draw/sdxmlimp.cxx | 21 ++++-- xmloff/source/meta/xmlmetai.cxx | 113 ++++++++++++++++++++++---------- 3 files changed, 94 insertions(+), 50 deletions(-) diff --git a/xmloff/inc/xmloff/xmlmetai.hxx b/xmloff/inc/xmloff/xmlmetai.hxx index efdd1d3f024f..2ddd51920054 100644 --- a/xmloff/inc/xmloff/xmlmetai.hxx +++ b/xmloff/inc/xmloff/xmlmetai.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef _XMLOFF_XMLMETAI_HXX -#define _XMLOFF_XMLMETAI_HXX +#ifndef XMLOFF_XMLMETAI_HXX +#define XMLOFF_XMLMETAI_HXX #include "sal/config.h" #include "xmloff/dllapi.h" @@ -69,12 +69,6 @@ public: virtual void EndElement(); -protected: - /// initialize DocumentProperties object with DOM and base URL - void initDocumentProperties(); - // set the BuildId property at the importer - void setBuildId(const ::rtl::OUString & i_rBuildId); - public: static void setBuildId(const ::rtl::OUString & rGenerator, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xImportInfo ); diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 578b3eefc719..7b69609fafe9 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -30,15 +30,11 @@ #include -#ifndef _XMLOFF_XMLMETAI_HXX #include -#endif #include "sdxmlimp_impl.hxx" #include "ximpbody.hxx" -#ifndef _SFX_XMLMETAI_HXX #include -#endif #include "ximpstyl.hxx" #include "xmloff/xmlnmspe.hxx" #include @@ -447,6 +443,17 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen if( xInfoSetInfo->hasPropertyByName( msPreview ) ) xInfoSet->getPropertyValue( msPreview ) >>= mbPreview; + + ::rtl::OUString const sOrganizerMode( + RTL_CONSTASCII_USTRINGPARAM("OrganizerMode")); + if (xInfoSetInfo->hasPropertyByName(sOrganizerMode)) + { + sal_Bool bStyleOnly(sal_False); + if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly) + { + mbLoadDoc = !bStyleOnly; + } + } } } @@ -765,7 +772,7 @@ SvXMLImportContext *SdXMLImport::CreateMetaContext(const OUString& rLocalName, { SvXMLImportContext* pContext = 0L; - if (!IsStylesOnlyMode() && (getImportFlags() & IMPORT_META)) + if (getImportFlags() & IMPORT_META) { uno::Reference xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( @@ -773,9 +780,11 @@ SvXMLImportContext *SdXMLImport::CreateMetaContext(const OUString& rLocalName, uno::UNO_QUERY_THROW); uno::Reference xDPS( GetModel(), uno::UNO_QUERY_THROW); + uno::Reference const xDocProps( + (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties()); pContext = new SvXMLMetaDocumentContext(*this, XML_NAMESPACE_OFFICE, rLocalName, - xDPS->getDocumentProperties(), xDocBuilder); + xDocProps, xDocBuilder); } if(!pContext) diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx index e2ba207e5cd6..9f5aebece935 100644 --- a/xmloff/source/meta/xmlmetai.cxx +++ b/xmloff/source/meta/xmlmetai.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -124,6 +125,71 @@ void XMLDocumentBuilderContext::EndElement() //=========================================================================== +static void +lcl_initDocumentProperties(SvXMLImport & rImport, + uno::Reference const& xDocBuilder, + uno::Reference const& xDocProps) +{ + uno::Sequence< uno::Any > aSeq(1); + uno::Reference< xml::dom::XSAXDocumentBuilder > const xDB(xDocBuilder, + uno::UNO_QUERY_THROW); + aSeq[0] <<= xDB->getDocument(); + uno::Reference< lang::XInitialization > const xInit(xDocProps, + uno::UNO_QUERY_THROW); + try { + xInit->initialize(aSeq); + rImport.SetStatistics(xDocProps->getDocumentStatistics()); + // convert all URLs from relative to absolute + xDocProps->setTemplateURL(rImport.GetAbsoluteReference( + xDocProps->getTemplateURL())); + xDocProps->setAutoloadURL(rImport.GetAbsoluteReference( + xDocProps->getAutoloadURL())); + SvXMLMetaDocumentContext::setBuildId( + xDocProps->getGenerator(), rImport.getImportInfo()); + } catch (uno::RuntimeException) { + throw; + } catch (uno::Exception & e) { + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii( + "SvXMLMetaDocumentContext::initDocumentProperties: " + "properties init exception"), + rImport, makeAny(e)); + } +} + +static void +lcl_initGenerator(SvXMLImport & rImport, + uno::Reference const& xDocBuilder) +{ + uno::Reference< xml::dom::XSAXDocumentBuilder > const xDB(xDocBuilder, + uno::UNO_QUERY_THROW); + uno::Reference< xml::dom::XDocument > const xDoc(xDB->getDocument(), + uno::UNO_SET_THROW); + try { + uno::Reference< xml::xpath::XXPathAPI > const xPath( + rImport.getServiceFactory()->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.xml.xpath.XPathAPI"))), + uno::UNO_QUERY_THROW ); + xPath->registerNS(GetXMLToken(XML_NP_OFFICE),GetXMLToken(XML_N_OFFICE)); + xPath->registerNS(GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META)); + + ::rtl::OUString const expr(RTL_CONSTASCII_USTRINGPARAM( + "string(/office:document-meta/office:meta/meta:generator)")); + uno::Reference< xml::xpath::XXPathObject > const xObj( + xPath->eval(xDoc.get(), expr), uno::UNO_SET_THROW); + OUString const value(xObj->getString()); + SvXMLMetaDocumentContext::setBuildId(value, rImport.getImportInfo()); + } catch (uno::RuntimeException) { + throw; + } catch (uno::Exception & e) { + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii( + "SvXMLMetaDocumentContext::initGenerator: exception"), + rImport, makeAny(e)); + } +} + SvXMLMetaDocumentContext::SvXMLMetaDocumentContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, const uno::Reference& xDocProps, @@ -132,8 +198,9 @@ SvXMLMetaDocumentContext::SvXMLMetaDocumentContext(SvXMLImport& rImport, mxDocProps(xDocProps), mxDocBuilder(xDocBuilder) { - DBG_ASSERT(xDocProps.is(), "SvXMLMetaDocumentContext: no document props"); - DBG_ASSERT(xDocBuilder.is(), "SvXMLMetaDocumentContext: no document hdlr"); +// #i103539#: must always read meta.xml for generator, xDocProps unwanted then +// OSL_ENSURE(xDocProps.is(), "SvXMLMetaDocumentContext: no document props"); + OSL_ENSURE(xDocBuilder.is(), "SvXMLMetaDocumentContext: no document hdlr"); // here are no attributes } @@ -166,6 +233,7 @@ void SvXMLMetaDocumentContext::StartElement( mxDocBuilder->startElement( GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(), GetXMLToken(XML_DOCUMENT_META)), xAttrList); + } void SvXMLMetaDocumentContext::EndElement() @@ -175,43 +243,16 @@ void SvXMLMetaDocumentContext::EndElement() GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(), GetXMLToken(XML_DOCUMENT_META))); mxDocBuilder->endDocument(); - initDocumentProperties(); -} - -void SvXMLMetaDocumentContext::initDocumentProperties() -{ - uno::Sequence< uno::Any > aSeq(1); - uno::Reference< xml::dom::XSAXDocumentBuilder > xDB (mxDocBuilder, - uno::UNO_QUERY_THROW); - aSeq[0] <<= xDB->getDocument(); - uno::Reference< lang::XInitialization > xInit(mxDocProps, - uno::UNO_QUERY_THROW); - try { - xInit->initialize(aSeq); - GetImport().SetStatistics(mxDocProps->getDocumentStatistics()); - // convert all URLs from relative to absolute - mxDocProps->setTemplateURL(GetImport().GetAbsoluteReference( - mxDocProps->getTemplateURL())); - mxDocProps->setAutoloadURL(GetImport().GetAbsoluteReference( - mxDocProps->getAutoloadURL())); - setBuildId(mxDocProps->getGenerator()); - } catch (uno::RuntimeException) { - throw; - } catch (uno::Exception & e) { - throw lang::WrappedTargetRuntimeException( - ::rtl::OUString::createFromAscii( - "SvXMLMetaDocumentContext::initDocumentProperties: " - "properties init exception"), - GetImport(), makeAny(e)); + if (mxDocProps.is()) + { + lcl_initDocumentProperties(GetImport(), mxDocBuilder, mxDocProps); + } + else + { + lcl_initGenerator(GetImport(), mxDocBuilder); } } -void SvXMLMetaDocumentContext::setBuildId(const ::rtl::OUString & i_rBuildId) -{ - SvXMLMetaDocumentContext::setBuildId( i_rBuildId, GetImport().getImportInfo() ); -} - -//static void SvXMLMetaDocumentContext::setBuildId(::rtl::OUString const& i_rBuildId, const uno::Reference& xImportInfo ) { OUString sBuildId; From 7c83fe565234aa5025729462f3250ed883f1b7df Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 3 Mar 2011 14:49:27 +0100 Subject: [PATCH 42/85] fwk167: #i90917# Filter out requests for controls which are not available for the explorer-style Windows file picker. --- .../win32/filepicker/WinFileOpenImpl.cxx | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx index 9fb13c1a2d5e..f701efe1357b 100644 --- a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx +++ b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx @@ -316,11 +316,24 @@ void SAL_CALL CWinFileOpenImpl::appendFilterGroup(const rtl::OUString& sGroupTit // XExtendedFilePicker //================================================================================================================= +// #i90917: Due to a different feature set for the system-dependent file pickers +// it's possible that generic code (e.g. sfx2) provides control ids +// (see ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR) which are NOT +// available on all platforms. This filter function should filter out control ids +// which are only available on KDE/GTK file pickers. +static bool filterControlCommand( sal_Int16 nControlId ) +{ + if ( nControlId == LISTBOX_FILTER_SELECTOR ) + return true; + return false; +} + void SAL_CALL CWinFileOpenImpl::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->setValue(aControlId, aControlAction, aValue); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setValue(aControlId, aControlAction, aValue); } //----------------------------------------------------------------------------------------- @@ -332,7 +345,10 @@ uno::Any SAL_CALL CWinFileOpenImpl::getValue(sal_Int16 aControlId, sal_Int16 aCo throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - return m_FilePickerState->getValue(aControlId, aControlAction); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getValue(aControlId, aControlAction); + else + return uno::Any(); } //----------------------------------------------------------------------------------------- @@ -343,7 +359,8 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->enableControl(ControlID, bEnable); + if ( !filterControlCommand( ControlID )) + m_FilePickerState->enableControl(ControlID, bEnable); } //----------------------------------------------------------------------------------------- @@ -353,7 +370,9 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUString& aLabel ) throw (uno::RuntimeException) { - m_FilePickerState->setLabel(aControlId, aLabel); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setLabel(aControlId, aLabel); } //----------------------------------------------------------------------------------------- @@ -363,7 +382,11 @@ void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUStr rtl::OUString SAL_CALL CWinFileOpenImpl::getLabel( sal_Int16 aControlId ) throw (uno::RuntimeException) { - return m_FilePickerState->getLabel(aControlId); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getLabel(aControlId); + else + return rtl::OUString(); } //----------------------------------------------------------------------------------------- From 4f24ef15969c9c062f6ed60d0f2848608cee079e Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 4 Mar 2011 14:43:09 +0100 Subject: [PATCH 43/85] calc66: #i103331# make OFFSET with external references work again + Introduced FormulaSubroutineToken to hold a FormulaTokenArray. * INDIRECT in case of external reference returns FormulaSubroutineToken instead of directly pushing the token array to code and signalling its presence to ScInterpreter::Interpret(). * ScInterpreter::ScExternalRef() checks if an external reference is used with OFFSET and if so does not resolve it but pushes it so it can be handled within OFFSET. + OFFSET recognizes external reference and creates an external reference of the new area and returns that as subroutine to be resolved by ScExternalRef(). * Interpret() pushes the subroutine to code and rememberes the token and array for late destruction. --- formula/inc/formula/token.hxx | 19 ++++++++ formula/inc/formula/tokenarray.hxx | 4 ++ formula/source/core/api/token.cxx | 71 +++++++++++++++++++++++------- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx index 30618c67381a..8a94b1005bc8 100644 --- a/formula/inc/formula/token.hxx +++ b/formula/inc/formula/token.hxx @@ -70,6 +70,7 @@ enum StackVarEnum svExternalSingleRef, svExternalDoubleRef, svExternalName, + svSubroutine, // A token with a subroutine token array. svError, // error token svMissing = 0x70, // 0 or "" svSep, // separator, ocSep, ocOpen, ocClose @@ -89,6 +90,7 @@ class FormulaToken; typedef SimpleIntrusiveReference< class FormulaToken > FormulaTokenRef; typedef SimpleIntrusiveReference< const class FormulaToken > FormulaConstTokenRef; +class FormulaTokenArray; class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken { @@ -364,6 +366,23 @@ public: }; +class FORMULA_DLLPUBLIC FormulaSubroutineToken : public FormulaToken +{ +public: + /** Takes ownership of pArray and deletes it upon destruction! */ + FormulaSubroutineToken( const FormulaTokenArray* pArray ) : + FormulaToken( svSubroutine, ocCall ), mpArray( pArray) {} + FormulaSubroutineToken( const FormulaSubroutineToken& r ); + virtual ~FormulaSubroutineToken(); + virtual FormulaToken* Clone() const { return new FormulaSubroutineToken(*this); } + virtual sal_Bool operator==( const FormulaToken& rToken ) const; + const FormulaTokenArray* GetTokenArray() const; + +private: + const FormulaTokenArray* mpArray; +}; + + class FORMULA_DLLPUBLIC FormulaUnknownToken : public FormulaToken { public: diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx index 31d780c81a79..bcd4061f5ac6 100644 --- a/formula/inc/formula/tokenarray.hxx +++ b/formula/inc/formula/tokenarray.hxx @@ -256,6 +256,7 @@ public: void Reset(); const FormulaToken* First(); const FormulaToken* Next(); + const FormulaToken* PeekNextOperator(); bool IsEndOfPath() const; /// if a jump or subroutine path is done bool HasStacked() const { return pCur->pNext != 0; } short GetPC() const { return pCur->nPC; } @@ -276,6 +277,9 @@ public: void Jump( short nStart, short nNext, short nStop = SHRT_MAX ); void Push( const FormulaTokenArray* ); void Pop(); + +private: + const FormulaToken* GetNonEndOfPathToken( short nIdx ) const; }; // ============================================================================= } // formula diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 3942712da6a4..b644d1cd8fb3 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1265,15 +1265,7 @@ const FormulaToken* FormulaTokenIterator::First() const FormulaToken* FormulaTokenIterator::Next() { - const FormulaToken* t = NULL; - ++pCur->nPC; - if( pCur->nPC < pCur->pArr->nRPN && pCur->nPC < pCur->nStop ) - { - t = pCur->pArr->pRPN[ pCur->nPC ]; - // such an OpCode ends an IF() or CHOOSE() path - if( t->GetOpCode() == ocSep || t->GetOpCode() == ocClose ) - t = NULL; - } + const FormulaToken* t = GetNonEndOfPathToken( ++pCur->nPC ); if( !t && pCur->pNext ) { Pop(); @@ -1282,6 +1274,25 @@ const FormulaToken* FormulaTokenIterator::Next() return t; } +const FormulaToken* FormulaTokenIterator::PeekNextOperator() +{ + const FormulaToken* t = NULL; + short nIdx = pCur->nPC; + while (!t && ((t = GetNonEndOfPathToken( ++nIdx)) != NULL)) + { + if (t->GetOpCode() == ocPush) + t = NULL; // ignore operands + } + if (!t && pCur->pNext) + { + ImpTokenIterator* pHere = pCur; + pCur = pCur->pNext; + t = PeekNextOperator(); + pCur = pHere; + } + return t; +} + //! The nPC counts after a Push() are -1 void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) @@ -1295,17 +1306,22 @@ void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) } } +const FormulaToken* FormulaTokenIterator::GetNonEndOfPathToken( short nIdx ) const +{ + if (nIdx < pCur->pArr->nRPN && nIdx < pCur->nStop) + { + const FormulaToken* t = pCur->pArr->pRPN[ nIdx ]; + // such an OpCode ends an IF() or CHOOSE() path + return (t->GetOpCode() == ocSep || t->GetOpCode() == ocClose) ? NULL : t; + } + return NULL; +} + bool FormulaTokenIterator::IsEndOfPath() const { - sal_uInt16 nTest = pCur->nPC + 1; - if( nTest < pCur->pArr->nRPN && nTest < pCur->nStop ) - { - const FormulaToken* t = pCur->pArr->pRPN[ nTest ]; - // such an OpCode ends an IF() or CHOOSE() path - return t->GetOpCode() == ocSep || t->GetOpCode() == ocClose; - } - return true; + return GetNonEndOfPathToken( pCur->nPC + 1) != NULL; } + // ----------------------------------------------------------------------------- // ========================================================================== // real implementations of virtual functions @@ -1367,6 +1383,27 @@ sal_Bool FormulaMissingToken::operator==( const FormulaToken& r ) const } +FormulaSubroutineToken::FormulaSubroutineToken( const FormulaSubroutineToken& r ) : + FormulaToken( r ), + mpArray( r.mpArray->Clone()) +{ +} +FormulaSubroutineToken::~FormulaSubroutineToken() +{ + delete mpArray; +} +const FormulaTokenArray* FormulaSubroutineToken::GetTokenArray() const +{ + return mpArray; +} +sal_Bool FormulaSubroutineToken::operator==( const FormulaToken& r ) const +{ + // Arrays don't equal.. + return FormulaToken::operator==( r ) && + (mpArray == static_cast(r).mpArray); +} + + sal_Bool FormulaUnknownToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ); From 2038d1496dc652b517c9b6b71cdae848bcec2ab8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 4 Mar 2011 14:59:30 +0100 Subject: [PATCH 44/85] dba34d: #i116795# compile with system HSQL --- connectivity/qa/makefile.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/connectivity/qa/makefile.mk b/connectivity/qa/makefile.mk index ee41cab63554..c087ab98bd7d 100644 --- a/connectivity/qa/makefile.mk +++ b/connectivity/qa/makefile.mk @@ -35,9 +35,16 @@ PACKAGE = complex/connectivity #----- compile .java files ----------------------------------------- -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar hsqldb.jar JAVAFILES := $(shell @$(FIND) complex -name "*.java") +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar + +.IF "$(SYSTEM_HSQLDB)" == "YES" +EXTRAJARFILES = $(HSQLDB_JAR) +.ELSE +JARFILES += hsqldb.jar +.ENDIF + #----- make a jar from compiled files ------------------------------ JARCLASSDIRS = $(PACKAGE) From 7bd65500828eec5062bfa74e9988771ccc0f797e Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Tue, 8 Mar 2011 15:41:52 +0100 Subject: [PATCH 45/85] dba34d: #i117276# mid for driver doesn't be static --- connectivity/source/drivers/jdbc/JConnection.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index f61dc9287649..d17ad87d5e37 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -822,7 +822,7 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"; static const char * cMethodName = "connect"; // Java-Call absetzen - static jmethodID mID = NULL; + jmethodID mID = NULL; if ( !mID ) mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature ); if ( mID ) From 0840df75dec4a7c04da12cdbfa291fc5caeb19cf Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 10 Mar 2011 12:54:21 +0100 Subject: [PATCH 46/85] dba34d: #i116509# check if first and previous work --- .../source/drivers/ado/AResultSet.cxx | 2 +- .../source/drivers/dbase/DNoException.cxx | 15 +++++++++------ connectivity/source/drivers/dbase/DTable.cxx | 2 +- .../source/drivers/dbase/dindexnode.cxx | 13 ++++++++----- .../source/drivers/odbcbase/OResultSet.cxx | 19 ++++++++++++++----- .../drivers/odbcbase/OResultSetMetaData.cxx | 6 +++++- .../source/drivers/odbcbase/OStatement.cxx | 12 ++++++++---- 7 files changed, 46 insertions(+), 23 deletions(-) diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 0c5db12c3355..2d902eb45c4f 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -400,7 +400,7 @@ void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) if(first()) - previous(); + m_bOnFirstAfterOpen = !previous(); } // ------------------------------------------------------------------------- void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx index 7534d06f068c..4f2e4890d705 100644 --- a/connectivity/source/drivers/dbase/DNoException.cxx +++ b/connectivity/source/drivers/dbase/DNoException.cxx @@ -242,7 +242,7 @@ void ODbaseTable::AllocBuffer() } // Falls noch kein Puffer vorhanden: allozieren: - if (m_pBuffer == NULL && nSize) + if (m_pBuffer == NULL && nSize > 0) { m_nBufferSize = nSize; m_pBuffer = new sal_uInt8[m_nBufferSize+1]; @@ -504,11 +504,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r sal_uIntPtr nTell = rStream.Tell() % 512; sal_uInt16 nBufferSize = rStream.GetBufferSize(); sal_uIntPtr nSize = nBufferSize - nTell; - char* pEmptyData = new char[nSize]; - memset(pEmptyData,0x00,nSize); - rStream.Write((sal_uInt8*)pEmptyData,nSize); - rStream.Seek(nTell); - delete [] pEmptyData; + if ( nSize <= nBufferSize ) + { + char* pEmptyData = new char[nSize]; + memset(pEmptyData,0x00,nSize); + rStream.Write((sal_uInt8*)pEmptyData,nSize); + rStream.Seek(nTell); + delete [] pEmptyData; + } } return rStream; } diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index a0844b93b0b7..6868fa72c18e 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2822,7 +2822,7 @@ void ODbaseTable::AllocBuffer() } // Falls noch kein Puffer vorhanden: allozieren: - if (m_pBuffer == NULL && nSize) + if (m_pBuffer == NULL && nSize > 0) { m_nBufferSize = nSize; m_pBuffer = new sal_uInt8[m_nBufferSize+1]; diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 767595d06b85..5e153e2f6111 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -926,11 +926,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r sal_uIntPtr nTell = rStream.Tell() % PAGE_SIZE; sal_uInt16 nBufferSize = rStream.GetBufferSize(); sal_uIntPtr nRemainSize = nBufferSize - nTell; - char* pEmptyData = new char[nRemainSize]; - memset(pEmptyData,0x00,nRemainSize); - rStream.Write((sal_uInt8*)pEmptyData,nRemainSize); - rStream.Seek(nTell); - delete [] pEmptyData; + if ( nRemainSize <= nBufferSize ) + { + char* pEmptyData = new char[nRemainSize]; + memset(pEmptyData,0x00,nRemainSize); + rStream.Write((sal_uInt8*)pEmptyData,nRemainSize); + rStream.Seek(nTell); + delete [] pEmptyData; + } } return rStream; } diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx index 7055bd273370..24c7b4a3a892 100644 --- a/connectivity/source/drivers/odbcbase/OResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx @@ -1365,15 +1365,24 @@ sal_Bool OResultSet::isBookmarkable() const //------------------------------------------------------------------------------ void OResultSet::setFetchDirection(sal_Int32 _par0) { - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + OSL_ENSURE(_par0>0,"Illegal fetch direction!"); + if ( _par0 > 0 ) + { + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + } } //------------------------------------------------------------------------------ void OResultSet::setFetchSize(sal_Int32 _par0) { - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); - delete m_pRowStatusArray; - m_pRowStatusArray = new SQLUSMALLINT[_par0]; - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + OSL_ENSURE(_par0>0,"Illegal fetch size!"); + if ( _par0 > 0 ) + { + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + delete m_pRowStatusArray; + + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + } } // ------------------------------------------------------------------------- IPropertyArrayHelper* OResultSet::createArrayHelper( ) const diff --git a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx index db4538b76e10..7a47a36545a2 100644 --- a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx @@ -60,7 +60,11 @@ OResultSetMetaData::~OResultSetMetaData() ); ::rtl::OUString sValue; if ( nRet == SQL_SUCCESS ) + { + if ( nRealLen < 0 ) + nRealLen = BUFFER_LEN; sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding()); + } delete [] pName; OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); if(nRealLen > BUFFER_LEN) @@ -74,7 +78,7 @@ OResultSetMetaData::~OResultSetMetaData() &nRealLen, NULL ); - if ( nRet == SQL_SUCCESS ) + if ( nRet == SQL_SUCCESS && nRealLen > 0) sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding()); delete [] pName; OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx index 874e24c20e75..1ffe2b0ffbca 100644 --- a/connectivity/source/drivers/odbcbase/OStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OStatement.cxx @@ -875,12 +875,16 @@ void OStatement_Base::setFetchDirection(sal_Int32 _par0) void OStatement_Base::setFetchSize(sal_Int32 _par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); + OSL_ENSURE(_par0>0,"Illegal fetch size!"); + if ( _par0 > 0 ) + { - SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); - delete m_pRowStatusArray; - m_pRowStatusArray = new SQLUSMALLINT[_par0]; - nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + delete m_pRowStatusArray; + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + } } //------------------------------------------------------------------------------ void OStatement_Base::setMaxFieldSize(sal_Int32 _par0) From 8575dc4a545812b80c20d01c3c3e35f1eb9f2123 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Thu, 10 Mar 2011 13:09:38 +0100 Subject: [PATCH 47/85] dr78: #i111413# removed all translation relevant strings from SEC, CSC, SECH and CSCH. As CWS dr78 didn't make it before translation freeze, string changes would pollute translation data. The core feature is still available, documents containing the functions can be loaded and saved, but the UI function names are non-translatable English names and function wizard resource is not available. TODO: undo this change for the next release. --- formula/source/core/resource/core_resource.src | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index f7cd137d08a5..b8a5f1250941 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -840,19 +840,19 @@ Resource RID_STRLIST_FUNCTION_NAMES }; String SC_OPCODE_COSECANT { - Text [ en-US ] = "CSC" ; + Text = "CSC" ; }; String SC_OPCODE_SECANT { - Text [ en-US ] = "SEC" ; + Text = "SEC" ; }; String SC_OPCODE_COSECANT_HYP { - Text [ en-US ] = "CSCH" ; + Text = "CSCH" ; }; String SC_OPCODE_SECANT_HYP { - Text [ en-US ] = "SECH" ; + Text = "SECH" ; }; String SC_OPCODE_EXP { From 71ac08253fa7af25d5f4d62bf053ddc4fbe2c44f Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 11 Mar 2011 15:50:36 +0100 Subject: [PATCH 48/85] fwk167: #i109640# Don't call SetWindowState if window state is the same as the current one --- framework/source/helper/persistentwindowstate.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index 877c2dd3d711..c25036c5c346 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -61,6 +61,7 @@ #endif #include #include +#include //_________________________________________________________________________________________________________________ // namespace @@ -343,7 +344,9 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere if (pWorkWindow->IsMinimized()) return; - pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); + ::rtl::OUString sOldWindowState = ::rtl::OStringToOUString( pSystemWindow->GetWindowState(), RTL_TEXTENCODING_ASCII_US ); + if ( sOldWindowState != sWindowState ) + pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); aSolarLock.clear(); // <- SOLAR SAFE ------------------------ From 10d74f6c33d5f678254760fca296a5d275ccfff9 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 13:00:38 +0100 Subject: [PATCH 49/85] fwk167: #i117378# Use BOOL instead of sal_Bool for Windows specific code. --- fpicker/source/win32/filepicker/previewadapter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx index a145c2af563d..b341a5b8252f 100644 --- a/fpicker/source/win32/filepicker/previewadapter.cxx +++ b/fpicker/source/win32/filepicker/previewadapter.cxx @@ -308,7 +308,7 @@ void SAL_CALL CPreviewAdapterImpl::rearrangeLayout() // style bit of the FileOpen dialog must be set after that // message LONG lStyle = GetWindowLong(prvwnd,GWL_STYLE); - sal_Bool bIsVisible = (sal_Bool)(lStyle & WS_VISIBLE); + BOOL bIsVisible = (BOOL)(lStyle & WS_VISIBLE); int cx = 0; From 95a6c29ae8853bead767ff4434b5af88e107994f Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 13:19:11 +0100 Subject: [PATCH 50/85] fwk167: #i117378# Use safer way to check for visibility --- fpicker/source/win32/filepicker/previewadapter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx index b341a5b8252f..2506dce59ede 100644 --- a/fpicker/source/win32/filepicker/previewadapter.cxx +++ b/fpicker/source/win32/filepicker/previewadapter.cxx @@ -308,7 +308,7 @@ void SAL_CALL CPreviewAdapterImpl::rearrangeLayout() // style bit of the FileOpen dialog must be set after that // message LONG lStyle = GetWindowLong(prvwnd,GWL_STYLE); - BOOL bIsVisible = (BOOL)(lStyle & WS_VISIBLE); + BOOL bIsVisible = ((lStyle & WS_VISIBLE) != 0); int cx = 0; From 1705149aa69a9e38313986bd7bef2ac565b35af9 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 16 Mar 2011 13:25:41 +0100 Subject: [PATCH 51/85] dba34d: #i32633# fix for lcase and ucase --- connectivity/source/drivers/file/fcomp.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index 9a303d1f1d27..28cdb41931d6 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -297,10 +297,19 @@ OOperand* OPredicateCompiler::execute_LIKE(OSQLParseNode* pPredicateNode) throw( OSQLParseNode* pAtom = pPart2->getChild(pPart2->count()-2); OSQLParseNode* pOptEscape = pPart2->getChild(pPart2->count()-1); - if (!(pAtom->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(pAtom,parameter))) + if (!(pAtom->getNodeType() == SQL_NODE_STRING || + SQL_ISRULE(pAtom,parameter) || + // odbc date + SQL_ISRULE(pAtom,set_fct_spec) || + SQL_ISRULE(pAtom,position_exp) || + SQL_ISRULE(pAtom,char_substring_fct) || + // upper, lower etc. + SQL_ISRULE(pAtom,fold)) ) { - m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL); + m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL); + return NULL; } + if (pOptEscape->count() != 0) { if (pOptEscape->count() != 2) From 104874537cf87e29f24861db53dd690673fb57c4 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 14:38:22 +0100 Subject: [PATCH 52/85] fwk167: #i116139# Check for preview frame in requestToolbar method. --- framework/source/layoutmanager/toolbarlayoutmanager.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 5992e7b42dc5..2f66699de459 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -420,6 +420,14 @@ bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL ) bool bMustCallCreate( false ); uno::Reference< ui::XUIElement > xUIElement; + ReadGuard aReadLock( m_aLock ); + uno::Reference< frame::XFrame > xFrame( m_xFrame ); + aReadLock.unlock(); + + uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame )); + if ( implts_isPreviewModel( xModel )) + return false; // no toolbars for preview frame! + UIElement aRequestedToolbar = impl_findToolbar( rResourceURL ); if ( aRequestedToolbar.m_aName != rResourceURL ) { From 77857a809994c9f28174803d721a999f83cca2b9 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 14:58:35 +0100 Subject: [PATCH 53/85] fwk167: #i117379# Use bool instead of Windows type BOOL to prevent misuse --- fpicker/source/win32/filepicker/previewadapter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx index 2506dce59ede..aa784a2f7607 100644 --- a/fpicker/source/win32/filepicker/previewadapter.cxx +++ b/fpicker/source/win32/filepicker/previewadapter.cxx @@ -308,7 +308,7 @@ void SAL_CALL CPreviewAdapterImpl::rearrangeLayout() // style bit of the FileOpen dialog must be set after that // message LONG lStyle = GetWindowLong(prvwnd,GWL_STYLE); - BOOL bIsVisible = ((lStyle & WS_VISIBLE) != 0); + bool bIsVisible = ((lStyle & WS_VISIBLE) != 0); int cx = 0; From d2b362879156f49ac77a69942cab2ffb0fdac12b Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 17:23:01 +0100 Subject: [PATCH 54/85] #i116487# Adjust copyright date to 2011 --- svx/source/intro/about_ooo.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/intro/about_ooo.src b/svx/source/intro/about_ooo.src index b49a0ff927cf..4523ffd739ce 100644 --- a/svx/source/intro/about_ooo.src +++ b/svx/source/intro/about_ooo.src @@ -30,7 +30,7 @@ String ABOUT_STR_COPYRIGHT { - Text[ en-US ] = "Copyright © 2000, 2010 Oracle and/or its affiliates. All rights reserved.\nThis product was created by %OOOVENDOR, based on OpenOffice.org.\nOpenOffice.org acknowledges all community members, especially those mentioned at\n http://www.openoffice.org/welcome/credits.html."; + Text[ en-US ] = "Copyright © 2000, 2011 Oracle and/or its affiliates. All rights reserved.\nThis product was created by %OOOVENDOR, based on OpenOffice.org.\nOpenOffice.org acknowledges all community members, especially those mentioned at\n http://www.openoffice.org/welcome/credits.html."; }; StringArray ABOUT_STR_DEVELOPER_ARY From 5dd2784030e00fa1857b30ee8c5da62e221bfd32 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 17 Mar 2011 09:16:41 +0100 Subject: [PATCH 55/85] mav60: #164341# support AES encryption --- .../schema/org/openoffice/Office/Common.xcs | 20 ++++++++-- sfx2/source/doc/objstor.cxx | 39 ++++++++++++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ae171230dd13..4516c884bb0f 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2392,9 +2392,23 @@ ODFVER_LATEST - - 3 - + + 3 + + + + MAV + Specifies whether SHA1 algorithm instead of SHA256 should be used in ODF12 for StartKey and Checksum generation during encryption. + + false + + + + MAV + Specifies whether Blowfish algorithm instead of AES should be used in ODF12 for encryption. + + false + diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9a86e962cac6..a80ba1ddc2a1 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -357,24 +357,51 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto const_cast( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } - ::rtl::OUString aVersion; SvtSaveOptions aSaveOpt; SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); - // older versions can not have this property set, it exists only starting from ODF1.2 - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) - aVersion = ODFVER_012_TEXT; + uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); + aEncryptionAlg[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); + aEncryptionAlg[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); + aEncryptionAlg[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); + // the default values, that should be used for ODF1.1 and older formats + aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA1; + aEncryptionAlg[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA1_1K; - if ( aVersion.getLength() ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) { try { - xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( aVersion ) ); + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( ODFVER_012_TEXT ) ); } catch( uno::Exception& ) { } + + if ( !aSaveOpt.IsUseSHA1_ODF12() ) + { + aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA256; + aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA256_1K; + } + if ( !aSaveOpt.IsUseBlowfish_ODF12() ) + aEncryptionAlg[1].Value <<= xml::crypto::CipherID::AES_CBC; } + + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlg ); + } + catch( uno::Exception& ) + { + const_cast( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + } + } } } From c696ee29fc4254652b4df9cd5242bae8096d7e1f Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 17 Mar 2011 11:11:01 +0100 Subject: [PATCH 56/85] dba34d: fix for assertion from comphelper --- .../odbcbase/ODatabaseMetaDataResultSet.cxx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx index 751ab7cf2988..828d0f6b7c3e 100644 --- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx @@ -979,7 +979,8 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, cons m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1011,7 +1012,8 @@ void ODatabaseMetaDataResultSet::openColumns( const Any& catalog, m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1077,7 +1079,8 @@ void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog, m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1110,7 +1113,8 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const ::rtl: m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1139,6 +1143,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + if ( catalog.hasValue() ) aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); @@ -1228,7 +1233,8 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const ::rtl m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1257,7 +1263,8 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const : m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1287,7 +1294,8 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const ::rtl: m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, From bd5f34e011d723600858e57667c17e21172f0f65 Mon Sep 17 00:00:00 2001 From: Frank Peters Date: Thu, 17 Mar 2011 11:37:28 +0100 Subject: [PATCH 57/85] #i117372# --- readlicense_oo/docs/readme/eval.xsl | 2 +- readlicense_oo/docs/readme/readme.xrm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/readlicense_oo/docs/readme/eval.xsl b/readlicense_oo/docs/readme/eval.xsl index e8830d43015c..613e61d673f9 100644 --- a/readlicense_oo/docs/readme/eval.xsl +++ b/readlicense_oo/docs/readme/eval.xsl @@ -1,5 +1,5 @@ - + diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index 78716869e822..66203b687635 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -1,6 +1,5 @@ - + @@ -31,6 +30,7 @@

Notes on Installation

+

${PRODUCTNAME} requires a recent version of JAVA for full functionality which is part of the ${PRODUCTNAME} installation package.

System Requirements

    From f74016fe581e96afec61ecef37920ca81e8767c9 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 17 Mar 2011 13:38:39 +0100 Subject: [PATCH 58/85] dba34d: check extensions is empty --- connectivity/source/drivers/flat/ETable.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index b18c577030b0..4417c0fe6a7a 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -494,7 +494,8 @@ String OFlatTable::getEntry() // name and extension have to coincide if ( m_pConnection->matchesExtension( sExt ) ) { - sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); + if ( sExt.getLength() ) + sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); if ( sName == m_Name ) { Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); From 0c3818deda652f31d685b4d4d440de4faab1c044 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 17 Mar 2011 16:55:49 +0100 Subject: [PATCH 59/85] mav60: #164341# fix problems with the new implementation --- sfx2/source/doc/objstor.cxx | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index a80ba1ddc2a1..56032d689e76 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -67,9 +67,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include @@ -361,13 +364,13 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); - aEncryptionAlg[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); - aEncryptionAlg[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); - aEncryptionAlg[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); + aEncryptionAlgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); + aEncryptionAlgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); + aEncryptionAlgs[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); // the default values, that should be used for ODF1.1 and older formats - aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA1; - aEncryptionAlg[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; - aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA1_1K; + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA1; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA1_1K; if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) { @@ -380,13 +383,13 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto { } - if ( !aSaveOpt.IsUseSHA1_ODF12() ) + if ( !aSaveOpt.IsUseSHA1InODF12() ) { - aEncryptionAlg[0].Value <<= xml::crypto::CipherID::SHA256; - aEncryptionAlg[2].Value <<= xml::crypto::CipherID::SHA256_1K; + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; } - if ( !aSaveOpt.IsUseBlowfish_ODF12() ) - aEncryptionAlg[1].Value <<= xml::crypto::CipherID::AES_CBC; + if ( !aSaveOpt.IsUseBlowfishInODF12() ) + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC; } try @@ -395,7 +398,7 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto // the setting does not trigger encryption, // it just provides the format for the case that contents should be encrypted uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); - xEncr->setEncryptionAlgorithms( aEncryptionAlg ); + xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); } catch( uno::Exception& ) { From e9e5d2cae62465c44defcc015f873849fdcf5a44 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 18 Mar 2011 09:55:33 +0100 Subject: [PATCH 60/85] fwk167: #i93666# Added separators to the new Vista/7 file dialog --- .../IVistaFilePickerInternalNotify.hxx | 2 + .../win32/filepicker/VistaFilePicker.cxx | 16 +++--- .../VistaFilePickerEventHandler.cxx | 52 +++--------------- .../win32/filepicker/VistaFilePickerImpl.cxx | 53 ++++++++++++++++++- .../win32/filepicker/VistaFilePickerImpl.hxx | 12 ++++- .../source/win32/filepicker/platform_vista.h | 27 ---------- 6 files changed, 78 insertions(+), 84 deletions(-) diff --git a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx index 8f4e0d040f3e..d47c21c40cb2 100644 --- a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx +++ b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx @@ -66,6 +66,8 @@ class IVistaFilePickerInternalNotify public: virtual void onAutoExtensionChanged (bool bChecked) = 0; + + virtual bool onFileTypeChanged( UINT nTypeIndex ) = 0; }; }}} diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index 14b185ee2688..f150120e132f 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -224,7 +224,7 @@ void SAL_CALL VistaFilePicker::setTitle(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilter(const ::rtl::OUString& sTitle , - const ::rtl::OUString& sFilter) + const ::rtl::OUString& sFilter) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException ) { @@ -263,17 +263,15 @@ void SAL_CALL VistaFilePicker::setCurrentFilter(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilterGroup(const ::rtl::OUString& /*sGroupTitle*/, - const css::uno::Sequence< css::beans::StringPair >& lFilters ) + const css::uno::Sequence< css::beans::StringPair >& rFilters ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - ::sal_Int32 c = lFilters.getLength(); - ::sal_Int32 i = 0; - for (i=0; isetRequest (VistaFilePickerImpl::E_APPEND_FILTERGROUP); + rRequest->setArgument(PROP_FILTER_GROUP, rFilters); + + m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::NON_BLOCKED); } //----------------------------------------------------------------------------------------- diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx index 2fadaa6bfdff..f399c55de694 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx @@ -269,33 +269,16 @@ STDMETHODIMP VistaFilePickerEventHandler::OnShareViolation(IFileDialog* } //----------------------------------------------------------------------------------------- -STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* /*pDialog*/) +STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* pDialog) { - /* - IFileDialogCustomize *iCustomize; - pDialog->QueryInterface(IID_IFileDialogCustomize, (void**)(&iCustomize)); + UINT nFileTypeIndex; + HRESULT hResult = pDialog->GetFileTypeIndex( &nFileTypeIndex ); - BOOL bValue = FALSE; - HRESULT hResult = iCustomize->GetCheckButtonState( css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &bValue); - - if ( bValue ) + if ( hResult == S_OK ) { - UINT nIndex; - - pDialog->GetFileTypeIndex( &nIndex ); - - LPCWSTR lpFilterExt = lFilters[nIndex].pszSpec; - - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - pDialog->SetDefaultExtension( lpFilterExt ); + if ( m_pInternalNotify->onFileTypeChanged( nFileTypeIndex )) + impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); } - return S_OK; - - */ - - impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); return S_OK; } @@ -334,32 +317,9 @@ STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustom DWORD nIDCtl , BOOL bChecked ) { - /* - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) - { - LPCWSTR lpFilterExt = 0; - if ( bChecked ) - { - UINT nIndex; - if (m_pDialog) - { - m_pDialog->GetFileTypeIndex( &nIndex ); - lpFilterExt = lFilters[nIndex].pszSpec; - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - } - } - - if (m_pDialog) - m_pDialog->SetDefaultExtension( lpFilterExt ); - } - */ - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) m_pInternalNotify->onAutoExtensionChanged(bChecked); - impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast( nIDCtl)); return S_OK; diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 677c2bdbfa7d..97afa038fcab 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,8 @@ #endif #include "..\misc\WinImplHelper.hxx" +#include + inline bool is_current_process_window(HWND hwnd) { DWORD pid; @@ -199,6 +202,10 @@ void VistaFilePickerImpl::doRequest(const RequestRef& rRequest) impl_sta_appendFilter(rRequest); break; + case E_APPEND_FILTERGROUP : + impl_sta_appendFilterGroup(rRequest); + break; + case E_SET_CURRENT_FILTER : impl_sta_setCurrentFilter(rRequest); break; @@ -330,6 +337,28 @@ void VistaFilePickerImpl::impl_sta_appendFilter(const RequestRef& rRequest) m_lFilters.addFilter(sTitle, sFilter); } +//------------------------------------------------------------------------------- +void VistaFilePickerImpl::impl_sta_appendFilterGroup(const RequestRef& rRequest) +{ + const css::uno::Sequence< css::beans::StringPair > aFilterGroup = + rRequest->getArgumentOrDefault(PROP_FILTER_GROUP, css::uno::Sequence< css::beans::StringPair >()); + + // SYNCHRONIZED-> + ::rtl::OUString aEmpty; + ::osl::ResettableMutexGuard aLock(m_aMutex); + + if ( m_lFilters.numFilter() > 0 && aFilterGroup.getLength() > 0 ) + m_lFilters.addFilter( STRING_SEPARATOR, aEmpty, sal_True ); + + ::sal_Int32 c = aFilterGroup.getLength(); + ::sal_Int32 i = 0; + for (i=0; isetArgument(PROP_DIALOG_SHOW_RESULT, (::sal_Bool)sal_True); + rRequest->setArgument(PROP_DIALOG_SHOW_RESULT, sal_True); } //------------------------------------------------------------------------------- @@ -1179,6 +1208,23 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const rtl::OUString& current } } +static void impl_refreshFileDialog( TFileDialog iDialog ) +{ + if ( SUCCEEDED(iDialog->SetFileName(L"")) && + SUCCEEDED(iDialog->SetFileName(L"*.*")) ) + { + IOleWindow* iOleWindow; + if (SUCCEEDED(iDialog->QueryInterface(IID_PPV_ARGS(&iOleWindow)))) + { + HWND hwnd; + if (SUCCEEDED(iOleWindow->GetWindow(&hwnd))) + { + PostMessage(hwnd, WM_COMMAND, IDOK, 0); + } + iOleWindow->Release(); + } + } +} //------------------------------------------------------------------------------- void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) @@ -1207,6 +1253,11 @@ void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) iDialog->SetDefaultExtension( pExt ); } +bool VistaFilePickerImpl::onFileTypeChanged( UINT /*nTypeIndex*/ ) +{ + return true; +} + } // namespace vista } // namespace win32 } // namespace fpicker diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx index 6be17935609b..201ed9f1764d 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx @@ -104,12 +104,14 @@ static const ::rtl::OUString PROP_TEMPLATE_DESCR = ::rtl::OUString::createF static const ::rtl::OUString PROP_FILTER_TITLE = ::rtl::OUString::createFromAscii("filter_title" ); // [OUString] static const ::rtl::OUString PROP_FILTER_VALUE = ::rtl::OUString::createFromAscii("filter_value" ); // [OUString] static const ::rtl::OUString PROP_FORCE = ::rtl::OUString::createFromAscii("force" ); // [sal_Bool] +static const ::rtl::OUString PROP_FILTER_GROUP = ::rtl::OUString::createFromAscii("filter_group" ); // [seq< css:beans::StringPair >] contains a group of filters static const ::rtl::OUString PROP_CONTROL_ID = ::rtl::OUString::createFromAscii("control_id" ); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_ACTION = ::rtl::OUString::createFromAscii("control_action" ); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_VALUE = ::rtl::OUString::createFromAscii("control_value" ); // [Any] static const ::rtl::OUString PROP_CONTROL_LABEL = ::rtl::OUString::createFromAscii("control_label" ); // [OUString] static const ::rtl::OUString PROP_CONTROL_ENABLE = ::rtl::OUString::createFromAscii("control_enable" ); // [sal_Bool] true=ON, false=OFF +static const ::rtl::OUString STRING_SEPARATOR = ::rtl::OUString::createFromAscii("------------------------------------------" ); //----------------------------------------------------------------------------- /** native implementation of the file picker on Vista and upcoming windows versions. @@ -149,7 +151,8 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex E_GET_CONTROL_VALUE, E_SET_CONTROL_LABEL, E_GET_CONTROL_LABEL, - E_ENABLE_CONTROL + E_ENABLE_CONTROL, + E_APPEND_FILTERGROUP }; public: @@ -168,8 +171,11 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex virtual void doRequest(const RequestRef& rRequest); virtual void after(); + //--------------------------------------------------------------------- + // IVistaFilePickerInternalNotify //--------------------------------------------------------------------- virtual void onAutoExtensionChanged (bool bChecked); + virtual bool onFileTypeChanged( UINT nTypeIndex ); private: @@ -185,6 +191,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex /// implementation of request E_APPEND_FILTER void impl_sta_appendFilter(const RequestRef& rRequest); + //--------------------------------------------------------------------- + /// implementation of request E_APPEND_FILTERGROUP + void impl_sta_appendFilterGroup(const RequestRef& rRequest); + //--------------------------------------------------------------------- /// implementation of request E_SET_CURRENT_FILTER void impl_sta_setCurrentFilter(const RequestRef& rRequest); diff --git a/fpicker/source/win32/filepicker/platform_vista.h b/fpicker/source/win32/filepicker/platform_vista.h index e8812909f757..553ff811ef5e 100644 --- a/fpicker/source/win32/filepicker/platform_vista.h +++ b/fpicker/source/win32/filepicker/platform_vista.h @@ -47,32 +47,6 @@ #pragma warning(pop) #endif -// ATL/WTL -//#include -//#include -//#include -//extern CAppModule _Module; -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - -/* -// STL -#include - -// Global functions -LPCTSTR PrepFilterString ( CString& sFilters ); -bool PathFromShellItem ( IShellItem* pItem, CString& sPath ); -bool BuildFilterSpecList ( _U_STRINGorID szFilterList, - std::vector& vecsFilterParts, - std::vector& vecFilters ); -*/ - #if defined _M_IX86 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 @@ -84,4 +58,3 @@ bool BuildFilterSpecList ( _U_STRINGorID szFilterList, #endif #endif - From 1768cff01e1d63687d9ecfedf65b81610dfd71b2 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 18 Mar 2011 13:16:16 +0100 Subject: [PATCH 61/85] dba34d: Solaris WaE --- connectivity/source/commontools/FValue.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 5ea0e601a9c3..6f65547736d9 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -795,7 +795,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); - break; default: switch(_rRH.m_eTypeKind) { @@ -803,7 +802,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); - break; default: break; } @@ -827,7 +825,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const ::rtl::OUString aVal1(m_aValue.m_pString); ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); return aVal1 == aVal2; - break; } default: if ( m_bSigned != _rRH.m_bSigned ) From 86528b0c6b49e25d38f40f2bfec468a4d13e9100 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 21 Mar 2011 15:01:58 +0100 Subject: [PATCH 62/85] CWS fwk167: #i117366# - move resources from sfx2 to sd and sc --- sfx2/source/appl/sfx.src | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sfx2/source/appl/sfx.src b/sfx2/source/appl/sfx.src index 3bca517c5fd5..746b4c9688d6 100644 --- a/sfx2/source/appl/sfx.src +++ b/sfx2/source/appl/sfx.src @@ -27,19 +27,6 @@ #include -String STR_STYLE_FILTER_USED -{ - Text [ en-US ] = "Applied Styles" ; -}; -String STR_STYLE_FILTER_USERDEF -{ - Text [ en-US ] = "Custom Styles" ; -}; -String STR_STYLE_FILTER_ALL -{ - Text [ en-US ] = "All Styles" ; -}; - String STR_ACCTITLE_PRODUCTIVITYTOOLS { Text [ en-US ] = "%PRODUCTNAME"; From 116bcf73991899a9988729c663a778c67be70dde Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 21 Mar 2011 15:03:07 +0100 Subject: [PATCH 63/85] CWS fwk167: #i117487# - use correct resource manager for error handlers --- sfx2/source/appl/appdata.cxx | 2 ++ sfx2/source/appl/appinit.cxx | 11 +++++------ sfx2/source/appl/appquit.cxx | 2 ++ sfx2/source/inc/appdata.hxx | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 71a6fc269c11..2914c648bfe9 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -98,6 +98,8 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pTopFrames( new SfxFrameArr_Impl ), pInitLinkList(0), pMatcher( 0 ), + pBasicResMgr( 0 ), + pSvtResMgr( 0 ), pAppDispatch(NULL), pTemplates( 0 ), pPool(0), diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index d9ff26beccba..ba23e04cad12 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -262,12 +262,11 @@ bool SfxApplication::Initialize_Impl() // nichtgehandelte Fehler durch Errorcode 1 an SFX gegeben. new SimpleErrorHandler; #endif - new SfxErrorHandler(RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1); - - new SfxErrorHandler( - RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END); - new SfxErrorHandler( - RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END ); + pAppData_Impl->pBasicResMgr = CreateResManager("sb"); + pAppData_Impl->pSvtResMgr = CreateResManager("svt"); + new SfxErrorHandler( RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1 ); + new SfxErrorHandler( RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END, pAppData_Impl->pSvtResMgr ); + new SfxErrorHandler( RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END, pAppData_Impl->pBasicResMgr ); // diverse Pointer SfxPickList::GetOrCreate( SvtHistoryOptions().GetSize( ePICKLIST ) ); diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index 351376091929..1a62f48a7a24 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -167,4 +167,6 @@ void SfxApplication::Deinitialize() NoChaos::ReleaseItemPool(); */ pAppData_Impl->pPool = NULL; + DELETEZ(pAppData_Impl->pBasicResMgr); + DELETEZ(pAppData_Impl->pSvtResMgr); } diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 7da892ca89c9..92a56655a27d 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -110,7 +110,8 @@ public: // application members SfxFilterMatcher* pMatcher; - ResMgr* pLabelResMgr; + ResMgr* pBasicResMgr; + ResMgr* pSvtResMgr; SfxStatusDispatcher* pAppDispatch; SfxDocumentTemplates* pTemplates; From aa67a378129447f60c1eb234f0657b14196b24d0 Mon Sep 17 00:00:00 2001 From: os Date: Tue, 22 Mar 2011 15:32:53 +0100 Subject: [PATCH 64/85] #i105244# handling of extensions while saving pictures fixed --- svx/inc/svx/xoutbmp.hxx | 1 + svx/source/xoutdev/_xoutbmp.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) mode change 100644 => 100755 svx/inc/svx/xoutbmp.hxx mode change 100644 => 100755 svx/source/xoutdev/_xoutbmp.cxx diff --git a/svx/inc/svx/xoutbmp.hxx b/svx/inc/svx/xoutbmp.hxx old mode 100644 new mode 100755 index 1d0fca8de220..6dd59dbd6e57 --- a/svx/inc/svx/xoutbmp.hxx +++ b/svx/inc/svx/xoutbmp.hxx @@ -43,6 +43,7 @@ #define XOUTBMP_CONTOUR_HORZ 0x00000001L #define XOUTBMP_CONTOUR_VERT 0x00000002L #define XOUTBMP_CONTOUR_EDGEDETECT 0x00000004L +#define XOUTBMP_DONT_ADD_EXTENSION 0x00000008L #define XOUTBMP_DONT_EXPAND_FILENAME 0x10000000L #define XOUTBMP_USE_GIF_IF_POSSIBLE 0x20000000L diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx old mode 100644 new mode 100755 index e8958bf82479..62c434097699 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -367,7 +367,8 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, if( aExt.Len() ) { - aURL.setExtension( aExt ); + if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); SfxMedium aMedium( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, sal_True ); @@ -472,7 +473,8 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, if( ( GRFILTER_FORMAT_NOTFOUND != nFilter ) && ( aGraphic.GetType() != GRAPHIC_NONE ) ) { - aURL.setExtension( aExt ); + if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, NULL ); } From 1c847b5fd09e5a64092e4df48591ec38ee3dabdd Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 23 Mar 2011 14:13:24 +0100 Subject: [PATCH 65/85] mav60: #164341# fix problems with the new implementation --- sfx2/source/doc/guisaveas.cxx | 8 ++++---- sfx2/source/doc/objstor.cxx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 2ccf5fa7a849..1df7d2b01920 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -670,6 +670,10 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) //------------------------------------------------------------------------- sal_Int8 ModelData_Impl::CheckStateForSave() { + // if the document is readonly or a new one a SaveAs operation must be used + if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) + return STATUS_SAVEAS; + // check acceptable entries for media descriptor sal_Bool bVersInfoNeedsStore = sal_False; ::comphelper::SequenceAsHashMap aAcceptedArgs; @@ -701,10 +705,6 @@ sal_Int8 ModelData_Impl::CheckStateForSave() if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore ) return STATUS_NO_ACTION; - // if the document is readonly or a new one a SaveAs operation must be used - if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) - return STATUS_SAVEAS; - // check that the old filter is acceptable ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( aFilterNameString, diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 56032d689e76..38f30b78974a 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -389,7 +389,7 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; } if ( !aSaveOpt.IsUseBlowfishInODF12() ) - aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; } try From eaf1fca59a2fcc9ebf16afbb82361f1a5cb714b3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 23 Mar 2011 17:32:53 +0000 Subject: [PATCH 66/85] mav60: #i117504#: DocumentMetadataAccess: do not commit document storage --- sfx2/source/doc/DocumentMetadataAccess.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index df0781be8877..0ff55513c547 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -699,11 +699,11 @@ writeStream(struct DocumentMetadataAccess_Impl & i_rImpl, buf.append(dir).append(static_cast('/')); writeStream(i_rImpl, xDir, i_xGraphName, rest, buf.makeStringAndClear()); - } - const uno::Reference xTransaction( - i_xStorage, uno::UNO_QUERY); - if (xTransaction.is()) { - xTransaction->commit(); + uno::Reference const xTransaction( + xDir, uno::UNO_QUERY); + if (xTransaction.is()) { + xTransaction->commit(); + } } } catch (uno::RuntimeException &) { throw; From 9823cbf7faac2ef54b29e453a8fd03bb7d987c6b Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Thu, 24 Mar 2011 11:13:10 +0100 Subject: [PATCH 67/85] #i10000# fix for Solaris warnings --- connectivity/source/commontools/FValue.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 5ea0e601a9c3..6f65547736d9 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -795,7 +795,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); - break; default: switch(_rRH.m_eTypeKind) { @@ -803,7 +802,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); - break; default: break; } @@ -827,7 +825,6 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const ::rtl::OUString aVal1(m_aValue.m_pString); ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); return aVal1 == aVal2; - break; } default: if ( m_bSigned != _rRH.m_bSigned ) From 9ec7075d48206f13b65fb0442962aa3a2e687156 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 24 Mar 2011 14:48:19 +0100 Subject: [PATCH 68/85] vcl2gnumake: fix a warning --- sfx2/source/appl/shutdowniconaqua.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index 14f12c79b53b..d51df52b02d1 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -115,6 +115,7 @@ using namespace ::com::sun::star::util; -(void)dockIconClicked: (NSObject*)pSender { + (void)pSender; // start start module ShutdownIcon::OpenURL( OUString( RTL_CONSTASCII_USTRINGPARAM( STARTMODULE_URL ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ) ); } From b46dab973c91c3a94bcda188a9888fef3fd16426 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 10:40:25 +0100 Subject: [PATCH 69/85] calcvba: #164410# improve VBA compatibility implementation in various areas: Excel symbols, MSForms symbols, document and forms event handling --- basic/inc/basic/sbxdef.hxx | 3 + basic/inc/basic/vbahelper.hxx | 49 ++ basic/source/basmgr/vbahelper.cxx | 158 +++++-- basic/source/classes/sb.cxx | 38 +- basic/source/classes/sbunoobj.cxx | 39 +- basic/source/classes/sbxmod.cxx | 116 +++-- basic/source/comp/codegen.cxx | 2 + basic/source/comp/dim.cxx | 7 + basic/source/comp/sbcomp.cxx | 446 ++++++++++++++++-- basic/source/comp/symtbl.cxx | 1 + basic/source/comp/token.cxx | 6 +- basic/source/inc/codegen.hxx | 3 +- basic/source/inc/namecont.hxx | 222 +++++---- basic/source/inc/runtime.hxx | 2 + basic/source/inc/sbtrace.hxx | 15 +- basic/source/inc/scriptcont.hxx | 17 +- basic/source/inc/symtbl.hxx | 3 + basic/source/runtime/methods.cxx | 47 +- basic/source/runtime/methods1.cxx | 7 +- basic/source/runtime/rtlproto.hxx | 1 + basic/source/runtime/runtime.cxx | 25 + basic/source/runtime/stdobj.cxx | 2 +- basic/source/runtime/step0.cxx | 2 + basic/source/runtime/step1.cxx | 3 +- basic/source/runtime/step2.cxx | 6 +- basic/source/uno/namecont.cxx | 235 ++++++--- basic/util/makefile.mk | 3 + framework/source/uielement/menubarmanager.cxx | 62 ++- oovbaapi/ooo/vba/XApplicationBase.idl | 1 - oovbaapi/ooo/vba/XCollectionBase.idl | 56 +++ oovbaapi/ooo/vba/XControlProvider.idl | 2 - oovbaapi/ooo/vba/XExecutableDialog.idl | 58 +++ oovbaapi/ooo/vba/excel/SheetObjects.idl | 26 +- oovbaapi/ooo/vba/excel/XApplication.idl | 17 +- oovbaapi/ooo/vba/makefile.mk | 2 + .../msforms/{XButton.idl => XCheckBox.idl} | 15 +- oovbaapi/ooo/vba/msforms/XComboBox.idl | 20 +- oovbaapi/ooo/vba/msforms/XCommandButton.idl | 56 +++ oovbaapi/ooo/vba/msforms/XControl.idl | 1 + oovbaapi/ooo/vba/msforms/XFrame.idl | 55 +++ oovbaapi/ooo/vba/msforms/XGroupBox.idl | 9 +- oovbaapi/ooo/vba/msforms/XLabel.idl | 10 +- oovbaapi/ooo/vba/msforms/XListBox.idl | 14 +- oovbaapi/ooo/vba/msforms/XNewFont.idl | 57 +++ oovbaapi/ooo/vba/msforms/XRadioButton.idl | 10 +- oovbaapi/ooo/vba/msforms/XTextBox.idl | 12 +- oovbaapi/ooo/vba/msforms/XToggleButton.idl | 13 +- oovbaapi/ooo/vba/msforms/XUserForm.idl | 2 + oovbaapi/ooo/vba/msforms/makefile.mk | 5 +- scripting/source/dlgprov/dlgevtatt.cxx | 25 +- sfx2/source/doc/objxtor.cxx | 87 +++- vbahelper/Library_msforms.mk | 15 +- vbahelper/Library_vbahelper.mk | 14 +- vbahelper/Package_inc.mk | 2 + vbahelper/inc/vbahelper/collectionbase.hxx | 214 +++++++++ .../inc/vbahelper/vbaapplicationbase.hxx | 1 - vbahelper/inc/vbahelper/vbacollectionimpl.hxx | 4 +- vbahelper/inc/vbahelper/vbadocumentbase.hxx | 1 + .../inc/vbahelper/vbaeventshelperbase.hxx | 68 ++- vbahelper/inc/vbahelper/vbahelper.hxx | 123 +++-- vbahelper/inc/vbahelper/vbawindowbase.hxx | 37 +- vbahelper/inc/vbahelper/weakreference.hxx | 94 ++++ vbahelper/prj/build.lst | 2 +- vbahelper/source/msforms/vbabutton.cxx | 53 ++- vbahelper/source/msforms/vbabutton.hxx | 15 +- vbahelper/source/msforms/vbacheckbox.cxx | 9 +- vbahelper/source/msforms/vbacheckbox.hxx | 5 +- vbahelper/source/msforms/vbacombobox.cxx | 95 +++- vbahelper/source/msforms/vbacombobox.hxx | 13 + vbahelper/source/msforms/vbacontrol.cxx | 123 +++-- vbahelper/source/msforms/vbacontrol.hxx | 24 +- vbahelper/source/msforms/vbacontrols.cxx | 188 ++++++-- vbahelper/source/msforms/vbacontrols.hxx | 27 +- vbahelper/source/msforms/vbaframe.cxx | 77 +-- vbahelper/source/msforms/vbaframe.hxx | 27 +- vbahelper/source/msforms/vbalabel.cxx | 7 +- vbahelper/source/msforms/vbalabel.hxx | 1 + vbahelper/source/msforms/vbalistbox.cxx | 9 +- vbahelper/source/msforms/vbalistbox.hxx | 3 +- vbahelper/source/msforms/vbamultipage.cxx | 11 +- vbahelper/source/msforms/vbamultipage.hxx | 9 +- vbahelper/source/msforms/vbanewfont.cxx | 160 +++++++ vbahelper/source/msforms/vbanewfont.hxx | 73 +++ vbahelper/source/msforms/vbaradiobutton.cxx | 8 +- vbahelper/source/msforms/vbaradiobutton.hxx | 1 + vbahelper/source/msforms/vbatextbox.cxx | 34 +- vbahelper/source/msforms/vbatextbox.hxx | 5 + vbahelper/source/msforms/vbatogglebutton.cxx | 53 ++- vbahelper/source/msforms/vbatogglebutton.hxx | 12 +- vbahelper/source/msforms/vbauserform.cxx | 36 +- vbahelper/source/msforms/vbauserform.hxx | 14 +- vbahelper/source/vbahelper/collectionbase.cxx | 333 +++++++++++++ .../source/vbahelper/vbaapplicationbase.cxx | 25 +- vbahelper/source/vbahelper/vbacommandbar.cxx | 9 +- .../source/vbahelper/vbacommandbarcontrol.cxx | 72 +-- .../source/vbahelper/vbacommandbarcontrol.hxx | 11 +- .../vbahelper/vbacommandbarcontrols.cxx | 27 +- .../vbahelper/vbacommandbarcontrols.hxx | 19 +- .../source/vbahelper/vbacommandbarhelper.hxx | 1 + .../source/vbahelper/vbadocumentbase.cxx | 17 +- .../source/vbahelper/vbaeventshelperbase.cxx | 285 ++++++++--- vbahelper/source/vbahelper/vbahelper.cxx | 441 +++++++++-------- vbahelper/source/vbahelper/vbawindowbase.cxx | 140 +++--- 103 files changed, 3911 insertions(+), 1209 deletions(-) mode change 100755 => 100644 basic/source/runtime/methods1.cxx create mode 100755 oovbaapi/ooo/vba/XCollectionBase.idl create mode 100755 oovbaapi/ooo/vba/XExecutableDialog.idl rename oovbaapi/ooo/vba/msforms/{XButton.idl => XCheckBox.idl} (86%) mode change 100644 => 100755 create mode 100644 oovbaapi/ooo/vba/msforms/XCommandButton.idl create mode 100755 oovbaapi/ooo/vba/msforms/XFrame.idl create mode 100755 oovbaapi/ooo/vba/msforms/XNewFont.idl create mode 100755 vbahelper/inc/vbahelper/collectionbase.hxx create mode 100755 vbahelper/inc/vbahelper/weakreference.hxx create mode 100755 vbahelper/source/msforms/vbanewfont.cxx create mode 100755 vbahelper/source/msforms/vbanewfont.hxx create mode 100755 vbahelper/source/vbahelper/collectionbase.cxx diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx index 6dc9fe1d8d66..cc669fd03649 100644 --- a/basic/inc/basic/sbxdef.hxx +++ b/basic/inc/basic/sbxdef.hxx @@ -108,6 +108,7 @@ enum SbxDataType { const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000; const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible +const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000; #endif @@ -320,6 +321,8 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion #define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN #define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one // is used for objects, the other for variables only +#define SBX_VAR_TO_DIM 0x2000 // Same value as SBX_NO_BROADCAST, cannot conflict as + // used for variables without broadcaster only // Broadcaster-IDs: #define SBX_HINT_DYING SFX_HINT_DYING diff --git a/basic/inc/basic/vbahelper.hxx b/basic/inc/basic/vbahelper.hxx index 0d99387965fe..f83548f7e02c 100755 --- a/basic/inc/basic/vbahelper.hxx +++ b/basic/inc/basic/vbahelper.hxx @@ -28,7 +28,9 @@ #ifndef BASIC_VBAHELPR_HXX #define BASIC_VBAHELPR_HXX +#include #include +#include namespace basic { namespace vba { @@ -39,6 +41,21 @@ namespace vba { // ============================================================================ +/** Creates and returns an enumeration of all open documents of the same type + as the specified document. + + First, the global module manager (com.sun.star.frame.ModuleManager) is + asked for the type of the passed model, and all open documents with the + same type will be stored in an enumeration object. + + @param rxModel + A document model determining the type of the documents. + */ +::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > createDocumentsEnumeration( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel ); + +// ============================================================================ + /** Locks or unlocks the controllers of all documents that have the same type as the specified document. @@ -80,6 +97,38 @@ void enableContainerWindowsOfAllDocuments( // ============================================================================ +/** Registers the passed path as working directory for the application the + passed document belongs to. + + @param rxModel + A document model determining the type of the application whose working + directory has been changed. + + @param rPath + The new working directory. + */ +void registerCurrentDirectory( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, + const ::rtl::OUString& rPath ); + +// ============================================================================ + +/** Returns the working directory of the application the passed document + belongs to. + + @param rxModel + A document model determining the type of the application whose working + directory is querried. + + @return + The working directory of the specified application, or an empty string + on error (e.g. if the passed document reference is empty). + */ +::rtl::OUString getCurrentDirectory( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel ); + +// ============================================================================ + } // namespace vba } // namespace basic diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx index a09446f2e40b..0e9338b52c5e 100755 --- a/basic/source/basmgr/vbahelper.cxx +++ b/basic/source/basmgr/vbahelper.cxx @@ -28,13 +28,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include "basic/vbahelper.hxx" +#include + +#include +#include #include #include #include #include #include #include +#include +#include namespace basic { namespace vba { @@ -45,64 +50,71 @@ using namespace ::com::sun::star; namespace { -/** Creates the global module manager needed to identify the type of documents. +/** Create an instance of a module manager. */ uno::Reference< frame::XModuleManager > lclCreateModuleManager() { uno::Reference< frame::XModuleManager > xModuleManager; try { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); xModuleManager.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), uno::UNO_QUERY ); } catch( uno::Exception& ) { } - OSL_ENSURE( xModuleManager.is(), "::basic::vba::lclCreateModuleManager - cannot create module manager" ); return xModuleManager; } // ---------------------------------------------------------------------------- -/** Returns the document service name of the specified document. +/** Implementation of an enumeration of all open documents of the same type. */ -::rtl::OUString lclIdentifyDocument( const uno::Reference< frame::XModuleManager >& rxModuleManager, const uno::Reference< frame::XModel >& rxModel ) +class DocumentsEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > { - ::rtl::OUString aServiceName; - if( rxModuleManager.is() ) - { - try - { - aServiceName = rxModuleManager->identify( rxModel ); - } - catch( uno::Exception& ) - { - } - OSL_ENSURE( aServiceName.getLength() > 0, "::basic::vba::lclIdentifyDocument - cannot identify document" ); - } - return aServiceName; -} +public: + DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ); + virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); +private: + typedef ::std::vector< uno::Reference< frame::XModel > > ModelVector; + ModelVector maModels; + ModelVector::iterator maModelIt; +}; -// ---------------------------------------------------------------------------- - -/** Returns an enumeration of all open documents. - */ -uno::Reference< container::XEnumeration > lclCreateDocumentEnumeration() +DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ) { - uno::Reference< container::XEnumeration > xEnumeration; try { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XDesktop > xDesktop( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), uno::UNO_QUERY_THROW ); uno::Reference< container::XEnumerationAccess > xComponentsEA( xDesktop->getComponents(), uno::UNO_SET_THROW ); - xEnumeration = xComponentsEA->createEnumeration(); - + uno::Reference< container::XEnumeration > xEnumeration( xComponentsEA->createEnumeration(), uno::UNO_SET_THROW ); + while( xEnumeration->hasMoreElements() ) + { + uno::Reference< frame::XModel > xCurrModel( xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); + if( xModuleManager->identify( xCurrModel ) == aIdentifier ) + maModels.push_back( xCurrModel ); + } } catch( uno::Exception& ) { } - OSL_ENSURE( xEnumeration.is(), "::basic::vba::lclCreateDocumentEnumeration - cannot create enumeration of all documents" ); - return xEnumeration; + maModelIt = maModels.begin(); +} + +sal_Bool SAL_CALL DocumentsEnumeration::hasMoreElements() throw (uno::RuntimeException) +{ + return maModelIt != maModels.end(); +} + +uno::Any SAL_CALL DocumentsEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( maModelIt == maModels.end() ) + throw container::NoSuchElementException(); + return uno::Any( *maModelIt++ ); } // ---------------------------------------------------------------------------- @@ -163,37 +175,39 @@ typedef void (*ModifyDocumentFunc)( const uno::Reference< frame::XModel >&, sal_ */ void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Reference< frame::XModel >& rxModel, sal_Bool bModificator ) { - uno::Reference< frame::XModuleManager > xModuleManager = lclCreateModuleManager(); - uno::Reference< container::XEnumeration > xDocumentsEnum = lclCreateDocumentEnumeration(); - ::rtl::OUString aIdentifier = lclIdentifyDocument( xModuleManager, rxModel ); - if( xModuleManager.is() && xDocumentsEnum.is() && (aIdentifier.getLength() > 0) ) + uno::Reference< container::XEnumeration > xDocumentsEnum( new DocumentsEnumeration( rxModel ) ); + // iterate over all open documents + while( xDocumentsEnum->hasMoreElements() ) try { - // iterate over all open documents - while( xDocumentsEnum->hasMoreElements() ) - { - try - { - uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW ); - ::rtl::OUString aCurrIdentifier = lclIdentifyDocument( xModuleManager, xCurrModel ); - if( aCurrIdentifier == aIdentifier ) - pModifyDocumentFunc( xCurrModel, bModificator ); - } - catch( uno::Exception& ) - { - } - } + uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW ); + pModifyDocumentFunc( xCurrModel, bModificator ); } - else + catch( uno::Exception& ) { - // no module manager, no documents enumeration, no identifier -> at least process the passed document - pModifyDocumentFunc( rxModel, bModificator ); } } +// ---------------------------------------------------------------------------- + +struct CurrDirPool +{ + ::osl::Mutex maMutex; + ::std::map< ::rtl::OUString, ::rtl::OUString > maCurrDirs; +}; + +struct StaticCurrDirPool : public ::rtl::Static< CurrDirPool, StaticCurrDirPool > {}; + } // namespace // ============================================================================ +uno::Reference< container::XEnumeration > createDocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ) +{ + return new DocumentsEnumeration( rxModel ); +} + +// ============================================================================ + void lockControllersOfAllDocuments( const uno::Reference< frame::XModel >& rxModel, sal_Bool bLockControllers ) { lclIterateDocuments( &lclLockControllers, rxModel, bLockControllers ); @@ -208,5 +222,45 @@ void enableContainerWindowsOfAllDocuments( const uno::Reference< frame::XModel > // ============================================================================ +void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, const ::rtl::OUString& rPath ) +{ + if( rPath.getLength() > 0 ) + { + CurrDirPool& rPool = StaticCurrDirPool::get(); + ::osl::MutexGuard aGuard( rPool.maMutex ); + try + { + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + if( aIdentifier.getLength() > 0 ) + rPool.maCurrDirs[ aIdentifier ] = rPath; + } + catch( uno::Exception& ) + { + } + } +} + +// ============================================================================ + +::rtl::OUString getCurrentDirectory( const uno::Reference< frame::XModel >& rxModel ) +{ + ::rtl::OUString aPath; + CurrDirPool& rPool = StaticCurrDirPool::get(); + ::osl::MutexGuard aGuard( rPool.maMutex ); + try + { + uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW ); + ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel ); + aPath = rPool.maCurrDirs[ aIdentifier ]; + } + catch( uno::Exception& ) + { + } + return aPath; +} + +// ============================================================================ + } // namespace vba } // namespace basic diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index f8ffa46d48a5..bf7b00e2a633 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include "sbunoobj.hxx" #include "sbjsmeth.hxx" #include "sbjsmod.hxx" @@ -136,6 +137,7 @@ void DocBasicItem::startListening() Any aThisComp; mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp ); Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY ); + mbDisposed = !xCloseBC.is(); if( xCloseBC.is() ) try { xCloseBC->addCloseListener( this ); } catch( uno::Exception& ) {} } @@ -437,7 +439,20 @@ SbxObject* SbiFactory::CreateObject( const String& rClass ) return new BasicCollection( aCollectionName ); } else - return NULL; + if( rClass.EqualsIgnoreCaseAscii( "FileSystemObject" ) ) + { + try + { + Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); + ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.FileSystemObject" ) ); + Reference< XInterface > xInterface( xFactory->createInstance( aServiceName ), UNO_SET_THROW ); + return new SbUnoObject( aServiceName, uno::makeAny( xInterface ) ); + } + catch( Exception& ) + {} + } + + return NULL; } @@ -934,8 +949,14 @@ void StarBASIC::SetModified( sal_Bool b ) SbxBase::SetModified( b ); } +extern void lcl_closeTraceFile(); + StarBASIC::~StarBASIC() { +#ifdef DBG_TRACE_BASIC + lcl_closeTraceFile(); +#endif + // Needs to be first action as it can trigger events disposeComVariablesForBasic( this ); @@ -2273,7 +2294,22 @@ void BasicCollection::CollRemove( SbxArray* pPar_ ) SbxVariable* p = pPar_->Get( 1 ); sal_Int32 nIndex = implGetIndex( p ); if( nIndex >= 0 && nIndex < (sal_Int32)xItemArray->Count32() ) + { xItemArray->Remove32( nIndex ); + + // Correct for stack if necessary + SbiInstance* pInst = pINST; + SbiRuntime* pRT = pInst ? pInst->pRun : NULL; + if( pRT ) + { + SbiForStack* pStack = pRT->FindForStackItemForCollection( this ); + if( pStack != NULL ) + { + if( pStack->nCurCollectionIndex >= nIndex ) + --pStack->nCurCollectionIndex; + } + } + } else SetError( SbERR_BAD_ARGUMENT ); } diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 13ae406cb305..6f20a68a274f 100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -1722,8 +1722,7 @@ String getBasicObjectTypeName( SbxObject* pObj ) return aName; } -bool checkUnoObjectType( SbUnoObject* pUnoObj, - const String& aClass ) +bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass ) { Any aToInspectObj = pUnoObj->getUnoAny(); TypeClass eType = aToInspectObj.getValueType().getTypeClass(); @@ -1740,6 +1739,21 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); if( xTypeProvider.is() ) { + /* Although interfaces in the ooo.vba namespace obey the IDL rules and + have a leading 'X', in Basic we want to be able to do something + like 'Dim wb As Workbooks' or 'Dim lb As MSForms.Label'. Here we + add a leading 'X' to the class name and a leading dot to the entire + type name. This results e.g. in '.XWorkbooks' or '.MSForms.XLabel' + which matches the interface names 'ooo.vba.excel.XWorkbooks' or + 'ooo.vba.msforms.XLabel'. + */ + ::rtl::OUString aClassName( sal_Unicode( '.' ) ); + sal_Int32 nClassNameDot = rClass.lastIndexOf( '.' ); + if( nClassNameDot >= 0 ) + aClassName += rClass.copy( 0, nClassNameDot + 1 ) + ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass.copy( nClassNameDot + 1 ); + else + aClassName += ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass; + Sequence< Type > aTypeSeq = xTypeProvider->getTypes(); const Type* pTypeArray = aTypeSeq.getConstArray(); sal_uInt32 nIfaceCount = aTypeSeq.getLength(); @@ -1753,8 +1767,8 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, DBG_ERROR("failed to get XIdlClass for type"); break; } - ::rtl::OUString sClassName = xClass->getName(); - if ( sClassName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) ) + ::rtl::OUString aInterfaceName = xClass->getName(); + if ( aInterfaceName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) ) { // there is a hack in the extensions/source/ole/oleobj.cxx to return the typename of the automation object, lets check if it // matches @@ -1767,20 +1781,15 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, // can't check type, leave it pass result = true; else - result = sTypeName.equals( aClass ); + result = sTypeName.equals( rClass ); } break; // finished checking automation object } - OSL_TRACE("Checking if object implements %s", - OUStringToOString( defaultNameSpace + aClass, - RTL_TEXTENCODING_UTF8 ).getStr() ); - // although interfaces in the ooo.vba.vba namespace - // obey the idl rules and have a leading X, in basic we - // want to be able to do something like - // 'dim wrkbooks as WorkBooks' - // so test assumes the 'X' has been dropped - sal_Int32 indexLastDot = sClassName.lastIndexOf('.'); - if ( indexLastDot > -1 && sClassName.copy( indexLastDot + 1).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("X") ) + aClass ) ) + + // match interface name with passed class name + OSL_TRACE("Checking if object implements %s", OUStringToOString( aClassName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( (aClassName.getLength() < aInterfaceName.getLength()) && + aInterfaceName.matchIgnoreAsciiCase( aClassName, aInterfaceName.getLength() - aClassName.getLength() ) ) { result = true; break; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index c722e680fd8c..24b031e8f4e9 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -88,10 +89,8 @@ using namespace com::sun::star; #include #include #include -#include #include - using namespace ::com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::reflection; using namespace com::sun::star::beans; @@ -107,6 +106,7 @@ using namespace com::sun::star::script; #include #include #include +#include typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; @@ -451,24 +451,36 @@ TYPEINIT1(SbUserFormModule,SbObjModule) typedef std::vector HighlightPortions; -bool getDefaultVBAMode( StarBASIC* pb ) +uno::Reference< frame::XModel > getDocumentModel( StarBASIC* pb ) { - bool bResult = false; - if ( pb && pb->IsDocBasic() ) + uno::Reference< frame::XModel > xModel; + if( pb && pb->IsDocBasic() ) { uno::Any aDoc; - if ( pb->GetUNOConstant( "ThisComponent", aDoc ) ) - { - uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); - if ( xProp.is() ) - { - uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); - if ( xVBAMode.is() ) - bResult = xVBAMode->getVBACompatibilityMode() == sal_True; - } - } + if( pb->GetUNOConstant( "ThisComponent", aDoc ) ) + xModel.set( aDoc, uno::UNO_QUERY ); } - return bResult; + return xModel; +} + +uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Reference< frame::XModel >& rxModel ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat; + try + { + uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW ); + xVBACompat.set( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY ); + } + catch( uno::Exception& ) + { + } + return xVBACompat; +} + +bool getDefaultVBAMode( StarBASIC* pb ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) ); + return xVBACompat.is() && xVBACompat->getVBACompatibilityMode(); } class AsyncQuitHandler @@ -501,20 +513,6 @@ IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ ) return 0L; } -void VBAUnlockDocuments( StarBASIC* pBasic ) -{ - if ( pBasic && pBasic->IsDocBasic() ) - { - SbUnoObject* pGlobs = dynamic_cast< SbUnoObject* >( pBasic->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ), SbxCLASS_DONTCARE ) ); - if ( pGlobs ) - { - uno::Reference< frame::XModel > xModel( pGlobs->getUnoAny(), uno::UNO_QUERY ); - ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); - ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); - } - } -} - ///////////////////////////////////////////////////////////////////////////// // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen @@ -833,7 +831,7 @@ void SbModule::SetSource( const String& r ) void SbModule::SetSource32( const ::rtl::OUString& r ) { // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override - SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); + SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); @@ -1031,6 +1029,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) sal_uInt16 nRes = 0; sal_Bool bDelInst = sal_Bool( pINST == NULL ); StarBASICRef xBasic; + uno::Reference< frame::XModel > xModel; + uno::Reference< script::vba::XVBACompatibility > xVBACompat; if( bDelInst ) { #ifdef DBG_TRACE_BASIC @@ -1041,6 +1041,23 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) pINST = new SbiInstance( (StarBASIC*) GetParent() ); + /* If a VBA script in a document is started, get the VBA compatibility + interface from the document Basic library container, and notify all + VBA script listeners about the started script. */ + if( mbVBACompat ) + { + StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() ); + if( pBasic && pBasic->IsDocBasic() ) try + { + xModel.set( getDocumentModel( pBasic ), uno::UNO_SET_THROW ); + xVBACompat.set( getVBACompatibility( xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STARTED, GetName() ); + } + catch( uno::Exception& ) + { + } + } + // Launcher problem // i80726 The Find below will genarate an error in Testtool so we reset it unless there was one before already sal_Bool bWasError = SbxBase::GetError() != 0; @@ -1183,9 +1200,20 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) ResetCapturedAssertions(); #endif - // VBA always ensures screenupdating is enabled after completing - if ( mbVBACompat ) - VBAUnlockDocuments( PTR_CAST( StarBASIC, GetParent() ) ); + if( xVBACompat.is() ) + { + // notify all VBA script listeners about the stopped script + try + { + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STOPPED, GetName() ); + } + catch( uno::Exception& ) + { + } + // VBA always ensures screenupdating is enabled after completing + ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); + ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); + } #ifdef DBG_TRACE_BASIC dbg_DeInitTrace(); @@ -2276,8 +2304,9 @@ public: uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY ); if ( xVbaMethodParameter.is() ) { +#endif sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 0; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu; Sequence< Any > aParams; aParams.realloc(2); @@ -2286,14 +2315,13 @@ public: mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); +#if IN_THE_FUTURE xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]); return; } } } - - mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) ); #endif } //liuchen 2009-7-21 @@ -2403,15 +2431,14 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun ) Sequence< Any > aArguments; triggerMethod( aMethodToRun, aArguments ); } -void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& /*aArguments*/) + +void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments ) { OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() ); // Search method SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD ); if( pMeth ) { -#if IN_THE_FUTURE - //liuchen 2009-7-21, support Excel VBA UserForm_QueryClose event with parameters if ( aArguments.getLength() > 0 ) // Setup parameters { SbxArrayRef xArray = new SbxArray; @@ -2439,8 +2466,6 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any pMeth->SetParameters( NULL ); } else -//liuchen 2009-7-21 -#endif { SbxValues aVals; pMeth->Get( aVals ); @@ -2532,7 +2557,7 @@ void SbUserFormModule::Unload() OSL_TRACE("** Unload() "); sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 1; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode; Sequence< Any > aParams; aParams.realloc(2); @@ -2542,7 +2567,7 @@ void SbUserFormModule::Unload() triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); aParams[0] >>= nCancel; - if (nCancel == 1) + if (nCancel != 0) // Basic returns -1 for "True" { return; } @@ -2585,6 +2610,9 @@ void SbUserFormModule::InitObject() SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE ); if ( m_xModel.is() && pGlobs ) { + // broadcast INITIALIZE_USERFORM script event before the dialog is created + Reference< script::vba::XVBACompatibility > xVBACompat( getVBACompatibility( m_xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::INITIALIZE_USERFORM, GetName() ); uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index a8c7e3f5330f..f59edfbb12e9 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -303,6 +303,8 @@ void SbiCodeGen::Save() nUserData |= nDefaultId; if( pPar->IsParamArray() ) nUserData |= PARAM_INFO_PARAMARRAY; + if( pPar->IsWithBrackets() ) + nUserData |= PARAM_INFO_WITHBRACKETS; if( nUserData ) { SbxParamInfo* pParam = (SbxParamInfo*)pInfo->GetParam( i ); diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 1ba8982404e4..03c4845569a7 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -51,7 +51,11 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bC SbiDimList* pDim = NULL; // Klammern? if( Peek() == LPAREN ) + { pDim = new SbiDimList( this ); + if( !pDim->GetDims() ) + pDef->SetWithBrackets(); + } pDef->SetType( t ); if( bStatic ) pDef->SetStatic(); @@ -382,6 +386,9 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) if( nFixedStringLength >= 0 ) nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (sal_uInt32(nFixedStringLength) << 17)); // len = all bits above 0x10000 + if( pDim != NULL && pDim->GetDims() > 0 ) + nOpnd2 |= SBX_TYPE_VAR_TO_DIM_FLAG; + aGen.Gen( eOp2, pDef->GetId(), nOpnd2 ); } diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 12e368d1c7eb..49c025a9e0a4 100755 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -44,12 +44,13 @@ #include // Trace ini file (set NULL to ignore) -static char GpTraceIniFile[] = "d:\\zBasic.Asm\\BasicTrace.ini"; +// can be overridden with the environment variable OOO_BASICTRACEINI +static char GpTraceIniFile[] = "~/BasicTrace.ini"; //static char* GpTraceIniFile = NULL; // Trace Settings, used if no ini file / not found in ini file -static char GpTraceFileNameDefault[] = "d:\\zBasic.Asm\\BasicTrace.txt"; +static char GpTraceFileNameDefault[] = "~/BasicTrace.txt"; static char* GpTraceFileName = GpTraceFileNameDefault; // GbTraceOn: @@ -63,6 +64,12 @@ static bool GbTraceOn = true; // with TraceCommand( "PCodeOn" / "PCodeOff" ), see below static bool GbIncludePCodes = false; +// GbInitOnlyAtOfficeStart: +// true = Tracing is only intialized onces after Office start when +// Basic runs the first time. Further calls to Basic, e.g. via events +// use the same output file. The trace ini file is not read again. +static bool GbInitOnlyAtOfficeStart = false; + static int GnIndentPerCallLevel = 4; static int GnIndentForPCode = 2; @@ -84,6 +91,37 @@ static int GnIndentForPCode = 2; long as it can be converted to string */ +#ifdef DBG_TRACE_PROFILING + +#include +#include +#include "canvas/elapsedtime.hxx" + +//*** Profiling *** +// GbTimerOn: +// true = including time stamps +static bool GbTimerOn = true; + +// GbTimeStampForEachStep: +// true = prints time stamp after each command / pcode (very slow) +static bool GbTimeStampForEachStep = false; + +// GbBlockAllAfterFirstFunctionUsage: +// true = everything (commands, pcodes, functions) is only printed +// for the first usage (improves performance when tracing / pro- +// filing large macros) +static bool GbBlockAllAfterFirstFunctionUsage = false; + +// GbBlockStepsAfterFirstFunctionUsage: +// true = commands / pcodes are only printed for the first time +// a function is executed. Afterwards only the entering/leaving +// messages are logged (improves performance when tracing / pro- +// filing large macros) +static bool GbBlockStepsAfterFirstFunctionUsage = false; + +#endif + + static void lcl_skipWhites( char*& rpc ) { while( *rpc == ' ' || *rpc == '\t' ) @@ -174,11 +212,28 @@ static void lcl_ReadIniFile( const char* pIniFileName ) if( strcmp( VarNameBuffer, "GbIncludePCodes") == 0 ) GbIncludePCodes = (strcmp( ValBuffer, "true" ) == 0); else + if( strcmp( VarNameBuffer, "GbInitOnlyAtOfficeStart") == 0 ) + GbInitOnlyAtOfficeStart = (strcmp( ValBuffer, "true" ) == 0); + else if( strcmp( VarNameBuffer, "GnIndentPerCallLevel") == 0 ) GnIndentPerCallLevel = strtol( ValBuffer, NULL, 10 ); else if( strcmp( VarNameBuffer, "GnIndentForPCode") == 0 ) GnIndentForPCode = strtol( ValBuffer, NULL, 10 ); +#ifdef DBG_TRACE_PROFILING + else + if( strcmp( VarNameBuffer, "GbTimerOn") == 0 ) + GbTimerOn = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbTimeStampForEachStep") == 0 ) + GbTimeStampForEachStep = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbBlockAllAfterFirstFunctionUsage") == 0 ) + GbBlockAllAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0); + else + if( strcmp( VarNameBuffer, "GbBlockStepsAfterFirstFunctionUsage") == 0 ) + GbBlockStepsAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0); +#endif } fclose( pFile ); } @@ -209,14 +264,14 @@ static void lcl_PrepareTraceForModule( SbModule* pModule ) pModule->Disassemble( aDisassemblyStr ); } -static void lcl_lineOut( const char* pFileName, const char* pStr, const char* pPreStr = NULL ) +static FILE* GpGlobalFile = NULL; + +static void lcl_lineOut( const char* pStr, const char* pPreStr = NULL, const char* pPostStr = NULL ) { - const char* pPrintFirst = (pPreStr != NULL) ? pPreStr : ""; - FILE* pFile = fopen( pFileName, "a+" ); - if( pFile != NULL ) + if( GpGlobalFile != NULL ) { - fprintf( pFile, "%s%s\n", pPrintFirst, pStr ); - fclose( pFile ); + fprintf( GpGlobalFile, "%s%s%s\n", pPreStr ? pPreStr : "", pStr, pPostStr ? pPostStr : "" ); + fflush( GpGlobalFile ); } } @@ -304,32 +359,198 @@ String lcl_dumpMethodParameters( SbMethod* pMethod ) // Public functions - static bool GbSavTraceOn = false; + +#ifdef DBG_TRACE_PROFILING +static canvas::tools::ElapsedTime* GpTimer = NULL; +static double GdStartTime = 0.0; +static double GdLastTime = 0.0; +static bool GbBlockSteps = false; +static bool GbBlockAll = false; + +struct FunctionItem +{ + String m_aCompleteFunctionName; + double m_dTotalTime; + double m_dNetTime; + int m_nCallCount; + bool m_bBlockAll; + bool m_bBlockSteps; + + FunctionItem( void ) + : m_dTotalTime( 0.0 ) + , m_dNetTime( 0.0 ) + , m_nCallCount( 0 ) + , m_bBlockAll( false ) + , m_bBlockSteps( false ) + {} +}; +typedef std::hash_map< ::rtl::OUString, FunctionItem*, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > FunctionItemMap; + +static std::stack< double > GaCallEnterTimeStack; +static std::stack< FunctionItem* > GaFunctionItemStack; +static FunctionItemMap GaFunctionItemMap; + +bool compareFunctionNetTime( FunctionItem* p1, FunctionItem* p2 ) +{ + return (p1->m_dNetTime > p2->m_dNetTime); +} + +void lcl_printTimeOutput( void ) +{ + // Overall time output + lcl_lineOut( "" ); + lcl_lineOut( "***** Time Output *****" ); + char TimeBuffer[500]; + double dTotalTime = GpTimer->getElapsedTime() - GdStartTime; + sprintf( TimeBuffer, "Total execution time = %f ms", dTotalTime*1000.0 ); + lcl_lineOut( TimeBuffer ); + lcl_lineOut( "" ); + + if( GbTimerOn ) + { + lcl_lineOut( "Functions:" ); + + std::vector avFunctionItems; + + FunctionItemMap::iterator it; + for( it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it ) + { + FunctionItem* pFunctionItem = it->second; + if( pFunctionItem != NULL ) + avFunctionItems.push_back( pFunctionItem ); + } + + std::sort( avFunctionItems.begin(), avFunctionItems.end(), compareFunctionNetTime ); + + std::vector::iterator itv; + for( itv = avFunctionItems.begin() ; itv != avFunctionItems.end() ; ++itv ) + { + FunctionItem* pFunctionItem = *itv; + if( pFunctionItem != NULL ) + { + rtl::OUString aCompleteFunctionName = pFunctionItem->m_aCompleteFunctionName; + const char* pName = OUStringToOString( aCompleteFunctionName, RTL_TEXTENCODING_ASCII_US ).getStr(); + int nNameLen = aCompleteFunctionName.getLength(); + + double dFctTotalTime = pFunctionItem->m_dTotalTime; + double dFctNetTime = pFunctionItem->m_dNetTime; + double dFctTotalTimePercent = 100.0 * dFctTotalTime / dTotalTime; + double dFctNetTimePercent = 100.0 * dFctNetTime / dTotalTime; + int nSpaceCount = 30 - nNameLen; + if( nSpaceCount < 0 ) + nSpaceCount = 2; + sprintf( TimeBuffer, "%s:%sCalled %d times\t%f ms (%f%%) / net %f (%f%%) ms", + pName, lcl_getSpaces( nSpaceCount ), pFunctionItem->m_nCallCount, + dFctTotalTime*1000.0, dFctTotalTimePercent, dFctNetTime*1000.0, dFctNetTimePercent ); + lcl_lineOut( TimeBuffer ); + } + } + } +} +#endif + + +static bool GbInitTraceAlreadyCalled = false; + void dbg_InitTrace( void ) { - if( GpTraceIniFile != NULL ) + if( GbInitOnlyAtOfficeStart && GbInitTraceAlreadyCalled ) + { +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif + GpGlobalFile = fopen( GpTraceFileName, "a+" ); + return; + } + GbInitTraceAlreadyCalled = true; + + if( const sal_Char* pcIniFileName = ::getenv( "OOO_BASICTRACEINI" ) ) + lcl_ReadIniFile( pcIniFileName ); + else if( GpTraceIniFile != NULL ) lcl_ReadIniFile( GpTraceIniFile ); - FILE* pFile = fopen( GpTraceFileName, "w" ); - if( pFile != NULL ) - fclose( pFile ); + GpGlobalFile = fopen( GpTraceFileName, "w" ); GbSavTraceOn = GbTraceOn; if( !GbTraceOn ) - lcl_lineOut( GpTraceFileName, "### Program started with trace off ###" ); + lcl_lineOut( "### Program started with trace off ###" ); + +#ifdef DBG_TRACE_PROFILING + GpTimer = new canvas::tools::ElapsedTime(); + GdStartTime = GpTimer->getElapsedTime(); + GdLastTime = GdStartTime; + GbBlockSteps = false; + GbBlockAll = false; +#endif } void dbg_DeInitTrace( void ) { GbTraceOn = GbSavTraceOn; + +#ifdef DBG_TRACE_PROFILING + while( !GaCallEnterTimeStack.empty() ) + GaCallEnterTimeStack.pop(); + while( !GaFunctionItemStack.empty() ) + GaFunctionItemStack.pop(); + + lcl_printTimeOutput(); + + for( FunctionItemMap::iterator it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it ) + delete it->second; + GaFunctionItemMap.clear(); + + if( GpGlobalFile ) + { + fclose( GpGlobalFile ); + GpGlobalFile = NULL; + } + + if( GbInitOnlyAtOfficeStart ) + { + if( GbTimerOn ) + GpTimer->pauseTimer(); + } + else + { + delete GpTimer; + } +#endif } static sal_Int32 GnLastCallLvl = 0; +void dbg_tracePrint( const String& aStr, sal_Int32 nCallLvl, bool bCallLvlRelativeToCurrent ) +{ + if( bCallLvlRelativeToCurrent ) + nCallLvl += GnLastCallLvl; + + int nIndent = nCallLvl * GnIndentPerCallLevel; + lcl_lineOut( OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); +} + void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) { if( !GbTraceOn ) return; + +#ifdef DBG_TRACE_PROFILING + if( GbBlockSteps || GbBlockAll ) + return; + + double dCurTime = 0.0; + bool bPrintTimeStamp = false; + if( GbTimerOn ) + { + GpTimer->pauseTimer(); + dCurTime = GpTimer->getElapsedTime(); + bPrintTimeStamp = GbTimeStampForEachStep; + } +#else + bool bPrintTimeStamp = false; +#endif + GnLastCallLvl = nCallLvl; SbModule* pTraceMod = pModule; @@ -346,14 +567,14 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); char Buffer[200]; sprintf( Buffer, "TRACE ERROR: Unknown module \"%s\"", pModuleNameStr ); - lcl_lineOut( GpTraceFileName, Buffer ); + lcl_lineOut( Buffer ); return; } PCToTextDataMap* pInnerMap = it->second; if( pInnerMap == NULL ) { - lcl_lineOut( GpTraceFileName, "TRACE INTERNAL ERROR: No inner map" ); + lcl_lineOut( "TRACE INTERNAL ERROR: No inner map" ); return; } @@ -363,7 +584,7 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); char Buffer[200]; sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", (int)nPC, pModuleNameStr ); - lcl_lineOut( GpTraceFileName, Buffer ); + lcl_lineOut( Buffer ); return; } @@ -371,24 +592,67 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ) const TraceTextData& rTraceTextData = itInner->second; const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT; + bool bSTMT = false; if( rStr_STMNT.getLength() ) - lcl_lineOut( GpTraceFileName, rStr_STMNT.getStr(), lcl_getSpaces( nIndent ) ); + bSTMT = true; + + char TimeBuffer[200]; +#ifdef DBG_TRACE_PROFILING + if( bPrintTimeStamp ) + { + double dDiffTime = dCurTime - GdLastTime; + GdLastTime = dCurTime; + sprintf( TimeBuffer, "\t\t// Time = %f ms / += %f ms", dCurTime*1000.0, dDiffTime*1000.0 ); + } +#endif + + if( bSTMT ) + { + lcl_lineOut( rStr_STMNT.getStr(), lcl_getSpaces( nIndent ), + (bPrintTimeStamp && !GbIncludePCodes) ? TimeBuffer : NULL ); + } if( !GbIncludePCodes ) + { +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif return; + } nIndent += GnIndentForPCode; const rtl::OString& rStr_PCode = rTraceTextData.m_aTraceStr_PCode; if( rStr_PCode.getLength() ) - lcl_lineOut( GpTraceFileName, rStr_PCode.getStr(), lcl_getSpaces( nIndent ) ); + { + lcl_lineOut( rStr_PCode.getStr(), lcl_getSpaces( nIndent ), + bPrintTimeStamp ? TimeBuffer : NULL ); + } + +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif } + void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallLvl, bool bLeave ) { static const char* pSeparator = "' ================================================================================"; if( !GbTraceOn ) return; + +#ifdef DBG_TRACE_PROFILING + double dCurTime = 0.0; + double dExecutionTime = 0.0; + if( GbTimerOn ) + { + dCurTime = GpTimer->getElapsedTime(); + GpTimer->pauseTimer(); + } +#endif + GnLastCallLvl = nCallLvl; SbModule* pTraceMod = pModule; @@ -399,39 +663,116 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL pTraceMod = pClassModuleObj->getClassModule(); } + String aCompleteFunctionName = pTraceMod->GetName(); + if( pMethod != NULL ) + { + aCompleteFunctionName.AppendAscii( "::" ); + String aMethodName = pMethod->GetName(); + aCompleteFunctionName += aMethodName; + } + else + { + aCompleteFunctionName.AppendAscii( "/RunInit" ); + } + + bool bOwnBlockSteps = false; +#ifdef DBG_TRACE_PROFILING + bool bOwnBlockAll = false; + FunctionItem* pFunctionItem = NULL; + if( GbTimerOn ) + { + FunctionItemMap::iterator itFunctionItem = GaFunctionItemMap.find( aCompleteFunctionName ); + if( itFunctionItem != GaFunctionItemMap.end() ) + pFunctionItem = itFunctionItem->second; + + if( pFunctionItem == NULL ) + { + DBG_ASSERT( !bLeave, "No FunctionItem in leave!" ); + + pFunctionItem = new FunctionItem(); + pFunctionItem->m_aCompleteFunctionName = aCompleteFunctionName; + GaFunctionItemMap[ aCompleteFunctionName ] = pFunctionItem; + } + else if( GbBlockAllAfterFirstFunctionUsage && !bLeave ) + { + pFunctionItem->m_bBlockAll = true; + } + else if( GbBlockStepsAfterFirstFunctionUsage && !bLeave ) + { + pFunctionItem->m_bBlockSteps = true; + } + + if( bLeave ) + { + bOwnBlockAll = GbBlockAll; + bOwnBlockSteps = GbBlockSteps; + GbBlockAll = false; + GbBlockSteps = false; + + dExecutionTime = dCurTime - GaCallEnterTimeStack.top(); + GaCallEnterTimeStack.pop(); + + pFunctionItem->m_dTotalTime += dExecutionTime; + pFunctionItem->m_dNetTime += dExecutionTime; + pFunctionItem->m_nCallCount++; + + GaFunctionItemStack.pop(); + if( !GaFunctionItemStack.empty() ) + { + FunctionItem* pParentItem = GaFunctionItemStack.top(); + if( pParentItem != NULL ) + { + pParentItem->m_dNetTime -= dExecutionTime; + + GbBlockSteps = pParentItem->m_bBlockSteps; + GbBlockAll = pParentItem->m_bBlockAll; + } + } + } + else + { + GbBlockSteps = bOwnBlockSteps = pFunctionItem->m_bBlockSteps; + GbBlockAll = bOwnBlockAll = pFunctionItem->m_bBlockAll; + + GaCallEnterTimeStack.push( dCurTime ); + GaFunctionItemStack.push( pFunctionItem ); + } + } + + if( bOwnBlockAll ) + { + if( GbTimerOn ) + GpTimer->continueTimer(); + return; + } +#endif + if( nCallLvl > 0 ) nCallLvl--; int nIndent = nCallLvl * GnIndentPerCallLevel; - if( !bLeave ) + if( !bLeave && !bOwnBlockSteps ) { - lcl_lineOut( GpTraceFileName, "" ); - lcl_lineOut( GpTraceFileName, pSeparator, lcl_getSpaces( nIndent ) ); + lcl_lineOut( "" ); + lcl_lineOut( pSeparator, lcl_getSpaces( nIndent ) ); } String aStr; if( bLeave ) { - lcl_lineOut( GpTraceFileName, "}", lcl_getSpaces( nIndent ) ); - aStr.AppendAscii( "' Leaving " ); + if( !bOwnBlockSteps ) + { + lcl_lineOut( "}", lcl_getSpaces( nIndent ) ); + aStr.AppendAscii( "' Leaving " ); + } } else { aStr.AppendAscii( "Entering " ); } - String aModuleName = pTraceMod->GetName(); - aStr += aModuleName; - if( pMethod != NULL ) - { - aStr.AppendAscii( "::" ); - String aMethodName = pMethod->GetName(); - aStr += aMethodName; - } - else - { - aStr.AppendAscii( "/RunInit" ); - } + if( !bLeave || !bOwnBlockSteps ) + aStr += aCompleteFunctionName; - if( pClassModuleObj != NULL ) + if( !bOwnBlockSteps && pClassModuleObj != NULL ) { aStr.AppendAscii( "[this=" ); aStr += pClassModuleObj->GetName(); @@ -440,18 +781,37 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL if( !bLeave ) aStr += lcl_dumpMethodParameters( pMethod ); - lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); + const char* pPostStr = NULL; +#ifdef DBG_TRACE_PROFILING + char TimeBuffer[200]; + if( GbTimerOn && bLeave ) + { + sprintf( TimeBuffer, " // Execution Time = %f ms", dExecutionTime*1000.0 ); + pPostStr = TimeBuffer; + } +#endif + lcl_lineOut( (!bLeave || !bOwnBlockSteps) ? OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr() : "}", + lcl_getSpaces( nIndent ), pPostStr ); if( !bLeave ) - lcl_lineOut( GpTraceFileName, "{", lcl_getSpaces( nIndent ) ); + lcl_lineOut( "{", lcl_getSpaces( nIndent ) ); - if( bLeave ) - lcl_lineOut( GpTraceFileName, "" ); + if( bLeave && !bOwnBlockSteps ) + lcl_lineOut( "" ); + +#ifdef DBG_TRACE_PROFILING + if( GbTimerOn ) + GpTimer->continueTimer(); +#endif } void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, sal_Int32 nCallLvl ) { if( !GbTraceOn ) return; +#ifdef DBG_TRACE_PROFILING + if( GbBlockSteps || GbBlockAll ) + return; +#endif GnLastCallLvl = nCallLvl; rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US ); @@ -460,7 +820,7 @@ void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool b const char* pHandledStr = bTraceErrHandled ? " / HANDLED" : ""; sprintf( Buffer, "*** ERROR%s, Id = %d, Msg = \"%s\" ***", pHandledStr, (int)nTraceErr, aOTraceErrMsg.getStr() ); int nIndent = nCallLvl * GnIndentPerCallLevel; - lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) ); + lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) ); } void dbg_RegisterTraceTextForPC( SbModule* pModule, sal_uInt32 nPC, @@ -540,7 +900,7 @@ void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) sprintf( Buffer, "### TRACE_PRINT: %s ###", pValStr ); int nIndent = GnLastCallLvl * GnIndentPerCallLevel; - lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) ); + lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) ); if( eOld != SbxERR_OK ) SbxBase::SetError( eOld ); diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 2688b5be28cf..cc6dc04fde65 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -302,6 +302,7 @@ SbiSymDef::SbiSymDef( const String& rName ) : aName( rName ) bOpt = bParamArray = bWithEvents = + bWithBrackets = bByVal = bChained = bGlobal = sal_False; diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index 8700ae4129ba..28c90ff0bd87 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -561,7 +561,8 @@ SbiToken SbiTokenizer::Next() } special: // #i92642 - if( eCurTok != NIL && eCurTok != REM && eCurTok != EOLN && (tp->t == NAME || tp->t == LINE) ) + bool bStartOfLine = (eCurTok == NIL || eCurTok == REM || eCurTok == EOLN); + if( !bStartOfLine && (tp->t == NAME || tp->t == LINE) ) return eCurTok = SYMBOL; else if( tp->t == TEXT ) return eCurTok = SYMBOL; @@ -628,6 +629,9 @@ special: // #129904 Suppress system if( eTok == STOP && aSym.CompareIgnoreCaseToAscii( "system" ) == COMPARE_EQUAL ) eCurTok = SYMBOL; + + if( eTok == GET && bStartOfLine ) + eCurTok = SYMBOL; } else { diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index a496322bb6d7..9ba99e7ceae8 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -87,6 +87,7 @@ public: // #111897 PARAM_INFO flags start at 0x00010000 to not // conflict with DefaultId in SbxParamInfo::nUserData -#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_PARAMARRAY 0x0010000 +#define PARAM_INFO_WITHBRACKETS 0x0020000 #endif diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 7fd6eb06f607..c0e8191be307 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -29,6 +29,7 @@ #define BASIC_NAMECONTAINER_HXX #include + #include #include #include @@ -46,71 +47,41 @@ #include #include #include +#include +#include +#include +#include + #include #include +#include +#include +#include #include #include #include #include #include #include +#include #include -#include - -#include -#include -#include -#include class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper8< - ::com::sun::star::lang::XInitialization, - ::com::sun::star::script::XStorageBasedLibraryContainer, - ::com::sun::star::script::XLibraryContainerPassword, - ::com::sun::star::script::XLibraryContainerExport, - ::com::sun::star::script::XLibraryContainer3, - ::com::sun::star::container::XContainer, - ::com::sun::star::script::vba::XVBACompatibility, - ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; - -typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, - ::com::sun::star::container::XContainer > NameContainerHelper; - - -struct hashName_Impl -{ - size_t operator()(const ::rtl::OUString Str) const - { - return (size_t)Str.hashCode(); - } -}; - -struct eqName_Impl -{ - sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const - { - return ( Str1 == Str2 ); - } -}; - -typedef std::hash_map -< - ::rtl::OUString, - sal_Int32, - hashName_Impl, - eqName_Impl -> -NameContainerNameMap; - - //============================================================================ -class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper +typedef ::cppu::WeakImplHelper3< + ::com::sun::star::container::XNameContainer, + ::com::sun::star::container::XContainer, + ::com::sun::star::util::XChangesNotifier > NameContainer_BASE; + +class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE { + typedef std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap; + NameContainerNameMap mHashMap; ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues; @@ -119,14 +90,16 @@ class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper ::com::sun::star::uno::Type mType; ::com::sun::star::uno::XInterface* mpxEventSource; - ::cppu::OInterfaceContainerHelper maListenerContainer; + ::cppu::OInterfaceContainerHelper maContainerListeners; + ::cppu::OInterfaceContainerHelper maChangesListeners; public: NameContainer( const ::com::sun::star::uno::Type& rType ) : mnElementCount( 0 ) , mType( rType ) , mpxEventSource( NULL ) - , maListenerContainer( m_aMutex ) + , maContainerListeners( m_aMutex ) + , maChangesListeners( m_aMutex ) {} void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource ) @@ -173,21 +146,18 @@ public: virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); }; //============================================================================ -class SfxLibrary; - -enum InitMode -{ - DEFAULT, - CONTAINER_INIT_FILE, - LIBRARY_INIT_FILE, - OFFICE_DOCUMENT, - OLD_BASIC_STORAGE -}; - class ModifiableHelper { private: @@ -217,9 +187,42 @@ public: } }; -class SfxLibraryContainer :public LibraryContainerHelper - ,public ::utl::OEventListenerAdapter +//============================================================================ + +typedef ::comphelper::OListenerContainerBase< + ::com::sun::star::script::vba::XVBAScriptListener, + ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE; + +class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE { +public: + explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex ); + +private: + virtual bool implTypedNotify( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener, + const ::com::sun::star::script::vba::VBAScriptEvent& rEvent ) + throw (::com::sun::star::uno::Exception); +}; + +//============================================================================ + +class SfxLibrary; + +typedef ::cppu::WeakComponentImplHelper8< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::script::XStorageBasedLibraryContainer, + ::com::sun::star::script::XLibraryContainerPassword, + ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, + ::com::sun::star::container::XContainer, + ::com::sun::star::script::vba::XVBACompatibility, + ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE; + +class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter +{ + VBAScriptListenerContainer maVBAScriptListeners; + sal_Int32 mnRunningVBAScripts; sal_Bool mbVBACompat; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; @@ -246,7 +249,14 @@ protected: BasicManager* mpBasMgr; sal_Bool mbOwnBasMgr; - InitMode meInitMode; + enum InitMode + { + DEFAULT, + CONTAINER_INIT_FILE, + LIBRARY_INIT_FILE, + OFFICE_DOCUMENT, + OLD_BASIC_STORAGE + } meInitMode; void implStoreLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName, @@ -508,10 +518,24 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; // Methods XVBACompatibility - virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRunningVBAScripts() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVBAScriptListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) + throw (::com::sun::star::uno::RuntimeException); }; +//============================================================================ + class LibraryContainerMethodGuard { private: @@ -529,12 +553,12 @@ public: } }; - //============================================================================ class SfxLibrary : public ::com::sun::star::container::XNameContainer , public ::com::sun::star::container::XContainer + , public ::com::sun::star::util::XChangesNotifier , public ::cppu::BaseMutex , public ::cppu::OComponentHelper { @@ -670,6 +694,14 @@ public: ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + // Methods XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XChangesListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + public: struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } }; void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess ) @@ -681,18 +713,19 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; }; -//=================================================================== +//============================================================================ + class ScriptSubPackageIterator { - com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage; - bool m_bIsValid; - bool m_bIsBundle; + bool m_bIsValid; + bool m_bIsBundle; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; - sal_Int32 m_nSubPkgCount; - sal_Int32 m_iNextSubPkg; + < com::sun::star::deployment::XPackage > > m_aSubPkgSeq; + sal_Int32 m_nSubPkgCount; + sal_Int32 m_iNextSubPkg; com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implDetectScriptPackage( const com::sun::star::uno::Reference @@ -704,13 +737,7 @@ public: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib ); }; -enum IteratorState -{ - USER_EXTENSIONS, - SHARED_EXTENSIONS, - BUNDLED_EXTENSIONS, - END_REACHED -}; +//============================================================================ class ScriptExtensionIterator { @@ -731,34 +758,37 @@ protected: com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledScriptPackage( bool& rbPureDialogLib ); - com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; - IteratorState m_eState; + enum IteratorState + { + USER_EXTENSIONS, + SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, + END_REACHED + } m_eState; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; - bool m_bUserPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq; + bool m_bUserPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; - bool m_bSharedPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; + bool m_bSharedPackagesLoaded; com::sun::star::uno::Sequence< com::sun::star::uno::Reference - < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; - bool m_bBundledPackagesLoaded; + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; + int m_iSharedPackage; + int m_iBundledPackage; - int m_iUserPackage; - int m_iSharedPackage; - int m_iBundledPackage; - - - - ScriptSubPackageIterator* m_pScriptSubPackageIterator; + ScriptSubPackageIterator* m_pScriptSubPackageIterator; }; // end class ScriptExtensionIterator - +//============================================================================ } // namespace basic diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 46cd9d16521f..406bd487034c 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -465,6 +465,8 @@ public: SbxArray* GetLocals(); SbxArray* GetParams(); + SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection ); + SbxBase* FindElementExtern( const String& rName ); static bool isVBAEnabled(); diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx index d91c7bdf16e8..4fd139202b52 100755 --- a/basic/source/inc/sbtrace.hxx +++ b/basic/source/inc/sbtrace.hxx @@ -28,7 +28,20 @@ #ifndef _SBTRACE_HXX #define _SBTRACE_HXX -//#define DBG_TRACE_BASIC +#define DBG_TRACE_BASIC + +// ############################################################################### +// ### +// ### ATTENTION: +// ### +// ### - DBG_TRACE_PROFILING can only be activated together with DBG_TRACE_BASIC +// ### +// ### - If you activate DBG_TRACE_PROFILING you also need to uncomment line +// ### # SHL1STDLIBS+=$(CANVASTOOLSLIB) in basic/util/makefile.mk (search +// ### for DBG_TRACE_PROFILING there) +// ### +// ############################################################################### +//#define DBG_TRACE_PROFILING #ifdef DBG_TRACE_BASIC void dbg_InitTrace( void ); diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index d788a73da0fc..9ef4c41c6ce3 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -35,11 +35,11 @@ class BasicManager; -//============================================================================ - namespace basic { +//============================================================================ + class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword { ::rtl::OUString maScriptLanguage; @@ -140,16 +140,15 @@ public: }; //============================================================================ -typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; -typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo - > SfxScriptLibrary_BASE; +typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; -class SfxScriptLibrary : public SfxLibrary - , public SfxScriptLibrary_BASE +class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE { friend class SfxScriptLibraryContainer; + typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap; + sal_Bool mbLoadedSource; sal_Bool mbLoadedBinary; ModuleInfoMap mModuleInfos; @@ -194,7 +193,9 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; }; -} // namespace base +//============================================================================ + +} // namespace basic #endif diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index c30445d87634..576639dc5a45 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -133,6 +133,7 @@ protected: sal_Bool bGlobal : 1; // sal_True: Global-Variable sal_Bool bParamArray : 1; // sal_True: ParamArray parameter sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents + sal_Bool bWithBrackets : 1; // sal_True: Followed by () sal_uInt16 nDefaultId; // Symbol number of default value short nFixedStringLength; // String length in: Dim foo As String*Length public: @@ -159,6 +160,7 @@ public: void SetOptional() { bOpt = sal_True; } void SetParamArray() { bParamArray = sal_True; } void SetWithEvents() { bWithEvents = sal_True; } + void SetWithBrackets(){ bWithBrackets = sal_True; } void SetByVal( sal_Bool bByVal_ = sal_True ) { bByVal = bByVal_; } void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; } @@ -170,6 +172,7 @@ public: sal_Bool IsOptional() const{ return bOpt; } sal_Bool IsParamArray() const{ return bParamArray; } sal_Bool IsWithEvents() const{ return bWithEvents; } + sal_Bool IsWithBrackets() const{ return bWithBrackets; } sal_Bool IsByVal() const { return bByVal; } sal_Bool IsStatic() const { return bStatic; } sal_Bool IsNew() const { return bNew; } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 1d1f1c641547..640dd7e8bcbe 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -82,6 +82,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::io; +using namespace com::sun::star::frame; #endif /* _USE_UNO */ @@ -96,6 +97,7 @@ using namespace com::sun::star::io; #include "iosys.hxx" #include "ddectrl.hxx" #include +#include #include #include @@ -118,6 +120,9 @@ using namespace com::sun::star::io; #include +// from source/classes/sbxmod.cxx +Reference< XModel > getDocumentModel( StarBASIC* ); + static void FilterWhiteSpace( String& rStr ) { rStr.EraseAllChars( ' ' ); @@ -382,22 +387,48 @@ RTLFUNC(Asc) } } -RTLFUNC(Chr) +void implChr( SbxArray& rPar, bool bChrW ) { - (void)pBasic; - (void)bWrite; - if ( rPar.Count() < 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else { SbxVariableRef pArg = rPar.Get( 1 ); - sal_Unicode aCh = (sal_Unicode)pArg->GetUShort(); - String aStr( aCh ); + + String aStr; + if( !bChrW && SbiRuntime::isVBAEnabled() ) + { + sal_Char c = (sal_Char)pArg->GetByte(); + ByteString s( c ); + aStr = String( s, gsl_getSystemTextEncoding() ); + } + else + { + sal_Unicode aCh = (sal_Unicode)pArg->GetUShort(); + aStr = String( aCh ); + } rPar.Get(0)->PutString( aStr ); } } +RTLFUNC(Chr) +{ + (void)pBasic; + (void)bWrite; + + bool bChrW = false; + implChr( rPar, bChrW ); +} + +RTLFUNC(ChrW) +{ + (void)pBasic; + (void)bWrite; + + bool bChrW = true; + implChr( rPar, bChrW ); +} + #ifdef UNX #define _MAX_PATH 260 @@ -481,7 +512,6 @@ RTLFUNC(CurDir) RTLFUNC(ChDir) // JSM { - (void)pBasic; (void)bWrite; rPar.Get(0)->PutEmpty(); @@ -504,6 +534,9 @@ RTLFUNC(ChDir) // JSM if( bError ) StarBASIC::Error( SbERR_PATH_NOT_FOUND ); #endif + // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.) + if( SbiRuntime::isVBAEnabled() ) + ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() ); } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx old mode 100755 new mode 100644 index 2f6d18685803..20eca1f985ff --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -1075,6 +1075,10 @@ sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm, { sal_uInt8 aByte; *pStrm >> aByte; + + if( bBinary && SbiRuntime::isVBAEnabled() && aByte == 1 && pStrm->IsEof() ) + aByte = 0; + rVar.PutByte( aByte ); } break; @@ -1185,7 +1189,8 @@ void PutGet( SbxArray& rPar, sal_Bool bPut ) } sal_Int16 nFileNo = rPar.Get(1)->GetInteger(); SbxVariable* pVar2 = rPar.Get(2); - sal_Bool bHasRecordNo = (sal_Bool)(pVar2->GetType() != SbxEMPTY); + SbxDataType eType2 = pVar2->GetType(); + sal_Bool bHasRecordNo = (sal_Bool)(eType2 != SbxEMPTY && eType2 != SbxERROR); long nRecordNo = pVar2->GetLong(); if ( nFileNo < 1 || ( bHasRecordNo && nRecordNo < 1 ) ) { diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index bba1867d3591..8594382bd733 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -157,6 +157,7 @@ extern RTLFUNC(Abs); extern RTLFUNC(Asc); extern RTLFUNC(Atn); extern RTLFUNC(Chr); +extern RTLFUNC(ChrW); extern RTLFUNC(Cos); extern RTLFUNC(CurDir); extern RTLFUNC(ChDir); // JSM diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 10d25cc2292b..1a83a323931d 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -648,6 +648,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams ) // Methoden sind immer byval! sal_Bool bByVal = v->IsA( TYPE(SbxMethod) ); SbxDataType t = v->GetType(); + bool bTargetTypeIsArray = false; if( p ) { bByVal |= sal_Bool( ( p->eType & SbxBYREF ) == 0 ); @@ -656,9 +657,13 @@ void SbiRuntime::SetParameters( SbxArray* pParams ) if( !bByVal && t != SbxVARIANT && (!v->IsFixed() || (SbxDataType)(v->GetType() & 0x0FFF ) != t) ) bByVal = sal_True; + + bTargetTypeIsArray = (p->nUserData & PARAM_INFO_WITHBRACKETS) != 0; } if( bByVal ) { + if( bTargetTypeIsArray ) + t = SbxOBJECT; SbxVariable* v2 = new SbxVariable( t ); v2->SetFlag( SBX_READWRITE ); *v2 = *v; @@ -1237,6 +1242,26 @@ void SbiRuntime::ClearForStack() PopFor(); } +SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* pCollection ) +{ + SbiForStack* pRet = NULL; + + SbiForStack* p = pForStk; + while( p ) + { + SbxVariable* pVar = p->refEnd.Is() ? (SbxVariable*)p->refEnd : NULL; + if( p->eForType == FOR_EACH_COLLECTION && pVar != NULL && + (pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection ) + { + pRet = p; + break; + } + } + + return pRet; +} + + ////////////////////////////////////////////////////////////////////////// // // DLL-Aufrufe diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 92d8152e60f4..4004b40e882c 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -128,7 +128,7 @@ static Methods aMethods[] = { { "Chr", SbxSTRING, 1 | _FUNCTION, RTLNAME(Chr),0 }, { "string", SbxINTEGER, 0,NULL,0 }, -{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(Chr),0}, +{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(ChrW),0}, { "string", SbxINTEGER, 0,NULL,0 }, { "CInt", SbxINTEGER, 1 | _FUNCTION, RTLNAME(CInt),0 }, diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 43c930e975d2..462726a4c55f 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -797,6 +797,8 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar ) // AB 2.4.1996, auch Arrays ohne Dimensionsangaben zulassen (VB-komp.) if( pDims ) { + refVar->ResetFlag( SBX_VAR_TO_DIM ); + for( sal_uInt16 i = 1; i < pDims->Count(); ) { sal_Int32 lb = pDims->Get( i++ )->GetLong(); diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 0a9572906cc8..4fd91b692a4b 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -38,8 +38,7 @@ #include "sbunoobj.hxx" #include "errobject.hxx" -bool checkUnoObjectType( SbUnoObject* refVal, - const String& aClass ); +bool checkUnoObjectType( SbUnoObject* refVal, const ::rtl::OUString& aClass ); // Laden einer numerischen Konstanten (+ID) diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index bbb3668b5b69..dc8ff0a5fd50 100755 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -624,7 +624,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) else if( bVBAEnabled ) // !pObj { SbxArray* pParam = pElem->GetParameters(); - if( pParam != NULL ) + if( pParam != NULL && !pElem->IsSet( SBX_VAR_TO_DIM ) ) Error( SbERR_NO_OBJECT ); } } @@ -1141,6 +1141,10 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3 aStr.Fill( nCount, 0 ); pVar->PutString( aStr ); } + + bool bVarToDim = ((nOp2 & SBX_TYPE_VAR_TO_DIM_FLAG) != 0); + if( bVarToDim ) + pVar->SetFlag( SBX_VAR_TO_DIM ); } // Einrichten einer lokalen Variablen (+StringID+Typ) diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index fbf1429f9753..ae110f4bcf6e 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -34,17 +34,13 @@ #include #include #include -#ifndef __RSC //autogen #include -#endif #include #include #include #include #include -#ifndef INCLUDED_COMPHELPER_ANYTOSTRING_HXX #include -#endif #include "namecont.hxx" #include @@ -65,11 +61,9 @@ #include #include #include -#include "com/sun/star/deployment/ExtensionManager.hpp" +#include +#include #include -#ifndef _RTL_USTRING_HXX_ -#include -#endif #include #include @@ -165,25 +159,29 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement ) // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; - aEvent.ReplacedElement = aOldElement; - - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + if( maContainerListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementReplaced( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + aEvent.ReplacedElement = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent ); + } + + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) + { + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -211,33 +209,35 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement ) mHashMap[ aName ] = nCount; mnElementCount++; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; - - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + if( maContainerListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementInserted( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + maContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); + } + + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) + { + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } -void NameContainer::removeByName( const OUString& Name ) +void NameContainer::removeByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) { - NameContainerNameMap::iterator aIt = mHashMap.find( Name ); + NameContainerNameMap::iterator aIt = mHashMap.find( aName ); if( aIt == mHashMap.end() ) { throw NoSuchElementException(); @@ -259,26 +259,29 @@ void NameContainer::removeByName( const OUString& Name ) mValues.realloc( iLast ); mnElementCount--; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= Name; - aEvent.Element = aOldElement; - - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + if( maContainerListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementRemoved( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); + } + + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) + { + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + // aEvent.Changes[ 0 ].Element remains empty (meaning "replaced with nothing") + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -290,7 +293,7 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.addInterface( xIface ); + maContainerListeners.addInterface( xIface ); } void SAL_CALL NameContainer::removeContainerListener( const Reference< XContainerListener >& xListener ) @@ -299,7 +302,26 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.removeInterface( xIface ); + maContainerListeners.removeInterface( xIface ); +} + +// Methods XChangesNotifier +void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.addInterface( xIface ); +} + +void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.removeInterface( xIface ); } //============================================================================ @@ -320,12 +342,28 @@ void ModifiableHelper::setModified( sal_Bool _bModified ) //============================================================================ +VBAScriptListenerContainer::VBAScriptListenerContainer( ::osl::Mutex& rMutex ) : + VBAScriptListenerContainer_BASE( rMutex ) +{ +} + +bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent ) throw (Exception) +{ + rxListener->notifyVBAScriptEvent( rEvent ); + return true; // notify all other listeners too +} + +//============================================================================ + // Implementation class SfxLibraryContainer DBG_NAME( SfxLibraryContainer ) // Ctor SfxLibraryContainer::SfxLibraryContainer( void ) - : LibraryContainerHelper( maMutex ) + : SfxLibraryContainer_BASE( maMutex ) + + , maVBAScriptListeners( maMutex ) + , mnRunningVBAScripts( 0 ) , mbVBACompat( sal_False ) , maModifiable( *this, maMutex ) , maNameContainer( getCppuType( (Reference< XNameAccess >*) NULL ) ) @@ -2649,6 +2687,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource ) // OComponentHelper void SAL_CALL SfxLibraryContainer::disposing() { + Reference< XModel > xModel = mxOwnerDocument; + EventObject aEvent( xModel.get() ); + maVBAScriptListeners.disposing( aEvent ); stopAllComponentListening(); mxOwnerDocument = WeakReference< XModel >(); } @@ -2838,7 +2879,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa */ if( mbVBACompat ) try { - Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref + Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); } @@ -2848,6 +2889,43 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa } } +sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException) +{ + LibraryContainerMethodGuard aGuard( *this ); + return mnRunningVBAScripts; +} + +void SAL_CALL SfxLibraryContainer::addVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.addTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::removeVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.removeTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) throw (RuntimeException) +{ + // own lock for accessing the number of running scripts + enterMethod(); + switch( nIdentifier ) + { + case vba::VBAScriptEventId::SCRIPT_STARTED: + ++mnRunningVBAScripts; + break; + case vba::VBAScriptEventId::SCRIPT_STOPPED: + --mnRunningVBAScripts; + break; + } + leaveMethod(); + + Reference< XModel > xModel = mxOwnerDocument; // weak-ref -> ref + Reference< XInterface > xSender( xModel, UNO_QUERY_THROW ); + vba::VBAScriptEvent aEvent( xSender, nIdentifier, rModuleName ); + maVBAScriptListeners.notify( aEvent ); +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) @@ -2941,7 +3019,9 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType ) aRet = Any( ::cppu::queryInterface( rType, static_cast< XContainer * >( this ), static_cast< XNameContainer * >( this ), - static_cast< XNameAccess * >( this ) ) ); + static_cast< XNameAccess * >( this ), + static_cast< XElementAccess * >( this ), + static_cast< XChangesNotifier * >( this ) ) ); //} if( !aRet.hasValue() ) aRet = OComponentHelper::queryInterface( rType ); @@ -3083,6 +3163,7 @@ Sequence< Type > SfxLibrary::getTypes() static OTypeCollection s_aTypes_NameContainer( ::getCppuType( (const Reference< XNameContainer > *)0 ), ::getCppuType( (const Reference< XContainer > *)0 ), + ::getCppuType( (const Reference< XChangesNotifier > *)0 ), OComponentHelper::getTypes() ); s_pTypes_NameContainer = &s_aTypes_NameContainer; } @@ -3110,9 +3191,6 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId() } } - -//============================================================================ - // Methods XContainer void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException) @@ -3127,6 +3205,19 @@ void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerLi maNameContainer.removeContainerListener( xListener ); } +// Methods XChangesNotifier +void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.setEventSource( static_cast< XInterface* >( (OWeakObject*)this ) ); + maNameContainer.addChangesListener( xListener ); +} + +void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.removeChangesListener( xListener ); +} //============================================================================ // Implementation class ScriptExtensionIterator diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk index 31a4dcca8f8b..ae4456cbc923 100644 --- a/basic/util/makefile.mk +++ b/basic/util/makefile.mk @@ -66,6 +66,9 @@ SHL1STDLIBS= \ $(VOSLIB) \ $(XMLSCRIPTLIB) +# Uncomment the following line if DBG_TRACE_PROFILING is active in source/inc/sbtrace.hxx +# SHL1STDLIBS+=$(CANVASTOOLSLIB) + .IF "$(SOLAR_JAVA)" != "TRUE" SHL1STDLIBS+=$(SJLIB) .ENDIF diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index fd8e0d3fbcd7..a74fbabb271e 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -134,16 +134,20 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier"; static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider"; -static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; +static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; +static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; +static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; -const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; -const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; -const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; -const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; -const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; -const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; -const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; -static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5; +static const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; +static const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; +static const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; +static const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; +static const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; +static const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; +static const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; +static const sal_Int32 LEN_DESCRIPTOR_STYLE = 5; +static const sal_Int32 LEN_DESCRIPTOR_ISVISIBLE = 9; +static const sal_Int32 LEN_DESCRIPTOR_ENABLED = 7; const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500; @@ -1757,6 +1761,8 @@ void MenuBarManager::FillMenu( rtl::OUString aLabel; rtl::OUString aHelpURL; rtl::OUString aModuleIdentifier( rModuleIdentifier ); + sal_Bool bShow(sal_True); + sal_Bool bEnabled(sal_True); sal_uInt16 nType = 0; Reference< XIndexAccess > xIndexContainer; Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider ); @@ -1768,29 +1774,26 @@ void MenuBarManager::FillMenu( for ( int i = 0; i < aProp.getLength(); i++ ) { rtl::OUString aPropName = aProp[i].Name; - if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, - LEN_DESCRIPTOR_COMMANDURL )) + if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, LEN_DESCRIPTOR_COMMANDURL )) aProp[i].Value >>= aCommandURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, - LEN_DESCRIPTOR_HELPURL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, LEN_DESCRIPTOR_HELPURL )) aProp[i].Value >>= aHelpURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, - LEN_DESCRIPTOR_CONTAINER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, LEN_DESCRIPTOR_CONTAINER )) aProp[i].Value >>= xIndexContainer; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, - LEN_DESCRIPTOR_LABEL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, LEN_DESCRIPTOR_LABEL )) aProp[i].Value >>= aLabel; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, - LEN_DESCRIPTOR_TYPE )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, LEN_DESCRIPTOR_TYPE )) aProp[i].Value >>= nType; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, - LEN_DESCRIPTOR_MODULEIDENTIFIER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, LEN_DESCRIPTOR_MODULEIDENTIFIER )) aProp[i].Value >>= aModuleIdentifier; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, - LEN_DESCRIPTOR_DISPATCHPROVIDER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, LEN_DESCRIPTOR_DISPATCHPROVIDER )) aProp[i].Value >>= xDispatchProvider; - else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN )) + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, LEN_DESCRIPTOR_STYLE )) aProp[i].Value >>= nStyle; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ISVISIBLE, LEN_DESCRIPTOR_ISVISIBLE )) + aProp[i].Value >>= bShow; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ENABLED, LEN_DESCRIPTOR_ENABLED )) + aProp[i].Value >>= bEnabled; } if ( nType == ::com::sun::star::ui::ItemType::DEFAULT ) @@ -1809,6 +1812,17 @@ void MenuBarManager::FillMenu( nBits |= MIB_RADIOCHECK; pMenu->SetItemBits( nId, nBits ); } + + if ( bShow ) + pMenu->ShowItem( nId ); + else + pMenu->HideItem( nId ); + + if ( bEnabled) + pMenu->EnableItem( nId, sal_True ); + else + pMenu->EnableItem( nId, sal_False ); + if ( xIndexContainer.is() ) { PopupMenu* pNewPopupMenu = new PopupMenu; diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl index 1291276ae643..3d0e6c9ce0f5 100644 --- a/oovbaapi/ooo/vba/XApplicationBase.idl +++ b/oovbaapi/ooo/vba/XApplicationBase.idl @@ -45,7 +45,6 @@ interface XApplicationBase [attribute, readonly] string Version; [attribute, readonly] any VBE; - [attribute, readonly] any VBProjects; void Quit(); diff --git a/oovbaapi/ooo/vba/XCollectionBase.idl b/oovbaapi/ooo/vba/XCollectionBase.idl new file mode 100755 index 000000000000..245b252f7856 --- /dev/null +++ b/oovbaapi/ooo/vba/XCollectionBase.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * Copyright 2010, Oracle and/or its affiliates. All rights reserved. + * + ************************************************************************/ + +#ifndef OOO_VBA_XOLLECTIONBASE_IDL +#define OOO_VBA_XOLLECTIONBASE_IDL + +#include +#include + +//============================================================================= + +module ooo { module vba { + +//============================================================================= + +/** Base interface for VBA collections. + + Every VBA collection provides the number of items, an enumeration access of + all collection items (e.g. for the "For Each" loop), and a way to access + single items, usually via the method "Item". + + The various VBA collection objects expect a specific number of arguments in + the "Item" method, therefore this method is not part of this base interface + but has to be specified seperately in every derived interface. + */ +interface XCollectionBase +{ + //------------------------------------------------------------------------- + /** Provides an enumeration of all items in this collection. + */ + interface ::com::sun::star::container::XEnumerationAccess; + + //------------------------------------------------------------------------- + /** Provides the name of the default item access method. + + Usually this method is called "Item". The access method has to be + specified and implemented separately by every derived class. + */ + interface ::com::sun::star::script::XDefaultMethod; + + //------------------------------------------------------------------------- + /** Returns the number of items contained in this collection. + */ + [attribute, readonly] long Count; + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; + +#endif diff --git a/oovbaapi/ooo/vba/XControlProvider.idl b/oovbaapi/ooo/vba/XControlProvider.idl index 23f890d5a1c3..df8b53bdfc72 100644 --- a/oovbaapi/ooo/vba/XControlProvider.idl +++ b/oovbaapi/ooo/vba/XControlProvider.idl @@ -51,8 +51,6 @@ module ooo { module vba { interface XControlProvider { ::ooo::vba::msforms::XControl createControl( [in] ::com::sun::star::drawing::XControlShape xControl, [in] ::com::sun::star::frame::XModel xDocOwner ); - ::ooo::vba::msforms::XControl createUserformControl( [in] ::com::sun::star::awt::XControl xControl, [in] ::com::sun::star::awt::XControl xDialog, [in] ::com::sun::star::frame::XModel xDocOwner ); - }; }; }; diff --git a/oovbaapi/ooo/vba/XExecutableDialog.idl b/oovbaapi/ooo/vba/XExecutableDialog.idl new file mode 100755 index 000000000000..8754c8071348 --- /dev/null +++ b/oovbaapi/ooo/vba/XExecutableDialog.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_XExecutableDialog_idl__ +#define __ooo_vba_XExecutableDialog_idl__ + +#include + +//============================================================================= + +module ooo { module vba { + +/** The VBA equivalent to the UNO interface + XExecutableDialog. + */ +interface XExecutableDialog +{ + /** Executes the dialog. + + @return + The return value is dependent on the calling context. Usually, on + cancelling the dialog the implementation will return , + otherwise the return value will contain the expected result. + */ + any execute(); +}; + +//============================================================================= + +}; }; + +#endif + + diff --git a/oovbaapi/ooo/vba/excel/SheetObjects.idl b/oovbaapi/ooo/vba/excel/SheetObjects.idl index 5947c52ff4a0..0a2a3fd9ffe9 100644 --- a/oovbaapi/ooo/vba/excel/SheetObjects.idl +++ b/oovbaapi/ooo/vba/excel/SheetObjects.idl @@ -74,10 +74,10 @@ interface XGraphicObjects : com::sun::star::uno::XInterface /** Adds a new graphic object to the sheet this collection belongs to. The type of the object is determined by the type of the collection. - @param fLeft Position of the left border in points (1/72 inch). - @param fTop Position of the top border in points (1/72 inch). - @param fWidth Width of the object in points (1/72 inch). - @param fHeight Height of the object in points (1/72 inch). + @param Left Position of the left border in points (1/72 inch). + @param Top Position of the top border in points (1/72 inch). + @param Width Width of the object in points (1/72 inch). + @param Height Height of the object in points (1/72 inch). @return The created graphic object. */ @@ -102,10 +102,10 @@ interface XLineObjects : com::sun::star::uno::XInterface /** Adds a new line object to the sheet this collection belongs to. The type of the object is determined by the type of the collection. - @param fX1 Position of the first X coordinate in points (1/72 inch). - @param fY1 Position of the first Y coordinate in points (1/72 inch). - @param fX2 Position of the last X coordinate in points (1/72 inch). - @param fY2 Position of the last Y coordinate in points (1/72 inch). + @param X1 Position of the first X coordinate in points (1/72 inch). + @param Y1 Position of the first Y coordinate in points (1/72 inch). + @param X2 Position of the last X coordinate in points (1/72 inch). + @param Y2 Position of the last Y coordinate in points (1/72 inch). @return The created line object. */ @@ -123,11 +123,11 @@ interface XDrawings : com::sun::star::uno::XInterface { /** Adds a new polygon object to the sheet this collection belongs to. - @param fX1 Position of the first X coordinate in points (1/72 inch). - @param fY1 Position of the first Y coordinate in points (1/72 inch). - @param fX2 Position of the last X coordinate in points (1/72 inch). - @param fY2 Position of the last Y coordinate in points (1/72 inch). - @param bClosed True = outline closed (last and first point connected). + @param X1 Position of the first X coordinate in points (1/72 inch). + @param Y1 Position of the first Y coordinate in points (1/72 inch). + @param X2 Position of the last X coordinate in points (1/72 inch). + @param Y2 Position of the last Y coordinate in points (1/72 inch). + @param Closed True = outline closed (last and first point connected). @return The created polygon object. */ diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 5ec821dbe8bb..267c9589bfae 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -64,15 +64,12 @@ interface XApplication [attribute] any CutCopyMode; [attribute] any StatusBar; [attribute] long Cursor; - [attribute] boolean EnableEvents; + [attribute] boolean EnableEvents; + [attribute] string DefaultFilePath; + [attribute, readonly] string LibraryPath; + [attribute, readonly] string TemplatesPath; + [attribute, readonly] string PathSeparator; - void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException); - - string getDefaultFilePath() raises(com::sun::star::script::BasicErrorException); - - string LibraryPath() raises(com::sun::star::script::BasicErrorException); - string TemplatesPath() raises(com::sun::star::script::BasicErrorException); - string PathSeparator() raises(com::sun::star::script::BasicErrorException); //any CommandBars( [in] any Index ); any Workbooks( [in] any Index ); any Worksheets( [in] any Index ); @@ -93,10 +90,10 @@ interface XApplication void Volatile([in] any Volatile); void DoEvents(); any Caller( [in] any Index ); + any GetOpenFilename( [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText, [in] any MultiSelect ); + any GetSaveAsFilename( [in] any InitialFileName, [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText ); }; }; }; }; #endif - - diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 4f6d378cfe3f..d1adc1c4252e 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -39,6 +39,7 @@ PACKAGE=ooo$/vba IDLFILES=\ XErrObject.idl \ XCollection.idl\ + XCollectionBase.idl\ XVBAToOOEventDescGen.idl\ XPropValue.idl\ XHelperInterface.idl\ @@ -58,6 +59,7 @@ IDLFILES=\ XGlobalsBase.idl\ XDocumentProperty.idl\ XDocumentProperties.idl\ + XExecutableDialog.idl\ XFontBase.idl\ XDialogsBase.idl\ XDialogBase.idl\ diff --git a/oovbaapi/ooo/vba/msforms/XButton.idl b/oovbaapi/ooo/vba/msforms/XCheckBox.idl old mode 100644 new mode 100755 similarity index 86% rename from oovbaapi/ooo/vba/msforms/XButton.idl rename to oovbaapi/ooo/vba/msforms/XCheckBox.idl index 24cf1ba26c60..7520a559b0d5 --- a/oovbaapi/ooo/vba/msforms/XButton.idl +++ b/oovbaapi/ooo/vba/msforms/XCheckBox.idl @@ -24,20 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __ooo_vba_msforms_XButton_idl__ -#define __ooo_vba_msforms_XButton_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#ifndef __ooo_vba_msforms_XCheckBox_idl__ +#define __ooo_vba_msforms_XCheckBox_idl__ + +#include + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XButton: com::sun::star::uno::XInterface + +interface XCheckBox { [attribute] string Caption; + [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl index 5f2b66431eb8..d4e57b2347a4 100644 --- a/oovbaapi/ooo/vba/msforms/XComboBox.idl +++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl @@ -24,26 +24,32 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XComboBox_idl__ #define __ooo_vba_msforms_XComboBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - +#include //============================================================================= module ooo { module vba { module msforms { - //============================================================================= -interface XComboBox: ::com::sun::star::uno::XInterface + +interface XComboBox { [attribute] any Value; [attribute] any ListIndex; - [attribute, readonly ] long ListCount; + [attribute, readonly] long ListCount; [attribute] string Text; + [attribute] long Style; + [attribute] long DropButtonStyle; + [attribute] long DragBehavior; + [attribute] long EnterFieldBehavior; + [attribute] long ListStyle; + [attribute] long TextAlign; + [attribute, readonly] XNewFont Font; + void AddItem( [in] any pvargItem, [in] any pvargIndex ); void removeItem( [in] any index ); void Clear(); diff --git a/oovbaapi/ooo/vba/msforms/XCommandButton.idl b/oovbaapi/ooo/vba/msforms/XCommandButton.idl new file mode 100644 index 000000000000..0e7697cbd162 --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XCommandButton.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XCommandButton_idl__ +#define __ooo_vba_msforms_XCommandButton_idl__ + +#include + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XCommandButton +{ + [attribute] string Caption; + [attribute] boolean AutoSize; + [attribute] boolean Cancel; + [attribute] boolean Default; + [attribute] long BackColor; + [attribute] long ForeColor; + [attribute, readonly] XNewFont Font; +}; + +//============================================================================= + +}; }; }; + +#endif + + diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl index 97ca9d152716..3cd1f2c3e75c 100644 --- a/oovbaapi/ooo/vba/msforms/XControl.idl +++ b/oovbaapi/ooo/vba/msforms/XControl.idl @@ -63,6 +63,7 @@ interface XControl [attribute] string Name; [attribute] string ControlTipText; [attribute] string Tag; + [attribute] long TabIndex; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XFrame.idl b/oovbaapi/ooo/vba/msforms/XFrame.idl new file mode 100755 index 000000000000..6038b61dd3bd --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XFrame.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XFrame_idl__ +#define __ooo_vba_msforms_XFrame_idl__ + +#include + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XFrame +{ + [attribute] string Caption; + [attribute] long SpecialEffect; + [attribute] long BorderStyle; + [attribute, readonly] XNewFont Font; + + any Controls( [in] any Index ); +}; + +//============================================================================= + +}; }; }; + +//============================================================================= + +#endif diff --git a/oovbaapi/ooo/vba/msforms/XGroupBox.idl b/oovbaapi/ooo/vba/msforms/XGroupBox.idl index 9ed6f9d45046..9718f23e1c66 100644 --- a/oovbaapi/ooo/vba/msforms/XGroupBox.idl +++ b/oovbaapi/ooo/vba/msforms/XGroupBox.idl @@ -24,19 +24,22 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XGroupBox_idl__ #define __ooo_vba_msforms_XGroupBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { + //============================================================================= + interface XGroupBox { [attribute] string Caption; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XLabel.idl b/oovbaapi/ooo/vba/msforms/XLabel.idl index d757af5074d8..399127a091c8 100644 --- a/oovbaapi/ooo/vba/msforms/XLabel.idl +++ b/oovbaapi/ooo/vba/msforms/XLabel.idl @@ -24,21 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XLabel_idl__ #define __ooo_vba_msforms_XLabel_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XLabel: com::sun::star::uno::XInterface + +interface XLabel { [attribute] string Caption; [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XListBox.idl b/oovbaapi/ooo/vba/msforms/XListBox.idl index bdc0c6bfc660..63f9cce0bdf8 100644 --- a/oovbaapi/ooo/vba/msforms/XListBox.idl +++ b/oovbaapi/ooo/vba/msforms/XListBox.idl @@ -24,25 +24,27 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XListBox_idl__ #define __ooo_vba_msforms_XListBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { - //============================================================================= -interface XListBox: com::sun::star::uno::XInterface + +interface XListBox { [attribute] any Value; [attribute] string Text; [attribute] boolean MultiSelect; [attribute] any ListIndex; - [attribute, readonly ] long ListCount; + [attribute, readonly] long ListCount; + [attribute, readonly] XNewFont Font; + void AddItem( [in] any pvargItem, [in] any pvargIndex ); void removeItem( [in] any index ); void Clear(); diff --git a/oovbaapi/ooo/vba/msforms/XNewFont.idl b/oovbaapi/ooo/vba/msforms/XNewFont.idl new file mode 100755 index 000000000000..755dd510b63a --- /dev/null +++ b/oovbaapi/ooo/vba/msforms/XNewFont.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_msforms_XNewFont_idl__ +#define __ooo_vba_msforms_XNewFont_idl__ + +#include + +//============================================================================= + +module ooo { module vba { module msforms { + +//============================================================================= + +interface XNewFont +{ + [attribute] string Name; + [attribute] double Size; + [attribute] short Charset; + [attribute] short Weight; + [attribute] boolean Bold; + [attribute] boolean Italic; + [attribute] boolean Underline; + [attribute] boolean Strikethrough; +}; + +//============================================================================= + +}; }; }; + +//============================================================================= + +#endif diff --git a/oovbaapi/ooo/vba/msforms/XRadioButton.idl b/oovbaapi/ooo/vba/msforms/XRadioButton.idl index b2289ce33331..2aced0e92e30 100644 --- a/oovbaapi/ooo/vba/msforms/XRadioButton.idl +++ b/oovbaapi/ooo/vba/msforms/XRadioButton.idl @@ -24,21 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XRadioButton_idl__ #define __ooo_vba_msforms_XRadioButton_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XRadioButton: com::sun::star::uno::XInterface + +interface XRadioButton { [attribute] string Caption; [attribute] any Value; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XTextBox.idl b/oovbaapi/ooo/vba/msforms/XTextBox.idl index 9c6b55e5ca6d..7ea6ca62898c 100644 --- a/oovbaapi/ooo/vba/msforms/XTextBox.idl +++ b/oovbaapi/ooo/vba/msforms/XTextBox.idl @@ -24,23 +24,27 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XTextBox_idl__ #define __ooo_vba_msforms_XTextBox_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { //============================================================================= -interface XTextBox: com::sun::star::uno::XInterface + +interface XTextBox { [attribute] string Text; [attribute] any Value; [attribute] long MaxLength; [attribute] boolean Multiline; + [attribute] long SpecialEffect; + [attribute] long BorderStyle; + [attribute, readonly] XNewFont Font; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XToggleButton.idl b/oovbaapi/ooo/vba/msforms/XToggleButton.idl index e66eea54babb..923f7e1e2203 100644 --- a/oovbaapi/ooo/vba/msforms/XToggleButton.idl +++ b/oovbaapi/ooo/vba/msforms/XToggleButton.idl @@ -24,22 +24,21 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_msforms_XToggleButton_idl__ #define __ooo_vba_msforms_XToggleButton_idl__ -#ifndef __ooo_vba_msforms_XButton_idl__ -#include -#endif -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module msforms { + //============================================================================= + interface XToggleButton { - interface XButton; + interface XCommandButton; [attribute] any Value; }; diff --git a/oovbaapi/ooo/vba/msforms/XUserForm.idl b/oovbaapi/ooo/vba/msforms/XUserForm.idl index c06aa2902b53..1e54dd1b8f41 100644 --- a/oovbaapi/ooo/vba/msforms/XUserForm.idl +++ b/oovbaapi/ooo/vba/msforms/XUserForm.idl @@ -39,6 +39,8 @@ interface XUserForm //interface ::ooo::vba::XHelperInterface; interface ::com::sun::star::script::XInvocation; [attribute] string Caption; + [attribute] double InnerWidth; + [attribute] double InnerHeight; void Show(); void Hide(); void RePaint(); diff --git a/oovbaapi/ooo/vba/msforms/makefile.mk b/oovbaapi/ooo/vba/msforms/makefile.mk index 56ac4caf87cb..1d7d9ee166e5 100644 --- a/oovbaapi/ooo/vba/msforms/makefile.mk +++ b/oovbaapi/ooo/vba/msforms/makefile.mk @@ -38,10 +38,13 @@ PACKAGE=ooo$/vba$/msforms IDLFILES=\ MSFormReturnTypes.idl \ + XCheckBox.idl \ XComboBox.idl \ - XButton.idl \ + XCommandButton.idl \ XControl.idl \ + XFrame.idl \ XLabel.idl \ + XNewFont.idl \ XTextBox.idl \ XRadioButton.idl \ XShape.idl \ diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 6c3694ea237d..ab2b52ae7d55 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -45,14 +45,13 @@ #include #include #include +#include #include #include #include #include #include -#include -#include using namespace ::com::sun::star; using namespace ::com::sun::star::awt; @@ -175,19 +174,17 @@ namespace dlgprov // handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" ) listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode ); listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel ); - // Note: in a future cws ( npower13_ObjectModule ) it will be possible - // to determine the vba mode from the basiclibrary container, the tunnel hack - // below can then be replaced - SfxObjectShell* pFoundShell = NULL; - if ( rxModel.is() ) + + // determine the VBA compatibility mode from the Basic library container + try + { + uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBACompat( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW ); + mbUseFakeVBAEvents = xVBACompat->getVBACompatibilityMode(); + } + catch( uno::Exception& ) { - uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY ); - if ( xObjShellTunnel.is() ) - { - pFoundShell = reinterpret_cast( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); - if ( pFoundShell ) - mbUseFakeVBAEvents = ooo::vba::isAlienExcelDoc( *pFoundShell ); - } } if ( mbUseFakeVBAEvents ) listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 3da1f374af1c..19169e90b984 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -29,6 +29,7 @@ #include "precompiled_sfx2.hxx" #include "arrdecl.hxx" +#include #include @@ -41,15 +42,9 @@ #include #include -#ifndef _SV_RESARY_HXX #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -64,15 +59,11 @@ #include #include -#ifndef _BASIC_SBUNO_HXX #include -#endif #include #include #include -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include -#endif #include #include @@ -132,8 +123,37 @@ DBG_NAME(SfxObjectShell) #define DocumentInfo #include "sfxslots.hxx" +namespace { + static WeakReference< XInterface > s_xCurrentComponent; +// remember all registered components for VBA compatibility, to be able to remove them on disposing the model +typedef ::std::map< XInterface*, ::rtl::OString > VBAConstantNameMap; +static VBAConstantNameMap s_aRegisteredVBAConstants; + +::rtl::OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent ) +{ + OSL_ENSURE( rxComponent.is(), "lclGetVBAGlobalConstName - missing component" ); + + VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( rxComponent.get() ); + if( aIt != s_aRegisteredVBAConstants.end() ) + return aIt->second; + + uno::Reference< beans::XPropertySet > xProps( rxComponent, uno::UNO_QUERY ); + if( xProps.is() ) try + { + ::rtl::OUString aConstName; + xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobalConstantName" ) ) ) >>= aConstName; + return ::rtl::OUStringToOString( aConstName, RTL_TEXTENCODING_ASCII_US ); + } + catch( uno::Exception& ) // not supported + { + } + return ::rtl::OString(); +} + +} // namespace + //========================================================================= @@ -164,14 +184,29 @@ void SAL_CALL SfxModelListener_Impl::notifyClosing( const com::sun::star::lang:: void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::EventObject& _rEvent ) throw ( com::sun::star::uno::RuntimeException ) { - // am I ThisComponent in AppBasic? ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + // am I ThisComponent in AppBasic? if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source ) { // remove ThisComponent reference from AppBasic SfxObjectShell::SetCurrentComponent( Reference< XInterface >() ); } + /* Remove VBA component from AppBasic. As every application registers its + own current component, the disposed component may not be the "current + component" of the SfxObjectShell. */ + if ( _rEvent.Source.is() ) + { + VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( _rEvent.Source.get() ); + if ( aIt != s_aRegisteredVBAConstants.end() ) + { + if ( BasicManager* pAppMgr = SFX_APP()->GetBasicManager() ) + pAppMgr->SetGlobalUNOConstant( aIt->second.getStr(), Any( Reference< XInterface >() ) ); + s_aRegisteredVBAConstants.erase( aIt ); + } + } + if ( !mpDoc->Get_Impl()->bClosing ) // GCC stuerzt ab, wenn schon im dtor, also vorher Flag abfragen mpDoc->DoClose(); @@ -908,8 +943,8 @@ sal_uInt16 SfxObjectShell::GetAutoStyleFilterIndex() void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComponent ) { - Reference< XInterface > xTest(s_xCurrentComponent); - if ( _rxComponent == xTest ) + Reference< XInterface > xOldCurrentComp(s_xCurrentComponent); + if ( _rxComponent == xOldCurrentComp ) // nothing to do return; // note that "_rxComponent.get() == s_xCurrentComponent.get().get()" is /sufficient/, but not @@ -920,7 +955,31 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); s_xCurrentComponent = _rxComponent; if ( pAppMgr ) - pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) ); + { + // set "ThisComponent" for Basic + pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) ); + + // set new current component for VBA compatibility + if ( _rxComponent.is() ) + { + ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent ); + if ( aVBAConstName.getLength() > 0 ) + { + pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( _rxComponent ) ); + s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName; + } + } + // no new component passed -> remove last registered VBA component + else if ( xOldCurrentComp.is() ) + { + ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp ); + if ( aVBAConstName.getLength() > 0 ) + { + pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( Reference< XInterface >() ) ); + s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() ); + } + } + } } Reference< XInterface > SfxObjectShell::GetCurrentComponent() diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk index 3e23c492f32b..58a90a7ccd42 100755 --- a/vbahelper/Library_msforms.mk +++ b/vbahelper/Library_msforms.mk @@ -50,17 +50,17 @@ $(eval $(call gb_Library_add_linked_libs,msforms,\ comphelper \ cppu \ cppuhelper \ + sal \ + sb \ + sfx \ svl \ svt \ - tl \ - sal \ - vbahelper \ - sfx \ svx \ - vcl \ - tk \ - sb \ stl \ + tk \ + tl \ + vbahelper \ + vcl \ $(gb_STDLIBS) \ )) @@ -79,6 +79,7 @@ $(eval $(call gb_Library_add_exception_objects,msforms,\ vbahelper/source/msforms/vbalistbox \ vbahelper/source/msforms/vbalistcontrolhelper \ vbahelper/source/msforms/vbamultipage \ + vbahelper/source/msforms/vbanewfont \ vbahelper/source/msforms/vbapages \ vbahelper/source/msforms/vbaprogressbar \ vbahelper/source/msforms/vbaradiobutton \ diff --git a/vbahelper/Library_vbahelper.mk b/vbahelper/Library_vbahelper.mk index 722b66d709a1..af6b4089ada8 100755 --- a/vbahelper/Library_vbahelper.mk +++ b/vbahelper/Library_vbahelper.mk @@ -50,25 +50,27 @@ $(eval $(call gb_Library_set_defs,vbahelper,\ # add libraries to be linked to vbahelper; again these names need to be given as # specified in Repository.mk $(eval $(call gb_Library_add_linked_libs,vbahelper,\ + comphelper \ cppu \ cppuhelper \ - comphelper \ - sb \ - tl \ + msfilter \ sal \ + sb \ sfx \ stl \ - svt \ - vcl \ svl \ - msfilter \ + svt \ tk \ + tl \ + utl \ + vcl \ $(gb_STDLIBS) \ )) # add all source files that shall be compiled with exceptions enabled # the name is relative to $(SRCROOT) and must not contain an extension $(eval $(call gb_Library_add_exception_objects,vbahelper,\ + vbahelper/source/vbahelper/collectionbase \ vbahelper/source/vbahelper/vbaapplicationbase \ vbahelper/source/vbahelper/vbacolorformat \ vbahelper/source/vbahelper/vbacommandbar \ diff --git a/vbahelper/Package_inc.mk b/vbahelper/Package_inc.mk index 6d8033aa5b02..385fbf15a625 100755 --- a/vbahelper/Package_inc.mk +++ b/vbahelper/Package_inc.mk @@ -26,6 +26,7 @@ #************************************************************************* $(eval $(call gb_Package_Package,vbahelper_inc,$(SRCDIR)/vbahelper/inc)) +$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/collectionbase.hxx,vbahelper/collectionbase.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/helperdecl.hxx,vbahelper/helperdecl.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaaccesshelper.hxx,vbahelper/vbaaccesshelper.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaapplicationbase.hxx,vbahelper/vbaapplicationbase.hxx)) @@ -47,5 +48,6 @@ $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashaperange.hxx, $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashapes.hxx,vbahelper/vbashapes.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbatextframe.hxx,vbahelper/vbatextframe.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbawindowbase.hxx,vbahelper/vbawindowbase.hxx)) +$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/weakreference.hxx,vbahelper/weakreference.hxx)) # vim: set noet sw=4 ts=4: diff --git a/vbahelper/inc/vbahelper/collectionbase.hxx b/vbahelper/inc/vbahelper/collectionbase.hxx new file mode 100755 index 000000000000..ebb5bf8f2b9a --- /dev/null +++ b/vbahelper/inc/vbahelper/collectionbase.hxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_COLLECTIONBASE_HXX +#define VBAHELPER_COLLECTIONBASE_HXX + +#include +#include +#include +#include +#include +#include +#include + +namespace vbahelper { + +// ============================================================================ + +typedef ::cppu::WeakImplHelper1< ov::XCollectionBase > CollectionBase_BASE; + +/** Base class of VBA objects implementing the VBA collection concept. + + This base class intentionally does not include the interface + XHelperInterface supported by all application VBA object. There may be + other VBA objects that do not support the special methods provided by + XHelperInterface. + */ +class VBAHELPER_DLLPUBLIC CollectionBase : public CollectionBase_BASE +{ +public: + /** Enumerates different container types a VBA collection can be based on. */ + enum ContainerType + { + /** Container elements are VBA items. + + The initial container contains the final VBA items provided by the + VBA collection. No conversion takes place on item access. + */ + CONTAINER_NATIVE_VBA, + + /** Container elements will be converted to VBA items on demand. + + The initial container contains intermediate objects (e.g. UNO + objects) which will be converted to VBA items everytime the item is + accessed (e.g. item access method, enumeration). Changes in the + initial container are reflected by the collection. + */ + CONTAINER_CONVERT_ON_DEMAND, + }; + + // ------------------------------------------------------------------------ + + CollectionBase( const css::uno::Type& rElementType ); + + // ------------------------------------------------------------------------ + + // attributes + virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); + // XDefaultMethod + virtual ::rtl::OUString SAL_CALL getDefaultMethodName() throw (css::uno::RuntimeException); + + // ------------------------------------------------------------------------ + + /** Associates this collection with the passed UNO container. + + @param rxElementAccess + The UNO container with the elements of this collection. Shall + support either XIndexAccess or XNameAccess, may support both. + + If the container does not support XIndexAccess, index access is + simulated based on the order returned by the function + XNameAccess::getElementNames(). + + If the container does not support XNameAccess, name access is + simulated by iterating the elements via index access and asking the + elements for their name via the interface XNamed. If the elements + do not support XNamed, the elements cannot be accessed by name. + + @param eContainerType + Specifies the type of the passed container. + */ + void initContainer( + const css::uno::Reference< css::container::XElementAccess >& rxElementAccess, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Initializes this collection with copies of all elements in the passed + temporary STL vector. + + @param rElements + The STL vector with the named elements of this collection. + @param eContainerType + Specifies the type of the passed vector. + */ + void initElements( + const ::std::vector< css::uno::Reference< css::container::XNamed > >& rElements, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Initializes this collection with copies of all elements in the passed + temporary STL vector. + + @param rElements + The STL vector with the named elements of this collection. + @param eContainerType + Specifies the type of the passed vector. + */ + void initElements( + const ::std::vector< css::beans::NamedValue >& rElements, + ContainerType eContainerType ) throw (css::uno::RuntimeException); + + /** Returns a VBA implementation object from the passed element. + + If the container type is CONTAINER_NATIVE_VBA, returns the passed + object unmodified. If the container type is CONTAINER_CONVERT_ON_DEMAND, + calls the virtual function implCreateCollectionItem() that implements + creation of the VBA implmentation object. + + @param rElement + The container element the VBA implementation object is based on. + + @param rIndex + The index or name that has been used to access the item. + */ + css::uno::Any createCollectionItem( + const css::uno::Any& rElement, + const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its one-based item index. + + @param nIndex + The one-based index of the collection item. + */ + css::uno::Any getItemByIndex( sal_Int32 nIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its name. + + @param rName + The name of the collection item. + */ + css::uno::Any getItemByName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException); + + /** Returns a collection item specified by its index or name. + + @param rIndex + The index or name of the collection item. May be empty, in that + case the entire collection is returned. + */ + css::uno::Any getAnyItemOrThis( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + + /** Returns a collection item of a specific type specified by its index or + name. + + @param rIndex + The index or name of the collection item. + */ + template< typename XType > + inline css::uno::Reference< XType > getAnyItem( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException) + { css::uno::Any aRet; if( rIndex.hasValue() ) aRet = getAnyItemOrThis( rIndex ); return css::uno::Reference< XType >( aRet, css::uno::UNO_QUERY_THROW ); } + +protected: + /** Derived classes implement creation of a VBA implementation object from + the passed intermediate container element. + + May be kept unimplemented if container type is CONTAINER_NATIVE_VBA. + + @param rElement + The container element the VBA implementation object is based on. + + @param rIndex + The index or name used to access the item. Can be used by + implementations as a hint how to find or convert the VBA object. + */ + virtual css::uno::Any implCreateCollectionItem( const css::uno::Any& rElement, const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); + +private: + css::uno::Reference< css::container::XIndexAccess > mxIndexAccess; + css::uno::Reference< css::container::XNameAccess > mxNameAccess; + css::uno::Type maElementType; + bool mbConvertOnDemand; +}; + +// ============================================================================ + +} // namespace vbahelper + +#endif diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index 6902bc7b5042..10cf0ba6ab70 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -60,7 +60,6 @@ public: virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException); virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); virtual void SAL_CALL OnTime( const css::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException); diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 601d996a5e64..da0fd29267ae 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -88,8 +88,8 @@ private: /** A wrapper that holds a com.sun.star.container.XEnumeration or a com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects. - The method nextElement() needs to be implemented by the derived class. This - class can be used to convert an enumeration or an index container + The method createCollectionObject() needs to be implemented by the derived + class. This class can be used to convert an enumeration or an index container containing UNO objects to an enumeration providing the related VBA objects. */ class VBAHELPER_DLLPUBLIC SimpleEnumerationBase : public EnumerationHelper_BASE diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 2588b7da1720..d1c7320fbfb1 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -37,6 +37,7 @@ class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE { protected: css::uno::Reference< css::frame::XModel > mxModel; + css::uno::Reference< css::uno::XInterface > mxVBProject; protected: virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; } VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext); diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx index 659837535ace..dc554d6a043f 100755 --- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -28,20 +28,26 @@ #ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX #define VBAHELPER_VBAEVENTSHELPERBASE_HXX -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include "vbahelper/vbahelper.hxx" namespace com { namespace sun { namespace star { + namespace script { namespace vba { class XVBAModuleInfo; } } namespace uno { class XComponentContext; } } } } // ============================================================================ -typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; +typedef ::cppu::WeakImplHelper3< + css::script::vba::XVBAEventProcessor, + css::document::XEventListener, + css::util::XChangesListener > VbaEventsHelperBase_BASE; class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE { @@ -51,15 +57,24 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaEventsHelperBase(); - // XVBAEventProcessor + // script::vba::XVBAEventProcessor virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::util::VetoException, css::uno::RuntimeException); - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException); + // document::XEventListener + virtual void SAL_CALL notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException); + + // util::XChangesListener + virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& rEvent ) throw (css::uno::RuntimeException); + + // lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& rEvent ) throw (css::uno::RuntimeException); // little helpers --------------------------------------------------------- + /** Helper to execute event handlers without throwing any exceptions. */ + void processVbaEventNoThrow( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ); + /** Throws, if the passed sequence does not contain a value at the specified index. */ static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) { if( (nIndex < 0) || (nIndex >= rArgs.getLength()) ) throw css::lang::IllegalArgumentException(); } @@ -72,12 +87,11 @@ public: protected: // ------------------------------------------------------------------------ - enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT }; struct EventHandlerInfo { sal_Int32 mnEventId; + sal_Int32 mnModuleType; ::rtl::OUString maMacroName; - EventHandlerType meType; sal_Int32 mnCancelIndex; css::uno::Any maUserData; }; @@ -85,14 +99,14 @@ protected: /** Registers a supported event handler. @param nEventId Event identifier from com.sun.star.script.vba.VBAEventId. + @param nModuleType Type of the module containing the event handler. @param pcMacroName Name of the associated VBA event handler macro. - @param eType Document event or global event. @param nCancelIndex 0-based index of Cancel parameter, or -1. @param rUserData User data for free usage in derived implementations. */ void registerEventHandler( sal_Int32 nEventId, + sal_Int32 nModuleType, const sal_Char* pcMacroName, - EventHandlerType eType = EVENTHANDLER_DOCUMENT, sal_Int32 nCancelIndex = -1, const css::uno::Any& rUserData = css::uno::Any() ); @@ -124,7 +138,6 @@ protected: virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, - bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException) = 0; /** Derived classes have to return the name of the Basic document module. */ @@ -133,25 +146,42 @@ protected: const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; private: + typedef ::std::map< sal_Int32, ::rtl::OUString > ModulePathMap; + + /** Starts listening at the document model. */ + void startListening(); + /** Stops listening at the document model. */ + void stopListening(); + /** Returns the event handler info struct for the specified event, or throws. */ const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException); /** Searches the event handler in the document and returns its full script path. */ ::rtl::OUString getEventHandlerPath( const EventHandlerInfo& rInfo, - const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - /** Removes this instance from all broadcasters. */ - void stopListening(); + /** On first call, accesses the Basic library containing the VBA source code. */ + void ensureVBALibrary() throw (css::uno::RuntimeException); + + /** Returns the type of the Basic module with the specified name. */ + sal_Int32 getModuleType( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException); + + /** Updates the map containing paths to event handlers for a Basic module. */ + ModulePathMap& updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException); protected: css::uno::Reference< css::frame::XModel > mxModel; SfxObjectShell* mpShell; private: - typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap; + typedef ::std::hash_map< ::rtl::OUString, ModulePathMap, ::rtl::OUStringHash > EventHandlerPathMap; - EventHandlerMap maEvents; + EventHandlerInfoMap maEventInfos; + EventHandlerPathMap maEventPaths; + css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos; + ::rtl::OUString maLibraryName; bool mbDisposed; }; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 22dc9a8f6cc8..bf20541eff1e 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -63,7 +63,12 @@ namespace ooo throw css::lang::IllegalArgumentException(); return aSomething; } - VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); + + class XHelperInterface; + + /** Returns the VBA document implementation object representing the passed UNO document model. */ + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getVBADocument( const css::uno::Reference< css::frame::XModel >& xModel ); + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException); @@ -90,18 +95,32 @@ namespace ooo VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection ); VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges, SfxViewShell* ); - /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value. - Returns false, if the Any is empty or contains an incompatible type. */ - VBAHELPER_DLLPUBLIC bool extractBoolFromAny( bool& rbValue, const css::uno::Any& rAny ); - /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value. + /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException); + /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value. + Returns nDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny, sal_Int32 nDefault ) throw (css::uno::RuntimeException); + + /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value. Throws, if the Any is empty or contains an incompatible type. */ VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException); + /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value. + Returns bDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny, bool bDefault ) throw (css::uno::RuntimeException); + + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Returns rDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC rtl::OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException ); VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic ) - VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints ); VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm ); VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& ); @@ -135,14 +154,21 @@ class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace { public: virtual ~AbstractGeometryAttributes() {} - virtual double getLeft() = 0; + virtual double getLeft() const = 0; virtual void setLeft( double ) = 0; - virtual double getTop() = 0; + virtual double getTop() const = 0; virtual void setTop( double ) = 0; - virtual double getHeight() = 0; + virtual double getHeight() const = 0; virtual void setHeight( double ) = 0; - virtual double getWidth() = 0; + virtual double getWidth() const = 0; virtual void setWidth( double ) = 0; + + virtual double getInnerHeight() const { return 0.0; } + virtual void setInnerHeight( double ) {} + virtual double getInnerWidth() const { return 0.0; } + virtual void setInnerWidth( double ) {} + virtual double getOffsetX() const { return 0.0; } + virtual double getOffsetY() const { return 0.0; } }; namespace msforms { @@ -156,20 +182,13 @@ protected: public: ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ); - double getHeight(); - - void setHeight(double _fheight) throw ( css::script::BasicErrorException ); - - double getWidth(); - + double getHeight() const; + void setHeight(double _fheight) throw ( css::script::BasicErrorException ); + double getWidth() const; void setWidth(double _fWidth) throw ( css::script::BasicErrorException ); - - double getLeft(); - + double getLeft() const; void setLeft(double _fLeft); - - double getTop(); - + double getTop() const; void setTop(double _fTop); }; @@ -178,13 +197,13 @@ class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeom std::auto_ptr< ShapeHelper > m_pShapeHelper; public: ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape ); - virtual double getLeft(); + virtual double getLeft() const; virtual void setLeft( double nLeft ); - virtual double getTop(); + virtual double getTop() const; virtual void setTop( double nTop ); - virtual double getHeight(); + virtual double getHeight() const; virtual void setHeight( double nHeight ); - virtual double getWidth(); + virtual double getWidth() const; virtual void setWidth( double nWidth); virtual ~ConcreteXShapeGeometryAttributes(); }; @@ -195,19 +214,39 @@ public: #define VBA_WIDTH "Width" class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes { - css::uno::Reference< css::awt::XWindow > mxWindow; - sal_Bool mbDialog; - public: - UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl ); - virtual double getLeft(); - virtual void setLeft( double nLeft ); - virtual double getTop(); - virtual void setTop( double nTop ); - virtual double getHeight(); - virtual void setHeight( double nHeight ); - virtual double getWidth(); - virtual void setWidth( double nWidth); + UserFormGeometryHelper( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xControl, + double fOffsetX, double fOffsetY ); + virtual double getLeft() const; + virtual void setLeft( double fLeft ); + virtual double getTop() const; + virtual void setTop( double fTop ); + virtual double getWidth() const; + virtual void setWidth( double fWidth ); + virtual double getHeight() const; + virtual void setHeight( double fHeight ); + virtual double getInnerWidth() const; + virtual void setInnerWidth( double fWidth ); + virtual double getInnerHeight() const; + virtual void setInnerHeight( double fHeight ); + virtual double getOffsetX() const; + virtual double getOffsetY() const; + +private: + double implGetPos( bool bPosY ) const; + void implSetPos( double fPos, bool bPosY ); + double implGetSize( bool bHeight, bool bOuter ) const; + void implSetSize( double fSize, bool bHeight, bool bOuter ); + +private: + css::uno::Reference< css::awt::XWindow > mxWindow; + css::uno::Reference< css::beans::XPropertySet > mxModelProps; + css::uno::Reference< css::awt::XUnitConversion > mxUnitConv; + double mfOffsetX; + double mfOffsetY; + sal_Bool mbDialog; }; class VBAHELPER_DLLPUBLIC ContainerUtilities @@ -230,8 +269,8 @@ public: static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException ); }; - } // openoffice -} // org + } // vba +} // ooo namespace ov = ooo::vba; diff --git a/vbahelper/inc/vbahelper/vbawindowbase.hxx b/vbahelper/inc/vbahelper/vbawindowbase.hxx index f42c2a19854e..e9f1d40e4bd4 100644 --- a/vbahelper/inc/vbahelper/vbawindowbase.hxx +++ b/vbahelper/inc/vbahelper/vbawindowbase.hxx @@ -24,24 +24,30 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef VBA_WINDOWBASE_HXX #define VBA_WINDOWBASE_HXX -#include -#include -#include -#include +#include +#include +#include #include -typedef InheritedHelperInterfaceImpl1 WindowBaseImpl_BASE; +typedef InheritedHelperInterfaceImpl1< ov::XWindowBase > WindowBaseImpl_BASE; class VBAHELPER_DLLPUBLIC VbaWindowBase : public WindowBaseImpl_BASE { -protected: - css::uno::Reference< css::frame::XModel > m_xModel; public: - VbaWindowBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel ); - VbaWindowBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext ); + VbaWindowBase( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XModel >& xModel, + const css::uno::Reference< css::frame::XController >& xController ) + throw (css::uno::RuntimeException); + VbaWindowBase( + css::uno::Sequence< css::uno::Any > const& aArgs, + css::uno::Reference< css::uno::XComponentContext > const& xContext ) + throw (css::uno::RuntimeException); // XWindowBase virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ; @@ -58,6 +64,19 @@ public: // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); + +protected: + css::uno::Reference< css::frame::XController > getController() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow > getWindow() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow2 > getWindow2() throw (css::uno::RuntimeException); + + css::uno::Reference< css::frame::XModel > m_xModel; + +private: + void construct( const css::uno::Reference< css::frame::XController >& xController ) throw (css::uno::RuntimeException); + + css::uno::WeakReference< css::frame::XController > m_xController; + css::uno::WeakReference< css::awt::XWindow > m_xWindow; }; #endif //VBA_WINDOWBASE_HXX diff --git a/vbahelper/inc/vbahelper/weakreference.hxx b/vbahelper/inc/vbahelper/weakreference.hxx new file mode 100755 index 000000000000..661f3bc5d73e --- /dev/null +++ b/vbahelper/inc/vbahelper/weakreference.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_WEAKREFERENCE_HXX +#define VBAHELPER_WEAKREFERENCE_HXX + +#include +#include + +namespace vbahelper { + +// ============================================================================ + +/** A weak reference holding any UNO implementation object. + + The held object must implement the ::com::sun::star::uno::XWeak interface. + + In difference to the ::com::sun::star::uno::WeakReference<> implementation + from cppuhelper/weakref.hxx, the class type of this weak reference is not + restricted to UNO interface types, but can be used for any C++ class type + implementing the XWeak interface somehow (e.g. ::cppu::WeakImplHelperN<>, + ::cppu::ImplInheritanceHelperN<>, etc.). + */ +template< typename ObjectType > +class WeakReference +{ +public: + /** Default constructor. Creates an empty weak reference. + */ + inline explicit WeakReference() SAL_THROW( () ) : mpObject( 0 ) {} + + /** Initializes this weak reference with the passed reference to an object. + */ + inline explicit WeakReference( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) : + mxWeakRef( rxObject.get() ), mpObject( rxObject.get() ) {} + + /** Releases this weak reference and takes over the passed reference. + */ + inline WeakReference& SAL_CALL operator=( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) + { + mxWeakRef = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak >( rxObject.get() ); + mpObject = rxObject.get(); + return *this; + } + + /** Gets an RTL reference to the referenced object. + + @return Reference or null, if the weakly referenced object is gone. + */ + inline SAL_CALL operator ::rtl::Reference< ObjectType >() SAL_THROW( () ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak > xRef = mxWeakRef; + ::rtl::Reference< ObjectType > xObject; + if( xRef.is() ) + xObject = mpObject; + else + mpObject = 0; + return xObject; + } + +private: + ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XWeak > mxWeakRef; + ObjectType* mpObject; +}; + +// ============================================================================ + +} // namespace vbahelper + +#endif diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst index 312c9b062233..be2e516de360 100644 --- a/vbahelper/prj/build.lst +++ b/vbahelper/prj/build.lst @@ -1,3 +1,3 @@ -vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal LIBXSLT:libxslt NULL +vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal unotools LIBXSLT:libxslt NULL vba vbahelper usr1 - all vba_mkout NULL vba vbahelper\prj nmake - all vba_prj NULL diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx index 21693128c899..775a05cbb5b5 100644 --- a/vbahelper/source/msforms/vbabutton.cxx +++ b/vbahelper/source/msforms/vbabutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbabutton.hxx" -#include +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -51,6 +52,56 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } +sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaButton::getDefault() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx index 1c65c293f76c..93a55e1bf73a 100644 --- a/vbahelper/source/msforms/vbabutton.hxx +++ b/vbahelper/source/msforms/vbabutton.hxx @@ -27,12 +27,12 @@ #ifndef SC_VBA_BUTTON_HXX #define SC_VBA_BUTTON_HXX #include -#include +#include #include "vbacontrol.hxx" #include -typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE; +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XCommandButton > ButtonImpl_BASE; class ScVbaButton : public ButtonImpl_BASE { @@ -41,6 +41,17 @@ public: // Attributes virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx index e9ea64f772b6..329586cf6b27 100644 --- a/vbahelper/source/msforms/vbacheckbox.cxx +++ b/vbahelper/source/msforms/vbacheckbox.cxx @@ -24,9 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbacheckbox.hxx" +#include "vbanewfont.hxx" #include -#include using namespace com::sun::star; using namespace ooo::vba; @@ -83,6 +84,12 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept } m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); } + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaCheckbox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx index 34d0828e0c66..59e4d7e75e49 100644 --- a/vbahelper/source/msforms/vbacheckbox.hxx +++ b/vbahelper/source/msforms/vbacheckbox.hxx @@ -27,12 +27,12 @@ #ifndef SC_VBA_CHECKBOX_HXX #define SC_VBA_CHECKBOX_HXX #include -#include +#include #include "vbacontrol.hxx" #include -typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE; +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XCheckBox, css::script::XDefaultProperty > CheckBoxImpl_BASE; class ScVbaCheckbox : public CheckBoxImpl_BASE { @@ -43,6 +43,7 @@ public: virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // XDefaultProperty rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } //XHelperInterface diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx index 0b5f1af30bb7..b0d1680e6101 100644 --- a/vbahelper/source/msforms/vbacombobox.cxx +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -24,8 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbacombobox.hxx" -#include +#include "vbanewfont.hxx" +#include +#include +#include +#include +#include +#include using namespace com::sun::star; using namespace ooo::vba; @@ -41,9 +48,17 @@ const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataF ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialogType ) : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialogType( bDialogType ) { - mpListHelper.reset( new ListControlHelper( m_xProps ) ); - // grab the default value property name - m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName; + mpListHelper.reset( new ListControlHelper( m_xProps ) ); + try + { + // grab the default value property name + m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName; + } + catch( uno::Exception& ) + { + } + if( sSourceName.getLength() == 0 ) + sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); } // Attributes @@ -103,7 +118,8 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException) void SAL_CALL ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { - m_xProps->setPropertyValue( sSourceName, _value ); + // booleans are converted to uppercase strings + m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) ); } // see Value @@ -131,22 +147,22 @@ ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) void SAL_CALL ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException) - { +{ mpListHelper->removeItem( index ); } void SAL_CALL ScVbaComboBox::Clear( ) throw (uno::RuntimeException) - { +{ mpListHelper->Clear(); - } +} void SAL_CALL ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException) { ScVbaControl::setRowSource( _rowsource ); mpListHelper->setRowSource( _rowsource ); - } +} sal_Int32 SAL_CALL ScVbaComboBox::getListCount() throw (uno::RuntimeException) @@ -158,7 +174,66 @@ uno::Any SAL_CALL ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) { return mpListHelper->List( pvargIndex, pvarColumn ); - } +} + +sal_Int32 SAL_CALL ScVbaComboBox::getStyle() throw (uno::RuntimeException) +{ + return msforms::fmStyle::fmStyleDropDownCombo; +} + +void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle() throw (uno::RuntimeException) +{ + return msforms::fmDropButtonStyle::fmDropButtonStyleArrow; +} + +void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior() throw (uno::RuntimeException) +{ + return msforms::fmDragBehavior::fmDragBehaviorDisabled; +} + +void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior() throw (uno::RuntimeException) +{ + return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll; +} + +void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getListStyle() throw (uno::RuntimeException) +{ + return msforms::fmListStyle::fmListStylePlain; +} + +void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign() throw (uno::RuntimeException) +{ + return msforms::fmTextAlign::fmTextAlignLeft; +} + +void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} rtl::OUString& ScVbaComboBox::getServiceImplName() diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx index 28215d16dcd7..922f6f63ca62 100644 --- a/vbahelper/source/msforms/vbacombobox.hxx +++ b/vbahelper/source/msforms/vbacombobox.hxx @@ -58,6 +58,19 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setStyle( sal_Int32 nStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDropButtonStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDragBehavior() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getEnterFieldBehavior() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getListStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index ed9f83a7c647..780191885049 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -43,8 +43,8 @@ #ifdef VBA_OOBUILD_HACK #include #endif -#include"vbacontrol.hxx" -#include"vbacombobox.hxx" +#include "vbacontrol.hxx" +#include "vbacombobox.hxx" #include "vbabutton.hxx" #include "vbalabel.hxx" #include "vbatextbox.hxx" @@ -397,99 +397,104 @@ void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag ) m_aControlTag = aTag; } +sal_Int32 SAL_CALL ScVbaControl::getTabIndex() throw (uno::RuntimeException) +{ + return 1; +} + +void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::RuntimeException) +{ +} //ScVbaControlFactory -ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel ) -{ -} - -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) -{ - uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); - if ( xControlShape.is() ) // form controls - return createControl( xControlShape, xParent ); - uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ); - if ( !xControl.is() ) - throw uno::RuntimeException(); // really we should be more informative - return createControl( xControl, xParent ); -} - -ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException) +/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createShapeControl( + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< drawing::XControlShape >& xControlShape, + const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW ); sal_Int32 nClassId = -1; const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") ); xProps->getPropertyValue( sClassId ) >>= nClassId; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW ); + ::std::auto_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xContext, xShape ) ); + switch( nClassId ) { case form::FormComponentType::COMBOBOX: - return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::COMMANDBUTTON: - return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::FIXEDTEXT: - return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::TEXTFIELD: - return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::RADIOBUTTON: - return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::LISTBOX: - return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::SPINBUTTON: - return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); case form::FormComponentType::IMAGECONTROL: - return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Donot support this Control Type." ), uno::Reference< uno::XInterface >() ); + return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() ); } + throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() ); } -ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) +/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createUserformControl( + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< awt::XControl >& xControl, + const uno::Reference< awt::XControl >& xDialog, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW ); - ScVbaControl* pControl = NULL; + uno::Reference< msforms::XControl > xVBAControl; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + ::std::auto_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xContext, xControl, fOffsetX, fOffsetY ) ); + if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) - pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) - pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) - pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); + xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) { sal_Bool bToggle = sal_False; xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle; if ( bToggle ) - pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else - pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); } else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) - pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); + xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) - pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) ) - pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); - else - throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); - return pControl; + xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) ); + + if( xVBAControl.is() ) + return xVBAControl; + throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() ); } rtl::OUString& @@ -520,7 +525,6 @@ class ControlProviderImpl : public ControlProvider_BASE public: ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {} virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); - virtual uno::Reference< msforms::XControl > SAL_CALL createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); }; uno::Reference< msforms::XControl > SAL_CALL @@ -528,27 +532,10 @@ ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape { uno::Reference< msforms::XControl > xControlToReturn; if ( xControlShape.is() ) - { - ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner ); - xControlToReturn.set( controlFactory.createControl( xDocOwner ) ); - } + xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner ); return xControlToReturn; } -uno::Reference< msforms::XControl > SAL_CALL -ControlProviderImpl::createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException) -{ - uno::Reference< msforms::XControl > xControlToReturn; - if ( xControl.is() && xDialog.is() ) - { - - ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner ); - xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) ); - ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() ); - pControl->setGeometryHelper( new UserFormGeometryHelper( m_xCtx, xControl ) ); - } - return xControlToReturn; -} namespace controlprovider { diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index 247eabfe95e8..e421f919b6a4 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -93,6 +93,8 @@ public: virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException); virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException); //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape virtual void removeResouce() throw( css::uno::RuntimeException ); //XHelperInterface @@ -104,15 +106,21 @@ public: class ScVbaControlFactory { public: - ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext, - const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel ); - ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException ); + static css::uno::Reference< ov::msforms::XControl > createShapeControl( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::drawing::XControlShape >& xControlShape, + const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); + + static css::uno::Reference< ov::msforms::XControl > createUserformControl( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xControl, + const css::uno::Reference< css::awt::XControl >& xDialog, + const css::uno::Reference< css::frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException); + private: - ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); - ScVbaControl* createControl( const css::uno::Reference< css::drawing::XControlShape >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::uno::XInterface > m_xControl; - css::uno::Reference< css::frame::XModel > m_xModel; + ScVbaControlFactory(); + ~ScVbaControlFactory(); }; #endif//SC_VBA_CONTROL_HXX diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 8d01687ef905..7411f7ad9463 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -27,13 +27,18 @@ #include #include +#include +#include +#include +#include #include #include #include #include "vbacontrols.hxx" +#include "vbacontrol.hxx" #include -#include +#include #include using namespace com::sun::star; @@ -153,11 +158,28 @@ class ControlsEnumWrapper : public EnumerationHelper_BASE uno::Reference m_xContext; uno::Reference m_xIndexAccess; uno::Reference m_xDlg; + uno::Reference< frame::XModel > m_xModel; + double mfOffsetX; + double mfOffsetY; sal_Int32 nIndex; public: - ControlsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< awt::XControl >& xDlg ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), m_xDlg( xDlg ), nIndex( 0 ) {} + ControlsEnumWrapper( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< container::XIndexAccess >& xIndexAccess, + const uno::Reference< awt::XControl >& xDlg, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) : + m_xParent( xParent ), + m_xContext( xContext), + m_xIndexAccess( xIndexAccess ), + m_xDlg( xDlg ), + m_xModel( xModel ), + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ), + nIndex( 0 ) {} virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) { @@ -168,14 +190,12 @@ public: { if ( nIndex < m_xIndexAccess->getCount() ) { - uno::Reference< frame::XModel > xModel; uno::Reference< awt::XControl > xControl; m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl; - uno::Reference xServiceManager( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), m_xContext ), uno::UNO_QUERY_THROW ); - - uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, m_xDlg, xModel ) ); + uno::Reference< msforms::XControl > xVBAControl; + if ( xControl.is() && m_xDlg.is() ) + xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY ); return uno::makeAny( xVBAControl ); } throw container::NoSuchElementException(); @@ -190,17 +210,24 @@ lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg ) return new ControlArrayWrapper( xDlg ); } -ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, - const css::uno::Reference< awt::XControl >& xDialog ) - : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) +ScVbaControls::ScVbaControls( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const css::uno::Reference< awt::XControl >& xDialog, + const uno::Reference< frame::XModel >& xModel, + double fOffsetX, double fOffsetY ) : + ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ), + mxDialog( xDialog ), + mxModel( xModel ), + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ) { - mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > ScVbaControls::createEnumeration() throw (uno::RuntimeException) { - uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) ); + uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) ); if ( !xEnum.is() ) throw uno::RuntimeException(); return xEnum; @@ -210,15 +237,9 @@ uno::Any ScVbaControls::createCollectionObject( const css::uno::Any& aSource ) { // Create control from awt::XControl - uno::Reference< awt::XControl > xControl; - aSource >>= xControl; - uno::Reference< frame::XModel > xModel; - uno::Reference xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); - - uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, mxDialog, xModel ) ); - - return uno::makeAny( xVBAControl ); + uno::Reference< awt::XControl > xControl( aSource, uno::UNO_QUERY_THROW ); + uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY ); + return uno::Any( xVBAControl ); } void SAL_CALL @@ -261,23 +282,117 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) ); sal_Int32 nInd = 0; - while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 ) + while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) ) { aNewName = aComServiceName; - aNewName += ::rtl::OUString::valueOf( nInd ); + aNewName += ::rtl::OUString::valueOf( nInd++ ); } } + double fDefWidth = 72.0, fDefHeight = 18.0; if ( aComServiceName.getLength() ) { - uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + // create a UNO control model based on the passed control type + uno::Reference< awt::XControlModel > xNewModel; + bool bFontSupport = false; + bool bNativeAX = false; + if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 24.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 72.0; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 108.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 108.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) ); + fDefWidth = 72.0; fDefHeight = 18.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 216.0; fDefHeight = 144.0; + bFontSupport = true; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 12.75; fDefHeight = 25.5; + } + else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) ) + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 12.75; fDefHeight = 63.8; + } + else + { + xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + fDefWidth = 72.0; fDefHeight = 18.0; + bNativeAX = true; + } + // need to set a few font properties to get rid of the default DONT_KNOW values + if( bFontSupport ) + { + uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) ); + xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) ); + } xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) ); uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); xNewControl = xControlContainer->getControl( aNewName ); - try + if( bNativeAX ) try { uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW ); @@ -299,6 +414,11 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); aResult <<= xNewControl; aResult = createCollectionObject( aResult ); + uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW ); + if( fDefWidth > 0.0 ) + xVBAControl->setWidth( fDefWidth ); + if( fDefHeight > 0.0 ) + xVBAControl->setHeight( fDefHeight ); } else throw uno::RuntimeException(); @@ -376,21 +496,5 @@ ScVbaControls::getElementType() throw (uno::RuntimeException) { return ooo::vba::msforms::XControl::static_type(0); } -rtl::OUString& -ScVbaControls::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") ); - return sImplName; -} -uno::Sequence< rtl::OUString > -ScVbaControls::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) ); - } - return aServiceNames; -} +VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" ) diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx index a72506609531..4b4838a45a8e 100644 --- a/vbahelper/source/msforms/vbacontrols.hxx +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -38,19 +38,17 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE; class ScVbaControls : public ControlsImpl_BASE { - css::uno::Reference< css::awt::XControl > mxDialog; - -protected: - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence getServiceNames(); - public: - ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, - const css::uno::Reference< css::awt::XControl >& xDialog ); + ScVbaControls( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xDialog, + const css::uno::Reference< css::frame::XModel >& xModel, + double fOffsetX, double fOffsetY ); // XControls virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Object, const css::uno::Any& StringKey, const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) throw (css::uno::RuntimeException); // XEnumerationAccess virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); @@ -59,6 +57,15 @@ public: // ScVbaCollectionBaseImpl virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); + // XHelperInterface + VBAHELPER_DECL_XHELPERINTERFACE + +private: + css::uno::Reference< css::awt::XControl > mxDialog; + css::uno::Reference< css::frame::XModel > mxModel; + double mfOffsetX; + double mfOffsetY; }; + #endif //SC_VBA_OLEOBJECTS_HXX diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx index c470ee0097e4..4a1fe6a58b49 100644 --- a/vbahelper/source/msforms/vbaframe.cxx +++ b/vbahelper/source/msforms/vbaframe.cxx @@ -24,62 +24,83 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbaframe.hxx" -#include +#include "vbanewfont.hxx" +#include "vbacontrols.hxx" +#include +#include using namespace com::sun::star; using namespace ooo::vba; const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); -ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) + +ScVbaFrame::ScVbaFrame( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< uno::XInterface >& xControl, + const uno::Reference< frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ) : + FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), + mxDialog( xDialog ) { } -// Attributes -rtl::OUString SAL_CALL -ScVbaFrame::getCaption() throw (css::uno::RuntimeException) +// XFrame attributes + +rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException) { rtl::OUString Label; m_xProps->getPropertyValue( LABEL ) >>= Label; return Label; } -void SAL_CALL -ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) { m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } -uno::Any SAL_CALL -ScVbaFrame::getValue() throw (css::uno::RuntimeException) +sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException) { - return uno::makeAny( getCaption() ); + return msforms::fmSpecialEffect::fmSpecialEffectEtched; } -void SAL_CALL -ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException) { - rtl::OUString sCaption; - _value >>= sCaption; - setCaption( sCaption ); } -rtl::OUString& -ScVbaFrame::getServiceImplName() +sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException) { - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") ); - return sImplName; + return msforms::fmBorderStyle::fmBorderStyleNone; } -uno::Sequence< rtl::OUString > -ScVbaFrame::getServiceNames() +void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException) { - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) ); - } - return aServiceNames; } + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + +// XFrame methods + +uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException) +{ + // horizontal anchor of frame children is inside border line (add one unit to compensate border line width) + double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0; + // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width) + double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0; + + uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) ); + if( rIndex.hasValue() ) + return uno::Any( xControls->Item( rIndex, uno::Any() ) ); + return uno::Any( xControls ); +} + +// XHelperInterface + +VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" ) diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx index 567e58b57272..d76f31230bba 100644 --- a/vbahelper/source/msforms/vbaframe.hxx +++ b/vbahelper/source/msforms/vbaframe.hxx @@ -27,24 +27,39 @@ #ifndef SC_VBA_FRAME_HXX #define SC_VBA_FRAME_HXX #include -#include +#include #include "vbacontrol.hxx" #include -typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE; +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XFrame > FrameImpl_BASE; class ScVbaFrame : public FrameImpl_BASE { public: - ScVbaFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ); - // Attributes - virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); - virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + ScVbaFrame( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::uno::XInterface >& xControl, + const css::uno::Reference< css::frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ); + + // XFrame attributes virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); + // XFrame methods + css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); + +private: + css::uno::Reference< css::awt::XControl > mxDialog; }; #endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx index 9bf7a7e001bf..d5aa1176e3d3 100644 --- a/vbahelper/source/msforms/vbalabel.cxx +++ b/vbahelper/source/msforms/vbalabel.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbalabel.hxx" -#include +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -64,6 +65,10 @@ ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run setCaption( sCaption ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} rtl::OUString& ScVbaLabel::getServiceImplName() diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx index af3bc074c54d..2dcee186d58b 100644 --- a/vbahelper/source/msforms/vbalabel.hxx +++ b/vbahelper/source/msforms/vbalabel.hxx @@ -44,6 +44,7 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx index 17f8c8341588..8829c8ae7256 100644 --- a/vbahelper/source/msforms/vbalistbox.cxx +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -24,12 +24,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include #include "vbalistbox.hxx" -#include +#include "vbanewfont.hxx" #include #include +#include using namespace com::sun::star; using namespace ooo::vba; @@ -267,6 +267,11 @@ ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) t return mpListHelper->List( pvargIndex, pvarColumn ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaListBox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx index 3d0797e2b7b2..7dbda1837cb0 100644 --- a/vbahelper/source/msforms/vbalistbox.hxx +++ b/vbahelper/source/msforms/vbalistbox.hxx @@ -60,9 +60,10 @@ public: virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException); virtual void SAL_CALL setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods + virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException); virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx index b6587c9b2367..78590f0fd85b 100644 --- a/vbahelper/source/msforms/vbamultipage.cxx +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -68,9 +68,16 @@ ScVbaMultiPage::getPages( sal_Int32 nPages ) return new PagesImpl( nPages ); } -ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +ScVbaMultiPage::ScVbaMultiPage( + const uno::Reference< ov::XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< uno::XInterface >& xControl, + const uno::Reference< frame::XModel >& xModel, + AbstractGeometryAttributes* pGeomHelper, + const uno::Reference< awt::XControl >& xDialog ) : + MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) { - mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialogProps.set( xDialog->getModel(), uno::UNO_QUERY_THROW ); // set dialog step to value of multipage pseudo model setValue(getValue()); } diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx index 4a54525cf95f..328a71b61592 100644 --- a/vbahelper/source/msforms/vbamultipage.hxx +++ b/vbahelper/source/msforms/vbamultipage.hxx @@ -42,7 +42,14 @@ class ScVbaMultiPage : public MultiPageImpl_BASE css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages ); css::uno::Reference< css::beans::XPropertySet > mxDialogProps; public: - ScVbaMultiPage( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper, const css::uno::Reference< css::uno::XInterface >& xDialog ); + ScVbaMultiPage( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::uno::XInterface >& xControl, + const css::uno::Reference< css::frame::XModel >& xModel, + ov::AbstractGeometryAttributes* pGeomHelper, + const css::uno::Reference< css::awt::XControl >& xDialog ); + // Attributes virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx new file mode 100755 index 000000000000..f487b4e6919c --- /dev/null +++ b/vbahelper/source/msforms/vbanewfont.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +VbaNewFont::VbaNewFont( + const uno::Reference< XHelperInterface >& rxParent, + const uno::Reference< uno::XComponentContext >& rxContext, + const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) : + VbaNewFont_BASE( rxParent, rxContext ), + mxProps( rxModelProps, uno::UNO_SET_THROW ) +{ +} + +// XNewFont attributes + +::rtl::OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ) ); + return aAny.get< ::rtl::OUString >(); +} + +void SAL_CALL VbaNewFont::setName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), + uno::Any( rName ) ); +} + +double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ) ); + return aAny.get< float >(); +} + +void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), + uno::Any( static_cast< float >( fSize ) ) ); +} + +sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ) ); + return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) ); +} + +void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException) +{ + rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW; + if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) ) + eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) ); + if( eFontEnc == RTL_TEXTENCODING_DONTKNOW ) + throw uno::RuntimeException(); + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ), + uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) ); +} + +sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException) +{ + return getBold() ? 700 : 400; +} + +void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException) +{ + setBold( nWeight >= 700 ); +} + +sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ) ); + return aAny.get< float >() > awt::FontWeight::NORMAL; +} + +void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), + uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ) ); + return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE; +} + +void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), + uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ) ); + return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE; +} + +void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), + uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) ); +} + +sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException) +{ + uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ) ); + return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE; +} + +void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException) +{ + mxProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), + uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) ); +} + +// XHelperInterface + +VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" ) + +// ============================================================================ diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx new file mode 100755 index 000000000000..d59d5caa139c --- /dev/null +++ b/vbahelper/source/msforms/vbanewfont.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_MSFORMS_VBANEWFONT_HXX +#define VBAHELPER_MSFORMS_VBANEWFONT_HXX + +#include +#include + +// ============================================================================ + +typedef InheritedHelperInterfaceImpl1< ov::msforms::XNewFont > VbaNewFont_BASE; + +class VbaNewFont : public VbaNewFont_BASE +{ +public: + VbaNewFont( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::beans::XPropertySet >& rxModelProps ) throw (css::uno::RuntimeException); + + // XNewFont attributes + virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSize( double fSize ) throw (css::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getCharset() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCharset( sal_Int16 nCharset ) throw (css::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getWeight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setWeight( sal_Int16 nWeight ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBold() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBold( sal_Bool bBold ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getItalic() throw (css::uno::RuntimeException); + virtual void SAL_CALL setItalic( sal_Bool bItalic ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getUnderline() throw (css::uno::RuntimeException); + virtual void SAL_CALL setUnderline( sal_Bool bUnderline ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getStrikethrough() throw (css::uno::RuntimeException); + virtual void SAL_CALL setStrikethrough( sal_Bool bStrikethrough ) throw (css::uno::RuntimeException); + + // XHelperInterface + VBAHELPER_DECL_XHELPERINTERFACE + +private: + css::uno::Reference< css::beans::XPropertySet > mxProps; +}; + +// ============================================================================ + +#endif diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx index 94d12c5823ba..12ee1ad8ae41 100644 --- a/vbahelper/source/msforms/vbaradiobutton.cxx +++ b/vbahelper/source/msforms/vbaradiobutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbaradiobutton.hxx" -#include +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -84,6 +85,11 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); } +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaRadioButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx index a0de21ae5d0e..3da00eb0765e 100644 --- a/vbahelper/source/msforms/vbaradiobutton.hxx +++ b/vbahelper/source/msforms/vbaradiobutton.hxx @@ -42,6 +42,7 @@ public: virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx index 2d83d41d77c3..c9e4381f449a 100644 --- a/vbahelper/source/msforms/vbatextbox.cxx +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -24,16 +24,16 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include #include "vbatextbox.hxx" -#include +#include "vbanewfont.hxx" +#include +#include +#include using namespace com::sun::star; using namespace ooo::vba; - - ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog ) { } @@ -48,7 +48,8 @@ ScVbaTextBox::getValue() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException) { - rtl::OUString sVal = getAnyAsString( _value ); + // booleans are converted to uppercase strings + rtl::OUString sVal = extractStringFromAny( _value, true ); setText( sVal ); } @@ -114,6 +115,29 @@ ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeExcept (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue); } +sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException) +{ + return msforms::fmSpecialEffect::fmSpecialEffectSunken; +} + +void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException) +{ + return msforms::fmBorderStyle::fmBorderStyleNone; +} + +void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaTextBox::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx index 0553e047488e..fb791db149e4 100644 --- a/vbahelper/source/msforms/vbatextbox.hxx +++ b/vbahelper/source/msforms/vbatextbox.hxx @@ -47,6 +47,11 @@ public: virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getMultiline() throw (css::uno::RuntimeException); virtual void SAL_CALL setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // XDefaultProperty rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } //XHelperInterface diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx index 071651ff8a36..d1a3b40d6eb7 100644 --- a/vbahelper/source/msforms/vbatogglebutton.cxx +++ b/vbahelper/source/msforms/vbatogglebutton.cxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbatogglebutton.hxx" -#include +#include "vbanewfont.hxx" using namespace com::sun::star; using namespace ooo::vba; @@ -79,6 +80,56 @@ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExcepti m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); } +sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException) +{ +} + +sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException) +{ + return sal_False; +} + +void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException) +{ +} + +sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException) +{ +} + +uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException) +{ + return new VbaNewFont( this, mxContext, m_xProps ); +} + rtl::OUString& ScVbaToggleButton::getServiceImplName() { diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx index bfdd68d09642..d2bf4c6b7f17 100644 --- a/vbahelper/source/msforms/vbatogglebutton.hxx +++ b/vbahelper/source/msforms/vbatogglebutton.hxx @@ -43,9 +43,19 @@ public: // Attributes virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); - virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException); + virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 16bc97babd7d..3eb799205389 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -54,7 +54,7 @@ ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Refer m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW ); m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); - setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) ); + setGeometryHelper( new UserFormGeometryHelper( xContext, xControl, 0.0, 0.0 ) ); } ScVbaUserForm::~ScVbaUserForm() @@ -105,18 +105,38 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException) } rtl::OUString SAL_CALL -ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException) +ScVbaUserForm::getCaption() throw (uno::RuntimeException) { rtl::OUString sCaption; m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption; return sCaption; } void -ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException) { m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) ); } +double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getInnerWidth(); +} + +void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setInnerWidth( fInnerWidth ); +} + +double SAL_CALL ScVbaUserForm::getInnerHeight() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getInnerHeight(); +} + +void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setInnerHeight( fInnerHeight ); +} + void SAL_CALL ScVbaUserForm::Hide( ) throw (uno::RuntimeException) { @@ -202,13 +222,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); if ( xControl.is() ) - { - ScVbaControlFactory aFac( mxContext, xControl, m_xModel ); - uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) ); - ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() ); - pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) ); - aResult = uno::makeAny( xVBAControl ); - } + aResult <<= ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ); } return aResult; @@ -225,7 +239,7 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects // thus we have to provide a dummy object in this case uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY ); - uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); + uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); return uno::makeAny( xControls ); diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx index 71e8b4f62aa9..1777a979b9f2 100644 --- a/vbahelper/source/msforms/vbauserform.hxx +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -50,18 +50,22 @@ public: // XUserForm virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException); virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException); - // XIntrospection - virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getInnerWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInnerWidth( double fInnerWidth ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getInnerHeight() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInnerHeight( double fInnerHeight ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Hide( ) throw (css::uno::RuntimeException); virtual void SAL_CALL UnloadObject( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException); + // XIntrospection + virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/source/vbahelper/collectionbase.cxx b/vbahelper/source/vbahelper/collectionbase.cxx new file mode 100755 index 000000000000..7a99aabecdf8 --- /dev/null +++ b/vbahelper/source/vbahelper/collectionbase.cxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#include +#include +#include +#include + +namespace vbahelper { + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +namespace { + +// ---------------------------------------------------------------------------- + +class CollectionEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration > +{ +public: + explicit CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ); + virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + +private: + ::rtl::Reference< CollectionBase > mxCollection; + sal_Int32 mnCurrIndex; +}; + +CollectionEnumeration::CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ) : + mxCollection( rxCollection ), + mnCurrIndex( 1 ) // collection expects one-based indexes +{ +} + +sal_Bool SAL_CALL CollectionEnumeration::hasMoreElements() throw (uno::RuntimeException) +{ + return mnCurrIndex <= mxCollection->getCount(); +} + +uno::Any SAL_CALL CollectionEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( hasMoreElements() ) + return mxCollection->getItemByIndex( mnCurrIndex++ ); + throw container::NoSuchElementException(); +} + +// ---------------------------------------------------------------------------- + +struct IsLessIgnoreCase +{ + inline bool operator()( const ::rtl::OUString& rName1, const ::rtl::OUString& rName2 ) const + { return ::rtl_ustr_compareIgnoreAsciiCase_WithLength( rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0; } +}; + +// ---------------------------------------------------------------------------- + +class SequenceToContainer : public ::cppu::WeakImplHelper2< container::XIndexAccess, container::XNameAccess > +{ +public: + explicit SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ); + explicit SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ); + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + // XNameAccess + virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException); + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + +private: + typedef uno::Sequence< ::rtl::OUString > ElementNameSequence; + typedef ::std::vector< uno::Any > ElementVector; + typedef ::std::map< ::rtl::OUString, uno::Any, IsLessIgnoreCase > ElementMap; + + ElementNameSequence maElementNames; + ElementVector maElements; + ElementMap maElementMap; + uno::Type maElementType; +}; + +SequenceToContainer::SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ) : + maElementType( rElementType ) +{ + maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) ); + maElements.reserve( rElements.size() ); + ::rtl::OUString* pElementName = maElementNames.getArray(); + for( ::std::vector< uno::Reference< container::XNamed > >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName ) + { + uno::Reference< container::XNamed > xNamed = *aIt; + *pElementName = xNamed->getName(); + maElements.push_back( uno::Any( xNamed ) ); + // same name may occur multiple times, VBA returns first occurance + if( maElementMap.count( *pElementName ) == 0 ) + maElementMap[ *pElementName ] <<= xNamed; + } +} + +SequenceToContainer::SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ) : + maElementType( rElementType ) +{ + maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) ); + maElements.reserve( rElements.size() ); + ::rtl::OUString* pElementName = maElementNames.getArray(); + for( ::std::vector< beans::NamedValue >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName ) + { + *pElementName = aIt->Name; + maElements.push_back( aIt->Value ); + // same name may occur multiple times, VBA returns first occurance + if( maElementMap.count( *pElementName ) == 0 ) + maElementMap[ *pElementName ] = aIt->Value; + } +} + +sal_Int32 SAL_CALL SequenceToContainer::getCount() throw (uno::RuntimeException) +{ + return static_cast< sal_Int32 >( maElements.size() ); +} + +uno::Any SAL_CALL SequenceToContainer::getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( (0 <= nIndex) && (nIndex < getCount()) ) + return maElements[ static_cast< size_t >( nIndex ) ]; + throw lang::IndexOutOfBoundsException(); +} + +uno::Any SAL_CALL SequenceToContainer::getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + ElementMap::iterator aIt = maElementMap.find( rName ); + if( aIt != maElementMap.end() ) + return aIt->second; + throw container::NoSuchElementException(); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SequenceToContainer::getElementNames() throw (uno::RuntimeException) +{ + return maElementNames; +} + +sal_Bool SAL_CALL SequenceToContainer::hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + return maElementMap.count( rName ) > 0; +} + +uno::Type SAL_CALL SequenceToContainer::getElementType() throw (uno::RuntimeException) +{ + return maElementType; +} + +sal_Bool SAL_CALL SequenceToContainer::hasElements() throw (uno::RuntimeException) +{ + return !maElements.empty(); +} + +} // namespace + +// ============================================================================ + +CollectionBase::CollectionBase( const uno::Type& rElementType ) : + maElementType( rElementType ), + mbConvertOnDemand( false ) +{ +} + +sal_Int32 SAL_CALL CollectionBase::getCount() throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + return mxIndexAccess->getCount(); + if( mxNameAccess.is() ) + return mxNameAccess->getElementNames().getLength(); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Reference< container::XEnumeration > SAL_CALL CollectionBase::createEnumeration() throw (uno::RuntimeException) +{ + return new CollectionEnumeration( this ); +} + +uno::Type SAL_CALL CollectionBase::getElementType() throw (uno::RuntimeException) +{ + return maElementType; +} + +sal_Bool SAL_CALL CollectionBase::hasElements() throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + return mxIndexAccess->hasElements(); + if( mxNameAccess.is() ) + return mxNameAccess->hasElements(); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +::rtl::OUString SAL_CALL CollectionBase::getDefaultMethodName() throw (uno::RuntimeException) +{ + static ::rtl::OUString saDefMethodName( RTL_CONSTASCII_USTRINGPARAM( "Item" ) ); + return saDefMethodName; +} + +// ---------------------------------------------------------------------------- + +void CollectionBase::initContainer( + const uno::Reference< container::XElementAccess >& rxElementAccess, + ContainerType eContainerType ) throw (uno::RuntimeException) +{ + mxIndexAccess.set( rxElementAccess, uno::UNO_QUERY ); + mxNameAccess.set( rxElementAccess, uno::UNO_QUERY ); + switch( eContainerType ) + { + case CONTAINER_NATIVE_VBA: + mbConvertOnDemand = false; + break; + case CONTAINER_CONVERT_ON_DEMAND: + mbConvertOnDemand = true; + break; + } +} + +void CollectionBase::initElements( const ::std::vector< uno::Reference< container::XNamed > >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException) +{ + // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity + initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType ); +} + +void CollectionBase::initElements( const ::std::vector< beans::NamedValue >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException) +{ + // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity + initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType ); +} + +uno::Any CollectionBase::createCollectionItem( const uno::Any& rElement, const uno::Any& rIndex ) throw (css::uno::RuntimeException) +{ + uno::Any aItem = mbConvertOnDemand ? implCreateCollectionItem( rElement, rIndex ) : rElement; + if( aItem.hasValue() ) + return aItem; + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item." ) ), 0 ); +} + +uno::Any CollectionBase::getItemByIndex( sal_Int32 nIndex ) throw (uno::RuntimeException) +{ + if( mxIndexAccess.is() ) + { + if( (1 <= nIndex) && (nIndex <= mxIndexAccess->getCount()) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxIndexAccess->getByIndex( nIndex - 1 ), uno::Any( nIndex ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 ); + } + if( mxNameAccess.is() ) + { + uno::Sequence< ::rtl::OUString > aElementNames = mxNameAccess->getElementNames(); + if( (1 <= nIndex) && (nIndex <= aElementNames.getLength()) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxNameAccess->getByName( aElementNames[ nIndex - 1 ] ), uno::Any( aElementNames[ nIndex - 1 ] ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Any CollectionBase::getItemByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException) +{ + if( mxNameAccess.is() ) + { + if( rName.getLength() > 0 ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( mxNameAccess->getByName( rName ), uno::Any( rName ) ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 ); + } + if( mxIndexAccess.is() ) + { + for( sal_Int32 nIndex = 0, nSize = mxIndexAccess->getCount(); nIndex < nSize; ++nIndex ) + { + uno::Any aElement = mxIndexAccess->getByIndex( nIndex ); + uno::Reference< container::XNamed > xNamed( aElement, uno::UNO_QUERY ); + if( xNamed.is() && xNamed->getName().equalsIgnoreAsciiCase( rName ) ) + // createCollectionItem() will convert from container element to VBA item + return createCollectionItem( aElement, uno::Any( nIndex ) ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 ); + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 ); +} + +uno::Any CollectionBase::getAnyItemOrThis( const uno::Any& rIndex ) throw (uno::RuntimeException) +{ + if( !rIndex.hasValue() ) + return uno::Any( uno::Reference< XCollectionBase >( this ) ); + if( rIndex.has< sal_Int32 >() ) + return getItemByIndex( rIndex.get< sal_Int32 >() ); + if( rIndex.has< ::rtl::OUString >() ) + return getItemByName( rIndex.get< ::rtl::OUString >() ); + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item index." ) ), 0 ); +} + +// protected ------------------------------------------------------------------ + +uno::Any CollectionBase::implCreateCollectionItem( const uno::Any& /*rElement*/, const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException) +{ + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Creation of VBA implementation object not implemented." ) ), 0 ); +} + +// ============================================================================ + +} // namespace vbahelper diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 54d280094f2c..6f782b629f40 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -387,9 +387,9 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) { try // return empty object on error { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getCurrentDocument(); + // "VBE" object does not have a parent, but pass document model to be able to determine application type + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= getCurrentDocument(); uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); @@ -401,25 +401,6 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) return uno::Any(); } -uno::Any SAL_CALL -VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) -{ - try // return empty object on error - { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getCurrentDocument(); - uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); - uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext ); - return uno::Any( xVBProjects ); - } - catch( uno::Exception& ) - { - } - return uno::Any(); -} - rtl::OUString& VbaApplicationBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbacommandbar.cxx b/vbahelper/source/vbahelper/vbacommandbar.cxx index 1e8d21d53583..11cbacb79894 100644 --- a/vbahelper/source/vbahelper/vbacommandbar.cxx +++ b/vbahelper/source/vbahelper/vbacommandbar.cxx @@ -154,14 +154,7 @@ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeExce uno::Any SAL_CALL ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException) { - uno::Reference< awt::XMenu > xMenu; - if( m_bIsMenu ) - { - uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager(); - uno::Reference< beans::XPropertySet > xPropertySet( xLayoutManager->getElement( m_sResourceUrl ), uno::UNO_QUERY_THROW ); - xMenu.set( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("XMenuBar") ), uno::UNO_QUERY ); - } - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) ); + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) ); if( aIndex.hasValue() ) { return xCommandBarControls->Item( aIndex, uno::Any() ); diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index 157d54eca7d5..d57bc00644a5 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -91,50 +91,37 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u ::sal_Bool SAL_CALL ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException) { - /*sal_Bool bVisible = sal_True; - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") ); + sal_Bool bVisible = sal_True; + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) ); if( aValue.hasValue() ) aValue >>= bVisible; - return bVisible;*/ - return getEnabled(); - + return bVisible; } void SAL_CALL ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException) { - /*uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") ); + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) ); if( aValue.hasValue() ) { - setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) ); + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ), uno::makeAny( _visible ) ); ApplyChange(); - }*/ - setEnabled( _visible); + } } ::sal_Bool SAL_CALL ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) { sal_Bool bEnabled = sal_True; - rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); - rtl::OUString aCommandURL ; - if( m_xParentMenu.is() ) + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) ); + if( aValue.hasValue() ) { - // currently only the menu in the MenuBat support Enable/Disable - // FIXME: how to support the menu item in Toolbar - bEnabled = m_xParentMenu->isItemEnabled( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ) ); + aValue >>= bEnabled; } else { // emulated with Visible - //bEnabled = getVisible(); - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); - if (aValue >>= aCommandURL){ - if (0 == aCommandURL.indexOf(aCommandURLappendix)){ - bEnabled = sal_False; - } - } - + bEnabled = getVisible(); } return bEnabled; } @@ -142,30 +129,16 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) void SAL_CALL ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) { - rtl::OUString aCommandURL ; - rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); - rtl::OUStringBuffer aCommandURLSringBuffer; - if( m_xParentMenu.is() ) + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) ); + if( aValue.hasValue() ) { - // currently only the menu in the MenuBat support Enable/Disable - m_xParentMenu->enableItem( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ), _enabled ); + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ), uno::makeAny( _enabled ) ); + ApplyChange(); } else { - uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); - if (aValue >>= aCommandURL){ - if (0 == aCommandURL.indexOf(aCommandURLappendix)){ - aCommandURL = aCommandURL.copy(3); - } - if (false == _enabled){ - aCommandURLSringBuffer = aCommandURLappendix; - } - aCommandURLSringBuffer.append(aCommandURL); - setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) ); - ApplyChange(); - } // emulated with Visible - //setVisible( _enabled ); + setVisible( _enabled ); } } @@ -206,14 +179,7 @@ ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicE if( !xSubMenu.is() ) throw uno::RuntimeException(); - uno::Reference< awt::XMenu > xMenu; - if( m_xParentMenu.is() ) - { - sal_Int16 nItemId = m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ); - xMenu.set( m_xParentMenu->getPopupMenu( nItemId ), uno::UNO_QUERY ); - } - - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) ); + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) ); if( aIndex.hasValue() ) { return xCommandBarControls->Item( aIndex, uno::Any() ); @@ -241,12 +207,11 @@ ScVbaCommandBarControl::getServiceNames() } //////////// ScVbaCommandBarPopup ////////////////////////////// -ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) +ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) { m_nPosition = nPosition; m_bTemporary = bTemporary; m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues; - m_xParentMenu = xMenu; } rtl::OUString& @@ -268,12 +233,11 @@ ScVbaCommandBarPopup::getServiceNames() } //////////// ScVbaCommandBarButton ////////////////////////////// -ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) +ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl ) { m_nPosition = nPosition; m_bTemporary = bTemporary; m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues; - m_xParentMenu = xMenu; } rtl::OUString& diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx index a165f8e1cccd..5066ba75eea0 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx @@ -43,10 +43,9 @@ class ScVbaCommandBarControl : public CommandBarControl_BASE protected: VbaCommandBarHelperRef pCBarHelper; rtl::OUString m_sResourceUrl; - css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; - css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; - css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; - css::uno::Reference< css::awt::XMenu > m_xParentMenu; + css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings; + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; + css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues; sal_Int32 m_nPosition; sal_Bool m_bTemporary; @@ -87,7 +86,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop class ScVbaCommandBarPopup : public CommandBarPopup_BASE { public: - ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException); + ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) { @@ -102,7 +101,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut class ScVbaCommandBarButton : public CommandBarButton_BASE { public: - ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException); + ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) { diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index 634b4a0e9395..da218d007736 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -55,14 +55,20 @@ public: } }; -ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl, const uno::Reference< awt::XMenu >& xMenu ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_xMenu( xMenu ) +ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ) { m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False; } -uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu ) +uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, + const rtl::OUString& sHelpURL, + const rtl::OUString& sLabel, + sal_uInt16 nType, + const uno::Any& aSubMenu, + sal_Bool isVisible, + sal_Bool isEnabled ) { - uno::Sequence< beans::PropertyValue > aProps(5); + uno::Sequence< beans::PropertyValue > aProps(7); aProps[0].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL ); aProps[0].Value <<= sCommandURL; @@ -74,6 +80,10 @@ uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemDat aProps[3].Value <<= nType; aProps[4].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ); aProps[4].Value = aSubMenu; + aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ); + aProps[5].Value <<= isVisible; + aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ); + aProps[6].Value <<= isEnabled; return aProps; } @@ -124,9 +134,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource ) getPropertyValue( aProps, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu; ScVbaCommandBarControl* pNewCommandBarControl = NULL; if( xSubMenu.is() ) - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu ); + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True ); else - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu ); + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True ); return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) ); } @@ -202,7 +212,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un sal_uInt16 nItemType = 0; if( IsMenu() ) { - aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu ); + aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true ); } else { @@ -217,12 +227,11 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings ); - // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux. ScVbaCommandBarControl* pNewCommandBarControl = NULL; if( nType == office::MsoControlType::msoControlPopup ) - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() ); + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary ); else - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() ); + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary ); return uno::Reference< XCommandBarControl >( pNewCommandBarControl ); } diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx index 0b35773660d1..79a4a8c5a5fe 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx @@ -38,17 +38,22 @@ typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE; class ScVbaCommandBarControls : public CommandBarControls_BASE { private: - VbaCommandBarHelperRef pCBarHelper; - css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; - rtl::OUString m_sResourceUrl; - css::uno::Reference< css::awt::XMenu > m_xMenu; - sal_Bool m_bIsMenu; + VbaCommandBarHelperRef pCBarHelper; + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings; + rtl::OUString m_sResourceUrl; + sal_Bool m_bIsMenu; - css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu ); + css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, + const rtl::OUString& sHelpURL, + const rtl::OUString& sLabel, + sal_uInt16 nType, + const css::uno::Any& aSubMenu, + sal_Bool isVisible, + sal_Bool isEnabled ); css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle ); public: - ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw( css::uno::RuntimeException ); + ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException ); sal_Bool IsMenu(){ return m_bIsMenu; } // XEnumerationAccess diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx index 1fa41d7141b3..93c6e5f55457 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx @@ -47,6 +47,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL"; static const char ITEM_DESCRIPTOR_UINAME[] = "UIName"; +static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar"; static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/"; diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 087e7188c8f6..b3053aa3d759 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -38,6 +38,7 @@ #include #include //Michael E. Bohn #include +#include #include #include @@ -265,20 +266,22 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) uno::Any SAL_CALL VbaDocumentBase::getVBProject() throw (uno::RuntimeException) { - try // return empty object on error + if( !mxVBProject.is() ) try { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); - aArgs[ 1 ] <<= getModel(); + uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW ); + uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Any > aArgs( 3 ); + aArgs[ 0 ] <<= xVBE; // the VBE + aArgs[ 1 ] <<= xVBE; // parent of a VBA project is the VBE + aArgs[ 2 ] <<= getModel(); // document model for script container access uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); - uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( + mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext ); - return uno::Any( xVBProjects ); } catch( uno::Exception& ) { } - return uno::Any(); + return uno::Any( mxVBProject ); } rtl::OUString& diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index 8000a7cdf66e..5e2cf949c473 100755 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -26,34 +26,40 @@ ************************************************************************/ #include "vbahelper/vbaeventshelperbase.hxx" +#include +#include +#include +#include #include +#include using namespace ::com::sun::star; using namespace ::ooo::vba; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + // ============================================================================ VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : mpShell( 0 ), - mbDisposed( false ) + mbDisposed( true ) { try { mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false ); mpShell = getSfxObjShell( mxModel ); - - // add dispose listener - uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); - xComponent->addEventListener( this ); } catch( uno::Exception& ) { } + mbDisposed = mpShell == 0; + startListening(); } VbaEventsHelperBase::~VbaEventsHelperBase() { - stopListening(); + OSL_ENSURE( mbDisposed, "VbaEventsHelperBase::~VbaEventsHelperBase - missing disposing notification" ); } sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) @@ -65,8 +71,8 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c return getEventHandlerPath( rInfo, rArgs ).getLength() > 0; } -void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) - throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) +sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, util::VetoException, uno::RuntimeException) { /* Derived classes may add new event identifiers to be processed while processing the original event. All unprocessed events are collected in @@ -79,9 +85,9 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un handler receives the Cancel value of the previous event handler. */ bool bCancel = false; - /* bSuccess will change to true if at least one event handler has been - executed successfully. */ - bool bSuccess = false; + /* bExecuted will change to true if at least one event handler has been + found and executed. */ + bool bExecuted = false; /* Loop as long as there are more events to be processed. Derived classes may add new events to be processed in the virtual implPrepareEvent() @@ -98,15 +104,15 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId ); uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs; aEventQueue.pop_front(); + OSL_TRACE( "VbaEventsHelperBase::processVbaEvent( \"%s\" )", ::rtl::OUStringToOString( rInfo.maMacroName, RTL_TEXTENCODING_UTF8 ).getStr() ); /* Let derived classes prepare the event, they may add new events for next iteration. If false is returned, the event handler must not be called. */ - bool bEventSuccess = false; if( implPrepareEvent( aEventQueue, rInfo, aEventArgs ) ) { // search the event handler macro in the document - ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); + OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); if( aMacroPath.getLength() > 0 ) { // build the argument list @@ -120,96 +126,225 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un } // execute the event handler uno::Any aRet, aCaller; - bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); - // extract new cancel value + executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); + // extract new cancel value (may be boolean or any integer type) if( rInfo.mnCancelIndex >= 0 ) { - if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) - throw lang::IllegalArgumentException(); - // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32 - bool bNewCancel = false; - sal_Int32 nNewCancel = 0; - if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel ) - bCancel = bNewCancel; - else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel ) - bCancel = nNewCancel != 0; + checkArgument( aVbaArgs, rInfo.mnCancelIndex ); + bCancel = extractBoolFromAny( aVbaArgs[ rInfo.mnCancelIndex ] ); } + // event handler has been found + bExecuted = true; } - // global success, if at least one event handler succeeded - bSuccess |= bEventSuccess; } // post processing (also, if event handler does not exist, or disabled, or on error - implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel ); + implPostProcessEvent( aEventQueue, rInfo, bCancel ); } // if event handlers want to cancel the event, do so regardless of any errors if( bCancel ) throw util::VetoException(); - // if no event handler finished successfully, throw - if( !bSuccess ) - throw script::provider::ScriptFrameworkErrorException(); + // return true, if at least one event handler has been found + return bExecuted; } -void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException) +void SAL_CALL VbaEventsHelperBase::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException) { - OSL_TRACE( "VbaEventsHelperBase::disposing" ); - stopListening(); - mbDisposed = true; + OSL_TRACE( "VbaEventsHelperBase::notifyEvent( \"%s\" )", ::rtl::OUStringToOString( rEvent.EventName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) ) + stopListening(); } -// protected ------------------------------------------------------------------ - -void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, - const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rEvent ) throw (uno::RuntimeException) { - EventHandlerInfo& rInfo = maEvents[ nEventId ]; - rInfo.mnEventId = nEventId; - rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName ); - rInfo.meType = eType; - rInfo.mnCancelIndex = nCancelIndex; - rInfo.maUserData = rUserData; -} - -// private -------------------------------------------------------------------- - -const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( - sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) -{ - EventHandlerMap::const_iterator aIt = maEvents.find( nEventId ); - if( aIt == maEvents.end() ) - throw lang::IllegalArgumentException(); - return aIt->second; -} - -::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, - const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) -{ - ::rtl::OUString aMacroName; - switch( rInfo.meType ) + // make sure the VBA library exists + try { - case EVENTHANDLER_GLOBAL: - aMacroName = rInfo.maMacroName; - break; - case EVENTHANDLER_DOCUMENT: - aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ). - append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); - break; + ensureVBALibrary(); + } + catch( uno::Exception& ) + { + return; + } + + // check that the sender of the event is the VBA library + uno::Reference< script::vba::XVBAModuleInfo > xSender( rEvent.Base, uno::UNO_QUERY ); + if( mxModuleInfos.get() != xSender.get() ) + return; + + // process all changed modules + for( sal_Int32 nIndex = 0, nLength = rEvent.Changes.getLength(); nIndex < nLength; ++nIndex ) + { + const util::ElementChange& rChange = rEvent.Changes[ nIndex ]; + OUString aModuleName; + if( (rChange.Accessor >>= aModuleName) && (aModuleName.getLength() > 0) ) try + { + // invalidate event handler path map depending on module type + if( getModuleType( aModuleName ) == script::ModuleType::NORMAL ) + // paths to global event handlers are stored with empty key (will be searched in all normal code modules) + maEventPaths.erase( OUString() ); + else + // paths to class/form/document event handlers are keyed by module name + maEventPaths.erase( aModuleName ); + } + catch( uno::Exception& ) + { + } } - MacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false ); - return aMacroInfo.mbFound ? ::rtl::OUString( aMacroInfo.msResolvedMacro ) : ::rtl::OUString(); } -void VbaEventsHelperBase::stopListening() +void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& rEvent ) throw (uno::RuntimeException) { - if( !mbDisposed ) try + uno::Reference< frame::XModel > xSender( rEvent.Source, uno::UNO_QUERY ); + if( xSender.is() ) + stopListening(); +} + +void VbaEventsHelperBase::processVbaEventNoThrow( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) +{ + try { - uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); - xComponent->removeEventListener( this ); + processVbaEvent( nEventId, rArgs ); } catch( uno::Exception& ) { } } +// protected ------------------------------------------------------------------ + +void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, sal_Int32 nModuleType, + const sal_Char* pcMacroName, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +{ + EventHandlerInfo& rInfo = maEventInfos[ nEventId ]; + rInfo.mnEventId = nEventId; + rInfo.mnModuleType = nModuleType; + rInfo.maMacroName = OUString::createFromAscii( pcMacroName ); + rInfo.mnCancelIndex = nCancelIndex; + rInfo.maUserData = rUserData; +} + +// private -------------------------------------------------------------------- + +void VbaEventsHelperBase::startListening() +{ + if( mbDisposed ) + return; + + uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY ); + if( xEventBroadcaster.is() ) + try { xEventBroadcaster->addEventListener( this ); } catch( uno::Exception& ) {} +} + +void VbaEventsHelperBase::stopListening() +{ + if( mbDisposed ) + return; + + uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY ); + if( xEventBroadcaster.is() ) + try { xEventBroadcaster->removeEventListener( this ); } catch( uno::Exception& ) {} + + mxModel.clear(); + mpShell = 0; + maEventInfos.clear(); + mbDisposed = true; +} + +const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( + sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) +{ + EventHandlerInfoMap::const_iterator aIt = maEventInfos.find( nEventId ); + if( aIt == maEventInfos.end() ) + throw lang::IllegalArgumentException(); + return aIt->second; +} + +OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + OUString aModuleName; + switch( rInfo.mnModuleType ) + { + // global event handlers may exist in any standard code module + case script::ModuleType::NORMAL: + break; + + // document event: get name of the code module associated to the event sender + case script::ModuleType::DOCUMENT: + aModuleName = implGetDocumentModuleName( rInfo, rArgs ); + if( aModuleName.getLength() == 0 ) + throw lang::IllegalArgumentException(); + break; + + default: + throw uno::RuntimeException(); // unsupported module type + } + + /* Performance improvement: Check the list of existing event handlers + instead of searching in Basic source code every time. */ + EventHandlerPathMap::iterator aIt = maEventPaths.find( aModuleName ); + ModulePathMap& rPathMap = (aIt == maEventPaths.end()) ? updateModulePathMap( aModuleName ) : aIt->second; + return rPathMap[ rInfo.mnEventId ]; +} + +void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException) +{ + if( !mxModuleInfos.is() ) try + { + maLibraryName = getDefaultProjectName( mpShell ); + if( maLibraryName.getLength() == 0 ) + throw uno::RuntimeException(); + uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW ); + mxModuleInfos.set( xBasicLibs->getByName( maLibraryName ), uno::UNO_QUERY_THROW ); + // listen to changes in the VBA source code + uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModuleInfos, uno::UNO_QUERY_THROW ); + xChangesNotifier->addChangesListener( this ); + } + catch( uno::Exception& ) + { + // error accessing the Basic library, so this object is useless + stopListening(); + throw uno::RuntimeException(); + } +} + +sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) throw (uno::RuntimeException) +{ + // make sure the VBA library exists + ensureVBALibrary(); + + // no module specified: global event handler in standard code modules + if( rModuleName.getLength() == 0 ) + return script::ModuleType::NORMAL; + + // get module type from module info + try + { + return mxModuleInfos->getModuleInfo( rModuleName ).ModuleType; + } + catch( uno::Exception& ) + { + } + throw uno::RuntimeException(); +} + +VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (uno::RuntimeException) +{ + // get type of the specified module (throws on error) + sal_Int32 nModuleType = getModuleType( rModuleName ); + // search for all event handlers + ModulePathMap& rPathMap = maEventPaths[ rModuleName ]; + for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt ) + { + const EventHandlerInfo& rInfo = aIt->second; + if( rInfo.mnModuleType == nModuleType ) + rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName ); + } + return rPathMap; +} + // ============================================================================ diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index cfce8b49e3d1..827d387f031d 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -628,82 +628,85 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno:: dispatchExecute( pViewShell, SID_VIEWSHELL1 ); } -bool extractBoolFromAny( bool& rbValue, const uno::Any& rAny ) +sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException) { - if( rAny >>= rbValue ) return true; + switch( rAny.getValueType().getTypeClass() ) + { + case uno::TypeClass_FLOAT: + return static_cast< sal_Int32 >( rAny.get< float >() ); + case uno::TypeClass_DOUBLE: + return static_cast< sal_Int32 >( rAny.get< double >() ); + case uno::TypeClass_BYTE: + case uno::TypeClass_SHORT: + case uno::TypeClass_LONG: + return rAny.get< sal_Int32 >(); + default:; + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to integer." ) ), 0 ); +} - sal_Int64 nSigned = 0; - if( rAny >>= nSigned ) { rbValue = nSigned != 0; return true; } - - sal_uInt64 nUnsigned = 0; - if( rAny >>= nUnsigned ) { rbValue = nUnsigned > 0; return true; } - - double fDouble = 0.0; - if( rAny >>= fDouble ) { rbValue = fDouble != 0.0; return true; } - - return false; +sal_Int32 extractIntFromAny( const uno::Any& rAny, sal_Int32 nDefault ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractIntFromAny( rAny ) : nDefault; } bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException) { - bool bValue = false; - if( extractBoolFromAny( bValue, rAny ) ) - return bValue; - throw uno::RuntimeException(); + switch( rAny.getValueType().getTypeClass() ) + { + case uno::TypeClass_FLOAT: + return rAny.get< float >() != 0.0; + case uno::TypeClass_DOUBLE: + return rAny.get< double >() != 0.0; + case uno::TypeClass_BYTE: + case uno::TypeClass_SHORT: + case uno::TypeClass_LONG: + return rAny.get< sal_Int32 >() != 0; + case uno::TypeClass_HYPER: + return rAny.get< sal_Int64 >() != 0; + default:; + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to boolean." ) ), 0 ); +} + +bool extractBoolFromAny( const uno::Any& rAny, bool bDefault ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractBoolFromAny( rAny ) : bDefault; +} + +::rtl::OUString extractStringFromAny( const uno::Any& rAny, bool bUppercaseBool ) throw (uno::RuntimeException) +{ + switch( rAny.getValueType().getTypeClass() ) + { + case uno::TypeClass_STRING: + return rAny.get< ::rtl::OUString >(); + case uno::TypeClass_BOOLEAN: + return bUppercaseBool ? + (rAny.get< bool >() ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TRUE" ) ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) )) : + ::rtl::OUString::valueOf( (sal_Bool)rAny.get< bool >() ); + case uno::TypeClass_FLOAT: + return ::rtl::OUString::valueOf( rAny.get< float >() ); + case uno::TypeClass_DOUBLE: + return ::rtl::OUString::valueOf( rAny.get< double >() ); + case uno::TypeClass_BYTE: + case uno::TypeClass_SHORT: + case uno::TypeClass_LONG: + return ::rtl::OUString::valueOf( rAny.get< sal_Int32 >() ); + case uno::TypeClass_HYPER: + return ::rtl::OUString::valueOf( rAny.get< sal_Int64 >() ); + default:; + } + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to string." ) ), 0 ); +} + +::rtl::OUString extractStringFromAny( const uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool ) throw (uno::RuntimeException) +{ + return rAny.hasValue() ? extractStringFromAny( rAny, bUppercaseBool ) : rDefault; } rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException ) { - uno::Type aType = pvargItem.getValueType(); - uno::TypeClass eTypeClass = aType.getTypeClass(); - rtl::OUString sString; - switch ( eTypeClass ) - { - case uno::TypeClass_BOOLEAN: - { - sal_Bool bBool = sal_False; - pvargItem >>= bBool; - sString = rtl::OUString::valueOf( bBool ); - break; - } - case uno::TypeClass_STRING: - pvargItem >>= sString; - break; - case uno::TypeClass_FLOAT: - { - float aFloat = 0; - pvargItem >>= aFloat; - sString = rtl::OUString::valueOf( aFloat ); - break; - } - case uno::TypeClass_DOUBLE: - { - double aDouble = 0; - pvargItem >>= aDouble; - sString = rtl::OUString::valueOf( aDouble ); - break; - } - case uno::TypeClass_SHORT: - case uno::TypeClass_LONG: - case uno::TypeClass_BYTE: - { - sal_Int32 aNum = 0; - pvargItem >>= aNum; - sString = rtl::OUString::valueOf( aNum ); - break; - } - - case uno::TypeClass_HYPER: - { - sal_Int64 aHyper = 0; - pvargItem >>= aHyper; - sString = rtl::OUString::valueOf( aHyper ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() ); - } - return sString; + return extractStringFromAny( pvargItem ); } @@ -840,7 +843,7 @@ rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike ) return sResult.makeStringAndClear( ); } -double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) +double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical) { double fConvertFactor = 1.0; if( bVertical ) @@ -854,12 +857,12 @@ double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt: return fConvertFactor; } -double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) +double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); return PointsToHmm( fPoints ) * fConvertFactor; } -double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) +double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); return HmmToPoints( fPixels/fConvertFactor ); @@ -994,128 +997,176 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r // ====UserFormGeomentryHelper==== //--------------------------------------------- -UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) -: mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() ) +UserFormGeometryHelper::UserFormGeometryHelper( + const uno::Reference< uno::XComponentContext >& /*xContext*/, + const uno::Reference< awt::XControl >& xControl, + double fOffsetX, double fOffsetY ) : + mfOffsetX( fOffsetX ), + mfOffsetY( fOffsetY ), + mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() ) { if ( !xControl.is() ) throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No control is provided!" ) ), uno::Reference< uno::XInterface >() ); mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW ); + mxModelProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); + mxUnitConv.set( mxWindow, uno::UNO_QUERY_THROW ); } -//--------------------------------------------- -double UserFormGeometryHelper::getLeft() +double UserFormGeometryHelper::getLeft() const { - return mxWindow->getPosSize().X; + return implGetPos( false ); } -//--------------------------------------------- -void UserFormGeometryHelper::setLeft( double nLeft ) +void UserFormGeometryHelper::setLeft( double fLeft ) { - mxWindow->setPosSize( nLeft, mxWindow->getPosSize().Y, 0, 0, awt::PosSize::POS ); + implSetPos( fLeft, false ); } -//--------------------------------------------- -double UserFormGeometryHelper::getTop() +double UserFormGeometryHelper::getTop() const { - return mxWindow->getPosSize().Y; + return implGetPos( true ); } -//--------------------------------------------- -void UserFormGeometryHelper::setTop( double nTop ) +void UserFormGeometryHelper::setTop( double fTop ) { - mxWindow->setPosSize( mxWindow->getPosSize().X, nTop, 0, 0, awt::PosSize::POS ); + implSetPos( fTop, true ); } -//--------------------------------------------- -double UserFormGeometryHelper::getWidth() +double UserFormGeometryHelper::getWidth() const { - if ( mbDialog ) + return implGetSize( false, true ); +} + +void UserFormGeometryHelper::setWidth( double fWidth ) +{ + implSetSize( fWidth, false, true ); +} + +double UserFormGeometryHelper::getHeight() const +{ + return implGetSize( true, true ); +} + +void UserFormGeometryHelper::setHeight( double fHeight ) +{ + implSetSize( fHeight, true, true ); +} + +double UserFormGeometryHelper::getInnerWidth() const +{ + return implGetSize( false, false ); +} + +void UserFormGeometryHelper::setInnerWidth( double fWidth ) +{ + implSetSize( fWidth, false, false ); +} + +double UserFormGeometryHelper::getInnerHeight() const +{ + return implGetSize( true, false ); +} + +void UserFormGeometryHelper::setInnerHeight( double fHeight ) +{ + implSetSize( fHeight, true, false ); +} + +double UserFormGeometryHelper::getOffsetX() const +{ + return mfOffsetX; +} + +double UserFormGeometryHelper::getOffsetY() const +{ + return mfOffsetY; +} + +// ---------------------------------------------------------------------------- + +static const ::rtl::OUString saPosXName( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ); +static const ::rtl::OUString saPosYName( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ); +static const ::rtl::OUString saWidthName( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ); +static const ::rtl::OUString saHeightName( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ); + +double UserFormGeometryHelper::implGetPos( bool bPosY ) const +{ + sal_Int32 nPosAppFont = mxModelProps->getPropertyValue( bPosY ? saPosYName : saPosXName ).get< sal_Int32 >(); + // appfont to pixel + awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosAppFont, nPosAppFont ), util::MeasureUnit::APPFONT ); + // pixel to VBA points + awt::Point aPosPoint = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::POINT ); + return bPosY ? (aPosPoint.Y - mfOffsetY) : (aPosPoint.X - mfOffsetX); +} + +void UserFormGeometryHelper::implSetPos( double fPos, bool bPosY ) +{ + // convert passed VBA points to pixels + sal_Int32 nPosPixel = static_cast< sal_Int32 >( fPos + (bPosY ? mfOffsetY : mfOffsetX) ); + awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosPixel, nPosPixel ), util::MeasureUnit::POINT ); + // pixel to appfont + awt::Point aPosAppFont = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::APPFONT ); + mxModelProps->setPropertyValue( bPosY ? saPosYName : saPosXName, uno::Any( bPosY ? aPosAppFont.Y : aPosAppFont.X ) ); +} + +double UserFormGeometryHelper::implGetSize( bool bHeight, bool bOuter ) const +{ + sal_Int32 nSizeAppFont = mxModelProps->getPropertyValue( bHeight ? saHeightName : saWidthName ).get< sal_Int32 >(); + // appfont to pixel + awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSizeAppFont, nSizeAppFont ), util::MeasureUnit::APPFONT ); + + /* The VBA symbols 'Width' and 'Height' return the outer size including + window decoration (in difference to the symbols 'InnerWidth' and + 'InnerHeight'), but the window API returns the inner size. */ + if( mbDialog && bOuter ) { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) + if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) ) { - // get the size with decoration - Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL ); - return aResult.getWidth(); + Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL ); + aSizePixel = awt::Size( aOuterRect.getWidth(), aOuterRect.getHeight() ); } } - return mxWindow->getPosSize().Width; + // pixel to VBA points + awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT ); + return bHeight ? aSizePoint.Height : aSizePoint.Width; } -//--------------------------------------------- -void UserFormGeometryHelper::setWidth( double nWidth ) +void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter ) { - sal_Int64 nNewWidth = nWidth; + // convert passed VBA points to pixels + sal_Int32 nSize = static_cast< sal_Int32 >( fSize ); + awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSize, nSize ), util::MeasureUnit::POINT ); - if ( mbDialog ) + /* The VBA symbols 'Width' and 'Height' set the outer size (in difference + to the symbols 'InnerWidth' and 'InnerHeight'), but the dialog model + expects the inner size. We have to remove the window extents from the + pixel height to get the same result. */ + if ( mbDialog && bOuter ) { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) + if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) ) { - // set the size with decoration - Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL ); - if ( !aRDecor.IsEmpty() ) + Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL ); + if( !aOuterRect.IsEmpty() ) { - sal_Int64 nDecor = aRDecor.getWidth(); - sal_Int64 nUnDecor = mxWindow->getPosSize().Width; - if ( nWidth < nDecor - nUnDecor ) - nUnDecor = nDecor - nWidth; // avoid negative size - nNewWidth = nWidth + nUnDecor - nDecor; + awt::Rectangle aInnerRect = mxWindow->getPosSize(); + sal_Int32 nDecorWidth = aOuterRect.getWidth() - aInnerRect.Width; + sal_Int32 nDecorHeight = aOuterRect.getHeight() - aInnerRect.Height; + aSizePixel.Width = ::std::max< sal_Int32 >( aSizePixel.Width - nDecorWidth, 1 ); + aSizePixel.Height = ::std::max< sal_Int32 >( aSizePixel.Height - nDecorHeight, 1 ); } } } - mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH ); + awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT ); + mxModelProps->setPropertyValue( bHeight ? saHeightName : saWidthName, uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) ); } -//--------------------------------------------- -double UserFormGeometryHelper::getHeight() -{ - if ( mbDialog ) - { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) - { - // get the size with decoration - Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL ); - return aResult.getHeight(); - } - } +// ============================================================================ - return mxWindow->getPosSize().Height; -} - -//--------------------------------------------- -void UserFormGeometryHelper::setHeight( double nHeight ) -{ - sal_Int64 nNewHeight = nHeight; - if ( mbDialog ) - { - const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ); - if ( pWindow ) - { - // set the size with decoration - Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL ); - if ( !aRDecor.IsEmpty() ) - { - sal_Int64 nDecor = aRDecor.getHeight(); - sal_Int64 nUnDecor = mxWindow->getPosSize().Height; - if ( nHeight < nDecor - nUnDecor ) - nUnDecor = nDecor - nHeight; // avoid negative size - nNewHeight = nHeight + nUnDecor - nDecor; - } - } - } - - mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT ); -} - -// ============ - - double ConcreteXShapeGeometryAttributes::getLeft() + double ConcreteXShapeGeometryAttributes::getLeft() const { return m_pShapeHelper->getLeft(); } @@ -1123,7 +1174,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) { m_pShapeHelper->setLeft( nLeft ); } - double ConcreteXShapeGeometryAttributes::getTop() + double ConcreteXShapeGeometryAttributes::getTop() const { return m_pShapeHelper->getTop(); } @@ -1132,7 +1183,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) m_pShapeHelper->setTop( nTop ); } - double ConcreteXShapeGeometryAttributes::getHeight() + double ConcreteXShapeGeometryAttributes::getHeight() const { return m_pShapeHelper->getHeight(); } @@ -1140,7 +1191,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) { m_pShapeHelper->setHeight( nHeight ); } - double ConcreteXShapeGeometryAttributes::getWidth() + double ConcreteXShapeGeometryAttributes::getWidth() const { return m_pShapeHelper->getWidth(); } @@ -1156,7 +1207,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() ); } - double ShapeHelper::getHeight() + double ShapeHelper::getHeight() const { return Millimeter::getInPoints(xShape->getSize().Height); } @@ -1177,7 +1228,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getWidth() + double ShapeHelper::getWidth() const { return Millimeter::getInPoints(xShape->getSize().Width); } @@ -1197,7 +1248,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getLeft() + double ShapeHelper::getLeft() const { return Millimeter::getInPoints(xShape->getPosition().X); } @@ -1211,7 +1262,7 @@ void UserFormGeometryHelper::setHeight( double nHeight ) } - double ShapeHelper::getTop() + double ShapeHelper::getTop() const { return Millimeter::getInPoints(xShape->getPosition().Y); } @@ -1279,38 +1330,50 @@ void UserFormGeometryHelper::setHeight( double nHeight ) return points; } - uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) - { - uno::Reference< uno::XInterface > xIf; - if ( pShell ) - { - rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - BasicManager* pBasMgr = pShell->GetBasicManager(); - if ( pBasMgr && pBasMgr->GetName().Len() ) - sProj = pShell->GetBasicManager()->GetName(); - StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ); - if ( pBasic ) - { - SbModule* pMod = pBasic->FindModule( aModName ); - if ( pMod ) - xIf = pMod->GetUnoModule(); - } - } - return xIf; - } +uno::Reference< XHelperInterface > getVBADocument( const uno::Reference< frame::XModel >& xModel ) +{ + uno::Reference< XHelperInterface > xIf; + try + { + uno::Reference< beans::XPropertySet > xDocProps( xModel, uno::UNO_QUERY_THROW ); + ::rtl::OUString aCodeName; + xDocProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ) >>= aCodeName; + xIf = getUnoDocModule( aCodeName, getSfxObjShell( xModel ) ); + } + catch( uno::Exception& ) + { + } + return xIf; +} - SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) - { - SfxObjectShell* pFoundShell = NULL; - if ( xModel.is() ) - { - uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW ); - pFoundShell = reinterpret_cast( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); - } - if ( !pFoundShell ) - throw uno::RuntimeException(); - return pFoundShell; - } +uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) +{ + uno::Reference< XHelperInterface > xIf; + if ( pShell ) + { + rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + BasicManager* pBasMgr = pShell->GetBasicManager(); + if ( pBasMgr && pBasMgr->GetName().Len() ) + sProj = pBasMgr->GetName(); + if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) ) + if( SbModule* pMod = pBasic->FindModule( aModName ) ) + xIf.set( pMod->GetUnoModule(), uno::UNO_QUERY ); + } + return xIf; +} + +SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) +{ + SfxObjectShell* pFoundShell = NULL; + if ( xModel.is() ) + { + uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW ); + pFoundShell = reinterpret_cast( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); + } + if ( !pFoundShell ) + throw uno::RuntimeException(); + return pFoundShell; +} } // openoffice } //org diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx index 54546a394690..132caef8b5e1 100644 --- a/vbahelper/source/vbahelper/vbawindowbase.cxx +++ b/vbahelper/source/vbahelper/vbawindowbase.cxx @@ -24,137 +24,113 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include -#include -#include -#include + +#include "vbahelper/vbawindowbase.hxx" +#include "vbahelper/helperdecl.hxx" #include using namespace ::com::sun::star; using namespace ::ooo::vba; -VbaWindowBase::VbaWindowBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowBaseImpl_BASE( xParent, xContext ), m_xModel( xModel ) +VbaWindowBase::VbaWindowBase( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XModel >& xModel, + const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : + WindowBaseImpl_BASE( xParent, xContext ), + m_xModel( xModel, uno::UNO_SET_THROW ) { + construct( xController ); } -VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext ) - : WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), - m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) +VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, + uno::Reference< uno::XComponentContext > const & xContext ) throw (uno::RuntimeException) : + WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ), + m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) ) { + construct( getXSomethingFromArgs< frame::XController >( args, 2 ) ); } sal_Bool SAL_CALL VbaWindowBase::getVisible() throw (uno::RuntimeException) { - sal_Bool bVisible = sal_True; - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow2 > xWindow2 (xWindow, uno::UNO_QUERY_THROW ); - if( xWindow2.is() ) - { - bVisible = xWindow2->isVisible(); - } - return bVisible; + return getWindow2()->isVisible(); } void SAL_CALL -VbaWindowBase::setVisible(sal_Bool _visible) throw (uno::RuntimeException) +VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException) { - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - xWindow->setVisible( _visible ); - } + getWindow2()->setVisible( _visible ); } -css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel ) +void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 nFlag ) { - css::awt::Rectangle aRect; - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) + css::awt::Rectangle aRect = xWindow->getPosSize(); + switch( nFlag ) { - aRect = xWindow->getPosSize(); - } - return aRect; -} - -void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, sal_uInt16 nFlag ) -{ - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW ); - if( xWindow.is() ) - { - css::awt::Rectangle aRect = xWindow->getPosSize(); - switch( nFlag ) - { - case css::awt::PosSize::X: - xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X ); - break; - case css::awt::PosSize::Y: - xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y ); - break; - case css::awt::PosSize::WIDTH: - xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH ); - break; - case css::awt::PosSize::HEIGHT: - xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT ); - break; - default: - break; - } + case css::awt::PosSize::X: + xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X ); + break; + case css::awt::PosSize::Y: + xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y ); + break; + case css::awt::PosSize::WIDTH: + xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH ); + break; + case css::awt::PosSize::HEIGHT: + xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT ); + break; + default: + break; } } sal_Int32 SAL_CALL VbaWindowBase::getHeight() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Height; + return getWindow()->getPosSize().Height; } void SAL_CALL VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT); + setPosSize( getWindow(), _height, css::awt::PosSize::HEIGHT ); } sal_Int32 SAL_CALL VbaWindowBase::getLeft() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.X; + return getWindow()->getPosSize().X; } void SAL_CALL VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _left, css::awt::PosSize::X); + setPosSize( getWindow(), _left, css::awt::PosSize::X ); } + sal_Int32 SAL_CALL VbaWindowBase::getTop() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Y; + return getWindow()->getPosSize().Y; } void SAL_CALL VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _top, css::awt::PosSize::Y); + setPosSize( getWindow(), _top, css::awt::PosSize::Y ); } + sal_Int32 SAL_CALL VbaWindowBase::getWidth() throw (uno::RuntimeException) { - css::awt::Rectangle aRect = getPosSize(m_xModel); - return aRect.Width; + return getWindow()->getPosSize().Width; } void SAL_CALL VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException) { - setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH); + setPosSize( getWindow(), _width, css::awt::PosSize::WIDTH ); } rtl::OUString& @@ -175,3 +151,27 @@ VbaWindowBase::getServiceNames() } return aServiceNames; } + +uno::Reference< frame::XController > VbaWindowBase::getController() throw (css::uno::RuntimeException) +{ + return uno::Reference< frame::XController >( m_xController, uno::UNO_SET_THROW ); +} + +uno::Reference< awt::XWindow > VbaWindowBase::getWindow() throw (uno::RuntimeException) +{ + return uno::Reference< awt::XWindow >( m_xWindow, uno::UNO_SET_THROW ); +} + +uno::Reference< awt::XWindow2 > VbaWindowBase::getWindow2() throw (uno::RuntimeException) +{ + return uno::Reference< awt::XWindow2 >( getWindow(), uno::UNO_QUERY_THROW ); +} + +void VbaWindowBase::construct( const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) +{ + if( !xController.is() ) throw uno::RuntimeException(); + uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW ); + uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); + m_xController = xController; + m_xWindow = xWindow; +} From 096ce2de8d86c9d8aa3a626cabd839232279a1a9 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 11:30:09 +0100 Subject: [PATCH 70/85] calcvba: #164410# add MSForms.(Combo|Text)Box.TextLength symbols --- oovbaapi/ooo/vba/msforms/XComboBox.idl | 1 + oovbaapi/ooo/vba/msforms/XTextBox.idl | 1 + vbahelper/source/msforms/vbacombobox.cxx | 5 +++++ vbahelper/source/msforms/vbacombobox.hxx | 1 + vbahelper/source/msforms/vbatextbox.cxx | 5 +++++ vbahelper/source/msforms/vbatextbox.hxx | 1 + 6 files changed, 14 insertions(+) diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl index d4e57b2347a4..51ca4a4135d1 100644 --- a/oovbaapi/ooo/vba/msforms/XComboBox.idl +++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl @@ -48,6 +48,7 @@ interface XComboBox [attribute] long EnterFieldBehavior; [attribute] long ListStyle; [attribute] long TextAlign; + [attribute, readonly] long TextLength; [attribute, readonly] XNewFont Font; void AddItem( [in] any pvargItem, [in] any pvargIndex ); diff --git a/oovbaapi/ooo/vba/msforms/XTextBox.idl b/oovbaapi/ooo/vba/msforms/XTextBox.idl index 7ea6ca62898c..267fbf7f01cb 100644 --- a/oovbaapi/ooo/vba/msforms/XTextBox.idl +++ b/oovbaapi/ooo/vba/msforms/XTextBox.idl @@ -44,6 +44,7 @@ interface XTextBox [attribute] boolean Multiline; [attribute] long SpecialEffect; [attribute] long BorderStyle; + [attribute, readonly] long TextLength; [attribute, readonly] XNewFont Font; }; diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx index b0d1680e6101..9a75fa5cbaa1 100644 --- a/vbahelper/source/msforms/vbacombobox.cxx +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -230,6 +230,11 @@ void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno { } +sal_Int32 SAL_CALL ScVbaComboBox::getTextLength() throw (uno::RuntimeException) +{ + return getText().getLength(); +} + uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException) { return new VbaNewFont( this, mxContext, m_xProps ); diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx index 922f6f63ca62..c73b617a743b 100644 --- a/vbahelper/source/msforms/vbacombobox.hxx +++ b/vbahelper/source/msforms/vbacombobox.hxx @@ -70,6 +70,7 @@ public: virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException); virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx index c9e4381f449a..b6aedcdceaf6 100644 --- a/vbahelper/source/msforms/vbatextbox.cxx +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -133,6 +133,11 @@ void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw ( { } +sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException) +{ + return getText().getLength(); +} + uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException) { return new VbaNewFont( this, mxContext, m_xProps ); diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx index fb791db149e4..586bceb607a0 100644 --- a/vbahelper/source/msforms/vbatextbox.hxx +++ b/vbahelper/source/msforms/vbatextbox.hxx @@ -51,6 +51,7 @@ public: virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // XDefaultProperty rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } From ba0031d8347d861d983436da1e2dfa8fdb3ed92a Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 13:55:17 +0100 Subject: [PATCH 71/85] calcvba: #164410# change namespace --- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 2 +- vbahelper/source/vbahelper/vbadocumentbase.cxx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 6f782b629f40..5ae0a2c23890 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -392,7 +392,7 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) aArgs[ 0 ] <<= getCurrentDocument(); uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBE" ) ), aArgs, mxContext ); return uno::Any( xVBE ); } catch( uno::Exception& ) diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index b3053aa3d759..7bb6bab3b0be 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -270,13 +270,12 @@ VbaDocumentBase::getVBProject() throw (uno::RuntimeException) { uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW ); uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Any > aArgs( 3 ); + uno::Sequence< uno::Any > aArgs( 2 ); aArgs[ 0 ] <<= xVBE; // the VBE - aArgs[ 1 ] <<= xVBE; // parent of a VBA project is the VBE aArgs[ 2 ] <<= getModel(); // document model for script container access uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext ); + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBProject" ) ), aArgs, mxContext ); } catch( uno::Exception& ) { From 3df85af7421b3c459c36337797f7f6fb86cebc91 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 16:51:06 +0100 Subject: [PATCH 72/85] calcvba: sequence index typo --- vbahelper/source/vbahelper/vbadocumentbase.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 7bb6bab3b0be..291bc6ad2931 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -272,7 +272,7 @@ VbaDocumentBase::getVBProject() throw (uno::RuntimeException) uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW ); uno::Sequence< uno::Any > aArgs( 2 ); aArgs[ 0 ] <<= xVBE; // the VBE - aArgs[ 2 ] <<= getModel(); // document model for script container access + aArgs[ 1 ] <<= getModel(); // document model for script container access uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBProject" ) ), aArgs, mxContext ); From 620ecfa0dd997c747b45ba29da656353526ec0e2 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 19:01:51 +0100 Subject: [PATCH 73/85] calcvba: #164410# obviously, extractBoolFromAny should also check for boolean value... --- basic/source/comp/makefile.mk | 3 ++- vbahelper/source/vbahelper/vbahelper.cxx | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/basic/source/comp/makefile.mk b/basic/source/comp/makefile.mk index d65f6a431e43..1e17b35cde61 100644 --- a/basic/source/comp/makefile.mk +++ b/basic/source/comp/makefile.mk @@ -53,7 +53,8 @@ EXCEPTIONSFILES= \ $(SLO)$/codegen.obj \ $(SLO)$/dim.obj \ $(SLO)$/exprtree.obj \ - $(SLO)$/parser.obj + $(SLO)$/parser.obj \ + $(SLO)$/sbcomp.obj # --- Targets -------------------------------------------------------------- diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 827d387f031d..2a13124a741e 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -654,6 +654,8 @@ bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException) { switch( rAny.getValueType().getTypeClass() ) { + case uno::TypeClass_BOOLEAN: + return rAny.get< bool >(); case uno::TypeClass_FLOAT: return rAny.get< float >() != 0.0; case uno::TypeClass_DOUBLE: From 65d4580044ab82df5ef30f00875e98d61e000ae4 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Sun, 27 Mar 2011 22:08:02 +0200 Subject: [PATCH 74/85] mav60: #164341# use simple nss initialization in case mscrypto is used --- sfx2/source/appl/appopen.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 281a87c962f7..8b76024c1afb 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -288,8 +288,9 @@ private: } catch( const uno::Exception& ) { - // unknown error, do not try to ask again - eResult = ::comphelper::DocPasswordVerifierResult_ABORT; + // unknown error, report it as wrong password + // TODO/LATER: we need an additional way to report unknown problems in this case + eResult = ::comphelper::DocPasswordVerifierResult_WRONG_PASSWORD; } return eResult; } From 0398365fafa23bd9d8f8548654b7b068ad561ea5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: [PATCH 75/85] solaris11: #i117566#: gstreamer: Sun C++ complains: C callbacks not extern "C" --- avmedia/source/gstreamer/gstframegrabber.cxx | 3 + avmedia/source/gstreamer/gstplayer.cxx | 176 ++++++++++--------- avmedia/source/gstreamer/gstplayer.hxx | 29 +-- 3 files changed, 101 insertions(+), 107 deletions(-) diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index bd55e11f8afe..49a6d9695fbc 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -31,6 +31,9 @@ #include #include +#include + + using namespace ::com::sun::star; namespace avmedia { namespace gst { diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index f082cfc5c513..ba354fe5f274 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -66,6 +66,92 @@ struct GstBusSource : public GSource {} }; + +// ----------------------------------------------------------------------- +extern "C" +{ + +static gpointer +lcl_implThreadFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->run() : NULL ); +} + +static gboolean +lcl_implBusCheck( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + return( pBusSource && + GST_IS_BUS( pBusSource->mpBus ) && + gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); +} + + +static gboolean +lcl_implBusPrepare( GSource* pSource, gint* pTimeout ) +{ + if (pTimeout) + { + *pTimeout = 0; + } + + return lcl_implBusCheck(pSource); +} + +static gboolean +lcl_implBusDispatch( GSource* pSource, + GSourceFunc /*aCallback*/, + gpointer pData ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + gboolean bRet = false; + + if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) + { + GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); + + if( pMsg ) + { + bRet = static_cast< Player* >( pData )->busCallback( + pBusSource->mpBus, pMsg ); + gst_message_unref( pMsg ); + } + } + + return( bRet ); +} + +static void +lcl_implBusFinalize( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + if( pBusSource && pBusSource->mpBus ) + { + gst_object_unref( pBusSource->mpBus ); + pBusSource->mpBus = NULL; + } +} + +static gboolean +lcl_implIdleFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->idle() : true ); +} + +static GstBusSyncReply +lcl_implHandleCreateWindowFunc( GstBus* pBus, GstMessage* pMsg, gpointer pData ) +{ + return (pData) + ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) + : GST_BUS_PASS; +} + +} // extern "C" + + + // --------------- // - Player - // --------------- @@ -102,7 +188,7 @@ Player::Player( GString* pURI ) : OSL_TRACE( ">>> --------------------------------" ); OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); - mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + mpThread = g_thread_create( &lcl_implThreadFunc, this, true, NULL ); } } @@ -572,62 +658,6 @@ bool Player::implInitPlayer() return( bRet ); } -// ------------------------------------------------------------------------------ -gboolean Player::implBusPrepare( GSource* pSource, - gint* pTimeout ) -{ - if( pTimeout ) - { - *pTimeout = 0; - } - - return( implBusCheck( pSource ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusCheck( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - return( pBusSource && - GST_IS_BUS( pBusSource->mpBus ) && - gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusDispatch( GSource* pSource, - GSourceFunc /*aCallback*/, - gpointer pData ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - gboolean bRet = false; - - if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) - { - GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); - - if( pMsg ) - { - bRet = static_cast< Player* >( pData )->busCallback( pBusSource->mpBus, pMsg ); - gst_message_unref( pMsg ); - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ -void Player::implBusFinalize( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - if( pBusSource && pBusSource->mpBus ) - { - gst_object_unref( pBusSource->mpBus ); - pBusSource->mpBus = NULL; - } -} - // ------------------------------------------------------------------------------ gboolean Player::busCallback( GstBus* /*pBus*/, GstMessage* pMsg ) @@ -673,26 +703,6 @@ gboolean Player::busCallback( GstBus* /*pBus*/, return( true ); } -// ------------------------------------------------------------------------------ -gboolean Player::implIdleFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->idle() : true ); -} - -// ------------------------------------------------------------------------------ -gpointer Player::implThreadFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->run() : NULL ); -} - -// ------------------------------------------------------------------------------ -GstBusSyncReply Player::implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) : GST_BUS_PASS ); -} - // ------------------------------------------------------------------------------ void Player::implHandleNewElementFunc( GstBin* /* pBin */, GstElement* pElement, @@ -824,10 +834,10 @@ gpointer Player::run() { static GSourceFuncs aSourceFuncs = { - Player::implBusPrepare, - Player::implBusCheck, - Player::implBusDispatch, - Player::implBusFinalize, + &lcl_implBusPrepare, + &lcl_implBusCheck, + &lcl_implBusDispatch, + &lcl_implBusFinalize, NULL, NULL }; @@ -842,7 +852,7 @@ gpointer Player::run() // add idle callback GSource* pIdleSource = g_idle_source_new(); - g_source_set_callback( pIdleSource, Player::implIdleFunc, this, NULL ); + g_source_set_callback( pIdleSource, &lcl_implIdleFunc, this, NULL ); g_source_attach( pIdleSource, mpContext ); // add bus callback @@ -853,7 +863,7 @@ gpointer Player::run() // add bus sync handler to intercept video window creation for setting our own window gst_bus_set_sync_handler( static_cast< GstBusSource* >( pBusSource )->mpBus, - Player::implHandleCreateWindowFunc, this ); + &lcl_implHandleCreateWindowFunc, this ); // watch for all elements (and pads) that will be added to the playbin, // in order to retrieve properties like video width and height diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index d751e381258d..0793eaf8caf2 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -149,11 +149,7 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); - -protected: - - Player( GString* pURI = NULL ); - +// these are public because the C callbacks call them virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -164,6 +160,10 @@ protected: virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, GstMessage* pMsg ); +protected: + + Player( GString* pURI = NULL ); + void implQuitThread(); bool implInitPlayer(); @@ -180,25 +180,6 @@ private: Player& operator=( const Player& ); - static gboolean implBusPrepare( GSource* pSource, - gint* pTimeout ); - - static gboolean implBusCheck( GSource* pSource ); - - static gboolean implBusDispatch( GSource* pSource, - GSourceFunc aCallback, - gpointer pData ); - - static void implBusFinalize( GSource* pSource ); - - static gboolean implIdleFunc( gpointer pData ); - - static gpointer implThreadFunc( gpointer pData ); - - static GstBusSyncReply implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pDData ); - static void implHandleNewElementFunc( GstBin* pBin, GstElement* pElement, gpointer pData ); From b33afb6c8b7410bf299941f9d52f5cc558df3fd4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: [PATCH 76/85] solaris11: #i117566#: gstreamer: Sun C++ complains about bogus atomic int abuse --- avmedia/source/gstreamer/gstplayer.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index ba354fe5f274..614ff80ce352 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -415,10 +415,14 @@ double SAL_CALL Player::getRate() void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { - if( bSet && !isPlaybackLoop() ) - g_atomic_int_inc( &mnLooping ); - else if( !bSet && isPlaybackLoop() ) - g_atomic_int_dec_and_test( &mnLooping ); + if (bSet) + { + g_atomic_int_compare_and_exchange(&mnLooping, 0, 1); + } + else + { + g_atomic_int_compare_and_exchange(&mnLooping, 1, 0); + } } // ------------------------------------------------------------------------------ @@ -810,16 +814,12 @@ void Player::implHandleNewPadFunc( GstElement* pElement, // ------------------------------------------------------------------------------ gboolean Player::idle() { - // test if main loop should quit and set flag mnQuit to 1 - bool bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 1 ); + // test if main loop should quit by comparing with 1 + // and set flag mnQuit to 0 so we call g_main_loop_quit exactly once + bool const bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 0 ); if( bQuit ) { - // set mnQuit back to 0 to avoid mutiple g_main_loop_quit calls - // in case Player::idle() is called again later; - // the flag should have been set only once within Ctor called from - // the application thread - g_atomic_int_dec_and_test( &mnQuit ); g_main_loop_quit( mpLoop ); } From c4de82c9a636e4c8e91cab392e5a1a17e6ee8677 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: [PATCH 77/85] solaris11: #i117566#: gstreamer: checkdll does not work for libavmedia_gst.so --- avmedia/source/gstreamer/makefile.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk index c648fcc77f89..857c5914b094 100644 --- a/avmedia/source/gstreamer/makefile.mk +++ b/avmedia/source/gstreamer/makefile.mk @@ -62,6 +62,8 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def +# on Solaris checkdll does not work: LD_LIBRARY_PATH breaks the 2 libxml2.so.2 +SHL1NOCHECK=t DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp From bff405512c43fc473a4a9041b203560143b9f15d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:18 +0000 Subject: [PATCH 78/85] solaris11: gvfs: should not abort via g_error (also causes Sun C++ warning) --- ucb/source/ucp/gvfs/gvfs_content.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucb/source/ucp/gvfs/gvfs_content.cxx b/ucb/source/ucp/gvfs/gvfs_content.cxx index 3b1d726f9304..666c0616ba0e 100644 --- a/ucb/source/ucp/gvfs/gvfs_content.cxx +++ b/ucb/source/ucp/gvfs/gvfs_content.cxx @@ -1177,7 +1177,7 @@ uno::Any Content::mapVFSException( const GnomeVFSResult result, sal_Bool bWrite switch (result) { case GNOME_VFS_OK: - g_error ("VFS_OK mapped to exception."); + g_warning("VFS_OK mapped to exception."); break; case GNOME_VFS_ERROR_EOF: g_warning ("VFS_EOF not handled somewhere."); From 851d6112c1e3b09ebeae211b6b997bffad6461e3 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 28 Mar 2011 12:43:38 +0200 Subject: [PATCH 79/85] calcvba: try to extract different types as numeric index --- vbahelper/source/vbahelper/collectionbase.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vbahelper/source/vbahelper/collectionbase.cxx b/vbahelper/source/vbahelper/collectionbase.cxx index 7a99aabecdf8..16fc673f54d5 100755 --- a/vbahelper/source/vbahelper/collectionbase.cxx +++ b/vbahelper/source/vbahelper/collectionbase.cxx @@ -314,11 +314,10 @@ uno::Any CollectionBase::getAnyItemOrThis( const uno::Any& rIndex ) throw (uno:: { if( !rIndex.hasValue() ) return uno::Any( uno::Reference< XCollectionBase >( this ) ); - if( rIndex.has< sal_Int32 >() ) - return getItemByIndex( rIndex.get< sal_Int32 >() ); if( rIndex.has< ::rtl::OUString >() ) return getItemByName( rIndex.get< ::rtl::OUString >() ); - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item index." ) ), 0 ); + // extractIntFromAny() throws if no index can be extracted + return getItemByIndex( extractIntFromAny( rIndex ) ); } // protected ------------------------------------------------------------------ From a11f433a956f0176643391e7c945b008ca91d9bf Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 30 Mar 2011 08:27:21 +0000 Subject: [PATCH 80/85] solaris11: #i117606#: framework: move imagesconfiguration.{c,h}xx to libfwk --- framework/Library_fwe.mk | 2 -- framework/Library_fwk.mk | 2 ++ framework/Package_inc.mk | 1 - .../inc/{framework => xml}/imagesconfiguration.hxx | 14 +++++++------- framework/inc/xml/imagesdocumenthandler.hxx | 8 +++----- framework/source/uiconfiguration/imagemanager.cxx | 3 ++- .../source/uiconfiguration/imagemanagerimpl.cxx | 3 ++- .../source/uiconfiguration/moduleimagemanager.cxx | 3 ++- .../source/{fwe => }/xml/imagesconfiguration.cxx | 5 ++--- .../source/{fwe => }/xml/imagesdocumenthandler.cxx | 0 10 files changed, 20 insertions(+), 21 deletions(-) rename framework/inc/{framework => xml}/imagesconfiguration.hxx (93%) rename framework/source/{fwe => }/xml/imagesconfiguration.cxx (98%) rename framework/source/{fwe => }/xml/imagesdocumenthandler.cxx (100%) diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk index 5d30d108cde6..408a514c2f06 100644 --- a/framework/Library_fwe.mk +++ b/framework/Library_fwe.mk @@ -83,8 +83,6 @@ $(eval $(call gb_Library_add_exception_objects,fwe,\ framework/source/fwe/interaction/preventduplicateinteraction \ framework/source/fwe/xml/eventsconfiguration \ framework/source/fwe/xml/eventsdocumenthandler \ - framework/source/fwe/xml/imagesconfiguration \ - framework/source/fwe/xml/imagesdocumenthandler \ framework/source/fwe/xml/menuconfiguration \ framework/source/fwe/xml/menudocumenthandler \ framework/source/fwe/xml/saxnamespacefilter \ diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index a34a1bc59720..3953d129afc2 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -183,6 +183,8 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ framework/source/uifactory/windowcontentfactorymanager \ framework/source/xml/acceleratorconfigurationreader \ framework/source/xml/acceleratorconfigurationwriter \ + framework/source/xml/imagesconfiguration \ + framework/source/xml/imagesdocumenthandler \ )) # vim: set noet sw=4 ts=4: diff --git a/framework/Package_inc.mk b/framework/Package_inc.mk index 6d1c03a5975b..d72dd52128b8 100644 --- a/framework/Package_inc.mk +++ b/framework/Package_inc.mk @@ -39,7 +39,6 @@ $(eval $(call gb_Package_add_file,framework_inc,inc/framework/undomanagerhelper. $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imutex.hxx,framework/imutex.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/iguard.hxx,framework/iguard.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imageproducer.hxx,framework/imageproducer.hxx)) -$(eval $(call gb_Package_add_file,framework_inc,inc/framework/imagesconfiguration.hxx,framework/imagesconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/interaction.hxx,framework/interaction.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuconfiguration.hxx,framework/menuconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuextensionsupplier.hxx,framework/menuextensionsupplier.hxx)) diff --git a/framework/inc/framework/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx similarity index 93% rename from framework/inc/framework/imagesconfiguration.hxx rename to framework/inc/xml/imagesconfiguration.hxx index 0771e2d8f7f1..3174e6d51b22 100644 --- a/framework/inc/framework/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ -#define __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ +#ifndef FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ +#define FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ #include #include @@ -50,7 +50,7 @@ enum ImageMaskMode ImageMaskMode_Bitmap }; -struct FWE_DLLPUBLIC ImageItemDescriptor +struct ImageItemDescriptor { ImageItemDescriptor() : nIndex( -1 ) {} @@ -58,7 +58,7 @@ struct FWE_DLLPUBLIC ImageItemDescriptor long nIndex; // index of the bitmap inside the bitmaplist }; -struct FWE_DLLPUBLIC ExternalImageItemDescriptor +struct ExternalImageItemDescriptor { String aCommandURL; // URL command to dispatch String aURL; // a URL to an external bitmap @@ -70,7 +70,7 @@ SV_DECL_PTRARR_DEL( ImageItemListDescriptor, ImageItemDescriptorPtr, 10, 2) typedef ExternalImageItemDescriptor* ExternalImageItemDescriptorPtr; SV_DECL_PTRARR_DEL( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr, 10, 2) -struct FWE_DLLPUBLIC ImageListItemDescriptor +struct ImageListItemDescriptor { ImageListItemDescriptor() : nMaskMode( ImageMaskMode_Color ), pImageItemList( 0 ) {} @@ -89,7 +89,7 @@ struct FWE_DLLPUBLIC ImageListItemDescriptor typedef ImageListItemDescriptor* ImageListItemDescriptorPtr; SV_DECL_PTRARR_DEL( ImageListDescriptor, ImageListItemDescriptorPtr, 10, 2) -struct FWE_DLLPUBLIC ImageListsDescriptor +struct ImageListsDescriptor { ImageListsDescriptor() : pImageList( 0 ), pExternalImageList( 0 ) {} @@ -99,7 +99,7 @@ struct FWE_DLLPUBLIC ImageListsDescriptor ExternalImageItemListDescriptor* pExternalImageList; }; -class FWE_DLLPUBLIC ImagesConfiguration +class ImagesConfiguration { public: // #110897# diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 59d1e4abdb3a..4aa370c013d7 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ -#define __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#ifndef FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ #include @@ -34,14 +34,12 @@ // interface includes //_________________________________________________________________________________________________________________ -#ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ #include -#endif //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include +#include #include #include #include diff --git a/framework/source/uiconfiguration/imagemanager.cxx b/framework/source/uiconfiguration/imagemanager.cxx index 2a57e72e1ce4..776af9982de4 100644 --- a/framework/source/uiconfiguration/imagemanager.cxx +++ b/framework/source/uiconfiguration/imagemanager.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include -#include +#include #include #include #include "imagemanagerimpl.hxx" diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 537fe623d633..d0caee82297e 100755 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include -#include +#include #include #include diff --git a/framework/source/uiconfiguration/moduleimagemanager.cxx b/framework/source/uiconfiguration/moduleimagemanager.cxx index fc90dd102912..0e0f828a253f 100644 --- a/framework/source/uiconfiguration/moduleimagemanager.cxx +++ b/framework/source/uiconfiguration/moduleimagemanager.cxx @@ -27,10 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include #include -#include +#include #include #include #include "imagemanagerimpl.hxx" diff --git a/framework/source/fwe/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx similarity index 98% rename from framework/source/fwe/xml/imagesconfiguration.cxx rename to framework/source/xml/imagesconfiguration.cxx index d561a76d5995..946b5b9d0f11 100644 --- a/framework/source/fwe/xml/imagesconfiguration.cxx +++ b/framework/source/xml/imagesconfiguration.cxx @@ -27,12 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" -#include + +#include #include -#ifndef __FRAMEWORK_CLASSES_IMAGESDOCUMENTHANDLER_HXX_ #include -#endif #include //_________________________________________________________________________________________________________________ diff --git a/framework/source/fwe/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx similarity index 100% rename from framework/source/fwe/xml/imagesdocumenthandler.cxx rename to framework/source/xml/imagesdocumenthandler.cxx From 17f6bf991346c40491d80a4a8869871c2d39f3b6 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Wed, 30 Mar 2011 11:04:52 +0200 Subject: [PATCH 81/85] calcvba: disable basic tracing by default --- basic/source/inc/sbtrace.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx index 4fd139202b52..6ab27050d263 100755 --- a/basic/source/inc/sbtrace.hxx +++ b/basic/source/inc/sbtrace.hxx @@ -28,7 +28,7 @@ #ifndef _SBTRACE_HXX #define _SBTRACE_HXX -#define DBG_TRACE_BASIC +//#define DBG_TRACE_BASIC // ############################################################################### // ### From 5a21dc127aba1a95b40a28e73c08220f80476541 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Wed, 30 Mar 2011 13:17:45 +0200 Subject: [PATCH 82/85] calcvba: missing include --- basic/source/comp/sbcomp.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 49c025a9e0a4..1b3395b70526 100755 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -33,7 +33,7 @@ #include "image.hxx" #include "sbtrace.hxx" #include - +#include //========================================================================== // Tracing, for debugging only From b6ef8202ec04395921c691f1d243474470d1ed1d Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 4 Apr 2011 13:05:00 +0200 Subject: [PATCH 83/85] masterfix DEV300: #i10000# build fix --- desktop/source/deployment/dp_services.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index f3dc75ae39c5..c302d1d1cc42 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -84,8 +84,6 @@ bool singleton_entries( uno::Reference const& ); extern "C" { -struct uno_Environment; - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ) { From 776de14da77af214201eba74e53ec5b1896a114b Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 4 Apr 2011 15:07:20 +0200 Subject: [PATCH 84/85] masterfix DEV300: #i10000# header cleanup --- framework/inc/xml/imagesdocumenthandler.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 4aa370c013d7..dd6201b5b9e3 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -57,7 +57,7 @@ namespace framework{ //***************************************************************************************************************** // Hash code function for using in all hash maps of follow implementation. -class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. +class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > { public: @@ -158,7 +158,7 @@ class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // S ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; }; -class FWE_DLLPUBLIC OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. +class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. { public: OWriteImagesDocumentHandler( From 86e7ed8c72184b7a04b836848743979aa3f5fd3d Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 4 Apr 2011 17:05:53 +0200 Subject: [PATCH 85/85] masterfix DEV300: #i10000# smoketest assertion fix --- framework/source/uielement/menubarmanager.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index a74fbabb271e..9df04fa17ab4 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1813,14 +1813,10 @@ void MenuBarManager::FillMenu( pMenu->SetItemBits( nId, nBits ); } - if ( bShow ) - pMenu->ShowItem( nId ); - else + if ( !bShow ) pMenu->HideItem( nId ); - if ( bEnabled) - pMenu->EnableItem( nId, sal_True ); - else + if ( !bEnabled) pMenu->EnableItem( nId, sal_False ); if ( xIndexContainer.is() )