diff options
159 files changed, 3773 insertions, 1732 deletions
diff --git a/chart2/prj/d.lst b/chart2/prj/d.lst index 440e2efbe8c5..bf1085336c05 100644 --- a/chart2/prj/d.lst +++ b/chart2/prj/d.lst @@ -21,3 +21,7 @@ mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\schart\statusbar ..\uiconfig\statusbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\schart\statusbar\*.xml mkdir: %_DEST%\inc%_EXT%\chart2 +..\%__SRC%\misc\chartcontroller.component %_DEST%\xml%_EXT%\chartcontroller.component +..\%__SRC%\misc\chartmodel.component %_DEST%\xml%_EXT%\chartmodel.component +..\%__SRC%\misc\charttools.component %_DEST%\xml%_EXT%\charttools.component +..\%__SRC%\misc\chartview.component %_DEST%\xml%_EXT%\chartview.component diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index ffc1e95ca796..1b0d8fb4889c 100755 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -52,17 +52,6 @@ namespace chart namespace wrapper { -namespace -{ - -rtl::OUString lcl_getCIDForDiagram( const Reference< frame::XModel >& xChartModel ) -{ - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - return ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xChartModel ); -} - -} //anonymous namespace - Chart2ModelContact::Chart2ModelContact( const Reference< uno::XComponentContext > & xContext ) : m_xContext( xContext ), diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index a3e8eec763b2..e8d91cd6c124 100755 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -239,14 +239,14 @@ void lcl_AddPropertiesToVector( Property( C2U( "DisableComplexChartTypes" ), PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); rOutProperties.push_back( Property( C2U( "DisableDataTableDialog" ), PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); } struct StaticChartDocumentWrapperPropertyArray_Initializer diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 19e7d5b2dcd4..c174614a0bf3 100755 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -750,20 +750,19 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { - if( aPosition.X < 0 || aPosition.Y < 0 || aPosition.X > 1 || aPosition.Y > 1 ) - { - DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); - return; - } - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); chart2::RelativePosition aRelativePosition; aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) + { + DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); + return; + } xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) ); } diff --git a/chart2/source/controller/chartcontroller.component b/chart2/source/controller/chartcontroller.component new file mode 100644 index 000000000000..fc99913b5a74 --- /dev/null +++ b/chart2/source/controller/chartcontroller.component @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.chart.ElementSelectorToolbarController"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ChartController"> + <service name="com.sun.star.chart2.ChartController"/> + <service name="com.sun.star.frame.Controller"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ChartDocumentWrapper"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart.ChartDocument"/> + <service name="com.sun.star.chart2.ChartDocumentWrapper"/> + <service name="com.sun.star.xml.UserDefinedAttributeSupplier"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ChartFrameLoader"> + <service name="com.sun.star.frame.SynchronousFrameLoader"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ChartTypeDialog"> + <service name="com.sun.star.chart2.ChartTypeDialog"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ShapeToolbarController"> + <service name="com.sun.star.chart2.ShapeToolbarController"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.WizardDialog"> + <service name="com.sun.star.chart2.WizardDialog"/> + </implementation> +</component> diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index eeeba4dda226..eedd2e3c6ba9 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -41,6 +41,7 @@ #include "CommonFunctors.hxx" #include "ControllerLockGuard.hxx" #include "ChartTypeHelper.hxx" +#include "ThreeDHelper.hxx" #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/chart2/AxisType.hpp> @@ -524,6 +525,9 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( try { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + sal_Int32 nSeriesInChartType = 0; const sal_Int32 nTotalSeries = countSeries(); if( xChartType.is()) @@ -539,7 +543,7 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( xChartType, nTotalSeries, // new series' index nSeriesInChartType, - m_xChartDocument->getFirstDiagram(), + xDiagram, m_xTemplate, bCreateDataCachedSequences )); @@ -560,6 +564,8 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( aSeries.insert( aIt, xNewSeries ); xSeriesCnt->setDataSeries( ContainerToSequence( aSeries )); } + + ThreeDHelper::setScheme( xDiagram, e3DScheme ); } catch( uno::Exception & ex ) { @@ -693,14 +699,19 @@ bool DialogModel::setData( m_xTemplate->getDataInterpreter()); if( xInterpreter.is()) { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + ::std::vector< Reference< XDataSeries > > aSeriesToReUse( - DiagramHelper::getDataSeriesFromDiagram( m_xChartDocument->getFirstDiagram())); + DiagramHelper::getDataSeriesFromDiagram( xDiagram )); applyInterpretedData( xInterpreter->interpretDataSource( xDataSource, rArguments, ContainerToSequence( aSeriesToReUse )), aSeriesToReUse, true /* bSetStyles */); + + ThreeDHelper::setScheme( xDiagram, e3DScheme ); } } catch( uno::Exception & ex ) diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index cddc1850eb40..330596f803f8 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -826,16 +826,14 @@ bool ChartController::executeDispatch_Delete() else { //remove additional shape - uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() ); - if( xShape.is() ) + impl_ClearSelection(); { - impl_ClearSelection(); + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( m_pDrawViewWrapper ) { - ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); - if( m_pDrawViewWrapper ) - m_pDrawViewWrapper->UnmarkAll(); + m_pDrawViewWrapper->DeleteMarked(); + bReturn = true; } - bReturn = DrawModelWrapper::removeShape( xShape ); } } return bReturn; diff --git a/chart2/source/controller/main/_serviceregistration_controller.cxx b/chart2/source/controller/main/_serviceregistration_controller.cxx index cf8f5525e624..0371f50f9996 100644 --- a/chart2/source/controller/main/_serviceregistration_controller.cxx +++ b/chart2/source/controller/main/_serviceregistration_controller.cxx @@ -108,13 +108,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries_chart2_controller ); -} -//================================================================================================== SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk index b8a256181045..fbc888f38c3f 100644 --- a/chart2/source/controller/makefile.mk +++ b/chart2/source/controller/makefile.mk @@ -126,3 +126,11 @@ RESLIB1DEPN=$(RESLIB1LIST) # --- Targets ----------------------------------------------------------------- .INCLUDE: target.mk + +ALLTAR : $(MISC)/chartcontroller.component + +$(MISC)/chartcontroller.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt chartcontroller.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt chartcontroller.component diff --git a/chart2/source/inc/exports.dxp b/chart2/source/inc/exports.dxp index 9630d7e06768..f0e1c69934bc 100644 --- a/chart2/source/inc/exports.dxp +++ b/chart2/source/inc/exports.dxp @@ -1,3 +1,2 @@ component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/chart2/source/model/chartmodel.component b/chart2/source/model/chartmodel.component new file mode 100644 index 000000000000..fa26e51ac401 --- /dev/null +++ b/chart2/source/model/chartmodel.component @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.chart.AreaChartType"> + <service name="com.sun.star.chart2.AreaChartType"/> + <service name="com.sun.star.chart2.ChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.BarChartType"> + <service name="com.sun.star.chart2.BarChartType"/> + <service name="com.sun.star.chart2.ChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.BubbleChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.BubbleChartType"/> + <service name="com.sun.star.chart2.ChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.CandleStickChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.CandleStickChartType"/> + <service name="com.sun.star.chart2.ChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.ChartTypeManager"> + <service name="com.sun.star.chart2.ChartTypeManager"/> + </implementation> + <implementation name="com.sun.star.comp.chart.ColumnChartType"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.ColumnChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.DataSeries"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.DataPointProperties"/> + <service name="com.sun.star.chart2.DataSeries"/> + </implementation> + <implementation name="com.sun.star.comp.chart.FilledNetChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.FilledNetChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.FormattedString"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.FormattedString"/> + </implementation> + <implementation name="com.sun.star.comp.chart.LineChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.LineChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.NetChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.NetChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.PieChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.PieChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.ScatterChartType"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.ScatterChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.Axis"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.Axis"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.CartesianCoordinateSystem2d"> + <service name="com.sun.star.chart2.CartesianCoordinateSystem2d"/> + <service name="com.sun.star.chart2.CoordinateSystems.Cartesian"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.CartesianCoordinateSystem3d"> + <service name="com.sun.star.chart2.CartesianCoordinateSystem3d"/> + <service name="com.sun.star.chart2.CoordinateSystems.Cartesian"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ChartModel"> + <service name="com.sun.star.chart.ChartDocument"/> + <service name="com.sun.star.chart2.ChartDocument"/> + <service name="com.sun.star.document.OfficeDocument"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.Diagram"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.Diagram"/> + <service name="com.sun.star.layout.LayoutElement"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.GridProperties"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.GridProperties"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.Legend"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.Legend"/> + <service name="com.sun.star.drawing.FillProperties"/> + <service name="com.sun.star.drawing.LineProperties"/> + <service name="com.sun.star.layout.LayoutElement"/> + <service name="com.sun.star.style.CharacterProperties"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.PageBackground"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.PageBackground"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.PolarCoordinateSystem2d"> + <service name="com.sun.star.chart2.CoordinateSystems.Polar"/> + <service name="com.sun.star.chart2.PolarCoordinateSystem2d"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.PolarCoordinateSystem3d"> + <service name="com.sun.star.chart2.CoordinateSystems.Polar"/> + <service name="com.sun.star.chart2.PolarCoordinateSystem3d"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.Title"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.Title"/> + <service name="com.sun.star.layout.LayoutElement"/> + <service name="com.sun.star.style.ParagraphProperties"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.XMLFilter"> + <service name="com.sun.star.document.ExportFilter"/> + <service name="com.sun.star.document.ImportFilter"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.report.XMLFilter"> + <service name="com.sun.star.document.ExportFilter"/> + <service name="com.sun.star.document.ImportFilter"/> + </implementation> +</component> diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index cb124d6a57d2..0cd293354d7d 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -1053,6 +1053,7 @@ void SAL_CALL ChartModel::setVisualAreaSize( ::sal_Int64 nAspect, const awt::Siz { if( nAspect == embed::Aspects::MSOLE_CONTENT ) { + ControllerLockGuard aLockGuard( this ); bool bChanged = (m_aVisualAreaSize.Width != aSize.Width || m_aVisualAreaSize.Height != aSize.Height); diff --git a/chart2/source/model/main/_serviceregistration_model.cxx b/chart2/source/model/main/_serviceregistration_model.cxx index b0a7739008ad..a8b214aaf124 100755 --- a/chart2/source/model/main/_serviceregistration_model.cxx +++ b/chart2/source/model/main/_serviceregistration_model.cxx @@ -193,16 +193,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return (::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries_chart2_model ) && - ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, - ChartTypeEntriesForServiceRegistration::getImplementationEntries() )); -} -//================================================================================================== SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/chart2/source/model/makefile.mk b/chart2/source/model/makefile.mk index dfb5522a7879..52cc85c10904 100644 --- a/chart2/source/model/makefile.mk +++ b/chart2/source/model/makefile.mk @@ -98,3 +98,11 @@ DEF1NAME= $(SHL1TARGET) # --- Targets ----------------------------------------------------------------- .INCLUDE: target.mk + +ALLTAR : $(MISC)/chartmodel.component + +$(MISC)/chartmodel.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + chartmodel.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt chartmodel.component diff --git a/chart2/source/tools/_serviceregistration_tools.cxx b/chart2/source/tools/_serviceregistration_tools.cxx index 387b87dfab5a..3b1271921ede 100755 --- a/chart2/source/tools/_serviceregistration_tools.cxx +++ b/chart2/source/tools/_serviceregistration_tools.cxx @@ -183,13 +183,6 @@ OOO_DLLPUBLIC_CHARTTOOLS void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -OOO_DLLPUBLIC_CHARTTOOLS sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries_chart2_tools ); -} -//================================================================================================== OOO_DLLPUBLIC_CHARTTOOLS void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/chart2/source/tools/charttools.component b/chart2/source/tools/charttools.component new file mode 100644 index 000000000000..7ca499a7ba80 --- /dev/null +++ b/chart2/source/tools/charttools.component @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.chart2.ExponentialScaling"> + <service name="com.sun.star.chart2.ExponentialScaling"/> + </implementation> + <implementation name="com.sun.star.chart2.LinearScaling"> + <service name="com.sun.star.chart2.LinearScaling"/> + </implementation> + <implementation name="com.sun.star.chart2.LogarithmicScaling"> + <service name="com.sun.star.chart2.LogarithmicScaling"/> + </implementation> + <implementation name="com.sun.star.chart2.PowerScaling"> + <service name="com.sun.star.chart2.PowerScaling"/> + </implementation> + <implementation name="com.sun.star.comp.chart.CachedDataSequence"> + <service name="com.sun.star.chart2.data.DataSequence"/> + <service name="com.sun.star.chart2.data.NumericalDataSequence"/> + <service name="com.sun.star.chart2.data.TextualDataSequence"/> + <service name="com.sun.star.comp.chart.CachedDataSequence"/> + </implementation> + <implementation name="com.sun.star.comp.chart.DataSource"> + <service name="com.sun.star.chart2.data.DataSource"/> + </implementation> + <implementation name="com.sun.star.comp.chart.InternalDataProvider"> + <service name="com.sun.star.chart2.data.DataProvider"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ConfigDefaultColorScheme"> + <service name="com.sun.star.chart2.ColorScheme"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ErrorBar"> + <service name="com.sun.star.chart2.ErrorBar"/> + <service name="com.sun.star.comp.chart2.ErrorBar"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.ExponentialRegressionCurve"> + <service name="com.sun.star.chart2.ExponentialRegressionCurve"/> + <service name="com.sun.star.chart2.RegressionCurve"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.LabeledDataSequence"> + <service name="com.sun.star.chart2.data.LabeledDataSequence"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.LinearRegressionCurve"> + <service name="com.sun.star.chart2.LinearRegressionCurve"/> + <service name="com.sun.star.chart2.RegressionCurve"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.LogarithmicRegressionCurve"> + <service name="com.sun.star.chart2.LogarithmicRegressionCurve"/> + <service name="com.sun.star.chart2.RegressionCurve"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.MeanValueRegressionCurve"> + <service name="com.sun.star.chart2.MeanValueRegressionCurve"/> + <service name="com.sun.star.chart2.RegressionCurve"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.PotentialRegressionCurve"> + <service name="com.sun.star.chart2.PotentialRegressionCurve"/> + <service name="com.sun.star.chart2.RegressionCurve"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.RegressionEquation"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.RegressionEquation"/> + <service name="com.sun.star.drawing.FillProperties"/> + <service name="com.sun.star.drawing.LineProperties"/> + <service name="com.sun.star.style.CharacterProperties"/> + </implementation> +</component> diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk index 2f990af7adb0..fd92b894bfab 100644 --- a/chart2/source/tools/makefile.mk +++ b/chart2/source/tools/makefile.mk @@ -187,3 +187,11 @@ $(MISC)$/$(SHL1TARGET).flt: makefile.mk \ exports.flt $(TYPE) exports.flt > $@ + +ALLTAR : $(MISC)/charttools.component + +$(MISC)/charttools.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + charttools.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt charttools.component diff --git a/chart2/source/view/chartview.component b/chart2/source/view/chartview.component new file mode 100644 index 000000000000..773666150651 --- /dev/null +++ b/chart2/source/view/chartview.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.chart2.ChartView"> + <service name="com.sun.star.chart2.ChartView"/> + </implementation> +</component> diff --git a/chart2/source/view/main/_serviceregistration_view.cxx b/chart2/source/view/main/_serviceregistration_view.cxx index 26f8b9d7cf7e..2f7e3db441e1 100644 --- a/chart2/source/view/main/_serviceregistration_view.cxx +++ b/chart2/source/view/main/_serviceregistration_view.cxx @@ -54,13 +54,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries_chart2_view ); -} -//================================================================================================== SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/chart2/source/view/makefile.mk b/chart2/source/view/makefile.mk index aa3c149a768f..0b54ac976ad2 100644 --- a/chart2/source/view/makefile.mk +++ b/chart2/source/view/makefile.mk @@ -118,3 +118,11 @@ DEF1DES= Viewable Component Chart View $(MISC)$/$(SHL1TARGET).flt: makefile.mk \ exports.flt $(TYPE) exports.flt > $@ + +ALLTAR : $(MISC)/chartview.component + +$(MISC)/chartview.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + chartview.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt chartview.component diff --git a/sc/addin/inc/addin.h b/sc/addin/inc/addin.h index 419d0e3a59db..82b84b402294 100644 --- a/sc/addin/inc/addin.h +++ b/sc/addin/inc/addin.h @@ -67,18 +67,11 @@ typedef enum NONE } ParamType; -#ifndef WIN #ifdef WNT #define CALLTYPE __cdecl #else #define CALLTYPE #endif -#else -#define PASCAL _pascal -#define FAR _far -#define CALLTYPE FAR PASCAL -#endif - #ifdef __cplusplus diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx b/sc/inc/ViewSettingsSequenceDefines.hxx index f23229d31a43..07c3d2b375e0 100644 --- a/sc/inc/ViewSettingsSequenceDefines.hxx +++ b/sc/inc/ViewSettingsSequenceDefines.hxx @@ -103,6 +103,6 @@ #define SC_PAGEVIEWZOOMVALUE "PageViewZoomValue" #define SC_SHOWPAGEBREAKPREVIEW "ShowPageBreakPreview" #define SC_VIEWID "ViewId" -#define SC_VIEW "View" +#define SC_VIEW "view" #endif diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index c5d49632292e..64dd9e3e7ea6 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -133,12 +133,6 @@ const SCROW SCROWS64K = 65536; // === old stuff defines ===================================================== -#ifdef WIN -// Under 16bit Windows rows still had to be limited to 8192. -// (define manually for testing) -#define SC_LIMIT_ROWS -#endif - #define MAXROW_30 8191 #define MAXROW_40 31999 diff --git a/sc/inc/callform.hxx b/sc/inc/callform.hxx index 58962ea18c03..1e78f0a951be 100644 --- a/sc/inc/callform.hxx +++ b/sc/inc/callform.hxx @@ -35,17 +35,11 @@ #define MAXARRSIZE 0xfffe //------------------------------------------------------------------------ -#ifndef WIN #ifndef WNT #define CALLTYPE #else #define CALLTYPE __cdecl #endif -#else -#define PASCAL _pascal -#define FAR _far -#define CALLTYPE FAR PASCAL -#endif extern "C" { typedef void (CALLTYPE* AdvData)( double& nHandle, void* pData ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index f7ae5e63f165..5c4685223281 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -161,6 +161,9 @@ namespace com { namespace sun { namespace star { namespace embed { class XEmbeddedObject; } + namespace script { namespace vba { + class XVBAEventProcessor; + } } namespace sheet { struct TablePageBreakData; } @@ -334,6 +337,9 @@ private: Timer aTrackTimer; + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > + mxVbaEvents; + public: ScTabOpList aTableOpList; // list of ScInterpreterTableOpParams currently in use ScInterpreterTableOpParams aLastTableOpParams; // remember last params @@ -739,7 +745,8 @@ public: const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const; void SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew ); - bool HasSheetEventScript( sal_Int32 nEvent ) const; // on any sheet + bool HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents = false ) const; + bool HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents = false ) const; // on any sheet BOOL HasCalcNotification( SCTAB nTab ) const; void SetCalcNotification( SCTAB nTab ); @@ -1276,6 +1283,7 @@ public: SC_DLLPUBLIC USHORT GetColWidth( SCCOL nCol, SCTAB nTab ) const; SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const; SC_DLLPUBLIC ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const; SCROW GetRowForHeight( SCTAB nTab, ULONG nHeight ) const; ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; @@ -1783,6 +1791,11 @@ public: void GetSortParam( ScSortParam& rParam, SCTAB nTab ); void SetSortParam( ScSortParam& rParam, SCTAB nTab ); + inline void SetVbaEventProcessor( const com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor >& rxVbaEvents ) + { mxVbaEvents = rxVbaEvents; } + inline com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > + GetVbaEventProcessor() const { return mxVbaEvents; } + /** Should only be GRAM_PODF or GRAM_ODFF. */ void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar ); formula::FormulaGrammar::Grammar GetStorageGrammar() const diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index 44aa1daa9a92..e1b88919dad6 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -186,7 +186,7 @@ public: bool IsDataDescriptionCell(const ScAddress& rPos); bool IsDimNameInUse(const ::rtl::OUString& rName) const; - String GetDimName( long nDim, BOOL& rIsDataLayout ); + String GetDimName( long nDim, BOOL& rIsDataLayout, sal_Int32* pFlags = NULL ); BOOL IsDuplicated( long nDim ); long GetDimCount(); void GetHeaderPositionData(const ScAddress& rPos, ::com::sun::star::sheet::DataPilotTableHeaderData& rData); @@ -259,6 +259,8 @@ public: PivotField* pRefColFields = NULL, SCSIZE nRefColCount = 0, PivotField* pRefRowFields = NULL, SCSIZE nRefRowCount = 0, PivotField* pRefPageFields = NULL, SCSIZE nRefPageCount = 0 ); + + static bool IsOrientationAllowed( USHORT nOrient, sal_Int32 nDimFlags ); }; diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index bfff0b97a168..8272b850b27e 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -140,6 +140,7 @@ public: void SetSubTotals(long nCount, const USHORT* pFuncs); long GetSubTotalsCount() const { return nSubTotalCount; } USHORT GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; } + bool HasShowEmpty() const; void SetShowEmpty(BOOL bSet); BOOL GetShowEmpty() const { return BOOL(nShowEmptyMode); } void SetFunction(USHORT nNew); // enum GeneralFunction diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx index 915a311411c4..489f272bc8ba 100644 --- a/sc/inc/pivot.hxx +++ b/sc/inc/pivot.hxx @@ -141,6 +141,7 @@ struct ScDPLabelData SCsCOL mnCol; USHORT mnFuncMask; /// Page/Column/Row subtotal function. sal_Int32 mnUsedHier; /// Used hierarchy. + sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension bool mbShowAll; /// true = Show all (also empty) results. bool mbIsValue; /// true = Sum or count in data field. diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx index d7586fb8df95..ad3fd4b1b51e 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -115,13 +115,11 @@ public: ScExtTabSettings& GetOrCreateTabSettings( SCTAB nTab ); /** Returns the number of sheet codenames. */ - size_t GetCodeNameCount() const; + SCTAB GetCodeNameCount() const; /** Returns the specified codename (empty string = no codename). */ - const String& GetCodeName( size_t nIdx ) const; + const String& GetCodeName( SCTAB nTab ) const; /** Appends a codename for a sheet. */ - void AppendCodeName( const String& rCodeName ); - void SetCodeName( const String& rCodeName, size_t nIdx ); - void DeleteCodeName( size_t nIdx ); + void SetCodeName( SCTAB nTab, const String& rCodeName ); private: ::std::auto_ptr< ScExtDocOptionsImpl > mxImpl; diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 9857d675b7ab..b788672aa715 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -99,6 +99,7 @@ class SC_DLLPUBLIC ScMatrix mutable ULONG nRefCnt; // reference count SCSIZE nColCount; SCSIZE nRowCount; + bool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call. void ResetIsString(); void DeleteIsString(); @@ -171,11 +172,19 @@ public: /** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is created instead and a double error value (errStackOverflow) is set. Compare nC and nR with a GetDimensions() call to check. */ - ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0) { CreateMatrix( nC, nR); } + ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0), mbCloneIfConst(true) { CreateMatrix( nC, nR); } /** Clone the matrix. */ ScMatrix* Clone() const; + /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise + return _this_ matrix, to be assigned to a ScMatrixRef. */ + ScMatrix* CloneIfConst(); + + /** Set the matrix to (im)mutable for CloneIfConst(), only the interpreter + should do this and know the consequences. */ + inline void SetImmutable( bool bVal ) { mbCloneIfConst = bVal; } + /** * Resize the matrix to specified new dimension. Note that this operation * clears all stored values. diff --git a/sc/inc/sheetevents.hxx b/sc/inc/sheetevents.hxx index 8f52efb990f7..bb27f5cf2068 100755..100644 --- a/sc/inc/sheetevents.hxx +++ b/sc/inc/sheetevents.hxx @@ -59,6 +59,8 @@ public: void SetScript(sal_Int32 nEvent, const rtl::OUString* pNew); static rtl::OUString GetEventName(sal_Int32 nEvent); + static sal_Int32 GetVbaSheetEventId(sal_Int32 nEvent); + static sal_Int32 GetVbaDocumentEventId(sal_Int32 nEvent); }; #endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 78e5875b6879..63cefe22626a 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -628,12 +628,12 @@ public: // nPPT fuer Test auf Veraenderung void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ); - USHORT GetColWidth( SCCOL nCol ); - SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ); - ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ); - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ); - ULONG GetColOffset( SCCOL nCol ); - ULONG GetRowOffset( SCROW nRow ); + USHORT GetColWidth( SCCOL nCol ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ) const; + ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const; + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const; + ULONG GetColOffset( SCCOL nCol ) const; + ULONG GetRowOffset( SCROW nRow ) const; /** * Get the last row such that the height of row 0 to the end row is as @@ -643,7 +643,7 @@ public: * * @return SCROW last row of the range within specified height. */ - SCROW GetRowForHeight(ULONG nHeight); + SCROW GetRowForHeight(ULONG nHeight) const; USHORT GetOriginalWidth( SCCOL nCol ) const; USHORT GetOriginalHeight( SCROW nRow ) const; @@ -683,6 +683,8 @@ public: void UpdatePageBreaks( const ScRange* pUserArea ); void RemoveManualBreaks(); BOOL HasManualBreaks() const; + void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks ); + void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks ); void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const; void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const; @@ -711,33 +713,33 @@ public: ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const; - bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool RowHidden(SCROW nRow, SCROW& rLastRow); - bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow); - bool ColHidden(SCCOL nCol, SCCOL& rLastCol); - bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool RowHidden(SCROW nRow, SCROW& rLastRow) const; + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const; + bool ColHidden(SCCOL nCol, SCCOL& rLastCol) const; + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden); void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden); void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset); - SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow); - sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow); + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const; + sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) const; - SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol); + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const; - bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); - bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow); + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered); void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered); - SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void SyncColRowFlags(); diff --git a/sc/inc/unoguard.hxx b/sc/inc/unoguard.hxx index 0768eada24d7..e5e57e959e7b 100644 --- a/sc/inc/unoguard.hxx +++ b/sc/inc/unoguard.hxx @@ -30,7 +30,7 @@ #include <vos/mutex.hxx> -class ScUnoGuard : public NAMESPACE_VOS(OGuard) +class ScUnoGuard : public vos::OGuard { public: ScUnoGuard(); diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 2d011f425398..1e56743d8129 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -565,6 +565,7 @@ #define SC_UNO_FIELD_SUBTOTALNAME "FieldSubtotalName" #define SC_UNO_GRANDTOTAL_NAME "GrandTotalName" #define SC_UNO_HAS_HIDDEN_MEMBER "HasHiddenMember" +#define SC_UNO_FLAGS "Flags" // (preliminary:) #define SC_UNO_REFVALUE "ReferenceValue" diff --git a/sc/prj/d.lst b/sc/prj/d.lst index 6f4e95203bed..a0d4c1290bf9 100644 --- a/sc/prj/d.lst +++ b/sc/prj/d.lst @@ -32,3 +32,6 @@ mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\scalc\statusbar ..\uiconfig\scalc\statusbar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\scalc\statusbar\*.xml ..\%__SRC%\bin\*-layout.zip %_DEST%\pck%_EXT%\*.* +..\%__SRC%\misc\sc.component %_DEST%\xml%_EXT%\sc.component +..\%__SRC%\misc\scd.component %_DEST%\xml%_EXT%\scd.component +..\%__SRC%\misc\vbaobj.component %_DEST%\xml%_EXT%\vbaobj.component diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 95482b1c624b..540fb577a79b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -136,10 +136,16 @@ ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, ScBroadcastAreaSlot::~ScBroadcastAreaSlot() { for ( ScBroadcastAreas::iterator aIter( aBroadcastAreaTbl.begin()); - aIter != aBroadcastAreaTbl.end(); ++aIter) + aIter != aBroadcastAreaTbl.end(); /* none */) { - if (!(*aIter)->DecRef()) - delete *aIter; + // Prevent hash from accessing dangling pointer in case area is + // deleted. + ScBroadcastArea* pArea = *aIter; + // Erase all so no hash will be accessed upon destruction of the + // hash_set. + aBroadcastAreaTbl.erase( aIter++); + if (!pArea->DecRef()) + delete pArea; } } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index e8ea10f7cf52..d2c99c75a95e 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -50,6 +50,7 @@ #include <tools/tenccvt.hxx> #include <tools/list.hxx> #include <rtl/crc.h> +#include <basic/basmgr.hxx> #include "document.hxx" #include "table.hxx" @@ -93,7 +94,8 @@ #include "tabprotection.hxx" #include "formulaparserpool.hxx" #include "clipparam.hxx" -#include <basic/basmgr.hxx> + +using namespace com::sun::star; // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and // dtor plus helpers are convenient. @@ -1118,11 +1120,11 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, String sCodeName; String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); + uno::Reference< container::XNameContainer > xLib; if( xLibContainer.is() ) { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); aLibAny >>= xLib; } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 1861988d78aa..8fea4b8af2b9 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -30,6 +30,7 @@ // INCLUDE --------------------------------------------------------------- +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include "scitems.hxx" #include <editeng/langitem.hxx> #include <svl/srchitem.hxx> @@ -88,7 +89,6 @@ #include <memory> using namespace com::sun::star; -using ::std::auto_ptr; //------------------------------------------------------------------------ @@ -512,15 +512,35 @@ void ScDocument::SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew ) pTab[nTab]->SetSheetEvents( pNew ); } -bool ScDocument::HasSheetEventScript( sal_Int32 nEvent ) const +bool ScDocument::HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents ) const { - for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++) - if (pTab[nTab]) + if (pTab[nTab]) + { + // check if any event handler script has been configured + const ScSheetEvents* pEvents = pTab[nTab]->GetSheetEvents(); + if ( pEvents && pEvents->GetScript( nEvent ) ) + return true; + // check if VBA event handlers exist + if (bWithVbaEvents && mxVbaEvents.is()) try { - const ScSheetEvents* pEvents = pTab[nTab]->GetSheetEvents(); - if ( pEvents && pEvents->GetScript( nEvent ) ) + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + if (mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ) || + mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaDocumentEventId( nEvent ), uno::Sequence< uno::Any >() )) return true; } + catch( uno::Exception& ) + { + } + } + return false; +} + +bool ScDocument::HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents ) const +{ + for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++) + if (HasSheetEventScript( nTab, nEvent, bWithVbaEvents )) + return true; return false; } @@ -1546,6 +1566,54 @@ void ScDocument::ResetEmbedded() aEmbedRange = ScRange(); } + +/** Similar to ScViewData::AddPixelsWhile(), but add height twips and only + while result is less than nStopTwips. + @return TRUE if advanced at least one row. + */ +bool lcl_AddTwipsWhile( long & rTwips, long nStopTwips, SCROW & rPosY, SCROW nEndRow, const ScTable * pTable ) +{ + SCROW nRow = rPosY; + bool bAdded = false; + bool bStop = false; + while (rTwips < nStopTwips && nRow <= nEndRow && !bStop) + { + SCROW nHeightEndRow; + USHORT nHeight = pTable->GetRowHeight( nRow, NULL, &nHeightEndRow); + if (nHeightEndRow > nEndRow) + nHeightEndRow = nEndRow; + if (!nHeight) + nRow = nHeightEndRow + 1; + else + { + SCROW nRows = nHeightEndRow - nRow + 1; + sal_Int64 nAdd = static_cast<sal_Int64>(nHeight) * nRows; + if (nAdd + rTwips >= nStopTwips) + { + sal_Int64 nDiff = nAdd + rTwips - nStopTwips; + nRows -= static_cast<SCROW>(nDiff / nHeight); + nAdd = nHeight * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rTwips >= nStopTwips) + { + --nRows; + nAdd -= nHeight; + } + bStop = true; + } + rTwips += static_cast<long>(nAdd); + nRow += nRows; + } + } + if (nRow > rPosY) + { + --nRow; + bAdded = true; + } + rPosY = nRow; + return bAdded; +} + ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) { ScTable* pTable = pTab[nTab]; @@ -1602,43 +1670,16 @@ ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS); SCROW nY1 = 0; - bEnd = FALSE; - for (SCROW i = nY1; i <= MAXROW && !bEnd; ++i) - { - if (pTable->RowHidden(i)) - continue; - - nY1 = i; - nAdd = static_cast<long>(pTable->GetRowHeight(i)); - if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) - { - nSize += nAdd; - ++nY1; - } - else - bEnd = TRUE; - } - if (!bEnd) - nY1 = MAXROW; // all hidden down to the bottom + // Was if(nSize+nAdd<=nTwips+1) inside loop => if(nSize+nAdd<nTwips+2) + if (lcl_AddTwipsWhile( nSize, nTwips+2, nY1, MAXROW, pTable) && nY1 < MAXROW) + ++nY1; // original loop ended on last matched +1 unless that was MAXROW nTwips = (long) (aPosRect.Bottom() / HMM_PER_TWIPS); SCROW nY2 = nY1; - bEnd = FALSE; - for (SCROW i = nY2; i <= MAXROW && !bEnd; ++i) - { - nY2 = i; - nAdd = static_cast<long>(pTable->GetRowHeight(i)); - if (nSize+nAdd < nTwips && nY2<MAXROW) - { - nSize += nAdd; - ++nY2; - } - else - bEnd = TRUE; - } - if (!bEnd) - nY2 = MAXROW; // all hidden down to the bottom + // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips) + if (lcl_AddTwipsWhile( nSize, nTwips, nY2, MAXROW, pTable) && nY2 < MAXROW) + ++nY2; // original loop ended on last matched +1 unless that was MAXROW return ScRange( nX1,nY1,nTab, nX2,nY2,nTab ); } diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 97aae44f1a7b..d77dc1041d9c 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -454,7 +454,7 @@ void ScDocument::TrackFormulas( ULONG nHintId ) { erBEEPER(); // outside the loop, check if any sheet has a "calculate" event script - bool bCalcEvent = HasSheetEventScript( SC_SHEETEVENT_CALCULATE ); + bool bCalcEvent = HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ); SvtBroadcaster* pBC; ScFormulaCell* pTrack; ScFormulaCell* pNext; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index bef4cbf87396..1efe32446eef 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -51,7 +51,7 @@ #include <tools/tenccvt.hxx> #include <com/sun/star/text/WritingMode2.hpp> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/sheet/TablePageBreakData.hpp> #include "document.hxx" @@ -3061,6 +3061,19 @@ void ScDocument::CalcAfterLoad() bCalcingAfterLoad = FALSE; SetDetectiveDirty(FALSE); // noch keine wirklichen Aenderungen + + // #i112436# If formula cells are already dirty, they don't broadcast further changes. + // So the source ranges of charts must be interpreted even if they are not visible, + // similar to ScMyShapeResizer::CreateChartListener for loading own files (i104899). + if (pChartListenerCollection) + { + sal_uInt16 nChartCount = pChartListenerCollection->GetCount(); + for ( sal_uInt16 nIndex = 0; nIndex < nChartCount; nIndex++ ) + { + ScChartListener* pChartListener = static_cast<ScChartListener*>(pChartListenerCollection->At(nIndex)); + InterpretDirtyCells(*pChartListener->GetRangeList()); + } + } } @@ -3161,7 +3174,16 @@ USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero ) co { if ( ValidTab(nTab) && pTab[nTab] ) return pTab[nTab]->GetRowHeight( nRow, NULL, NULL, bHiddenAsZero ); - DBG_ERROR("Falsche Tabellennummer"); + DBG_ERROR("Wrong sheet number"); + return 0; +} + + +USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) const +{ + if ( ValidTab(nTab) && pTab[nTab] ) + return pTab[nTab]->GetRowHeight( nRow, pStartRow, pEndRow, bHiddenAsZero ); + DBG_ERROR("Wrong sheet number"); return 0; } @@ -3684,24 +3706,35 @@ SCCOL ScDocument::GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const SCROW ScDocument::GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart, bool bCareManualSize) const { - if ( ValidTab(nTab) && pTab[nTab] && pTab[nTab]->GetRowFlagsArray() && pTab[nTab]->mpRowHeights ) - { - BYTE nStartFlags = pTab[nTab]->GetRowFlags(nStart); - USHORT nStartHeight = pTab[nTab]->GetOriginalHeight(nStart); - for (SCROW nRow = nStart + 1; nRow <= MAXROW; nRow++) + const ScBitMaskCompressedArray< SCROW, BYTE> * pRowFlagsArray; + if ( ValidTab(nTab) && pTab[nTab] && ((pRowFlagsArray = pTab[nTab]->GetRowFlagsArray()) != NULL) && + pTab[nTab]->mpRowHeights && pTab[nTab]->mpHiddenRows ) + { + size_t nIndex; // ignored + SCROW nFlagsEndRow; + SCROW nHiddenEndRow; + SCROW nHeightEndRow; + BYTE nFlags; + bool bHidden; + USHORT nHeight; + BYTE nStartFlags = nFlags = pRowFlagsArray->GetValue( nStart, nIndex, nFlagsEndRow); + bool bStartHidden = bHidden = pTab[nTab]->RowHidden( nStart, NULL, &nHiddenEndRow); + USHORT nStartHeight = nHeight = pTab[nTab]->GetRowHeight( nStart, NULL, &nHeightEndRow, false); + SCROW nRow; + while ((nRow = std::min( nHiddenEndRow, std::min( nFlagsEndRow, nHeightEndRow)) + 1) <= MAXROW) { - size_t nIndex; // ignored - SCROW nFlagsEndRow; - SCROW nHeightEndRow; - BYTE nFlags = pTab[nTab]->GetRowFlagsArray()->GetValue( nRow, nIndex, nFlagsEndRow ); - USHORT nHeight = pTab[nTab]->GetRowHeight(nRow, NULL, &nHeightEndRow); - if (((nStartFlags & CR_MANUALBREAK) != (nFlags & CR_MANUALBREAK)) || - ((nStartFlags & CR_MANUALSIZE) != (nFlags & CR_MANUALSIZE)) || - (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != nHeight)) || - (!bCareManualSize && ((nStartHeight != nHeight)))) + if (nFlagsEndRow < nRow) + nFlags = pRowFlagsArray->GetValue( nRow, nIndex, nFlagsEndRow); + if (nHiddenEndRow < nRow) + bHidden = pTab[nTab]->RowHidden( nRow, NULL, &nHiddenEndRow); + if (nHeightEndRow < nRow) + nHeight = pTab[nTab]->GetRowHeight( nRow, NULL, &nHeightEndRow, false); + if ( ((nStartFlags & CR_MANUALBREAK) != (nFlags & CR_MANUALBREAK)) || + ((nStartFlags & CR_MANUALSIZE) != (nFlags & CR_MANUALSIZE)) || + (bStartHidden != bHidden) || + (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != nHeight)) || + (!bCareManualSize && ((nStartHeight != nHeight)))) return nRow; - - nRow = std::min( nFlagsEndRow, nHeightEndRow ); } return MAXROW+1; } @@ -5226,8 +5259,8 @@ bool ScDocument::IsInVBAMode() const bool bResult = false; if ( pShell ) { - com::sun::star::uno::Reference< com::sun::star::script::XVBACompat > xVBA( pShell->GetBasicContainer(), com::sun::star::uno::UNO_QUERY ); - bResult = xVBA->getVBACompatModeOn(); + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBACompatibility > xVBA( pShell->GetBasicContainer(), com::sun::star::uno::UNO_QUERY ); + bResult = xVBA.is() && xVBA->getVBACompatibilityMode(); } return bResult; } diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 7ca41d47f79d..29ba9f15dc92 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -65,8 +65,10 @@ #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp> #include <com/sun/star/sheet/DataPilotTablePositionData.hpp> #include <com/sun/star/sheet/DataPilotTablePositionType.hpp> +#include <com/sun/star/sheet/DimensionFlags.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp> @@ -844,7 +846,7 @@ bool ScDPObject::IsDimNameInUse(const OUString& rName) const return false; } -String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout ) +String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout, sal_Int32* pFlags ) { rIsDataLayout = FALSE; String aRet; @@ -878,6 +880,10 @@ String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout ) rIsDataLayout = TRUE; else aRet = String( aName ); + + if (pFlags) + *pFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, + rtl::OUString::createFromAscii(SC_UNO_FLAGS), 0 ); } } } @@ -2002,6 +2008,8 @@ BOOL ScDPObject::FillLabelData(ScPivotParam& rParam) GetHierarchies(nDim, pNewLabel->maHiers); GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers); lcl_FillLabelData(*pNewLabel, xDimProp); + pNewLabel->mnFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, + rtl::OUString::createFromAscii(SC_UNO_FLAGS), 0 ); rParam.maLabelArray.push_back(pNewLabel); } } @@ -2230,6 +2238,32 @@ void ScDPObject::ConvertOrientation( ScDPSaveData& rSaveData, } } +// static +bool ScDPObject::IsOrientationAllowed( USHORT nOrient, sal_Int32 nDimFlags ) +{ + bool bAllowed = true; + switch (nOrient) + { + case sheet::DataPilotFieldOrientation_PAGE: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_PAGE_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_COLUMN: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_COLUMN_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_ROW: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_ROW_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_DATA: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_DATA_ORIENTATION ) == 0; + break; + default: + { + // allowed to remove from previous orientation + } + } + return bAllowed; +} + // ----------------------------------------------------------------------- // static @@ -2293,6 +2327,9 @@ uno::Sequence<rtl::OUString> ScDPObject::GetRegisteredSources() return aSeq; } +// use getContext from addincol.cxx +uno::Reference<uno::XComponentContext> getContext(uno::Reference<lang::XMultiServiceFactory> xMSF); + // static uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPServiceDesc& rDesc ) { @@ -2317,12 +2354,26 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS if ( xIntFac.is() ) { uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); - if ( xFac.is() && xInfo.is() && xInfo->getImplementationName() == aImplName ) + if ( xInfo.is() && xInfo->getImplementationName() == aImplName ) { try { - uno::Reference<uno::XInterface> xInterface = xFac->createInstance(); + // #i113160# try XSingleComponentFactory in addition to (old) XSingleServiceFactory, + // passing the context to the component (see ScUnoAddInCollection::Initialize) + + uno::Reference<uno::XInterface> xInterface; + uno::Reference<uno::XComponentContext> xCtx = getContext(xManager); + uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY ); + if (xCtx.is() && xCFac.is()) + xInterface = xCFac->createInstanceWithContext(xCtx); + + if (!xInterface.is()) + { + uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); + if ( xFac.is() ) + xInterface = xFac->createInstance(); + } + uno::Reference<lang::XInitialization> xInit( xInterface, uno::UNO_QUERY ); if (xInit.is()) { diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index dd493bb0df6c..bad05968bf72 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -410,6 +410,11 @@ void ScDPSaveDimension::SetSubTotals(long nCount, const USHORT* pFuncs) bSubTotalDefault = FALSE; } +bool ScDPSaveDimension::HasShowEmpty() const +{ + return nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW; +} + void ScDPSaveDimension::SetShowEmpty(BOOL bSet) { nShowEmptyMode = bSet; diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index da40e6e230c4..b4ca5dbc7330 100755..100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1576,6 +1576,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn static SfxItemPropertyMapEntry aDPDimensionMap_Impl[] = { {MAP_CHAR_LEN(SC_UNO_FILTER), 0, &getCppuType((uno::Sequence<sheet::TableFilterField>*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNO_FLAGS), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 }, {MAP_CHAR_LEN(SC_UNO_FUNCTION), 0, &getCppuType((sheet::GeneralFunction*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_ISDATALA), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0 }, {MAP_CHAR_LEN(SC_UNO_NUMBERFO), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 }, @@ -1753,6 +1754,11 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert aRet <<= mpSubtotalName.get() ? *mpSubtotalName : OUString::createFromAscii(""); else if (aNameStr.EqualsAscii(SC_UNO_HAS_HIDDEN_MEMBER)) aRet <<= mbHasHiddenMember; + else if (aNameStr.EqualsAscii(SC_UNO_FLAGS)) + { + sal_Int32 nFlags = 0; // tabular data: all orientations are possible + aRet <<= nFlags; + } else { DBG_ERROR("unknown property"); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 8418cb3c3a25..99da4979a1b6 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -219,6 +219,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX nArrY=0; SCROW nYExtra = nY2+1; + USHORT nDocHeight = ScGlobal::nStdRowHeight; + SCROW nDocHeightEndRow = -1; for (nSignedY=((SCsROW)nY1)-1; nSignedY<=(SCsROW)nYExtra; nSignedY++) { if (nSignedY >= 0) @@ -226,11 +228,13 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX else nY = MAXROW+1; // ungueltig - USHORT nDocHeight; - if (ValidRow(nY)) - nDocHeight = GetRowHeight( nY, nTab ); - else - nDocHeight = ScGlobal::nStdRowHeight; + if (nY > nDocHeightEndRow) + { + if (ValidRow(nY)) + nDocHeight = GetRowHeight( nY, nTab, NULL, &nDocHeightEndRow ); + else + nDocHeight = ScGlobal::nStdRowHeight; + } if ( nArrY==0 || nDocHeight || nY > MAXROW ) { @@ -384,11 +388,15 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX nArrY = 1; SCSIZE nUIndex; + bool bHiddenRow = true; + SCROW nHiddenEndRow = -1; (void) pThisCol->Search( nY1, nUIndex ); while ( nUIndex < pThisCol->nCount && (nThisRow=pThisCol->pItems[nUIndex].nRow) <= nY2 ) { - if ( !RowHidden( nThisRow,nTab ) ) + if (nThisRow > nHiddenEndRow) + bHiddenRow = RowHidden( nThisRow, nTab, nHiddenEndRow); + if ( !bHiddenRow ) { while ( pRowInfo[nArrY].nRowNo < nThisRow ) ++nArrY; diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx index baf3f4cf3f95..4401ac19d199 100644 --- a/sc/source/core/data/markdata.cxx +++ b/sc/source/core/data/markdata.cxx @@ -429,18 +429,28 @@ SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges ) if (!bMultiMarked) return 0; - DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); + DBG_ASSERT(pMultiSel, "bMultiMarked, but pMultiSel == 0"); + + const SCCOLROW nMultiStart = aMultiRange.aStart.Col(); + const SCCOLROW nMultiEnd = aMultiRange.aEnd.Col(); + if (nMultiStart == 0 && nMultiEnd == MAXCOL) + { + // One or more entire rows. + pRanges[0] = 0; + pRanges[1] = MAXCOL; + return 1; + } SCCOLROW nRangeCnt = 0; - SCCOLROW nStart = 0; - while (nStart<=MAXCOL) + SCCOLROW nStart = nMultiStart; + while (nStart <= nMultiEnd) { - while (nStart<MAXCOL && !pMultiSel[nStart].HasMarks()) + while (nStart < nMultiEnd && !pMultiSel[nStart].HasMarks()) ++nStart; if (pMultiSel[nStart].HasMarks()) { SCCOLROW nEnd = nStart; - while (nEnd<MAXCOL && pMultiSel[nEnd].HasMarks()) + while (nEnd < nMultiEnd && pMultiSel[nEnd].HasMarks()) ++nEnd; if (!pMultiSel[nEnd].HasMarks()) --nEnd; @@ -450,7 +460,7 @@ SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges ) nStart = nEnd+1; } else - nStart = MAXCOL+1; + nStart = nMultiEnd+1; } return nRangeCnt; @@ -464,37 +474,51 @@ SCCOLROW ScMarkData::GetMarkRowRanges( SCCOLROW* pRanges ) if (!bMultiMarked) return 0; - DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); + DBG_ASSERT(pMultiSel, "bMultiMarked, but pMultiSel == 0"); - // Welche Zeilen sind markiert? + // Which rows are marked? - BOOL* bRowMarked = new BOOL[MAXROW+1]; + // Optimized to not loop over MAXCOL*MAXROW as worst case, i.e. Ctrl+A + + const SCCOLROW nMultiStart = aMultiRange.aStart.Row(); + const SCCOLROW nMultiEnd = aMultiRange.aEnd.Row(); + + BOOL* bRowMarked = new BOOL[MAXROWCOUNT]; + memset( bRowMarked, 0, sizeof(BOOL) * MAXROWCOUNT); SCROW nRow; SCCOL nCol; - for (nRow=0; nRow<=MAXROW; nRow++) - bRowMarked[nRow] = FALSE; - SCROW nTop, nBottom; - for (nCol=0; nCol<=MAXCOL; nCol++) + SCROW nTop = -1, nBottom = -1; + for (nCol = aMultiRange.aStart.Col(); nCol <= aMultiRange.aEnd.Col(); ++nCol) { ScMarkArrayIter aMarkIter( &pMultiSel[nCol] ); while (aMarkIter.Next( nTop, nBottom )) for (nRow=nTop; nRow<=nBottom; nRow++) bRowMarked[nRow] = TRUE; + if (nTop == nMultiStart && nBottom == nMultiEnd) + break; // for, all relevant rows marked + } + + if (nTop == nMultiStart && nBottom == nMultiEnd) + { + pRanges[0] = nTop; + pRanges[1] = nBottom; + delete[] bRowMarked; + return 1; } - // zu Bereichen zusammenfassen + // Combine to ranges of rows. SCCOLROW nRangeCnt = 0; - SCCOLROW nStart = 0; - while (nStart<=MAXROW) + SCCOLROW nStart = nMultiStart; + while (nStart <= nMultiEnd) { - while (nStart<MAXROW && !bRowMarked[nStart]) + while (nStart < nMultiEnd && !bRowMarked[nStart]) ++nStart; if (bRowMarked[nStart]) { SCCOLROW nEnd = nStart; - while (nEnd<MAXROW && bRowMarked[nEnd]) + while (nEnd < nMultiEnd && bRowMarked[nEnd]) ++nEnd; if (!bRowMarked[nEnd]) --nEnd; @@ -504,7 +528,7 @@ SCCOLROW ScMarkData::GetMarkRowRanges( SCCOLROW* pRanges ) nStart = nEnd+1; } else - nStart = MAXROW+1; + nStart = nMultiEnd+1; } delete[] bRowMarked; diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index 5a6174bc0129..ddac72f0230b 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -82,6 +82,7 @@ ScDPLabelData::ScDPLabelData( const String& rName, short nCol, bool bIsValue ) : mnCol( nCol ), mnFuncMask( PIVOT_FUNC_NONE ), mnUsedHier( 0 ), + mnFlags( 0 ), mbShowAll( false ), mbIsValue( bIsValue ) { diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx index e9e430ef85d9..e1875b5db15b 100755..100644 --- a/sc/source/core/data/sheetevents.cxx +++ b/sc/source/core/data/sheetevents.cxx @@ -33,9 +33,9 @@ // INCLUDE --------------------------------------------------------------- -#include <tools/debug.hxx> - #include "sheetevents.hxx" +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <tools/debug.hxx> // ----------------------------------------------------------------------- @@ -61,6 +61,37 @@ rtl::OUString ScSheetEvents::GetEventName(sal_Int32 nEvent) return rtl::OUString::createFromAscii(aEventNames[nEvent]); } +// static +sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent) +{ + using namespace ::com::sun::star::script::vba::VBAEventId; + if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT) + { + DBG_ERRORFILE("invalid event number"); + return NO_EVENT; + } + + static const sal_Int32 nVbaEventIds[] = + { + WORKSHEET_ACTIVATE, // SC_SHEETEVENT_FOCUS + WORKSHEET_DEACTIVATE, // SC_SHEETEVENT_UNFOCUS + WORKSHEET_SELECTIONCHANGE, // SC_SHEETEVENT_SELECT + WORKSHEET_BEFOREDOUBLECLICK, // SC_SHEETEVENT_DOUBLECLICK + WORKSHEET_BEFORERIGHTCLICK, // SC_SHEETEVENT_RIGHTCLICK + WORKSHEET_CHANGE, // SC_SHEETEVENT_CHANGE + WORKSHEET_CALCULATE // SC_SHEETEVENT_CALCULATE + }; + return nVbaEventIds[nEvent]; +} + +// static +sal_Int32 ScSheetEvents::GetVbaDocumentEventId(sal_Int32 nEvent) +{ + using namespace ::com::sun::star::script::vba::VBAEventId; + sal_Int32 nSheetEventId = GetVbaSheetEventId(nEvent); + return (nSheetEventId != NO_EVENT) ? (nSheetEventId + USERDEFINED_START) : NO_EVENT; +} + // ----------------------------------------------------------------------- ScSheetEvents::ScSheetEvents() : diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 87561abf1513..e534bb9dfb78 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -28,67 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - -//------------------------------------------------------------------------ - -#ifdef WIN - -// SFX -#define _SFXAPPWIN_HXX -#define _SFX_SAVEOPT_HXX -//#define _SFX_CHILDWIN_HXX *** -#define _SFXCTRLITEM_HXX -#define _SFXPRNMON_HXX -#define _INTRO_HXX -#define _SFXMSGDESCR_HXX -#define _SFXMSGPOOL_HXX -#define _SFXFILEDLG_HXX -#define _PASSWD_HXX -#define _SFXTBXCTRL_HXX -#define _SFXSTBITEM_HXX -#define _SFXMNUITEM_HXX -#define _SFXIMGMGR_HXX -#define _SFXTBXMGR_HXX -#define _SFXSTBMGR_HXX -#define _SFX_MINFITEM_HXX -#define _SFXEVENT_HXX - -//#define _SI_HXX -//#define SI_NODRW -#define _SI_DLL_HXX -#define _SIDLL_HXX -#define _SI_NOITEMS -#define _SI_NOOTHERFORMS -#define _SI_NOSBXCONTROLS -#define _SINOSBXCONTROLS -#define _SI_NODRW // -#define _SI_NOCONTROL -#define _VCBRW_HXX -#define _VCTRLS_HXX -//#define _VCSBX_HXX -#define _VCONT_HXX -#define _VDRWOBJ_HXX -#define _VCATTR_HXX - - -#define _SVX_DAILDLL_HXX -#define _SVX_HYPHEN_HXX -#define _SVX_IMPGRF_HXX -#define _SVX_OPTITEMS_HXX -#define _SVX_OPTGERL_HXX -#define _SVX_OPTSAVE_HXX -#define _SVX_OPTSPELL_HXX -#define _SVX_OPTPATH_HXX -#define _SVX_OPTLINGU_HXX -#define _SVX_RULER_HXX -#define _SVX_RULRITEM_HXX -#define _SVX_SPLWRAP_HXX -#define _SVX_SPLDLG_HXX -#define _SVX_THESDLG_HXX - -#endif //WIN - // INCLUDE --------------------------------------------------------------- #include "scitems.hxx" @@ -115,8 +54,6 @@ #include "sheetevents.hxx" #include "segmenttree.hxx" -// STATIC DATA ----------------------------------------------------------- - // ----------------------------------------------------------------------- ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 9bd5b031fde5..4223c05c4f83 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -155,6 +155,22 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE mpFilteredRows->insertSegment(nStartRow, nSize, true); mpHiddenRows->insertSegment(nStartRow, nSize, true); + + if (!maRowManualBreaks.empty()) + { + std::set<SCROW>::reverse_iterator rit = maRowManualBreaks.rbegin(); + while (rit != maRowManualBreaks.rend()) + { + SCROW nRow = *rit; + if (nRow < nStartRow) + break; // while + else + { + maRowManualBreaks.erase( (++rit).base()); + maRowManualBreaks.insert( static_cast<SCROW>( nRow + nSize)); + } + } + } } for (SCCOL j=nStartCol; j<=nEndCol; j++) @@ -185,6 +201,18 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE mpFilteredRows->removeSegment(nStartRow, nStartRow+nSize); mpHiddenRows->removeSegment(nStartRow, nStartRow+nSize); + + if (!maRowManualBreaks.empty()) + { + std::set<SCROW>::iterator it = maRowManualBreaks.upper_bound( static_cast<SCROW>( nStartRow + nSize - 1)); + maRowManualBreaks.erase( maRowManualBreaks.lower_bound( nStartRow), it); + while (it != maRowManualBreaks.end()) + { + SCROW nRow = *it; + maRowManualBreaks.erase( it++); + maRowManualBreaks.insert( static_cast<SCROW>( nRow - nSize)); + } + } } { // scope for bulk broadcast @@ -233,6 +261,22 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE mpHiddenCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true); mpFilteredCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true); + + if (!maColManualBreaks.empty()) + { + std::set<SCCOL>::reverse_iterator rit = maColManualBreaks.rbegin(); + while (rit != maColManualBreaks.rend()) + { + SCCOL nCol = *rit; + if (nCol < nStartCol) + break; // while + else + { + maColManualBreaks.erase( (++rit).base()); + maColManualBreaks.insert( static_cast<SCCOL>( nCol + nSize)); + } + } + } } @@ -291,6 +335,18 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE SCCOL nRmSize = nStartCol + static_cast<SCCOL>(nSize); mpHiddenCols->removeSegment(nStartCol, nRmSize); mpFilteredCols->removeSegment(nStartCol, nRmSize); + + if (!maColManualBreaks.empty()) + { + std::set<SCCOL>::iterator it = maColManualBreaks.upper_bound( static_cast<SCCOL>( nStartCol + nSize - 1)); + maColManualBreaks.erase( maColManualBreaks.lower_bound( nStartCol), it); + while (it != maColManualBreaks.end()) + { + SCCOL nCol = *it; + maColManualBreaks.erase( it++); + maColManualBreaks.insert( static_cast<SCCOL>( nCol - nSize)); + } + } } @@ -688,6 +744,7 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, pDestTab->IncRecalcLevel(); if (bWidth) + { for (SCCOL i=nCol1; i<=nCol2; i++) { bool bThisHidden = ColHidden(i); @@ -703,6 +760,8 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (bChange) bFlagChange = true; } + pDestTab->SetColManualBreaks( maColManualBreaks); + } if (bHeight) { @@ -754,6 +813,7 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, pDestTab->SetRowFiltered(i, nLastRow, bFiltered); i = nLastRow; } + pDestTab->SetRowManualBreaks( maRowManualBreaks); } pDestTab->DecRecalcLevel(); } @@ -791,11 +851,17 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (bWidth||bHeight) { if (bWidth) + { for (SCCOL i=nCol1; i<=nCol2; i++) pDestTab->pColWidth[i] = pColWidth[i]; + pDestTab->SetColManualBreaks( maColManualBreaks); + } if (bHeight) + { pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0); - DecRecalcLevel(); + pDestTab->SetRowManualBreaks( maRowManualBreaks); + } + DecRecalcLevel(); } } } @@ -2241,7 +2307,7 @@ void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ) } -USHORT ScTable::GetColWidth( SCCOL nCol ) +USHORT ScTable::GetColWidth( SCCOL nCol ) const { DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer"); @@ -2315,34 +2381,50 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) } -USHORT ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) +USHORT ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) const { - DBG_ASSERT(VALIDROW(nRow),"Falsche Zeilennummer"); + DBG_ASSERT(VALIDROW(nRow),"Invalid row number"); if (VALIDROW(nRow) && mpRowHeights) { - if (bHiddenAsZero && RowHidden(nRow)) + if (bHiddenAsZero && RowHidden( nRow, pStartRow, pEndRow)) return 0; else { ScFlatUInt16RowSegments::RangeData aData; if (!mpRowHeights->getRangeData(nRow, aData)) + { + if (pStartRow) + *pStartRow = nRow; + if (pEndRow) + *pEndRow = nRow; // TODO: What should we return in case the search fails? return 0; + } + // If bHiddenAsZero, pStartRow and pEndRow were initialized to + // boundaries of a non-hidden segment. Assume that the previous and + // next segment are hidden then and limit the current height + // segment. if (pStartRow) - *pStartRow = aData.mnRow1; + *pStartRow = (bHiddenAsZero ? std::max( *pStartRow, aData.mnRow1) : aData.mnRow1); if (pEndRow) - *pEndRow = aData.mnRow2; + *pEndRow = (bHiddenAsZero ? std::min( *pEndRow, aData.mnRow2) : aData.mnRow2); return aData.mnValue; } } else + { + if (pStartRow) + *pStartRow = nRow; + if (pEndRow) + *pEndRow = nRow; return (USHORT) ScGlobal::nStdRowHeight; + } } -ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) +ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); @@ -2368,7 +2450,7 @@ ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) } -ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) +ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); @@ -3018,10 +3100,13 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); if( pDrawLayer ) { - long x = GetColOffset( MAXCOL + 1 ); - long y = GetRowOffset( MAXROW + 1 ); - x = (long) ((double) x * HMM_PER_TWIPS); - y = (long) ((double) y * HMM_PER_TWIPS); + double fValX = GetColOffset( MAXCOL + 1 ) * HMM_PER_TWIPS; + double fValY = GetRowOffset( MAXROW + 1 ) * HMM_PER_TWIPS; + const long nMax = ::std::numeric_limits<long>::max(); + // #i113884# Avoid int32 overflow with possible negative results than can cause bad effects. + // If the draw page size is smaller than all rows, only the bottom of the sheet is affected. + long x = ( fValX > (double)nMax ) ? nMax : (long) fValX; + long y = ( fValY > (double)nMax ) ? nMax : (long) fValY; if ( IsLayoutRTL() ) // IsNegativePage x = -x; @@ -3036,7 +3121,7 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos } -ULONG ScTable::GetRowOffset( SCROW nRow ) +ULONG ScTable::GetRowOffset( SCROW nRow ) const { ULONG n = 0; if ( mpHiddenRows && mpRowHeights ) @@ -3059,7 +3144,7 @@ ULONG ScTable::GetRowOffset( SCROW nRow ) return n; } -SCROW ScTable::GetRowForHeight(ULONG nHeight) +SCROW ScTable::GetRowForHeight(ULONG nHeight) const { sal_uInt32 nSum = 0; @@ -3086,7 +3171,7 @@ SCROW ScTable::GetRowForHeight(ULONG nHeight) } -ULONG ScTable::GetColOffset( SCCOL nCol ) +ULONG ScTable::GetColOffset( SCCOL nCol ) const { ULONG n = 0; if ( pColWidth ) diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index 2635b5821e4f..7c13756aab38 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -326,6 +326,22 @@ BOOL ScTable::HasManualBreaks() const return !maRowManualBreaks.empty() || !maColManualBreaks.empty(); } +void ScTable::SetRowManualBreaks( const ::std::set<SCROW>& rBreaks ) +{ + maRowManualBreaks = rBreaks; + InvalidatePageBreaks(); + if (IsStreamValid()) + SetStreamValid(FALSE); +} + +void ScTable::SetColManualBreaks( const ::std::set<SCCOL>& rBreaks ) +{ + maColManualBreaks = rBreaks; + InvalidatePageBreaks(); + if (IsStreamValid()) + SetStreamValid(FALSE); +} + void ScTable::GetAllRowBreaks(set<SCROW>& rBreaks, bool bPage, bool bManual) const { if (bPage) @@ -355,7 +371,7 @@ bool ScTable::HasRowPageBreak(SCROW nRow) const if (!ValidRow(nRow)) return false; - return maRowPageBreaks.count(nRow) > 0; + return maRowPageBreaks.find(nRow) != maRowPageBreaks.end(); } bool ScTable::HasColPageBreak(SCCOL nCol) const @@ -363,7 +379,7 @@ bool ScTable::HasColPageBreak(SCCOL nCol) const if (!ValidCol(nCol)) return false; - return maColPageBreaks.count(nCol) > 0; + return maColPageBreaks.find(nCol) != maColPageBreaks.end(); } bool ScTable::HasRowManualBreak(SCROW nRow) const @@ -371,7 +387,7 @@ bool ScTable::HasRowManualBreak(SCROW nRow) const if (!ValidRow(nRow)) return false; - return maRowManualBreaks.count(nRow) > 0; + return maRowManualBreaks.find(nRow) != maRowManualBreaks.end(); } bool ScTable::HasColManualBreak(SCCOL nCol) const @@ -379,7 +395,7 @@ bool ScTable::HasColManualBreak(SCCOL nCol) const if (!ValidCol(nCol)) return false; - return (maColManualBreaks.count(nCol) > 0); + return maColManualBreaks.find(nCol) != maColManualBreaks.end(); } SCROW ScTable::GetNextManualBreak(SCROW nRow) const @@ -483,15 +499,27 @@ Sequence<TablePageBreakData> ScTable::GetRowBreakData() const return aSeq; } -bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const { if (!ValidRow(nRow)) + { + if (pFirstRow) + *pFirstRow = nRow; + if (pLastRow) + *pLastRow = nRow; return true; + } ScFlatBoolRowSegments::RangeData aData; if (!mpHiddenRows->getRangeData(nRow, aData)) + { // search failed. + if (pFirstRow) + *pFirstRow = nRow; + if (pLastRow) + *pLastRow = nRow; return true; + } if (pFirstRow) *pFirstRow = aData.mnRow1; @@ -502,7 +530,7 @@ bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) } -bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) +bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) const { rLastRow = nRow; if (!ValidRow(nRow)) @@ -517,7 +545,7 @@ bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) return aData.mbValue; } -bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) +bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; while (nRow <= nEndRow) @@ -532,7 +560,7 @@ bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) return false; } -bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) +bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) const { rLastCol = nCol; if (!ValidCol(nCol)) @@ -546,7 +574,7 @@ bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) return aData.mbValue; } -bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const { if (!ValidCol(nCol)) return true; @@ -627,7 +655,7 @@ void ScTable::CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, } } -SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; ScFlatBoolRowSegments::RangeData aData; @@ -650,7 +678,7 @@ SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nEndRow; ScFlatBoolRowSegments::RangeData aData; @@ -673,7 +701,7 @@ SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nCount = 0; SCROW nRow = nStartRow; @@ -694,7 +722,7 @@ SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) return nCount; } -sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) +sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) const { sal_uInt32 nHeight = 0; SCROW nRow = nStartRow; @@ -717,7 +745,7 @@ sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) return nHeight; } -SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) +SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) const { if (bCol) { @@ -741,7 +769,7 @@ SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) return ::std::numeric_limits<SCCOLROW>::max(); } -bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const { if (!ValidRow(nRow)) return false; @@ -759,7 +787,7 @@ bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) return aData.mbValue; } -bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const { if (!ValidCol(nCol)) return false; @@ -777,7 +805,7 @@ bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) return aData.mbValue; } -bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) +bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; while (nRow <= nEndRow) @@ -837,7 +865,7 @@ void ScTable::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered) mpFilteredCols->setFalse(nStartCol, nEndCol); } -SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; ScFlatBoolRowSegments::RangeData aData; @@ -860,7 +888,7 @@ SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nEndRow; ScFlatBoolRowSegments::RangeData aData; @@ -883,7 +911,7 @@ SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nCount = 0; SCROW nRow = nStartRow; diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx index fc3d9bf51be2..58ee1b06f7f7 100644 --- a/sc/source/core/tool/chartpos.cxx +++ b/sc/source/core/tool/chartpos.cxx @@ -175,25 +175,9 @@ void ScChartPositioner::GlueState() const BYTE nOccu = 1; const BYTE nFree = 2; const BYTE nGlue = 3; -#ifdef WIN - // we hate 16bit, don't we? - BYTE huge* p; - BYTE huge* pA = (BYTE huge*) SvMemAlloc( nCR ); - if ( nCR > (ULONG)((USHORT)~0) ) - { // in 32k Bloecken initialisieren - ULONG j; - for ( j=0; j<nCR; j+=0x8000 ) - { - memset( pA+j, nHole, Min( (ULONG)0x8000, nCR-j ) ); - } - } - else - memset( pA, nHole, nCR * sizeof(BYTE) ); -#else BYTE* p; BYTE* pA = new BYTE[ nCR ]; memset( pA, 0, nCR * sizeof(BYTE) ); -#endif SCCOL nCol, nCol1, nCol2; SCROW nRow, nRow1, nRow2; @@ -285,11 +269,7 @@ void ScChartPositioner::GlueState() eGlue = SC_CHARTGLUE_NONE; } -#ifdef WIN - SvMemFree( pA ); -#else delete [] pA; -#endif } void ScChartPositioner::CheckColRowHeaders() @@ -524,9 +504,6 @@ ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, nRowCount( nChartRows ) { DBG_ASSERT( nColCount && nRowCount, "ScChartPositionMap without dimension" ); -#ifdef WIN -#error ScChartPositionMap not implemented for 16-bit dumdums -#endif ScAddress* pPos; SCCOL nCol; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index c28d295275ae..828c9ae64c7d 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -121,24 +121,6 @@ enum ScanState ssStop }; -// ODFF names that are not written in the current mapping but to be recognized. -// New names will be written in a future relase, then exchange (!) with the -// names in formula/source/core/resource/core_resource.src to be able to still -// read the old names as well. -struct FunctionName -{ - const sal_Char* pName; - OpCode eOp; -}; -static const FunctionName aOdffAliases[] = { - // Renamed old names: - // XXX none yet. - // Renamed new names: - { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE - { "LEGACY.TDIST", ocTDist } // TDIST -> LEGACY.TDIST -}; -static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); - static const sal_Char* pInternal[ 1 ] = { "TTT" }; using namespace ::com::sun::star::i18n; @@ -2524,6 +2506,25 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) } else if (mxSymbols->isODFF()) { + // ODFF names that are not written in the current mapping but to be + // recognized. New names will be written in a future relase, then + // exchange (!) with the names in + // formula/source/core/resource/core_resource.src to be able to still + // read the old names as well. + struct FunctionName + { + const sal_Char* pName; + OpCode eOp; + }; + static const FunctionName aOdffAliases[] = { + // Renamed old names: + // XXX none yet. + // Renamed new names: + { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE + { "LEGACY.TDIST", ocTDist }, // TDIST -> LEGACY.TDIST + { "ORG.OPENOFFICE.EASTERSUNDAY", ocEasterSunday } // EASTERSUNDAY -> ORG.OPENOFFICE.EASTERSUNDAY + }; + static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); for (size_t i=0; i<nOdffAliases; ++i) { if (rName.EqualsIgnoreCaseAscii( aOdffAliases[i].pName)) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 30aa0b8aa13e..fcc7a24e7a42 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2481,22 +2481,13 @@ void ScInterpreter::ScN() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" ); USHORT nErr = nGlobalError; nGlobalError = 0; - double fVal; - if ( GetRawStackType() == svString ) - { - fVal = 0.0; - Pop(); - } - else - { - // Temporarily override the ConvertStringToValue() error for - // GetCellValue() / GetCellValueOrZero() - USHORT nSErr = mnStringNoValueError; - mnStringNoValueError = errCellNoValue; - fVal = GetDouble(); - mnStringNoValueError = nSErr; - } - if ( nGlobalError == NOTAVAILABLE || nGlobalError == errIllegalArgument ) + // Temporarily override the ConvertStringToValue() error for + // GetCellValue() / GetCellValueOrZero() + USHORT nSErr = mnStringNoValueError; + mnStringNoValueError = errCellNoValue; + double fVal = GetDouble(); + mnStringNoValueError = nSErr; + if ( nGlobalError == NOTAVAILABLE || nGlobalError == errCellNoValue ) nGlobalError = 0; // N(#NA) and N("text") are ok if ( !nGlobalError && nErr != NOTAVAILABLE ) nGlobalError = nErr; @@ -2976,10 +2967,6 @@ void ScInterpreter::ScMin( BOOL bTextAsZero ) PushDouble(nMin); } -#if defined(WIN) && defined(MSC) -#pragma optimize("",off) -#endif - void ScInterpreter::ScMax( BOOL bTextAsZero ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScMax" ); @@ -3100,10 +3087,6 @@ void ScInterpreter::ScMax( BOOL bTextAsZero ) else PushDouble(nMax); } -#if defined(WIN) && defined(MSC) -#pragma optimize("",on) -#endif - double ScInterpreter::IterateParameters( ScIterFunc eFunc, BOOL bTextAsZero ) { @@ -5789,10 +5772,6 @@ void ScInterpreter::ScVLookup() CalculateLookup(FALSE); } -#if defined(WIN) && defined(MSC) -#pragma optimize("",off) -#endif - void ScInterpreter::ScSubTotal() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSubTotal" ); @@ -5832,10 +5811,6 @@ void ScInterpreter::ScSubTotal() PushDouble( nVal ); } } -#if defined(WIN) && defined(MSC) -#pragma optimize("",on) -#endif - ScDBQueryParamBase* ScInterpreter::GetDBParams( BOOL& rMissingField ) { @@ -7097,22 +7072,71 @@ void ScInterpreter::ScText() if ( MustHaveParamCount( GetByte(), 2 ) ) { String sFormatString = GetString(); - double fVal = GetDouble(); String aStr; - Color* pColor = NULL; - LanguageType eCellLang; - const ScPatternAttr* pPattern = pDok->GetPattern( - aPos.Col(), aPos.Row(), aPos.Tab() ); - if ( pPattern ) - eCellLang = ((const SvxLanguageItem&) - pPattern->GetItem( ATTR_LANGUAGE_FORMAT )).GetValue(); - else - eCellLang = ScGlobal::eLnge; - if ( !pFormatter->GetPreviewStringGuess( sFormatString, fVal, aStr, - &pColor, eCellLang ) ) - PushIllegalArgument(); + bool bString = false; + double fVal = 0.0; + switch (GetStackType()) + { + case svError: + PopError(); + break; + case svDouble: + fVal = PopDouble(); + break; + default: + { + FormulaTokenRef xTok( PopToken()); + if (!nGlobalError) + { + PushTempToken( xTok); + // Temporarily override the ConvertStringToValue() + // error for GetCellValue() / GetCellValueOrZero() + USHORT nSErr = mnStringNoValueError; + mnStringNoValueError = errNotNumericString; + fVal = GetDouble(); + mnStringNoValueError = nSErr; + if (nGlobalError == errNotNumericString) + { + // Not numeric. + nGlobalError = 0; + PushTempToken( xTok); + aStr = GetString(); + bString = true; + } + } + } + } + if (nGlobalError) + PushError( nGlobalError); else - PushString(aStr); + { + String aResult; + Color* pColor = NULL; + LanguageType eCellLang; + const ScPatternAttr* pPattern = pDok->GetPattern( + aPos.Col(), aPos.Row(), aPos.Tab() ); + if ( pPattern ) + eCellLang = ((const SvxLanguageItem&) + pPattern->GetItem( ATTR_LANGUAGE_FORMAT )).GetValue(); + else + eCellLang = ScGlobal::eLnge; + if (bString) + { + if (!pFormatter->GetPreviewString( sFormatString, aStr, + aResult, &pColor, eCellLang)) + PushIllegalArgument(); + else + PushString( aResult); + } + else + { + if (!pFormatter->GetPreviewStringGuess( sFormatString, fVal, + aResult, &pColor, eCellLang)) + PushIllegalArgument(); + else + PushString( aResult); + } + } } } diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index dac5f0c99ac5..404eaf763a51 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -682,10 +682,6 @@ void ScInterpreter::ScNPV() } } -#if defined(WIN) && defined(MSC) -#pragma optimize("",off) -#endif - void ScInterpreter::ScIRR() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScIRR" ); @@ -752,10 +748,6 @@ void ScInterpreter::ScIRR() else PushError( errNoConvergence); } -#if defined(WIN) && defined(MSC) -#pragma optimize("",on) -#endif - void ScInterpreter::ScMIRR() { // range_of_values ; rate_invest ; rate_reinvest diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 5c326001ff02..47cde7186067 100644..100755 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -231,6 +231,12 @@ double ScInterpreter::ConvertStringToValue( const String& rStr ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ConvertStringToValue" ); double fValue = 0.0; + if (mnStringNoValueError == errCellNoValue) + { + // Requested that all strings result in 0, error handled by caller. + SetError( mnStringNoValueError); + return fValue; + } ::rtl::OUString aStr( rStr); rtl_math_ConversionStatus eStatus; sal_Int32 nParseEnd; @@ -3964,5 +3970,10 @@ StackVar ScInterpreter::Interpret() while( maxsp-- ) (*p++)->DecRef(); - return xResult->GetType(); + StackVar eType = xResult->GetType(); + if (eType == svMatrix) + // Results are immutable in case they would be reused as input for new + // interpreters. + static_cast<ScToken*>(xResult.operator->())->GetMatrix()->SetImmutable( true); + return eType; } diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index ba4322a3281a..73794cf15b2d 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -310,6 +310,9 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR) RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetNewMat" ); ScMatrix* pMat = new ScMatrix( nC, nR); pMat->SetErrorInterpreter( this); + // A temporary matrix is mutable and ScMatrix::CloneIfConst() returns the + // very matrix. + pMat->SetImmutable( false); SCSIZE nCols, nRows; pMat->GetDimensions( nCols, nRows); if ( nCols != nC || nRows != nR ) @@ -2069,23 +2072,25 @@ bool ScInterpreter::CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE { PushIllegalArgument(); return false; - } // if (!pMatY->IsValue(i)) - } // for ( SCSIZE i = 0; i < nCountY; i++ ) + } + } + if ( _bLOG ) { + ScMatrixRef pNewY = pMatY->CloneIfConst(); for (SCSIZE nElem = 0; nElem < nCountY; nElem++) { - const double fVal = pMatY->GetDouble(nElem); + const double fVal = pNewY->GetDouble(nElem); if (fVal <= 0.0) { PushIllegalArgument(); return false; } else - pMatY->PutDouble(log(fVal), nElem); - } // for (nElem = 0; nElem < nCountY; nElem++) - } // if ( _bRKP ) - + pNewY->PutDouble(log(fVal), nElem); + } + pMatY = pNewY; + } if (pMatX) { diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index fbb859b64ebf..2ecc20f53405 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -81,6 +81,11 @@ ScMatrix* ScMatrix::Clone() const return pScMat; } +ScMatrix* ScMatrix::CloneIfConst() +{ + return (mbCloneIfConst || IsEternalRef()) ? Clone() : this; +} + void ScMatrix::Resize( SCSIZE nC, SCSIZE nR) { Clear(); diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 2cf2d8f580c0..458629979172 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -420,7 +420,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) } -void ExcTable::FillAsTable( size_t nCodeNameIdx ) +void ExcTable::FillAsTable( SCTAB nCodeNameIdx ) { InitializeTable( mnScTab ); @@ -550,7 +550,7 @@ void ExcTable::FillAsTable( size_t nCodeNameIdx ) Add( new ExcEof ); } -void ExcTable::FillAsXmlTable( size_t nCodeNameIdx ) +void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx ) { RootData& rR = GetOldRoot(); @@ -640,7 +640,7 @@ void ExcTable::FillAsXmlTable( size_t nCodeNameIdx ) } -void ExcTable::FillAsEmptyTable( size_t nCodeNameIdx ) +void ExcTable::FillAsEmptyTable( SCTAB nCodeNameIdx ) { InitializeTable( mnScTab ); @@ -723,7 +723,7 @@ void ExcDocument::ReadDoc( void ) aHeader.FillAsHeader( maBoundsheetList ); SCTAB nScTab = 0, nScTabCount = GetTabInfo().GetScTabCount(); - size_t nCodeNameIdx = 0, nCodeNameCount = GetExtDocOptions().GetCodeNameCount(); + SCTAB nCodeNameIdx = 0, nCodeNameCount = GetExtDocOptions().GetCodeNameCount(); for( ; nScTab < nScTabCount; ++nScTab ) { diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 9608804da9f9..d75a0e669603 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -56,7 +56,6 @@ #include <svx/xflclit.hxx> #include <filter/msfilter/svxmsbas.hxx> #include <basic/basmgr.hxx> -#include <oox/xls/excelvbaproject.hxx> #include <vcl/graph.hxx> #include <vcl/bmpacc.hxx> @@ -243,17 +242,6 @@ void ImportExcel8::ReadBasic( void ) { SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg ); bool bAsComment = !bLoadExecutable; - if ( !bAsComment ) - { - uno::Any aGlobs; - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= pShell->GetModel(); - aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); - pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); - BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); - if ( pAppMgr ) - pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); - } aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); } } @@ -292,8 +280,6 @@ void ImportExcel8::PostDocLoad( void ) // read doc info (no docshell while pasting from clipboard) LoadDocumentProperties(); - // attach document events to VBA macros - AttachDocumentEvents(); // #i45843# Pivot tables are now handled outside of PostDocLoad, so they are available // when formula cells are calculated, for the GETPIVOTDATA function. @@ -318,21 +304,6 @@ void ImportExcel8::LoadDocumentProperties() } } -void ImportExcel8::AttachDocumentEvents() -{ - SfxObjectShell* pShell = GetDocShell(); - if( HasBasic() && pShell ) - { - uno::Reference< lang::XMultiServiceFactory > xGlobalFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< sheet::XSpreadsheetDocument > xDocument( pShell->GetModel(), uno::UNO_QUERY ); - if( xGlobalFactory.is() && xDocument.is() ) - { - ::oox::xls::VbaProject aVbaProject( xGlobalFactory, xDocument ); - aVbaProject.attachToEvents(); - } - } -} - //___________________________________________________________________ // autofilter diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 209d24ac043d..059f5ba7426b 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -87,7 +87,7 @@ #include "excimp8.hxx" #include "excform.hxx" -#if defined( WNT ) || defined( WIN ) +#if defined( WNT ) #include <math.h> #else #include <stdlib.h> diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index dc87bba4c050..8d09cae60941 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -98,7 +98,6 @@ #include "convuno.hxx" #include "postit.hxx" #include "globstr.hrc" -#include "chartlis.hxx" #include "fprogressbar.hxx" #include "xltracer.hxx" @@ -4056,9 +4055,8 @@ void XclImpObjectManager::ConvertObjects() for( XclImpSheetDrawingMap::iterator aIt = maSheetDrawings.begin(), aEnd = maSheetDrawings.end(); aIt != aEnd; ++aIt ) aIt->second->ConvertObjects( aDffConv ); - ScChartListenerCollection* pChartListeners = GetDoc().GetChartListenerCollection(); - if( pChartListeners && (pChartListeners->GetCount() > 0) ) - pChartListeners->SetDirty(); + // #i112436# don't call ScChartListenerCollection::SetDirty here, + // instead use InterpretDirtyCells in ScDocument::CalcAfterLoad. } String XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx index 70ff46a0d741..5d21d91c9f53 100644 --- a/sc/source/filter/excel/xiname.cxx +++ b/sc/source/filter/excel/xiname.cxx @@ -132,7 +132,8 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : if( nXclTab != EXC_NAME_GLOBAL ) { sal_uInt16 nUsedTab = (GetBiff() == EXC_BIFF8) ? nXclTab : nExtSheet; - maScName.Append( '_' ).Append( String::CreateFromInt32( nUsedTab ) ); + // #163146# do not rename sheet-local names by default, this breaks VBA scripts +// maScName.Append( '_' ).Append( String::CreateFromInt32( nUsedTab ) ); // TODO: may not work for BIFF5, handle skipped sheets (all BIFF) mnScTab = static_cast< SCTAB >( nUsedTab - 1 ); } @@ -208,7 +209,8 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : // 4) *** create a defined name in the Calc document *** ------------------ - if( pTokArr && (bBuiltIn || !::get_flag( nFlags, EXC_NAME_HIDDEN )) && !mbVBName ) + // #163146# do not ignore hidden names (may be regular names created by VBA scripts) + if( pTokArr /*&& (bBuiltIn || !::get_flag( nFlags, EXC_NAME_HIDDEN ))*/ && !mbVBName ) { // create the Calc name data ScRangeData* pData = new ScRangeData( GetDocPtr(), maScName, *pTokArr, ScAddress(), nNameType ); diff --git a/sc/source/filter/excel/xiroot.cxx b/sc/source/filter/excel/xiroot.cxx index 3fd2650cf2ff..5f8bcbd481e5 100644 --- a/sc/source/filter/excel/xiroot.cxx +++ b/sc/source/filter/excel/xiroot.cxx @@ -289,7 +289,7 @@ void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals ) } else { - GetExtDocOptions().AppendCodeName( aName ); + GetExtDocOptions().SetCodeName( GetCurrScTab(), aName ); GetDoc().SetCodeName( GetCurrScTab(), aName ); } } diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx index bb77fac2be73..153a5d5ed3cc 100644 --- a/sc/source/filter/excel/xlescher.cxx +++ b/sc/source/filter/excel/xlescher.cxx @@ -36,8 +36,8 @@ #include "document.hxx" #include "xestream.hxx" #include "xistream.hxx" -#include "xltools.hxx" #include "xlroot.hxx" +#include "xltools.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Reference; diff --git a/sc/source/filter/inc/excdoc.hxx b/sc/source/filter/inc/excdoc.hxx index f00e8d091590..5da6a5d38d83 100644 --- a/sc/source/filter/inc/excdoc.hxx +++ b/sc/source/filter/inc/excdoc.hxx @@ -69,7 +69,7 @@ private: // pRec mit new anlegen und vergessen, delete macht ExcTable selber! void Add( XclExpRecordBase* pRec ); - void FillAsXmlTable( size_t nCodeNameIdx ); + void FillAsXmlTable( SCTAB nCodeNameIdx ); public: ExcTable( const XclExpRoot& rRoot ); @@ -77,8 +77,8 @@ public: ~ExcTable(); void FillAsHeader( ExcBoundsheetList& rBoundsheetList ); - void FillAsTable( size_t nCodeNameIdx ); - void FillAsEmptyTable( size_t nCodeNameIdx ); + void FillAsTable( SCTAB nCodeNameIdx ); + void FillAsEmptyTable( SCTAB nCodeNameIdx ); void Write( XclExpStream& ); void WriteXml( XclExpXmlStream& ); diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx index 5b2bbe2e7b5d..7e4cca15dfe1 100644 --- a/sc/source/filter/inc/excimp8.hxx +++ b/sc/source/filter/inc/excimp8.hxx @@ -81,7 +81,6 @@ protected: private: void LoadDocumentProperties(); - void AttachDocumentEvents(); }; diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index 2f6f81b7279c..33b3c8e30b97 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -48,7 +48,7 @@ #include "lotattr.hxx" -static NAMESPACE_VOS( OMutex ) aLotImpSemaphore; +static vos:: OMutex aLotImpSemaphore; ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, CharSet eQ ) : diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 4ab0c8bb3b14..058898d16547 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -73,7 +73,7 @@ #include <string.h> #include <math.h> #include <ctype.h> -#if defined( MAC ) || defined( ICC ) +#if defined( ICC ) #include <stdlib.h> #endif diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index e43ff21a114d..f8cba5ecf6c3 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -503,9 +503,13 @@ void ScXMLExportDataPilot::WriteMembers(ScDPSaveDimension* pDim) void ScXMLExportDataPilot::WriteLevels(ScDPSaveDimension* pDim) { - rtl::OUStringBuffer sBuffer; - SvXMLUnitConverter::convertBool(sBuffer, pDim->GetShowEmpty()); - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear()); + // #i114202# GetShowEmpty is only valid if HasShowEmpty is true. + if (pDim->HasShowEmpty()) + { + rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertBool(sBuffer, pDim->GetShowEmpty()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear()); + } SvXMLElementExport aElemDPL(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, sal_True, sal_True); WriteSubTotals(pDim); diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index f8bafa32f205..66f3ea613a3a 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -1234,10 +1234,31 @@ void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nFie const sal_Int32 nStringIndex) { DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); - if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) + DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nField), "wrong field"); + if (aTables[nTable].size() == static_cast<size_t>(nField)) aTables[nTable].push_back(nStringIndex); - aTables[nTable][nField] = nStringIndex; + else + aTables[nTable][nField] = nStringIndex; +} + +void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, + const sal_Int32 nStringIndex, const sal_Int32 nEndField) +{ + DBG_ASSERT( nStartField <= nEndField, "bad field range"); + DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); + DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nStartField), "wrong field"); + ScMysalInt32Vec& rTable = aTables[nTable]; + size_t nSize = rTable.size(); + if (nSize == static_cast<size_t>(nStartField)) + rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nStartField + 1), nStringIndex); + else + { + size_t nField = static_cast<size_t>(nStartField); + for ( ; nField < nSize && nField <= static_cast<size_t>(nEndField); ++nField) + rTable[nField] = nStringIndex; + if (nField <= static_cast<size_t>(nEndField)) + rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nField + 1), nStringIndex); + } } rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) diff --git a/sc/source/filter/xml/XMLStylesExportHelper.hxx b/sc/source/filter/xml/XMLStylesExportHelper.hxx index 34672aeef96e..79b19b7ce9ab 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.hxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.hxx @@ -286,6 +286,7 @@ public: virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields); sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField); void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex); + void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField); virtual rtl::OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField); }; diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 8e78f64b2090..ae5a7bcebe66 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -487,21 +487,31 @@ void ScXMLTableRowCellContext::DoMerge(const com::sun::star::table::CellAddress& uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange()); if ( xCellRange.is() ) { - table::CellRangeAddress aCellAddress; - if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress)) + // Stored merge range may actually be of a larger extend than what + // we support, in which case getCellRangeByPosition() throws + // IndexOutOfBoundsException. Do nothing then. + try { - //unmerge + table::CellRangeAddress aCellAddress; + if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress)) + { + //unmerge + uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, + aCellAddress.EndColumn, aCellAddress.EndRow), uno::UNO_QUERY); + if (xMergeable.is()) + xMergeable->merge(sal_False); + } + + //merge uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, - aCellAddress.EndColumn, aCellAddress.EndRow), uno::UNO_QUERY); + aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows), uno::UNO_QUERY); if (xMergeable.is()) - xMergeable->merge(sal_False); + xMergeable->merge(sal_True); + } + catch ( lang::IndexOutOfBoundsException & ) + { + DBG_ERRORFILE("ScXMLTableRowCellContext::DoMerge: range to be merged larger than what we support"); } - - //merge - uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow, - aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows), uno::UNO_QUERY); - if (xMergeable.is()) - xMergeable->merge(sal_True); } } } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0563f6430063..ca5403e3b18d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2576,14 +2576,13 @@ void ScXMLExport::_ExportAutoStyles() } sal_Int32 nOld(nRow); nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow), false); - for (sal_Int32 i = nOld + 1; i < nRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + if (nRow > nOld + 1) + pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1); } if (aCellAddress.EndRow > nRows) { sal_Int32 nIndex(pRowStyles->GetStyleNameIndex(nTable, nRows)); - for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + pRowStyles->AddFieldStyleName(nTable, nRows + 1, nIndex, aCellAddress.EndRow); } } } @@ -4341,7 +4340,7 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& uno::Reference <container::XNameAccess> xCodeNameAccess; DBG_ASSERT( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" ); - if( pDoc ) + if( pDoc && pDoc->IsInVBAMode() ) { xCodeNameAccess = new XMLCodeNameProvider( pDoc ); if( xCodeNameAccess.is() && xCodeNameAccess->hasElements() ) diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index 4127f5246428..d061ea24b194 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -81,9 +81,11 @@ const XMLPropertyMapEntry aXMLScCellStylesProperties[] = MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_IMPORT_MAP ), MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MAP ), MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALBLTR ), - MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), // #i102690# for old files + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTHS ), MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALTLBR ), - MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), // #i102690# for old files + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTHS ), MAP( "HoriJustify", XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_PROP_PARAGRAPH|XML_SC_TYPE_HORIJUSTIFY|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_TEXT_ALIGN_SOURCE, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYSOURCE|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_REPEAT_CONTENT, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYREPEAT|MID_FLAG_MERGE_PROPERTY, 0 ), @@ -490,6 +492,18 @@ void ScXMLCellExportPropertyMapper::ContextFilter( pParaMarginBottomRel->maValue.clear(); } + // #i102690# old diagonal line attribute names without "s" are only read, not written + if (pDiagonalTLBRWidthState) + { + pDiagonalTLBRWidthState->mnIndex = -1; + pDiagonalTLBRWidthState->maValue.clear(); + } + if (pDiagonalBLTRWidthState) + { + pDiagonalBLTRWidthState->mnIndex = -1; + pDiagonalBLTRWidthState->maValue.clear(); + } + SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); } diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx index 07e7138afc71..f8abf5e6443d 100644 --- a/sc/source/filter/xml/xmlstyle.hxx +++ b/sc/source/filter/xml/xmlstyle.hxx @@ -90,6 +90,8 @@ extern const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]; #define CTF_SC_DIAGONALTLBRWIDTH (XML_SC_CTF_START + 26) #define CTF_SC_DIAGONALBLTR (XML_SC_CTF_START + 27) #define CTF_SC_DIAGONALBLTRWIDTH (XML_SC_CTF_START + 28) +#define CTF_SC_DIAGONALTLBRWIDTHS (XML_SC_CTF_START + 29) +#define CTF_SC_DIAGONALBLTRWIDTHS (XML_SC_CTF_START + 30) #define CTF_SC_ROWHEIGHT (XML_SC_CTF_START + 50) #define CTF_SC_ROWOPTIMALHEIGHT (XML_SC_CTF_START + 51) diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 9a04e284bf45..3866bba63239 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -105,6 +105,7 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& XMLPropertyState* pAllBorderWidthProperty = NULL; XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL }; XMLPropertyState* pDiagBorders[2] = { 0 }; + XMLPropertyState* pOldDiagBorderWidths[2] = { 0 }; // old attribute names without "s" XMLPropertyState* pDiagBorderWidths[2] = { 0 }; ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end()); @@ -134,8 +135,10 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& case CTF_SC_BOTTOMBORDERWIDTH : pBorderWidths[XML_LINE_BOTTOM] = &*property; break; case CTF_SC_DIAGONALTLBR : pDiagBorders[XML_LINE_TLBR] = &*property; break; case CTF_SC_DIAGONALBLTR : pDiagBorders[XML_LINE_BLTR] = &*property; break; - case CTF_SC_DIAGONALTLBRWIDTH : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; - case CTF_SC_DIAGONALBLTRWIDTH : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTH : pOldDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTHS : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTH : pOldDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTHS : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; } } } @@ -179,17 +182,23 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& } for( i = 0; i < 2; ++i ) { - if( pDiagBorders[i] && pDiagBorderWidths[i] ) + if( pDiagBorders[i] && ( pDiagBorderWidths[i] || pOldDiagBorderWidths[i] ) ) { table::BorderLine aBorderLine; pDiagBorders[i]->maValue >>= aBorderLine; table::BorderLine aBorderLineWidth; - pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; // prefer new attribute + else + pOldDiagBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; aBorderLine.LineDistance = aBorderLineWidth.LineDistance; pDiagBorders[i]->maValue <<= aBorderLine; - pDiagBorderWidths[i]->mnIndex = -1; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->mnIndex = -1; + if (pOldDiagBorderWidths[i]) + pOldDiagBorderWidths[i]->mnIndex = -1; // reset mnIndex for old and new attribute if both are present } } diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 6e7cfed9d95c..82c276d98f2c 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -33,12 +33,16 @@ #include "dpcontrol.hxx" #include "dpcontrol.hrc" -#include "vcl/outdev.hxx" -#include "vcl/settings.hxx" -#include "vcl/wintypes.hxx" -#include "vcl/decoview.hxx" +#include <vcl/outdev.hxx> +#include <vcl/settings.hxx> +#include <vcl/wintypes.hxx> +#include <vcl/decoview.hxx> #include "strload.hxx" #include "global.hxx" +#include "scitems.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "patattr.hxx" #include "AccessibleFilterMenu.hxx" #include "AccessibleFilterTopWindow.hxx" @@ -55,7 +59,8 @@ using ::std::vector; using ::std::hash_map; using ::std::auto_ptr; -ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY) : +ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY, ScDocument* pDoc) : + mpDoc(pDoc), mpOutDev(pOutDev), mpStyle(pStyle), mbBaseButton(true), @@ -135,17 +140,28 @@ void ScDPFieldButton::draw() Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1)); // Field name. - Font aTextFont( mpStyle->GetLabelFont() ); - double fFontHeight = 12.0; - fFontHeight *= static_cast<double>(maZoomY.GetNumerator()) / static_cast<double>(maZoomY.GetDenominator()); - aTextFont.SetHeight(static_cast<long>(fFontHeight)); + // Get the font and size the same way as in scenario selection (lcl_DrawOneFrame in gridwin4.cxx) + Font aTextFont( mpStyle->GetAppFont() ); + if ( mpDoc ) + { + // use ScPatternAttr::GetFont only for font size + Font aAttrFont; + static_cast<const ScPatternAttr&>(mpDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)). + GetFont( aAttrFont, SC_AUTOCOL_BLACK, mpOutDev, &maZoomY ); + aTextFont.SetSize( aAttrFont.GetSize() ); + } mpOutDev->SetFont(aTextFont); + mpOutDev->SetTextColor(mpStyle->GetButtonTextColor()); Point aTextPos = maPos; - long nTHeight = static_cast<long>(fFontHeight); + long nTHeight = mpOutDev->GetTextHeight(); aTextPos.setX(maPos.getX() + nMargin); aTextPos.setY(maPos.getY() + (maSize.Height()-nTHeight)/2); + + mpOutDev->Push(PUSH_CLIPREGION); + mpOutDev->IntersectClipRegion(aRect); mpOutDev->DrawText(aTextPos, maText); + mpOutDev->Pop(); } if (mbPopupButton) @@ -959,7 +975,7 @@ ScDPFieldPopupWindow::ScDPFieldPopupWindow(Window* pParent, ScDocument* pDoc) : mnCurTabStop(0), mpExtendedData(NULL), mpOKAction(NULL), - maWndSize(160, 330), + maWndSize(240, 330), mePrevToggleAllState(STATE_DONTKNOW) { maTabStopCtrls.reserve(7); @@ -1032,7 +1048,7 @@ void ScDPFieldPopupWindow::getSectionPosSize(Point& rPos, Size& rSize, SectionTy const sal_uInt16 nMenuHeight = 60; const sal_uInt16 nSingleItemBtnAreaHeight = 32; // height of the middle area below the list box where the single-action buttons are. const sal_uInt16 nBottomBtnAreaHeight = 50; // height of the bottom area where the OK and Cancel buttons are. - const sal_uInt16 nBtnWidth = 60; + const sal_uInt16 nBtnWidth = 90; const sal_uInt16 nLabelHeight = static_cast< sal_uInt16 >( getLabelFont().GetHeight() ); const sal_uInt16 nBtnHeight = nLabelHeight*2; const sal_uInt16 nBottomMargin = 10; @@ -1089,7 +1105,7 @@ void ScDPFieldPopupWindow::getSectionPosSize(Point& rPos, Size& rSize, SectionTy { long h = 26; rPos = Point(nListBoxMargin, nSingleBtnAreaY); - rPos.X() += 75; + rPos.X() += 150; rPos.Y() += (nSingleItemBtnAreaHeight - h)/2; rSize = Size(h, h); } @@ -1098,7 +1114,7 @@ void ScDPFieldPopupWindow::getSectionPosSize(Point& rPos, Size& rSize, SectionTy { long h = 26; rPos = Point(nListBoxMargin, nSingleBtnAreaY); - rPos.X() += 75 + h + 10; + rPos.X() += 150 + h + 10; rPos.Y() += (nSingleItemBtnAreaHeight - h)/2; rSize = Size(h, h); } diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index 6b04993ba0bc..b5a19ef0ec9b 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -735,8 +735,9 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR for (long nDim=0; nDim<nDimCount; nDim++) { BOOL bIsDataLayout; - String aName = rDPObj.GetDimName( nDim, bIsDataLayout ); - if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) ) + sal_Int32 nDimFlags = 0; + String aName = rDPObj.GetDimName( nDim, bIsDataLayout, &nDimFlags ); + if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) && ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ) ) { const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0; if ( !pDimension || (pDimension->GetOrientation() != nOrient) ) diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index 1eca44a787ed..56d7e3550cda 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -567,7 +567,9 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po } } - if ( (toArr->back().get() == NULL) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed + && (toArr->back().get() == NULL) && (!Contains( toArr, fData.mnCol, nAt )) ) { // ggF. in anderem Fenster entfernen @@ -714,7 +716,8 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF { ScDPFuncData fData( *((*fromArr)[nFromIndex]) ); - if ( Contains( fromArr, fData.mnCol, nAt ) ) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) ) { fromWnd->DelField( nAt ); Remove( fromArr, nAt ); @@ -935,21 +938,41 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt ) if ( bIsDrag ) { Point aPos = ScreenToOutputPixel( rAt ); + ScDPFieldType eCheckTarget = TYPE_SELECT; if ( aRectPage.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_PAGE ); + eCheckTarget = TYPE_PAGE; else if ( aRectCol.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_COL ); + eCheckTarget = TYPE_COL; else if ( aRectRow.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_ROW ); + eCheckTarget = TYPE_ROW; else if ( aRectData.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_DATA ); + eCheckTarget = TYPE_DATA; else if ( eDnDFromType != TYPE_SELECT ) ePtr = POINTER_PIVOT_DELETE; else if ( aRectSelect.IsInside( aPos ) ) ePtr = lclGetPointerForField( TYPE_SELECT ); else ePtr = POINTER_NOTALLOWED; + + if ( eCheckTarget != TYPE_SELECT ) + { + // check if the target orientation is allowed for this field + ScDPFuncDataVec* fromArr = NULL; + switch ( eDnDFromType ) + { + case TYPE_PAGE: fromArr = &aPageArr; break; + case TYPE_COL: fromArr = &aColArr; break; + case TYPE_ROW: fromArr = &aRowArr; break; + case TYPE_DATA: fromArr = &aDataArr; break; + case TYPE_SELECT: fromArr = &aSelectArr; break; + } + ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) ); + if (IsOrientationAllowed( fData.mnCol, eCheckTarget )) + ePtr = lclGetPointerForField( eCheckTarget ); + else + ePtr = POINTER_NOTALLOWED; + } } return ePtr; @@ -1218,6 +1241,28 @@ String ScDPLayoutDlg::GetLabelString( SCsCOL nCol ) return String(); } +//---------------------------------------------------------------------------- + +bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ) +{ + bool bAllowed = true; + ScDPLabelData* pData = GetLabelData( nCol ); + DBG_ASSERT( pData, "LabelData not found" ); + if (pData) + { + sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN; + switch (eType) + { + case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break; + case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break; + case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break; + case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break; + case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break; + } + bAllowed = ScDPObject::IsOrientationAllowed( (USHORT)eOrient, pData->mnFlags ); + } + return bAllowed; +} //---------------------------------------------------------------------------- diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 171daa0ca882..42f2a2d86933 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -46,13 +46,8 @@ #include <com/sun/star/uno/Sequence.hxx> #include "miscuno.hxx" - //! TODO make dynamic -#ifdef WIN -const SCSIZE ASCIIDLG_MAXROWS = 10000; -#else const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT; -#endif using namespace rtl; diff --git a/sc/source/ui/dbgui/textimportoptions.src b/sc/source/ui/dbgui/textimportoptions.src index fff3c4b40749..69e2d69b3142 100644 --- a/sc/source/ui/dbgui/textimportoptions.src +++ b/sc/source/ui/dbgui/textimportoptions.src @@ -33,34 +33,34 @@ ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS { Text [ en-US ] = "Import Options" ; - Size = MAP_APPFONT ( 190 , 101 ) ; + Size = MAP_APPFONT ( 230 , 101 ) ; Moveable = TRUE ; Closeable = TRUE ; OutputSize = TRUE ; OKButton BTN_OK { - Pos = MAP_APPFONT ( 135, 6 ) ; + Pos = MAP_APPFONT ( 175, 6 ) ; Size = MAP_APPFONT ( 50, 14 ) ; DefButton = TRUE ; }; CancelButton BTN_CANCEL { - Pos = MAP_APPFONT ( 135, 23 ) ; + Pos = MAP_APPFONT ( 175, 23 ) ; Size = MAP_APPFONT ( 50, 14 ) ; }; HelpButton BTN_HELP { - Pos = MAP_APPFONT ( 135, 43 ) ; + Pos = MAP_APPFONT ( 175, 43 ) ; Size = MAP_APPFONT ( 50, 14 ) ; }; FixedLine FL_CHOOSE_LANG { Pos = MAP_APPFONT( 6, 3 ) ; - Size = MAP_APPFONT( 125, 14 ) ; + Size = MAP_APPFONT( 165, 14 ) ; Text [ en-US ] = "Select the language to use for import" ; }; @@ -68,7 +68,7 @@ ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS RadioButton RB_AUTOMATIC { Pos = MAP_APPFONT( 12, 20 ) ; - Size = MAP_APPFONT( 50, 10 ) ; + Size = MAP_APPFONT( 159, 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Automatic" ; @@ -77,7 +77,7 @@ ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS RadioButton RB_CUSTOM { Pos = MAP_APPFONT( 12, 34 ) ; - Size = MAP_APPFONT( 50, 10 ) ; + Size = MAP_APPFONT( 159, 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Custom" ; @@ -86,7 +86,7 @@ ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS ListBox LB_CUSTOM_LANG { Pos = MAP_APPFONT( 20, 50 ) ; - Size = MAP_APPFONT( 100, 55 ) ; + Size = MAP_APPFONT( 140, 120 ) ; TabStop = TRUE ; DropDown = TRUE ; Sort = TRUE ; @@ -94,19 +94,17 @@ ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS FixedLine FL_OPTION { - Pos = MAP_APPFONT( 6, 70 ); - Size = MAP_APPFONT( 125, 14 ); - - Text [ en-US ] = "Options" ; + Pos = MAP_APPFONT( 6, 70 ); + Size = MAP_APPFONT( 165, 14 ); + Text [ en-US ] = "Options" ; }; CheckBox BTN_CONVERT_DATE { Pos = MAP_APPFONT( 12, 86 ); - Size = MAP_APPFONT( 125, 10 ); - TabStop = TRUE ; - - Text [ en-US ] = "Detect special numbers (such as dates)." ; + Size = MAP_APPFONT( 159, 10 ); + TabStop = TRUE ; + Text [ en-US ] = "Detect special numbers (such as dates)." ; }; }; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 27b8eef7bbd6..36b6641d94a6 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -50,9 +50,9 @@ #include <basic/sbstar.hxx> #include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/script/XLibraryContainer.hpp> -#include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> +#include <com/sun/star/script/XLibraryContainer.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include <list> @@ -2605,7 +2605,6 @@ uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, St script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) { - ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); script::ModuleInfo sModuleInfo; sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); @@ -2648,7 +2647,7 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String if ( sTmpSource.getLength() == 0 ) sTmpSource = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); aSourceAny <<= sTmpSource; - uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); if ( xVBAModuleInfo.is() ) { String sCodeName( genModuleName ); @@ -2679,7 +2678,7 @@ void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName ) } if( xLib.is() ) { - uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); if( xLib->hasByName( sModuleName ) ) xLib->removeByName( sModuleName ); if ( xVBAModuleInfo.is() ) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index a446c86b4d1b..d5d7f6e09292 100755..100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -29,15 +29,11 @@ #include "precompiled_sc.hxx" // System - Includes ----------------------------------------------------- - - #include "scitems.hxx" #include <editeng/eeitem.hxx> #include <editeng/svxenum.hxx> #include <svx/algitem.hxx> - - #include <sot/clsids.hxx> #include <unotools/securityoptions.hxx> #include <tools/stream.hxx> @@ -68,11 +64,15 @@ #include "chgtrack.hxx" #include "chgviset.hxx" #include <sfx2/request.hxx> -#include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/document/UpdateDocMode.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/sheet/XSpreadsheetView.hpp> #include <com/sun/star/task/XJob.hpp> - +#include <basic/sbstar.hxx> +#include <basic/basmgr.hxx> +#include <vbahelper/vbaaccesshelper.hxx> #include "scabstdlg.hxx" //CHINA001 #include <sot/formats.hxx> @@ -127,8 +127,9 @@ #include <rtl/logfile.hxx> #include <comphelper/processfactory.hxx> -#include <basic/sbstar.hxx> -#include <basic/basmgr.hxx> +#include "uiitems.hxx" +#include "cellsuno.hxx" + using namespace com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -374,28 +375,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) } else aDocument.SetInsertingFromOtherDoc( FALSE ); -#if 0 // disable load of vba related libraries - // add vba globals ( if they are availabl ) - uno::Any aGlobs; - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= GetModel(); - aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); - GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); - // Fake ThisComponent being setup by Activate ( which is a view - // related thing ), - // a) if another document is opened then in theory ThisComponent - // will be reset as before, - // b) when this document is 'really' Activated then ThisComponent - // again will be set as before - // The only wrinkle seems if this document is loaded 'InVisible' - // but.. I don't see that this is possible from the vba API - // I could be wrong though - // There may be implications setting the current component - // too early :-/ so I will just manually set the Basic Variables - BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); - if ( pAppMgr ) - pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); -#endif + aDocument.SetImportingXML( FALSE ); aDocument.EnableExecuteLink( true ); aDocument.EnableUndo( TRUE ); @@ -517,9 +497,70 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) return bRet; } - void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + if ( xVbaEvents.is() ) try + { + using namespace ::com::sun::star::script::vba::VBAEventId; + if (rHint.ISA(ScTablesHint) ) + { + const ScTablesHint& rScHint = static_cast< const ScTablesHint& >( rHint ); + if (rScHint.GetId() == SC_TAB_INSERTED) + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= rScHint.GetTab1(); + xVbaEvents->processVbaEvent( WORKBOOK_NEWSHEET, aArgs ); + } + } + else if ( rHint.ISA( SfxEventHint ) ) + { + ULONG nEventId = static_cast< const SfxEventHint& >( rHint ).GetEventId(); + switch ( nEventId ) + { + case SFX_EVENT_ACTIVATEDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_ACTIVATE, aArgs ); + } + break; + case SFX_EVENT_DEACTIVATEDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_DEACTIVATE, aArgs ); + } + break; + case SFX_EVENT_OPENDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_OPEN, aArgs ); + } + break; + case SFX_EVENT_SAVEDOCDONE: + case SFX_EVENT_SAVEASDOCDONE: + case SFX_EVENT_SAVETODOCDONE: + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= true; + xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); + } + break; + case SFX_EVENT_SAVEASDOCFAILED: + case SFX_EVENT_SAVEDOCFAILED: + case SFX_EVENT_SAVETODOCFAILED: + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= false; + xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); + } + break; + } + } + } + catch( uno::Exception& ) + { + } + if (rHint.ISA(SfxSimpleHint)) // ohne Parameter { ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId(); @@ -578,6 +619,25 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) SetReadOnlyUI( sal_True ); } } + + // VBA specific initialization + if( aDocument.IsInVBAMode() ) try + { + uno::Reference< frame::XModel > xModel( GetModel(), uno::UNO_SET_THROW ); + + // create VBAGlobals object if not yet done (this also creates the "ThisExcelDoc" symbol) + uno::Reference< lang::XMultiServiceFactory > xFactory( xModel, uno::UNO_QUERY_THROW ); + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); + + // create the VBA document event processor + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= xModel; + xVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( this, "com.sun.star.script.vba.VBASpreadsheetEventProcessor" , aArgs ), uno::UNO_QUERY ); + aDocument.SetVbaEventProcessor( xVbaEvents ); + } + catch( uno::Exception& ) + { + } } break; case SFX_EVENT_VIEWCREATED: @@ -2252,6 +2312,45 @@ BOOL __EXPORT ScDocShell::DoSaveCompleted( SfxMedium * pNewStor ) } +sal_Bool ScDocShell::QuerySlotExecutable( USHORT nSlotId ) +{ + // #i112634# ask VBA event handlers whether to save or print the document + + using namespace ::com::sun::star::script::vba; + + sal_Int32 nVbaEventId = VBAEventId::NO_EVENT; + uno::Sequence< uno::Any > aArgs; + switch( nSlotId ) + { + case SID_SAVEDOC: + case SID_SAVEASDOC: + nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE; + aArgs.realloc( 1 ); + aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); + break; + case SID_PRINTDOC: + case SID_PRINTDOCDIRECT: + nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT; + break; + } + + sal_Bool bSlotExecutable = sal_True; + if( nVbaEventId != VBAEventId::NO_EVENT ) try + { + uno::Reference< XVBAEventProcessor > xEventProcessor( aDocument.GetVbaEventProcessor(), uno::UNO_QUERY_THROW ); + xEventProcessor->processVbaEvent( nVbaEventId, aArgs ); + } + catch( util::VetoException& ) + { + bSlotExecutable = sal_False; + } + catch( uno::Exception& ) + { + } + return bSlotExecutable; +} + + USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) { if(SC_MOD()->GetCurRefDlgId()>0) @@ -2278,6 +2377,26 @@ USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) DoEnterHandler(); + // start 'Workbook_BeforeClose' VBA event handler for possible veto + if( !IsInPrepareClose() ) + { + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs ); + } + catch( util::VetoException& ) + { + // if event processor throws VetoException, macro has vetoed close + return sal_False; + } + catch( uno::Exception& ) + { + } + } + // end handler code + USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing ); if (nRet == TRUE) // TRUE = schliessen aDocument.DisableIdle(TRUE); // nicht mehr drin rumpfuschen !!! diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 0993d2ce4a14..d50ce6f21c9c 100755..100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1293,7 +1293,7 @@ void ScDocShell::DoHardRecalc( BOOL /* bApi */ ) // (might check for the presence of any formulas on each sheet) SCTAB nTabCount = aDocument.GetTableCount(); SCTAB nTab; - if (aDocument.HasSheetEventScript( SC_SHEETEVENT_CALCULATE )) + if (aDocument.HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true )) // search also for VBA hendler for (nTab=0; nTab<nTabCount; nTab++) aDocument.SetCalcNotification(nTab); diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 0569e95605b1..7fa31246275a 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -2024,7 +2024,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri if (!isFileLoadable(aFile)) return NULL; - String aOptions; + String aOptions( pFileData->maFilterOptions ); ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false); const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter); @@ -2040,9 +2040,6 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri setRelativeFileName(nFileId, aStr); } - // Update the filter data now that we are loading it again. - setFilterData(nFileId, rFilter, aOptions); - SfxItemSet* pSet = new SfxAllItemSet(SFX_APP()->GetPool()); if (aOptions.Len()) pSet->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, aOptions)); @@ -2077,6 +2074,13 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri pExtOptNew->GetDocSettings().mnLinkCnt = nLinkCount + 1; pNewShell->DoLoad(pMedium.release()); + + // with UseInteractionHandler, options may be set by dialog during DoLoad + String aNew = ScDocumentLoader::GetOptions(*pNewShell->GetMedium()); + if (aNew.Len() && aNew != aOptions) + aOptions = aNew; + setFilterData(nFileId, rFilter, aOptions); // update the filter data, including the new options + return aRef; } diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index bfbeba2d1302..a5159d8a8043 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -486,11 +486,16 @@ void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN ) { SdrView * pView = pViewData->GetScDrawView(); - EditView & rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); String aStatusVal; LanguageType nLang = LANGUAGE_NONE; - bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + bool bIsLookUpWord = false; + if ( pOutView ) + { + EditView& rEditView = pOutView->GetEditView(); + bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + } rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); // disable thesaurus main menu and context menu entry if there is nothing to look up diff --git a/sc/source/ui/drawfunc/futext2.cxx b/sc/source/ui/drawfunc/futext2.cxx index 340e71faa71c..ef7e0d675162 100644 --- a/sc/source/ui/drawfunc/futext2.cxx +++ b/sc/source/ui/drawfunc/futext2.cxx @@ -129,10 +129,6 @@ //#define _GRAPH_HXX #define _SOUND_HXX -#if defined WIN -#define _MENUBTN_HXX -#endif - //svtools #define _SCRWIN_HXX #define _RULER_HXX diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 5b4fc6227225..19147cfaf61f 100755..100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -215,6 +215,7 @@ public: virtual BOOL SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ); // SfxInPlaceObject virtual BOOL DoSaveCompleted( SfxMedium * pNewStor); // SfxObjectShell + virtual sal_Bool QuerySlotExecutable( USHORT nSlotId ); virtual void Draw( OutputDevice *, const JobSetup & rSetup, USHORT nAspect = ASPECT_CONTENT ); diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index 15f0c9174cc8..45badf0c88fd 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -64,7 +64,8 @@ class ScAccessibleFilterMenu; class ScDPFieldButton { public: - ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL); + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL, + ScDocument* pDoc = NULL); ~ScDPFieldButton(); void setText(const ::rtl::OUString& rText); @@ -86,6 +87,7 @@ private: ::rtl::OUString maText; Fraction maZoomX; Fraction maZoomY; + ScDocument* mpDoc; OutputDevice* mpOutDev; const StyleSettings* mpStyle; bool mbBaseButton; diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc index becd05165a4e..00b1658849d6 100644 --- a/sc/source/ui/inc/miscdlgs.hrc +++ b/sc/source/ui/inc/miscdlgs.hrc @@ -185,5 +185,4 @@ // Tab Bg Color #define TAB_BG_COLOR_CT_BORDER 1 #define TAB_BG_COLOR_SET_BGDCOLOR 2 -#define TAB_BG_COLOR_GB_BGDCOLOR 3 diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx index c74b9e028d2f..e16c3266510e 100644 --- a/sc/source/ui/inc/pvlaydlg.hxx +++ b/sc/source/ui/inc/pvlaydlg.hxx @@ -198,6 +198,7 @@ private: Point DlgPos2WndPos ( const Point& rPt, Window& rWnd ); ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL ); String GetLabelString ( SCsCOL nCol ); + bool IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ); String GetFuncString ( USHORT& rFuncMask, BOOL bIsValue = TRUE ); BOOL Contains ( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt ); void Remove ( ScDPFuncDataVec* pArr, size_t nAt ); diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx index 241fc806022d..338609ae0e4d 100644 --- a/sc/source/ui/inc/tabbgcolordlg.hxx +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -32,7 +32,6 @@ #define SC_TABBGCOLORDLG_HXX #include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> #include <vcl/imagebtn.hxx> #include <svtools/valueset.hxx> @@ -63,7 +62,6 @@ private: Control aBorderWin; ScTabBgColorValueSet aTabBgColorSet; - FixedLine aTabBgColorBox; OKButton aBtnOk; CancelButton aBtnCancel; HelpButton aBtnHelp; diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index b4313c1d7a32..28cc2a823928 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -144,7 +144,6 @@ private: ScNavigatorSettings* pNavSettings; // used in first Activate - ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aPendingUserData; BOOL bFirstActivate; BOOL bActiveDrawSh; diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 106d196a8175..fb9c674a4488 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -482,6 +482,24 @@ public: BOOL IsSelCtrlMouseClick() { return bSelCtrlMouseClick; } static inline long ToPixel( USHORT nTwips, double nFactor ); + + /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY + may be > nEndPixels! + */ + static void AddPixelsWhile( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nEndRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); + + /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated >= nStartRow, + rScrY may be > nEndPixels! + */ + static void AddPixelsWhileBackward( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nStartRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); }; diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index fdc4c9fd34bf..463c06d76712 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -39,14 +39,15 @@ #include "scresid.hxx" #include "miscdlgs.hrc" -#include "tools/debug.hxx" -#include "tools/color.hxx" -#include "sfx2/objsh.hxx" -#include "svx/xtable.hxx" -#include "svx/drawitem.hxx" -#include "unotools/pathoptions.hxx" -#include "tools/resid.hxx" -#include "editeng/editrids.hrc" +#include <tools/debug.hxx> +#include <tools/color.hxx> +#include <sfx2/objsh.hxx> +#include <svx/xtable.hxx> +#include <svx/drawitem.hxx> +#include <unotools/pathoptions.hxx> +#include <tools/resid.hxx> +#include <editeng/editrids.hrc> +#include <editeng/eerdll.hxx> #include <boost/scoped_ptr.hpp> @@ -62,7 +63,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ), aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ), aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ), - aTabBgColorBox ( this, ScResId( TAB_BG_COLOR_GB_BGDCOLOR ) ), aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), aBtnHelp ( this, ScResId( BTN_HELP ) ), @@ -75,7 +75,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, this->SetText( rTitle ); this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE); - aTabBgColorBox.SetText(rTitle); FillColorValueSets_Impl(); aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) ); aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) ); @@ -120,7 +119,7 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() long nCount = pColorTable->Count(); XColorEntry* pEntry = NULL; Color aColWhite( COL_WHITE ); - String aStrWhite( ScResId( RID_SVXITEMS_COLOR_WHITE ) ); + String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) ); WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); aTabBgColorSet.SetText( aTabBgColorNoColorText ); aTabBgColorSet.SetStyle( nBits ); diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src index ea7cabf7716d..4c64e312bc2d 100644 --- a/sc/source/ui/src/optdlg.src +++ b/sc/source/ui/src/optdlg.src @@ -152,13 +152,13 @@ TabPage RID_SCPAGE_CALC CheckBox BTN_GENERAL_PREC { Pos = MAP_APPFONT ( 12 , 147 ) ; - Size = MAP_APPFONT ( 136 , 10 ) ; + Size = MAP_APPFONT ( 148 , 10 ) ; Text [ en-US ] = "Limit decimals for general number format" ; }; FixedText FT_PREC { - Pos = MAP_APPFONT ( 150 , 148 ) ; - Size = MAP_APPFONT ( 72 , 8 ) ; + Pos = MAP_APPFONT ( 138 , 148 ) ; + Size = MAP_APPFONT ( 84 , 8 ) ; Text [ en-US ] = "~Decimal places" ; Right = TRUE ; }; diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index c284045c5b11..3fb2c74a9954 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -592,7 +592,7 @@ ScUndoDeleteMulti::ScUndoDeleteMulti( ScDocShell* pNewDocShell, __EXPORT ScUndoDeleteMulti::~ScUndoDeleteMulti() { - delete pRanges; + delete [] pRanges; } String __EXPORT ScUndoDeleteMulti::GetComment() const diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 2d8340ad030b..70845f6c0bc9 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -28,18 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - -//------------------------------------------------------------------ - -// ?#define _MACRODLG_HXX -// ? #define _BIGINT_HXX -// ? #define _SVDXOUT_HXX -// ? #define _SVDATTR_HXX -// ? #define _SVDSURO_HXX - -// INCLUDE --------------------------------------------------------------- - #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 8b20d9849f47..437c220ba1c3 100644 --- a/sc/source/ui/unoobj/appluno.cxx +++ b/sc/source/ui/unoobj/appluno.cxx @@ -184,21 +184,6 @@ SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "ScSpreadsheetSettings", SCSPREAD //------------------------------------------------------------------------ -static void lcl_WriteInfo( registry::XRegistryKey* pRegistryKey, - const rtl::OUString& rImplementationName, - const uno::Sequence< rtl::OUString >& rServices ) - throw( registry::InvalidRegistryException ) -{ - rtl::OUString aImpl(rtl::OUString::createFromAscii( "/" )); - aImpl += rImplementationName; - aImpl += rtl::OUString::createFromAscii( "/UNO/SERVICES" ); - uno::Reference<registry::XRegistryKey> xNewKey(pRegistryKey->createKey(aImpl)); - - const rtl::OUString* pArray = rServices.getConstArray(); - for( sal_Int32 i = 0; i < rServices.getLength(); i++ ) - xNewKey->createKey( pArray[i]); -} - extern "C" { SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( @@ -207,111 +192,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void * /* pServiceManager */, registry::XRegistryKey * pRegistryKey ) -{ - if (pRegistryKey) - { - try - { - lcl_WriteInfo( pRegistryKey, - ScSpreadsheetSettings::getImplementationName_Static(), - ScSpreadsheetSettings::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScRecentFunctionsObj::getImplementationName_Static(), - ScRecentFunctionsObj::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScFunctionListObj::getImplementationName_Static(), - ScFunctionListObj::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScAutoFormatsObj::getImplementationName_Static(), - ScAutoFormatsObj::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScFunctionAccess::getImplementationName_Static(), - ScFunctionAccess::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScFilterOptionsObj::getImplementationName_Static(), - ScFilterOptionsObj::getSupportedServiceNames_Static() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLImport_getImplementationName(), - ScXMLImport_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLImport_Meta_getImplementationName(), - ScXMLImport_Meta_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLImport_Styles_getImplementationName(), - ScXMLImport_Styles_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLImport_Content_getImplementationName(), - ScXMLImport_Content_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLImport_Settings_getImplementationName(), - ScXMLImport_Settings_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOOoExport_getImplementationName(), - ScXMLOOoExport_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOOoExport_Meta_getImplementationName(), - ScXMLOOoExport_Meta_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOOoExport_Styles_getImplementationName(), - ScXMLOOoExport_Styles_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOOoExport_Content_getImplementationName(), - ScXMLOOoExport_Content_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOOoExport_Settings_getImplementationName(), - ScXMLOOoExport_Settings_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOasisExport_getImplementationName(), - ScXMLOasisExport_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOasisExport_Meta_getImplementationName(), - ScXMLOasisExport_Meta_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOasisExport_Styles_getImplementationName(), - ScXMLOasisExport_Styles_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOasisExport_Content_getImplementationName(), - ScXMLOasisExport_Content_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScXMLOasisExport_Settings_getImplementationName(), - ScXMLOasisExport_Settings_getSupportedServiceNames() ); - - lcl_WriteInfo( pRegistryKey, - ScDocument_getImplementationName(), - ScDocument_getSupportedServiceNames() ); - - return sal_True; - } - catch (registry::InvalidRegistryException&) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; -} - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ ) { diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index 75e415b8f018..a680185a1d1c 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -193,11 +193,14 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue( if (pPrinter) { String aString(sPrinterName); - SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString ); - if (pNewPrinter->IsKnown()) - pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER ); - else - delete pNewPrinter; + if (pPrinter->GetName() != aString) + { + SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString ); + if (pNewPrinter->IsKnown()) + pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER ); + else + delete pNewPrinter; + } } else throw uno::RuntimeException(); diff --git a/sc/source/ui/unoobj/detreg.cxx b/sc/source/ui/unoobj/detreg.cxx index 498d0fc886ec..e1e77e5deac9 100644 --- a/sc/source/ui/unoobj/detreg.cxx +++ b/sc/source/ui/unoobj/detreg.cxx @@ -49,27 +49,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; } -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /* pServiceManager */ , - void* pRegistryKey ) -{ - Reference< ::registry::XRegistryKey > - xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ; - - OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") ); - OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ); - - // Eigentliche Implementierung und ihre Services registrieren - sal_Int32 i; - Reference< ::registry::XRegistryKey > xNewKey(xKey->createKey( aDelimiter + ScFilterDetect::impl_getStaticImplementationName() + - aUnoServices )); - - Sequence< OUString > aServices(ScFilterDetect::impl_getStaticSupportedServiceNames()); - for(i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; -} - SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, void* pServiceManager, void* /* pRegistryKey */ ) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 6d267d4098ff..3d3f0f479601 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -28,14 +28,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - #include "scitems.hxx" #include <svx/fmdpage.hxx> #include <svx/fmview.hxx> #include <svx/svditer.hxx> #include <svx/svdpage.hxx> #include <svx/svxids.hrc> +#include <svx/unoshape.hxx> #include <svl/numuno.hxx> #include <svl/smplhint.hxx> @@ -49,6 +48,7 @@ #include <tools/multisel.hxx> #include <tools/resary.hxx> #include <toolkit/awt/vclxdevice.hxx> + #include <ctype.h> #include <float.h> // DBL_MAX @@ -61,6 +61,7 @@ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> #include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/reflection/XIdlClassProvider.hpp> #include <comphelper/processfactory.hxx> @@ -100,10 +101,6 @@ #include "sc.hrc" #include "scresid.hxx" -#ifndef _SVX_UNOSHAPE_HXX -#include <svx/unoshape.hxx> -#endif - using namespace com::sun::star; //------------------------------------------------------------------------ @@ -592,8 +589,8 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) DELETEZ( pPrintFuncCache ); - // handle "OnCalculate" sheet events - if ( pDocShell && pDocShell->GetDocument()->HasSheetEventScript( SC_SHEETEVENT_CALCULATE ) ) + // handle "OnCalculate" sheet events (search also for VBA event handlers) + if ( pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) ) HandleCalculateEvents(); } } @@ -2156,20 +2153,8 @@ bool ScModelObj::HasChangesListeners() const if ( maChangesListeners.getLength() > 0 ) return true; - if ( pDocShell ) - { - // "change" event set in any sheet? - ScDocument* pDoc = pDocShell->GetDocument(); - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab = 0; nTab < nTabCount; nTab++) - { - const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); - if (pEvents && pEvents->GetScript(SC_SHEETEVENT_CHANGE)) - return true; - } - } - - return false; + // "change" event set in any sheet? + return pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript(SC_SHEETEVENT_CHANGE); } void ScModelObj::NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges, @@ -2283,17 +2268,29 @@ void ScModelObj::HandleCalculateEvents() SCTAB nTabCount = pDoc->GetTableCount(); for (SCTAB nTab = 0; nTab < nTabCount; nTab++) { - const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); - if (pEvents) + if (pDoc->HasCalcNotification(nTab)) { - const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE); - if (pScript && pDoc->HasCalcNotification(nTab)) + if (const ScSheetEvents* pEvents = pDoc->GetSheetEvents( nTab )) + { + if (const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE)) + { + uno::Any aRet; + uno::Sequence<uno::Any> aParams; + uno::Sequence<sal_Int16> aOutArgsIndex; + uno::Sequence<uno::Any> aOutArgs; + pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); + } + } + + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs ); + } + catch( uno::Exception& ) { - uno::Any aRet; - uno::Sequence<uno::Any> aParams; - uno::Sequence<sal_Int16> aOutArgsIndex; - uno::Sequence<uno::Any> aOutArgs; - pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } } diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 0b3a6f01f9ea..a173e6d1e051 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -65,6 +65,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> #include <svx/unomod.hxx> +#include <vbahelper/vbaaccesshelper.hxx> #include <comphelper/processfactory.hxx> #include <basic/basmgr.hxx> @@ -72,19 +73,6 @@ using namespace ::com::sun::star; -#ifndef CWS_NPOWER14MISCFIXES -uno::Reference< uno::XInterface > lcl_createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException) -{ - uno::Any aUnoVar; - if ( !pShell || !pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) - throw lang::IllegalArgumentException(); - uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW ); - ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); - uno::Reference< uno::XInterface > xIf = xVBAFactory->createInstanceWithArguments( sVarName, aArgs ); - return xIf; -} -#endif - class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess > { uno::Any maWorkbook; @@ -98,13 +86,10 @@ public: throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() ); uno::Sequence< uno::Any > aArgs(2); - aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); + // access the application object ( parent for workbook ) + aArgs[0] = uno::Any( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.Application", uno::Sequence< uno::Any >() ) ); aArgs[1] = uno::Any( mpDocShell->GetModel() ); -#ifdef CWS_NPOWER14MISCFIXES maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); -#else - maWorkbook <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); -#endif } virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) @@ -139,13 +124,8 @@ public: aArgs[0] = maWorkbook; aArgs[1] = uno::Any( xModel ); aArgs[2] = uno::Any( rtl::OUString( sSheetName ) ); -#ifdef CWS_NPOWER14MISCFIXES // use the convience function maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); -#else - // use the temp function - maCachedObject <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); -#endif break; } } @@ -557,6 +537,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( break; case SC_SERVICE_OPCODEMAPPER: + if (pDocShell) { ScDocument* pDoc = pDocShell->GetDocument(); ScAddress aAddress; @@ -566,44 +547,35 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( break; } case SC_SERVICE_VBAOBJECTPROVIDER: - if ( pDocShell ) + if (pDocShell && pDocShell->GetDocument()->IsInVBAMode()) { OSL_TRACE("**** creating VBA Object mapper"); xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell ))); } break; case SC_SERVICE_VBACODENAMEPROVIDER: + if (pDocShell && pDocShell->GetDocument()->IsInVBAMode()) { - // Only create the excel faking service for excel docs - const SfxFilter *pFilt = pDocShell->GetMedium()->GetFilter(); - if ( pFilt && pFilt->IsAlienFormat() ) - { - // application/vnd.ms-excel is the mime type for Excel - static const rtl::OUString sExcelMimeType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.ms-excel" ) ); - if ( sExcelMimeType.equals( pFilt->GetMimeType() ) ) - xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell ))); - } - break; + OSL_TRACE("**** creating VBA Object provider"); + xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell ))); } + break; case SC_SERVICE_VBAGLOBALS: + if (pDocShell) { uno::Any aGlobs; - ScDocument* pDoc = pDocShell->GetDocument(); - if ( pDoc ) + if ( !pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aGlobs ) ) { - if ( !pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aGlobs ) ) - { - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= pDocShell->GetModel(); - aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); - pDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); - BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); - if ( pAppMgr ) - pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); - } - aGlobs >>= xRet; + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= pDocShell->GetModel(); + xRet = ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); + pDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", uno::Any( xRet ) ); + BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); + if ( pAppMgr ) + pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); } } + break; } return xRet; diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index d10d3ba54f86..fd1e655b8ffb 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -28,6 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/view/DocumentZoomType.hpp> #include <editeng/outliner.hxx> #include <svx/fmdpage.hxx> @@ -67,8 +71,6 @@ #include "appoptio.hxx" #include "gridwin.hxx" #include "sheetevents.hxx" -#include <com/sun/star/view/DocumentZoomType.hpp> -#include <com/sun/star/awt/MouseButton.hpp> #include "AccessibilityHints.hxx" #include <svx/sdrhittesthelper.hxx> @@ -468,7 +470,8 @@ void SAL_CALL ScViewPaneObj::release() throw() //UNUSED2008-05 aPropSet( lcl_GetViewOptPropertyMap() ), //UNUSED2008-05 aMouseClickHandlers( 0 ), //UNUSED2008-05 aActivationListeners( 0 ), -//UNUSED2008-05 bDrawSelModeSet(sal_False) +//UNUSED2008-05 bDrawSelModeSet(sal_False), +//UNUSED2008-05 bFilteredRangeSelection(sal_True) //UNUSED2008-05 { //UNUSED2008-05 } @@ -551,10 +554,22 @@ void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent ) uno::Sequence<uno::Any> aParams; uno::Sequence<sal_Int16> aOutArgsIndex; uno::Sequence<uno::Any> aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } + + // execute VBA event handlers + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); + } + catch( uno::Exception& ) + { + } } void ScTabViewObj::SheetChanged() @@ -1242,14 +1257,12 @@ bool ScTabViewObj::IsMouseListening() const return true; // also include sheet events, because MousePressed must be called for them - ScTabViewShell* pViewSh = GetViewShell(); - ScViewData* pViewData = pViewSh->GetViewData(); - const ScSheetEvents* pEvents = pViewData->GetDocument()->GetSheetEvents(pViewData->GetTabNo()); - if ( pEvents && ( pEvents->GetScript(SC_SHEETEVENT_RIGHTCLICK) != NULL || - pEvents->GetScript(SC_SHEETEVENT_DOUBLECLICK) != NULL ) ) - return true; - - return false; + ScViewData* pViewData = GetViewShell()->GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + SCTAB nTab = pViewData->GetTabNo(); + return + pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) || + pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ); } sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) @@ -1257,33 +1270,29 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) { sal_Bool bReturn(sal_False); - if (aMouseClickHandlers.Count()) + uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); + if (aMouseClickHandlers.Count() && xTarget.is()) { - uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); + awt::EnhancedMouseEvent aMouseEvent; - if (xTarget.is()) - { - awt::EnhancedMouseEvent aMouseEvent; + aMouseEvent.Buttons = e.Buttons; + aMouseEvent.X = e.X; + aMouseEvent.Y = e.Y; + aMouseEvent.ClickCount = e.ClickCount; + aMouseEvent.PopupTrigger = e.PopupTrigger; + aMouseEvent.Target = xTarget; - aMouseEvent.Buttons = e.Buttons; - aMouseEvent.X = e.X; - aMouseEvent.Y = e.Y; - aMouseEvent.ClickCount = e.ClickCount; - aMouseEvent.PopupTrigger = e.PopupTrigger; - aMouseEvent.Target = xTarget; - - for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ ) + for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ ) + { + try { - try - { - if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent )) - bReturn = sal_True; - } - catch ( uno::Exception& ) - { - aMouseClickHandlers.DeleteAndDestroy(n); - --n; // because it will be increased again in the loop - } + if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent )) + bReturn = sal_True; + } + catch ( uno::Exception& ) + { + aMouseClickHandlers.DeleteAndDestroy(n); + --n; // because it will be increased again in the loop } } } @@ -1291,7 +1300,7 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) // handle sheet events bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 ); bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 ); - if ( ( bDoubleClick || bRightClick ) && !bReturn ) + if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is()) { sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK; @@ -1307,28 +1316,41 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) if (pScript) { // the macro parameter is the clicked object, as in the mousePressed call above - uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); - if (xTarget.is()) - { - uno::Sequence<uno::Any> aParams(1); - aParams[0] <<= xTarget; + uno::Sequence<uno::Any> aParams(1); + aParams[0] <<= xTarget; - uno::Any aRet; - uno::Sequence<sal_Int16> aOutArgsIndex; - uno::Sequence<uno::Any> aOutArgs; + uno::Any aRet; + uno::Sequence<sal_Int16> aOutArgsIndex; + uno::Sequence<uno::Any> aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); + /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); - // look for a boolean return value of true - sal_Bool bRetValue = sal_False; - if (aRet >>= bRetValue) - { - if (bRetValue) - bReturn = sal_True; - } + // look for a boolean return value of true + sal_Bool bRetValue = sal_False; + if (aRet >>= bRetValue) + { + if (bRetValue) + bReturn = sal_True; } } } + + // execute VBA event handler + if (!bReturn && xTarget.is()) try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= xTarget; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); + } + catch( util::VetoException& ) + { + bReturn = sal_True; + } + catch( uno::Exception& ) + { + } } return bReturn; @@ -1820,14 +1842,25 @@ void ScTabViewObj::SelectionChanged() // the macro parameter is the selection as returned by getSelection uno::Sequence<uno::Any> aParams(1); aParams[0] = getSelection(); - uno::Any aRet; uno::Sequence<sal_Int16> aOutArgsIndex; uno::Sequence<uno::Any> aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } + + // execute VBA event handler + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= getSelection(); + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs ); + } + catch( uno::Exception& ) + { + } } diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index b1c4db637434..2c39d7154b4b 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -31,6 +31,7 @@ #include "scmod.hxx" #include "cellsuno.hxx" #include <comphelper/processfactory.hxx> +#include <com/sun/star/sheet/XSheetCellRange.hpp> using namespace ::com::sun::star; using namespace ::ooo::vba; @@ -41,6 +42,27 @@ namespace vba { namespace excel { + +ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) +{ + ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xRange ); + if ( !pScCellRangesBase ) + { + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying doc shell uno range object" ) ), uno::Reference< uno::XInterface >() ); + } + return pScCellRangesBase->GetDocShell(); +} + +ScDocument* GetDocumentFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) +{ + ScDocShell* pDocShell = GetDocShellFromRange( xRange ); + if ( !pDocShell ) + { + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying document from uno range object" ) ), uno::Reference< uno::XInterface >() ); + } + return pDocShell->GetDocument(); +} + void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ) { ScTabViewShell* pViewSh = excel::getBestViewShell( xModel ); @@ -207,12 +229,40 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) return NULL; } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW ); + rtl::OUString sCodeName; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName; + // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible + // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there + // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at + // the document in the future could fix this, especially IF the switching of the vba mode takes care to + // create the special document module objects if they don't exist. + uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xRange ) ), uno::UNO_QUERY ); + + return xParent; +} + +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException ) +{ + uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); + uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW ); + + return getUnoSheetModuleObj( xRange ); +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } + } //excel } //vba } //ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 9af804ab169f..da0474e6ceb0 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -29,6 +29,9 @@ #include<vbahelper/vbahelper.hxx> #include <docsh.hxx> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <ooo/vba/XHelperInterface.hpp> class ScCellRangesBase; @@ -48,6 +51,11 @@ namespace ooo ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); + css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); + css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); + ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); class ScVbaCellRangeAccess { public: diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 0a84b8dd12a5..92bb3fd39db0 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -47,62 +47,64 @@ INCPRE=$(INCCOM)$/$(TARGET) # ------------------------------------------------------------------ SLOFILES= \ - $(SLO)$/vbaglobals.obj \ - $(SLO)$/vbaworkbook.obj \ - $(SLO)$/vbaworksheets.obj \ + $(SLO)$/excelvbahelper.obj \ + $(SLO)$/service.obj \ $(SLO)$/vbaapplication.obj \ - $(SLO)$/vbarange.obj \ - $(SLO)$/vbaname.obj \ - $(SLO)$/vbanames.obj \ - $(SLO)$/vbacomment.obj \ - $(SLO)$/vbacomments.obj \ - $(SLO)$/vbaworkbooks.obj \ - $(SLO)$/vbaworksheet.obj \ - $(SLO)$/vbaoutline.obj \ - $(SLO)$/vbafont.obj\ - $(SLO)$/excelvbahelper.obj\ - $(SLO)$/vbainterior.obj\ - $(SLO)$/vbawsfunction.obj\ - $(SLO)$/vbawindow.obj\ - $(SLO)$/vbachart.obj\ - $(SLO)$/vbachartobject.obj\ - $(SLO)$/vbachartobjects.obj\ - $(SLO)$/vbaseriescollection.obj\ - $(SLO)$/vbadialogs.obj \ - $(SLO)$/vbadialog.obj \ - $(SLO)$/vbapivottable.obj \ - $(SLO)$/vbapivotcache.obj \ - $(SLO)$/vbapivottables.obj \ - $(SLO)$/vbawindows.obj \ - $(SLO)$/vbapalette.obj \ + $(SLO)$/vbaassistant.obj \ + $(SLO)$/vbaaxes.obj \ + $(SLO)$/vbaaxis.obj \ + $(SLO)$/vbaaxistitle.obj \ $(SLO)$/vbaborders.obj \ $(SLO)$/vbacharacters.obj \ - $(SLO)$/vbavalidation.obj \ - $(SLO)$/vbasheetobject.obj \ - $(SLO)$/vbasheetobjects.obj \ - $(SLO)$/vbaoleobject.obj \ - $(SLO)$/vbaoleobjects.obj \ - $(SLO)$/vbatextboxshape.obj \ - $(SLO)$/vbapane.obj \ - $(SLO)$/vbatextframe.obj \ - $(SLO)$/vbacharttitle.obj \ + $(SLO)$/vbachart.obj \ + $(SLO)$/vbachartobject.obj \ + $(SLO)$/vbachartobjects.obj \ $(SLO)$/vbacharts.obj \ - $(SLO)$/vbaaxistitle.obj \ - $(SLO)$/vbaaxes.obj \ - $(SLO)$/vbaaxis.obj \ - $(SLO)$/vbaformat.obj \ + $(SLO)$/vbacharttitle.obj \ + $(SLO)$/vbacomment.obj \ + $(SLO)$/vbacomments.obj \ $(SLO)$/vbacondition.obj \ + $(SLO)$/vbadialog.obj \ + $(SLO)$/vbadialogs.obj \ + $(SLO)$/vbaeventshelper.obj \ + $(SLO)$/vbafont.obj \ + $(SLO)$/vbaformat.obj \ $(SLO)$/vbaformatcondition.obj \ $(SLO)$/vbaformatconditions.obj \ - $(SLO)$/vbastyle.obj \ - $(SLO)$/vbastyles.obj \ - $(SLO)$/vbaassistant.obj \ + $(SLO)$/vbaglobals.obj \ $(SLO)$/vbahyperlink.obj \ $(SLO)$/vbahyperlinks.obj \ - $(SLO)$/vbapagesetup.obj \ + $(SLO)$/vbainterior.obj \ + $(SLO)$/vbaname.obj \ + $(SLO)$/vbanames.obj \ + $(SLO)$/vbaoleobject.obj \ + $(SLO)$/vbaoleobjects.obj \ + $(SLO)$/vbaoutline.obj \ $(SLO)$/vbapagebreak.obj \ $(SLO)$/vbapagebreaks.obj \ - $(SLO)$/service.obj + $(SLO)$/vbapagesetup.obj \ + $(SLO)$/vbapalette.obj \ + $(SLO)$/vbapane.obj \ + $(SLO)$/vbapivotcache.obj \ + $(SLO)$/vbapivottable.obj \ + $(SLO)$/vbapivottables.obj \ + $(SLO)$/vbarange.obj \ + $(SLO)$/vbaseriescollection.obj \ + $(SLO)$/vbasheetobject.obj \ + $(SLO)$/vbasheetobjects.obj \ + $(SLO)$/vbastyle.obj \ + $(SLO)$/vbastyles.obj \ + $(SLO)$/vbatextboxshape.obj \ + $(SLO)$/vbatextframe.obj \ + $(SLO)$/vbavalidation.obj \ + $(SLO)$/vbawindow.obj \ + $(SLO)$/vbawindows.obj \ + $(SLO)$/vbaworkbook.obj \ + $(SLO)$/vbaworkbooks.obj \ + $(SLO)$/vbaworksheet.obj \ + $(SLO)$/vbaworksheets.obj \ + $(SLO)$/vbawsfunction.obj + .ENDIF # --- Targets ------------------------------------------------------ diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 8be0f6d9f726..7e986338e7d1 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -66,6 +66,10 @@ namespace application { extern sdecl::ServiceDecl const serviceDecl; } +namespace vbaeventshelper +{ +extern sdecl::ServiceDecl const serviceDecl; +} namespace textframe { extern sdecl::ServiceDecl const serviceDecl; @@ -80,41 +84,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - OSL_TRACE("In component_writeInfo"); -#if 0 - // Component registration - if ( component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) ) - { - // Singleton registration - try - { - registry::XRegistryKey * pKey = - reinterpret_cast< registry::XRegistryKey * >(pRegistryKey); - - Reference< registry::XRegistryKey >xKey = pKey->createKey( - rtl::OUString::createFromAscii( ("ooo.vba.Globals/UNO/SINGLETONS/ooo.vba.theGlobals") ) ); - xKey->setStringValue( ::rtl::OUString::createFromAscii( - ("ooo.vba.Globals") ) ); - return sal_True; - } - catch( uno::Exception& /*e*/ ) - { - //recomp & friends will detect false returned and fail - } - } - return sal_False; -#else - // Component registration - return component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, textframe::serviceDecl ); -#endif - - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) @@ -122,8 +91,8 @@ extern "C" OSL_TRACE("In component_getFactory for %s", pImplName ); void* pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ); - if( !pRet ) - pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, textframe::serviceDecl ); + if( !pRet ) + pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); OSL_TRACE("Ret is 0x%x", pRet); return pRet; } diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index aea8d8bc11d4..f3965393e919 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -24,14 +24,14 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <stdio.h> +#include <stdio.h> -#include<com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> #include <com/sun/star/sheet/XSpreadsheets.hpp> -#include<com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include<ooo/vba/excel/XlCalculation.hpp> +#include <ooo/vba/excel/XlCalculation.hpp> #include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> @@ -88,12 +88,6 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -// Enable our own join detection for Intersection and Union -// should be more efficient than using ScRangeList::Join ( because -// we already are testing the same things ) - -#define OWN_JOIN 1 - // #TODO is this defined somewhere else? #if ( defined UNX ) || ( defined OS2 ) //unix #define FILE_PATH_SEPERATOR "/" @@ -117,7 +111,8 @@ public: ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ) : ScVbaApplication_BASE( xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ), - m_xDisplayAlerts( sal_True) + m_bDisplayAlerts( sal_True ), + m_bEnableEvents( sal_True ) { } @@ -193,18 +188,47 @@ ScVbaApplication::hasProperty( const ::rtl::OUString& Name ) throw(uno::RuntimeE uno::Reference< excel::XWorkbook > ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) { - return new ActiveWorkbook( this, mxContext ); + uno::Reference< excel::XWorkbook > xWrkbk; + ScDocShell* pShell = excel::getDocShell( getCurrentExcelDoc( mxContext ) ); + if ( pShell ) + { + String aName; + if ( pShell->GetDocument() ) + { + aName = pShell->GetDocument()->GetCodeName(); + xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY ); + // fallback ( e.g. it's possible a new document was created via the api ) + // in that case the document will not have the appropriate Document Modules + // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document + // vba mode etc. ) + if ( !xWrkbk.is() ) + return new ActiveWorkbook( this, mxContext ); + } + } + return xWrkbk; } uno::Reference< excel::XWorkbook > SAL_CALL ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel = getThisExcelDoc(mxContext); - if( !xModel.is() ) - return uno::Reference< excel::XWorkbook >(); - - ScVbaWorkbook *pWb = new ScVbaWorkbook( this, mxContext, xModel ); - return uno::Reference< excel::XWorkbook > (pWb); + uno::Reference< excel::XWorkbook > xWrkbk; + ScDocShell* pShell = excel::getDocShell( getThisExcelDoc( mxContext ) ); + if ( pShell ) + { + String aName; + if ( pShell->GetDocument() ) + { + aName = pShell->GetDocument()->GetCodeName(); + xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY ); + // fallback ( e.g. it's possible a new document was created via the api ) + // in that case the document will not have the appropriate Document Modules + // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document + // vba mode etc. ) + if ( !xWrkbk.is() ) + return new ActiveWorkbook( this, mxContext ); + } + } + return xWrkbk; } uno::Reference< XAssistant > SAL_CALL @@ -246,10 +270,10 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); if ( xRanges.is() ) - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRanges ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ) ) ); } - return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( this, mxContext, xRange ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange ) ) ); } else { @@ -272,7 +296,8 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException ) sal_Int32 nCursorX = pTabView->GetCurX(); sal_Int32 nCursorY = pTabView->GetCurY(); - return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); + uno::Reference< XHelperInterface > xParent( excel::getUnoSheetModuleObj( xRange ), uno::UNO_QUERY_THROW ); + return new ScVbaRange( xParent, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); } uno::Any SAL_CALL @@ -531,10 +556,8 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); try { - // FIXME: pass proper Worksheet parent uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( - uno::Reference< XHelperInterface >(), mxContext, sRangeName, - excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + mxContext, sRangeName, excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); if( bScroll ) { @@ -681,14 +704,27 @@ ScVbaApplication::getName() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException) { - m_xDisplayAlerts = displayAlerts; + m_bDisplayAlerts = displayAlerts; } sal_Bool SAL_CALL ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) { - return m_xDisplayAlerts; + return m_bDisplayAlerts; +} + +void SAL_CALL +ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) +{ + m_bEnableEvents = bEnable; +} + +sal_Bool SAL_CALL +ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) +{ + return m_bEnableEvents; } + void SAL_CALL ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException ) { @@ -764,410 +800,289 @@ ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::Run return sPathSep; } -typedef std::list< ScRange > Ranges; -typedef std::list< ScRangeList > RangesList; +// ---------------------------------------------------------------------------- +// Helpers for Intersect and Union + +namespace { + +typedef ::std::list< ScRange > ListOfScRange; -void lcl_addRangesToVec( RangesList& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException ) +/** Appends all ranges of a VBA Range object in the passed Any to the list of ranges. */ +void lclAddToListOfScRange( ListOfScRange& rList, const uno::Any& rArg ) + throw (script::BasicErrorException, uno::RuntimeException) { - ScRangeList theRanges; - uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xCol->getCount(); - for( sal_Int32 i = 1; i <= nCount; ++i ) + if( rArg.hasValue() ) { - uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); - table::CellRangeAddress addr = xAddressable->getRangeAddress(); - ScRange refRange; - ScUnoConversion::FillScRange( refRange, addr ); - theRanges.Append( refRange ); + uno::Reference< excel::XRange > xRange( rArg, uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); + for( sal_Int32 nIdx = 1, nCount = xCol->getCount(); nIdx <= nCount; ++nIdx ) + { + uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::Any( nIdx ), uno::Any() ), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); + ScRange aScRange; + ScUnoConversion::FillScRange( aScRange, xAddressable->getRangeAddress() ); + rList.push_back( aScRange ); + } } - vRanges.push_back( theRanges ); } -void lcl_addRangeToVec( Ranges& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException ) +/** Returns true, if the passed ranges can be expressed by a single range. The + new range will be contained in r1 then, the range r2 can be removed. */ +bool lclTryJoin( ScRange& r1, const ScRange& r2 ) { - uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xCol->getCount(); - for( sal_Int32 i = 1; i <= nCount; ++i ) + // 1) r2 is completely inside r1 + if( r1.In( r2 ) ) + return true; + + // 2) r1 is completely inside r2 + if( r2.In( r1 ) ) { - uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); - table::CellRangeAddress addr = xAddressable->getRangeAddress(); - ScRange refRange; - ScUnoConversion::FillScRange( refRange, addr ); - vRanges.push_back( refRange ); + r1 = r2; + return true; } -} -bool lcl_canJoin( ScRange& r1, ScRange& r2 ) -{ - bool bCanJoin = false; - SCCOL startEndColDiff = r2.aStart.Col() - r1.aEnd.Col(); - SCROW startEndRowDiff = r2.aStart.Row() - r1.aEnd.Row(); - SCCOL startColDiff = r2.aStart.Col() - r1.aStart.Col(); - SCCOL endColDiff = r2.aEnd.Col() - r1.aEnd.Col(); - SCROW startRowDiff = r2.aStart.Row() - r1.aStart.Row(); - SCROW endRowDiff = r2.aEnd.Row() - r1.aEnd.Row(); - if ( ( startRowDiff == endRowDiff ) && startRowDiff == 0 && startColDiff >=0 && endColDiff > 0 && ( startEndColDiff <= 1 && startEndColDiff >= -r1.aEnd.Col() ) ) - bCanJoin = true; - else if ( ( startColDiff == endColDiff ) && startColDiff == 0 && startRowDiff >= 0 && endRowDiff > 0 && ( startEndRowDiff <= 1 && startEndRowDiff >= -r1.aEnd.Row() ) ) - bCanJoin = true; -#ifdef DEBUG - String sr1; - String sr2; - r1.Format( sr1, SCA_VALID ) ; - r2.Format( sr2, SCA_VALID ) ; - OSL_TRACE(" canJoin address %s with %s %s ( startRowDiff(%d), endRowDiff(%d), startColDiff(%d) endColDiff(%d) startEndRowDiff(%d), startEndColDiff(%d) ", - rtl::OUStringToOString( sr1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( sr2, RTL_TEXTENCODING_UTF8 ).getStr(), bCanJoin ? "true" : "false", startRowDiff, endRowDiff, startColDiff, endColDiff, startEndRowDiff, startEndColDiff ); -#endif - return bCanJoin; -} -// strips out ranges that contain other ranges, also -// if the borders of the intersecting ranges are alligned -// then the the range is extended to the larger -// e.g. Range("A4:D10"), Range("B4:E10") would be combined -// to Range("A4:E10") -void lcl_strip_containedRanges( Ranges& vRanges ) -{ - // get rid of ranges that are surrounded by other ranges - Ranges::iterator it_outer = vRanges.begin(); - while( it_outer != vRanges.end() ) + SCCOL n1L = r1.aStart.Col(); + SCCOL n1R = r1.aEnd.Col(); + SCROW n1T = r1.aStart.Row(); + SCROW n1B = r1.aEnd.Row(); + SCCOL n2L = r2.aStart.Col(); + SCCOL n2R = r2.aEnd.Col(); + SCROW n2T = r2.aStart.Row(); + SCROW n2B = r2.aEnd.Row(); + + // 3) r1 and r2 have equal upper and lower border + if( (n1T == n2T) && (n1B == n2B) ) { - bool it_outer_erased = false; // true = it_outer erased from vRanges - Ranges::iterator it_inner = vRanges.begin(); - /* Exit the inner loop if outer iterator has been erased in its last - iteration (this means it has been joined to last it_inner, or that - the it_inner contains it completely). The inner loop will restart - with next element of the outer loop, and all elements (from the - beginning of the list) will be checked against that new element. */ - while( !it_outer_erased && (it_inner != vRanges.end()) ) + // check that r1 overlaps or touches r2 + if( ((n1L < n2L) && (n2L - 1 <= n1R)) || ((n2L < n1L) && (n1L - 1 <= n2R)) ) { - bool it_inner_erased = false; // true = it_inner erased from vRanges - if ( it_outer != it_inner ) - { -#ifdef DEBUG - String r1; - String r2; - it_outer->Format( r1, SCA_VALID ) ; - it_inner->Format( r2, SCA_VALID ) ; - OSL_TRACE( "try strip/join address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - if ( it_outer->In( *it_inner ) ) - { - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } - else if ( it_inner->In( *it_outer ) ) - { - it_outer = vRanges.erase( it_outer ); - it_outer_erased = true; - } -#ifndef OWN_JOIN - else if ( (*it_inner).aStart.Row() == (*it_outer).aStart.Row() - && (*it_inner).aEnd.Row() == (*it_outer).aEnd.Row() ) - { - it_outer->ExtendTo( *it_inner ); - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } -#else - else if ( lcl_canJoin( *it_outer, *it_inner ) ) - { - it_outer->ExtendTo( *it_inner ); - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } - else if ( lcl_canJoin( *it_inner, *it_outer) ) - { - it_inner->ExtendTo( *it_outer ); - it_outer = vRanges.erase( it_outer ); - it_outer_erased = true; - } -#endif - } - /* If it_inner has not been erased from vRanges, continue inner - loop with next element. Otherwise, it_inner already points to - the next element (return value of list::erase()). */ - if( !it_inner_erased ) - ++it_inner; + r1.aStart.SetCol( ::std::min( n1L, n2L ) ); + r1.aEnd.SetCol( ::std::max( n1R, n2R ) ); + return true; } - /* If it_outer has not been erased from vRanges, continue outer loop - with next element. Otherwise, it_outer already points to the next - element (return value of list::erase()). */ - if( !it_outer_erased ) - ++it_outer; + return false; } + // 4) r1 and r2 have equal left and right border + if( (n1L == n2L) && (n1R == n2R) ) + { + // check that r1 overlaps or touches r2 + if( ((n1T < n2T) && (n2T + 1 <= n1B)) || ((n2T < n1T) && (n1T + 1 <= n2B)) ) + { + r1.aStart.SetRow( ::std::min( n1T, n2T ) ); + r1.aEnd.SetRow( ::std::max( n1B, n2B ) ); + return true; + } + return false; + } + + // 5) cannot join these ranges + return false; } -Ranges -lcl_intersectionImpl( ScRangeList& rl1, ScRangeList& rl2 ) +/** Strips out ranges that are contained by other ranges, joins ranges that can be joined + together (aligned borders, e.g. A4:D10 and B4:E10 would be combined to A4:E10. */ +void lclJoinRanges( ListOfScRange& rList ) { - Ranges intersections; - for ( USHORT x = 0 ; x < rl1.Count(); ++x ) + ListOfScRange::iterator aOuterIt = rList.begin(); + while( aOuterIt != rList.end() ) { - for ( USHORT y = 0 ; y < rl2.Count(); ++y ) + bool bAnyErased = false; // true = any range erased from rList + ListOfScRange::iterator aInnerIt = rList.begin(); + while( aInnerIt != rList.end() ) { -#ifdef DEBUG - String r1; - String r2; - rl1.GetObject( x )->Format( r1, SCA_VALID ) ; - rl2.GetObject( y )->Format( r2, SCA_VALID ) ; - OSL_TRACE( "comparing address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - if( rl1.GetObject( x )->Intersects( *rl2.GetObject( y ) ) ) + bool bInnerErased = false; // true = aInnerIt erased from rList + // do not compare a range with itself + if( (aOuterIt != aInnerIt) && lclTryJoin( *aOuterIt, *aInnerIt ) ) { - ScRange aIntersection = ScRange( Max( rl1.GetObject( x )->aStart.Col(), rl2.GetObject( y )->aStart.Col() ), - Max( rl1.GetObject( x )->aStart.Row(), rl2.GetObject( y )->aStart.Row() ), - Max( rl1.GetObject( x )->aStart.Tab(), rl2.GetObject( y )->aStart.Tab() ), - Min( rl1.GetObject( x )->aEnd.Col(), rl2.GetObject( y )->aEnd.Col() ), - Min( rl1.GetObject( x )->aEnd.Row(), rl2.GetObject( y )->aEnd.Row() ), - Min( rl1.GetObject( x )->aEnd.Tab(), rl2.GetObject( y )->aEnd.Tab() ) ); - intersections.push_back( aIntersection ); + // aOuterIt points to joined range, aInnerIt will be removed + aInnerIt = rList.erase( aInnerIt ); + bInnerErased = bAnyErased = true; } + /* If aInnerIt has been erased from rList, it already points to + the next element (return value of list::erase()). */ + if( !bInnerErased ) + ++aInnerIt; } + // if any range has been erased, repeat outer loop with the same range + if( !bAnyErased ) + ++aOuterIt; } - lcl_strip_containedRanges( intersections ); - return intersections; } -// Intersection of a set of ranges ( where each range is represented by a ScRangeList e.g. -// any range can be a multi-area range ) -// An intersection is performed between each range in the set of ranges. -// The resulting set of intersections is then processed to strip out any -// intersections that contain other intersections ( and also ranges that directly line up -// are joined ) ( see lcl_strip_containedRanges ) -RangesList lcl_intersections( RangesList& vRanges ) +/** Intersects the passed list with all ranges of a VBA Range object in the passed Any. */ +void lclIntersectRanges( ListOfScRange& rList, const uno::Any& rArg ) + throw (script::BasicErrorException, uno::RuntimeException) { - RangesList intersections; - RangesList::iterator it = vRanges.begin(); - while( it != vRanges.end() ) + // extract the ranges from the passed argument, will throw on invalid data + ListOfScRange aList2; + lclAddToListOfScRange( aList2, rArg ); + // do nothing, if the passed list is already empty + if( !rList.empty() && !aList2.empty() ) { - Ranges intermediateList; - for( RangesList::iterator it_inner = vRanges.begin(); it_inner != vRanges.end(); ++it_inner ) + // save original list in a local + ListOfScRange aList1; + aList1.swap( rList ); + // join ranges from passed argument + lclJoinRanges( aList2 ); + // calculate intersection of the ranges in both lists + for( ListOfScRange::const_iterator aOuterIt = aList1.begin(), aOuterEnd = aList1.end(); aOuterIt != aOuterEnd; ++aOuterIt ) { - if ( it != it_inner ) + for( ListOfScRange::const_iterator aInnerIt = aList2.begin(), aInnerEnd = aList2.end(); aInnerIt != aInnerEnd; ++aInnerIt ) { - Ranges ranges = lcl_intersectionImpl( *it, *it_inner ); - for ( Ranges::iterator range_it = ranges.begin(); range_it != ranges.end(); ++range_it ) - intermediateList.push_back( *range_it ); + if( aOuterIt->Intersects( *aInnerIt ) ) + { + ScRange aIsectRange( + Max( aOuterIt->aStart.Col(), aInnerIt->aStart.Col() ), + Max( aOuterIt->aStart.Row(), aInnerIt->aStart.Row() ), + Max( aOuterIt->aStart.Tab(), aInnerIt->aStart.Tab() ), + Min( aOuterIt->aEnd.Col(), aInnerIt->aEnd.Col() ), + Min( aOuterIt->aEnd.Row(), aInnerIt->aEnd.Row() ), + Min( aOuterIt->aEnd.Tab(), aInnerIt->aEnd.Tab() ) ); + rList.push_back( aIsectRange ); + } } } - it = vRanges.erase( it ); // remove it so we don't include it in the next pass. - // 'it' is removed uncontidionally from vRanges, so the while loop will terminate - - ScRangeList argIntersect; - lcl_strip_containedRanges( intermediateList ); - - for( Ranges::iterator it_inter = intermediateList.begin(); it_inter != intermediateList.end(); ++it_inter ) -#ifndef OWN_JOIN - argIntersect.Join( *it_inter ); -#else - argIntersect.Append( *it_inter ); -#endif - - intersections.push_back( argIntersect ); + // again, join the result ranges + lclJoinRanges( rList ); } - return intersections; -} - -uno::Reference< excel::XRange > SAL_CALL -ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException) -{ - if ( !Arg1.is() || !Arg2.is() ) - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - - RangesList vRanges; - lcl_addRangesToVec( vRanges, uno::makeAny( Arg1 ) ); - lcl_addRangesToVec( vRanges, uno::makeAny( Arg2 ) ); - - if ( Arg3.hasValue() ) - lcl_addRangesToVec( vRanges, Arg3 ); - if ( Arg4.hasValue() ) - lcl_addRangesToVec( vRanges, Arg4 ); - if ( Arg5.hasValue() ) - lcl_addRangesToVec( vRanges, Arg5 ); - if ( Arg6.hasValue() ) - lcl_addRangesToVec( vRanges, Arg6 ); - if ( Arg7.hasValue() ) - lcl_addRangesToVec( vRanges, Arg7 ); - if ( Arg8.hasValue() ) - lcl_addRangesToVec( vRanges, Arg8 ); - if ( Arg9.hasValue() ) - lcl_addRangesToVec( vRanges, Arg9 ); - if ( Arg10.hasValue() ) - lcl_addRangesToVec( vRanges, Arg10 ); - if ( Arg11.hasValue() ) - lcl_addRangesToVec( vRanges, Arg11 ); - if ( Arg12.hasValue() ) - lcl_addRangesToVec( vRanges, Arg12 ); - if ( Arg13.hasValue() ) - lcl_addRangesToVec( vRanges, Arg13 ); - if ( Arg14.hasValue() ) - lcl_addRangesToVec( vRanges, Arg14 ); - if ( Arg15.hasValue() ) - lcl_addRangesToVec( vRanges, Arg15 ); - if ( Arg16.hasValue() ) - lcl_addRangesToVec( vRanges, Arg16 ); - if ( Arg17.hasValue() ) - lcl_addRangesToVec( vRanges, Arg17 ); - if ( Arg18.hasValue() ) - lcl_addRangesToVec( vRanges, Arg18 ); - if ( Arg19.hasValue() ) - lcl_addRangesToVec( vRanges, Arg19 ); - if ( Arg20.hasValue() ) - lcl_addRangesToVec( vRanges, Arg20 ); - if ( Arg21.hasValue() ) - lcl_addRangesToVec( vRanges, Arg21 ); - if ( Arg22.hasValue() ) - lcl_addRangesToVec( vRanges, Arg22 ); - if ( Arg23.hasValue() ) - lcl_addRangesToVec( vRanges, Arg23 ); - if ( Arg24.hasValue() ) - lcl_addRangesToVec( vRanges, Arg24 ); - if ( Arg25.hasValue() ) - lcl_addRangesToVec( vRanges, Arg25 ); - if ( Arg26.hasValue() ) - lcl_addRangesToVec( vRanges, Arg26 ); - if ( Arg27.hasValue() ) - lcl_addRangesToVec( vRanges, Arg27 ); - if ( Arg28.hasValue() ) - lcl_addRangesToVec( vRanges, Arg28 ); - if ( Arg29.hasValue() ) - lcl_addRangesToVec( vRanges, Arg29 ); - if ( Arg30.hasValue() ) - lcl_addRangesToVec( vRanges, Arg30 ); - - uno::Reference< excel::XRange > xRefRange; - - ScRangeList aCellRanges; - // first pass - gets the set of all possible interections of Arg1..ArgN - RangesList intersections = lcl_intersections( vRanges ); - // second pass - gets the intersections of the intersections ( don't ask, but this - // is what seems to happen ) - if ( intersections.size() > 1) - intersections = lcl_intersections( intersections ); - for( RangesList::iterator it = intersections.begin(); it != intersections.end(); ++it ) - { - for ( USHORT x = 0 ; x < it->Count(); ++x ) -#ifndef OWN_JOIN - aCellRanges.Join( *it->GetObject(x) ); -#else - aCellRanges.Append( *it->GetObject(x) ); -#endif - } - - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = excel::getDocShell( xModel ); - if ( aCellRanges.Count() == 1 ) - { - xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); - } - else if ( aCellRanges.Count() > 1 ) - { - uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xRanges ); - - } - return xRefRange; } -uno::Reference< excel::XRange > SAL_CALL -ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException) +/** Creates a VBA Range object from the passed list of ranges. */ +uno::Reference< excel::XRange > lclCreateVbaRange( + const uno::Reference< uno::XComponentContext >& rxContext, + const uno::Reference< frame::XModel >& rxModel, + const ListOfScRange& rList ) throw (uno::RuntimeException) { - if ( !Arg1.is() || !Arg2.is() ) - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - - uno::Reference< excel::XRange > xRange; - Ranges vRanges; - lcl_addRangeToVec( vRanges, uno::makeAny( Arg1 ) ); - lcl_addRangeToVec( vRanges, uno::makeAny( Arg2 ) ); - - if ( Arg3.hasValue() ) - lcl_addRangeToVec( vRanges, Arg3 ); - if ( Arg4.hasValue() ) - lcl_addRangeToVec( vRanges, Arg4 ); - if ( Arg5.hasValue() ) - lcl_addRangeToVec( vRanges, Arg5 ); - if ( Arg6.hasValue() ) - lcl_addRangeToVec( vRanges, Arg6 ); - if ( Arg7.hasValue() ) - lcl_addRangeToVec( vRanges, Arg7 ); - if ( Arg8.hasValue() ) - lcl_addRangeToVec( vRanges, Arg8 ); - if ( Arg9.hasValue() ) - lcl_addRangeToVec( vRanges, Arg9 ); - if ( Arg10.hasValue() ) - lcl_addRangeToVec( vRanges, Arg10 ); - if ( Arg11.hasValue() ) - lcl_addRangeToVec( vRanges, Arg11 ); - if ( Arg12.hasValue() ) - lcl_addRangeToVec( vRanges, Arg12 ); - if ( Arg13.hasValue() ) - lcl_addRangeToVec( vRanges, Arg13 ); - if ( Arg14.hasValue() ) - lcl_addRangeToVec( vRanges, Arg14 ); - if ( Arg15.hasValue() ) - lcl_addRangeToVec( vRanges, Arg15 ); - if ( Arg16.hasValue() ) - lcl_addRangeToVec( vRanges, Arg16 ); - if ( Arg17.hasValue() ) - lcl_addRangeToVec( vRanges, Arg17 ); - if ( Arg18.hasValue() ) - lcl_addRangeToVec( vRanges, Arg18 ); - if ( Arg19.hasValue() ) - lcl_addRangeToVec( vRanges, Arg19 ); - if ( Arg20.hasValue() ) - lcl_addRangeToVec( vRanges, Arg20 ); - if ( Arg21.hasValue() ) - lcl_addRangeToVec( vRanges, Arg21 ); - if ( Arg22.hasValue() ) - lcl_addRangeToVec( vRanges, Arg22 ); - if ( Arg23.hasValue() ) - lcl_addRangeToVec( vRanges, Arg23 ); - if ( Arg24.hasValue() ) - lcl_addRangeToVec( vRanges, Arg24 ); - if ( Arg25.hasValue() ) - lcl_addRangeToVec( vRanges, Arg25 ); - if ( Arg26.hasValue() ) - lcl_addRangeToVec( vRanges, Arg26 ); - if ( Arg27.hasValue() ) - lcl_addRangeToVec( vRanges, Arg27 ); - if ( Arg28.hasValue() ) - lcl_addRangeToVec( vRanges, Arg28 ); - if ( Arg29.hasValue() ) - lcl_addRangeToVec( vRanges, Arg29 ); - if ( Arg30.hasValue() ) - lcl_addRangeToVec( vRanges, Arg30 ); + ScDocShell* pDocShell = excel::getDocShell( rxModel ); + if( !pDocShell ) throw uno::RuntimeException(); ScRangeList aCellRanges; - lcl_strip_containedRanges( vRanges ); - - for( Ranges::iterator it = vRanges.begin(); it != vRanges.end(); ++it ) - aCellRanges.Append( *it ); + for( ListOfScRange::const_iterator aIt = rList.begin(), aEnd = rList.end(); aIt != aEnd; ++aIt ) + aCellRanges.Append( *aIt ); - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = excel::getDocShell( xModel ); - if ( aCellRanges.Count() == 1 ) + if( aCellRanges.Count() == 1 ) { - // normal range - xRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), rxContext, xRange ); } - else if ( aCellRanges.Count() > 1 ) // Multi-Area + if( aCellRanges.Count() > 1 ) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xRanges ); + return new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), rxContext, xRanges ); } - - // #FIXME need proper (WorkSheet) parent - return xRange; + return 0; +} + +} // namespace + +// ---------------------------------------------------------------------------- + +uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Intersect( + const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2, + const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6, + const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10, + const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14, + const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18, + const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22, + const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26, + const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 ) + throw (script::BasicErrorException, uno::RuntimeException) +{ + if( !rArg1.is() || !rArg2.is() ) + DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); + + // initialize the result list with 1st parameter, join its ranges together + ListOfScRange aList; + lclAddToListOfScRange( aList, uno::Any( rArg1 ) ); + lclJoinRanges( aList ); + + // process all other parameters, this updates the list with intersection + lclIntersectRanges( aList, uno::Any( rArg2 ) ); + lclIntersectRanges( aList, rArg3 ); + lclIntersectRanges( aList, rArg4 ); + lclIntersectRanges( aList, rArg5 ); + lclIntersectRanges( aList, rArg6 ); + lclIntersectRanges( aList, rArg7 ); + lclIntersectRanges( aList, rArg8 ); + lclIntersectRanges( aList, rArg9 ); + lclIntersectRanges( aList, rArg10 ); + lclIntersectRanges( aList, rArg11 ); + lclIntersectRanges( aList, rArg12 ); + lclIntersectRanges( aList, rArg13 ); + lclIntersectRanges( aList, rArg14 ); + lclIntersectRanges( aList, rArg15 ); + lclIntersectRanges( aList, rArg16 ); + lclIntersectRanges( aList, rArg17 ); + lclIntersectRanges( aList, rArg18 ); + lclIntersectRanges( aList, rArg19 ); + lclIntersectRanges( aList, rArg20 ); + lclIntersectRanges( aList, rArg21 ); + lclIntersectRanges( aList, rArg22 ); + lclIntersectRanges( aList, rArg23 ); + lclIntersectRanges( aList, rArg24 ); + lclIntersectRanges( aList, rArg25 ); + lclIntersectRanges( aList, rArg26 ); + lclIntersectRanges( aList, rArg27 ); + lclIntersectRanges( aList, rArg28 ); + lclIntersectRanges( aList, rArg29 ); + lclIntersectRanges( aList, rArg30 ); + + // create the VBA Range object + return lclCreateVbaRange( mxContext, getCurrentDocument(), aList ); +} + +uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Union( + const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2, + const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6, + const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10, + const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14, + const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18, + const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22, + const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26, + const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 ) + throw (script::BasicErrorException, uno::RuntimeException) +{ + if( !rArg1.is() || !rArg2.is() ) + DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); + + ListOfScRange aList; + lclAddToListOfScRange( aList, uno::Any( rArg1 ) ); + lclAddToListOfScRange( aList, uno::Any( rArg2 ) ); + lclAddToListOfScRange( aList, rArg3 ); + lclAddToListOfScRange( aList, rArg4 ); + lclAddToListOfScRange( aList, rArg5 ); + lclAddToListOfScRange( aList, rArg6 ); + lclAddToListOfScRange( aList, rArg7 ); + lclAddToListOfScRange( aList, rArg8 ); + lclAddToListOfScRange( aList, rArg9 ); + lclAddToListOfScRange( aList, rArg10 ); + lclAddToListOfScRange( aList, rArg11 ); + lclAddToListOfScRange( aList, rArg12 ); + lclAddToListOfScRange( aList, rArg13 ); + lclAddToListOfScRange( aList, rArg14 ); + lclAddToListOfScRange( aList, rArg15 ); + lclAddToListOfScRange( aList, rArg16 ); + lclAddToListOfScRange( aList, rArg17 ); + lclAddToListOfScRange( aList, rArg18 ); + lclAddToListOfScRange( aList, rArg19 ); + lclAddToListOfScRange( aList, rArg20 ); + lclAddToListOfScRange( aList, rArg21 ); + lclAddToListOfScRange( aList, rArg22 ); + lclAddToListOfScRange( aList, rArg23 ); + lclAddToListOfScRange( aList, rArg24 ); + lclAddToListOfScRange( aList, rArg25 ); + lclAddToListOfScRange( aList, rArg26 ); + lclAddToListOfScRange( aList, rArg27 ); + lclAddToListOfScRange( aList, rArg28 ); + lclAddToListOfScRange( aList, rArg29 ); + lclAddToListOfScRange( aList, rArg30 ); + + // simply join together all ranges as much as possible, strip out covered ranges etc. + lclJoinRanges( aList ); + + // create the VBA Range object + return lclCreateVbaRange( mxContext, getCurrentDocument(), aList ); } void diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index 96638651bcd1..a7be5feb1d27 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -43,7 +43,9 @@ class ScVbaApplication : public ScVbaApplication_BASE { private: sal_Int32 m_xCalculation; - sal_Bool m_xDisplayAlerts; + sal_Bool m_bDisplayAlerts; + sal_Bool m_bEnableEvents; + rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); protected: @@ -100,6 +102,9 @@ public: virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException); virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual void SAL_CALL wait( double time ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbachartobjects.cxx b/sc/source/ui/vba/vbachartobjects.cxx index 41b26501f4ad..5117cfd75858 100644 --- a/sc/source/ui/vba/vbachartobjects.cxx +++ b/sc/source/ui/vba/vbachartobjects.cxx @@ -47,16 +47,15 @@ using namespace ::ooo::vba; class ChartObjectEnumerationImpl : public EnumerationHelperImpl { uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier; - uno::Reference< XHelperInterface > xParent; public: - ChartObjectEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier, const uno::Reference< XHelperInterface >& _xParent ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), xDrawPageSupplier( _xDrawPageSupplier ), xParent( _xParent ) {} + ChartObjectEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier, const uno::Reference< XHelperInterface >& _xParent ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( _xParent, xContext, xEnumeration ), xDrawPageSupplier( _xDrawPageSupplier ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< table::XTableChart > xTableChart( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); // parent Object is sheet - return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( xParent, m_xContext, xTableChart, xDrawPageSupplier ) ) ); + return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( m_xParent, m_xContext, xTableChart, xDrawPageSupplier ) ) ); } }; diff --git a/sc/source/ui/vba/vbacomments.cxx b/sc/source/ui/vba/vbacomments.cxx index a68dd4245741..7a6d3d774937 100644 --- a/sc/source/ui/vba/vbacomments.cxx +++ b/sc/source/ui/vba/vbacomments.cxx @@ -50,10 +50,11 @@ class CommentEnumeration : public EnumerationHelperImpl css::uno::Reference< css::frame::XModel > mxModel; public: CommentEnumeration( + const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : - EnumerationHelperImpl( xContext, xEnumeration ), + EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel, uno::UNO_SET_THROW ) {} @@ -80,8 +81,7 @@ uno::Reference< container::XEnumeration > ScVbaComments::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - - return new CommentEnumeration( mxContext, xEnumAccess->createEnumeration(), mxModel ); + return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel ); } uno::Any diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx new file mode 100755 index 000000000000..45667adf2f2c --- /dev/null +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -0,0 +1,753 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbaeventshelper.hxx" + +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/frame/XBorderResizeListener.hpp> +#include <com/sun/star/frame/XControllerBorder.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> +#include <com/sun/star/util/XCloseListener.hpp> + +#include <ooo/vba/excel/XApplication.hpp> + +#include <cppuhelper/implbase4.hxx> +#include <toolkit/unohlp.hxx> +#include <vbahelper/helperdecl.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> + +#include "cellsuno.hxx" +#include "convuno.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::script::vba::VBAEventId; +using namespace ::ooo::vba; + +// ============================================================================ + +typedef ::cppu::WeakImplHelper4< + awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener, util::XChangesListener > ScVbaEventsListener_BASE; + +// This class is to process Workbook window related event +class ScVbaEventsListener : public ScVbaEventsListener_BASE +{ +public : + ScVbaEventsListener( ScVbaEventsHelper& rVbaEvents, const uno::Reference< frame::XModel >& rxModel, ScDocShell* pDocShell ); + virtual ~ScVbaEventsListener(); + + void startListening(); + void stopListening(); + + // XWindowListener + virtual void SAL_CALL windowResized( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowMoved( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowShown( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowHidden( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + + // XCloseListener + virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException); + virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException); + + // XBorderResizeListener + virtual void SAL_CALL borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException); + + // XChangesListener + virtual void SAL_CALL changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException); + +private: + uno::Reference< frame::XFrame > getFrame(); + uno::Reference< awt::XWindow > getContainerWindow(); + bool isMouseReleased(); + DECL_LINK( fireResizeMacro, void* ); + void processWindowResizeMacro(); + +private: + ::osl::Mutex maMutex; + ScVbaEventsHelper& mrVbaEvents; + uno::Reference< frame::XModel > mxModel; + ScDocShell* mpDocShell; + bool mbWindowResized; + bool mbBorderChanged; + bool mbDisposed; +}; + +// ---------------------------------------------------------------------------- + +ScVbaEventsListener::ScVbaEventsListener( ScVbaEventsHelper& rVbaEvents, const uno::Reference< frame::XModel >& rxModel, ScDocShell* pDocShell ) : + mrVbaEvents( rVbaEvents ), + mxModel( rxModel ), + mpDocShell( pDocShell ), + mbWindowResized( false ), + mbBorderChanged( false ), + mbDisposed( !rxModel.is() ) +{ + OSL_TRACE( "ScVbaEventsListener::ScVbaEventsListener( 0x%x ) - ctor ", this ); +} + +ScVbaEventsListener::~ScVbaEventsListener() +{ + OSL_TRACE( "ScVbaEventsListener::~ScVbaEventsListener( 0x%x ) - dtor ", this ); + stopListening(); +} + +void ScVbaEventsListener::startListening() +{ + if( !mbDisposed ) + { + // add window listener + try + { + uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW ); + xWindow->addWindowListener( this ); + } + catch( uno::Exception& ) + { + } + // add close listener + try + { + uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW ); + xCloseBroadcaster->addCloseListener( this ); + } + catch( uno::Exception& ) + { + } + // add Border resize listener + try + { + uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + xControllerBorder->addBorderResizeListener( this ); + } + catch( uno::Exception& ) + { + } + // add content change listener + try + { + uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModel, uno::UNO_QUERY_THROW ); + xChangesNotifier->addChangesListener( this ); + } + catch( uno::Exception& ) + { + } + } +} + +void ScVbaEventsListener::stopListening() +{ + if( !mbDisposed ) + { + try + { + uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW ); + xWindow->removeWindowListener( this ); + } + catch( uno::Exception& ) + { + } + try + { + uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW ); + xCloseBroadcaster->removeCloseListener( this ); + } + catch( uno::Exception& ) + { + } + try + { + uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + xControllerBorder->removeBorderResizeListener( this ); + } + catch( uno::Exception& ) + { + } + try + { + uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModel, uno::UNO_QUERY_THROW ); + xChangesNotifier->removeChangesListener( this ); + } + catch( uno::Exception& ) + { + } + } + mbDisposed = true; +} + +void SAL_CALL ScVbaEventsListener::windowResized( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( maMutex ); + // Workbook_window_resize event + mbWindowResized = true; + if( !mbDisposed && mbBorderChanged ) + { + if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + mbBorderChanged = mbWindowResized = false; + acquire(); // ensure we don't get deleted before the event is handled + Application::PostUserEvent( LINK( this, ScVbaEventsListener, fireResizeMacro ), 0 ); + } + } +} + +void SAL_CALL ScVbaEventsListener::windowMoved( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaEventsListener::windowShown( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaEventsListener::windowHidden( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaEventsListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( maMutex ); + OSL_TRACE( "ScVbaEventsListener::disposing( 0x%x )", this ); + mbDisposed = true; +} + +void SAL_CALL ScVbaEventsListener::queryClosing( const lang::EventObject& /*Source*/, sal_Bool /*GetsOwnership*/ ) throw (util::CloseVetoException, uno::RuntimeException) +{ + // it can cancel the close, but need to throw a CloseVetoException, and it will be transmit to caller. +} + +void SAL_CALL ScVbaEventsListener::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + stopListening(); +} + +void SAL_CALL ScVbaEventsListener::borderWidthsChanged( const uno::Reference< uno::XInterface >& /*aObject*/, const frame::BorderWidths& /*aNewSize*/ ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + // work with WindowResized event to guard Window Resize event. + mbBorderChanged = true; + if( !mbDisposed && mbWindowResized ) + { + if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + mbWindowResized = mbBorderChanged = false; + acquire(); // ensure we don't get deleted before the timer fires. + Application::PostUserEvent( LINK( this, ScVbaEventsListener, fireResizeMacro ), 0 ); + } + } +} + +void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException) +{ + sal_Int32 nCount = aEvent.Changes.getLength(); + if( nCount == 0 ) + return; + + util::ElementChange aChange = aEvent.Changes[ 0 ]; + rtl::OUString sOperation; + aChange.Accessor >>= sOperation; + if( !sOperation.equalsIgnoreAsciiCaseAscii("cell-change") ) + return; + + if( nCount == 1 ) + { + uno::Reference< table::XCellRange > xRangeObj; + aChange.ReplacedElement >>= xRangeObj; + if( xRangeObj.is() ) + { + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xRangeObj; + mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs ); + } + return; + } + + ScRangeList aRangeList; + for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex ) + { + aChange = aEvent.Changes[ nIndex ]; + aChange.Accessor >>= sOperation; + uno::Reference< table::XCellRange > xRangeObj; + aChange.ReplacedElement >>= xRangeObj; + if( xRangeObj.is() && sOperation.equalsIgnoreAsciiCaseAscii("cell-change") ) + { + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable( xRangeObj, uno::UNO_QUERY ); + if( xCellRangeAddressable.is() ) + { + ScRange aRange; + ScUnoConversion::FillScRange( aRange, xCellRangeAddressable->getRangeAddress() ); + aRangeList.Append( aRange ); + } + } + } + + if( (aRangeList.Count() > 0) && mpDocShell ) + { + uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( mpDocShell, aRangeList ) ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xRanges; + mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs ); + } +} + +// ---------------------------------------------------------------------------- + +uno::Reference< frame::XFrame > ScVbaEventsListener::getFrame() +{ + if( !mbDisposed && mxModel.is() ) try + { + uno::Reference< frame::XController > xController( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + return xController->getFrame(); + } + catch( uno::Exception& ) + { + } + return uno::Reference< frame::XFrame >(); +} + +uno::Reference< awt::XWindow > ScVbaEventsListener::getContainerWindow() +{ + try + { + uno::Reference< frame::XFrame > xFrame( getFrame(), uno::UNO_SET_THROW ); + return xFrame->getContainerWindow(); + } + catch( uno::Exception& ) + { + } + return uno::Reference< awt::XWindow >(); +} + +bool ScVbaEventsListener::isMouseReleased() +{ + if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + Window::PointerState aPointerState = pWindow->GetPointerState(); + return (aPointerState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT )) == 0; + } + return false; +} + +IMPL_LINK( ScVbaEventsListener, fireResizeMacro, void*, EMPTYARG ) +{ + if( !mbDisposed && isMouseReleased() ) + processWindowResizeMacro(); + release(); + return 0; +} + +void ScVbaEventsListener::processWindowResizeMacro() +{ + OSL_TRACE( "**** Attempt to FIRE MACRO **** " ); + if( !mbDisposed ) + mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); +} + +// ============================================================================ + +ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& xContext ) : + VbaEventsHelperBase( rArgs, xContext ), + mbOpened( false ) +{ + mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class + mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0; + + if( !mxModel.is() || !mpDocShell || !mpDoc ) + return; + +#define REGISTER_EVENT( eventid, eventname, type, cancelindex, worksheet ) \ + registerEventHandler( eventid, eventname, type, cancelindex, uno::Any( worksheet ) ) + +#define REGISTER_WORKBOOK_EVENT( eventid, eventname, cancelindex ) \ + REGISTER_EVENT( WORKBOOK_##eventid, "Workbook_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, false ) + +#define REGISTER_WORKSHEET_EVENT( eventid, eventname, cancelindex ) \ + REGISTER_EVENT( WORKSHEET_##eventid, "Worksheet_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, true ); \ + REGISTER_EVENT( (USERDEFINED_START + WORKSHEET_##eventid), "Workbook_Sheet" eventname, EVENTHANDLER_DOCUMENT, (((cancelindex) >= 0) ? ((cancelindex) + 1) : -1), false ) + + // global + REGISTER_EVENT( AUTO_OPEN, "Auto_Open", EVENTHANDLER_GLOBAL, -1, false ); + REGISTER_EVENT( AUTO_CLOSE, "Auto_Close", EVENTHANDLER_GLOBAL, -1, false ); + + // Workbook + REGISTER_WORKBOOK_EVENT( ACTIVATE, "Activate", -1 ); + REGISTER_WORKBOOK_EVENT( DEACTIVATE, "Deactivate", -1 ); + REGISTER_WORKBOOK_EVENT( OPEN, "Open", -1 ); + REGISTER_WORKBOOK_EVENT( BEFORECLOSE, "BeforeClose", 0 ); + REGISTER_WORKBOOK_EVENT( BEFOREPRINT, "BeforePrint", 0 ); + REGISTER_WORKBOOK_EVENT( BEFORESAVE, "BeforeSave", 1 ); + REGISTER_WORKBOOK_EVENT( AFTERSAVE, "AfterSave", -1 ); + REGISTER_WORKBOOK_EVENT( NEWSHEET, "NewSheet", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWACTIVATE, "WindowActivate", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWDEACTIVATE, "WindowDeactivate", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWRESIZE, "WindowResize", -1 ); + + // Worksheet events. All events have a corresponding workbook event. + REGISTER_WORKSHEET_EVENT( ACTIVATE, "Activate", -1 ); + REGISTER_WORKSHEET_EVENT( DEACTIVATE, "Deactivate", -1 ); + REGISTER_WORKSHEET_EVENT( BEFOREDOUBLECLICK, "BeforeDoubleClick", 1 ); + REGISTER_WORKSHEET_EVENT( BEFORERIGHTCLICK, "BeforeRightClick", 1 ); + REGISTER_WORKSHEET_EVENT( CALCULATE, "Calculate", -1 ); + REGISTER_WORKSHEET_EVENT( CHANGE, "Change", -1 ); + REGISTER_WORKSHEET_EVENT( SELECTIONCHANGE, "SelectionChange", -1 ); + REGISTER_WORKSHEET_EVENT( FOLLOWHYPERLINK, "FollowHyperlink", -1 ); + +#undef REGISTER_EVENT +#undef REGISTER_WORKBOOK_EVENT +#undef REGISTER_WORKSHEET_EVENT +} + +ScVbaEventsHelper::~ScVbaEventsHelper() +{ +} + +void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) throw (uno::RuntimeException) +{ + mxListener.clear(); + VbaEventsHelperBase::disposing( rSource ); +} + +// protected ------------------------------------------------------------------ + +bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +{ + // document and document shell are needed during event processing + if( !mpDocShell || !mpDoc ) + throw uno::RuntimeException(); + + // get Application object and check if events are enabled (this is an Excel-only attribute) + uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); + if( !xApplication.is() && mpShell ) + { + uno::Any aVBAGlobals; + mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); + uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY ); + if( xHelperInterface.is() ) + { + xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY ); + mxApplication = xApplication; + } + } + if( !xApplication.is() ) + throw uno::RuntimeException(); + + // return whether event processing is enabled + return xApplication->getEnableEvents(); +} + +bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) +{ + // check preconditions for some events, add more events if needed + bool bExecuteEvent = true; + switch( rInfo.mnEventId ) + { + case WORKBOOK_ACTIVATE: + // while loading, framework fires this before 'opened' event, delay it + bExecuteEvent = mbOpened; + break; + case WORKBOOK_OPEN: + bExecuteEvent = !mbOpened; + if( bExecuteEvent ) + { + // execute delayed Activate event too (see above) + rEventQueue.push_back( WORKBOOK_ACTIVATE ); + rEventQueue.push_back( WORKBOOK_WINDOWACTIVATE ); + rEventQueue.push_back( AUTO_OPEN ); + } + break; + case WORKSHEET_SELECTIONCHANGE: + // if selection is not changed, then do not fire the event + bExecuteEvent = mbOpened && isSelectionChanged( rArgs, 0 ); + break; + } + + // add workbook event associated to a sheet event + bool bSheetEvent = false; + rInfo.maUserData >>= bSheetEvent; + if( bSheetEvent && bExecuteEvent ) + rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + + return bExecuteEvent; +} + +uno::Sequence< uno::Any > ScVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException) +{ + // fill arguments for workbook events associated to sheet events according to sheet events, sheet will be added below + bool bSheetEventAsBookEvent = rInfo.mnEventId > USERDEFINED_START; + sal_Int32 nEventId = bSheetEventAsBookEvent ? (rInfo.mnEventId - USERDEFINED_START) : rInfo.mnEventId; + + uno::Sequence< uno::Any > aVbaArgs; + switch( nEventId ) + { + // *** Workbook *** + + // no arguments + case WORKBOOK_ACTIVATE: + case WORKBOOK_DEACTIVATE: + case WORKBOOK_OPEN: + break; + // 1 arg: cancel + case WORKBOOK_BEFORECLOSE: + case WORKBOOK_BEFOREPRINT: + aVbaArgs.realloc( 1 ); + // current cancel state will be inserted by caller + break; + // 2 args: saveAs, cancel + case WORKBOOK_BEFORESAVE: + aVbaArgs.realloc( 2 ); + checkArgumentType< bool >( rArgs, 0 ); + aVbaArgs[ 0 ] = rArgs[ 0 ]; + // current cancel state will be inserted by caller + break; + // 1 arg: success + case WORKBOOK_AFTERSAVE: + aVbaArgs.realloc( 1 ); + checkArgumentType< bool >( rArgs, 0 ); + aVbaArgs[ 0 ] = rArgs[ 0 ]; + break; + // 1 arg: window + case WORKBOOK_WINDOWACTIVATE: + case WORKBOOK_WINDOWDEACTIVATE: + case WORKBOOK_WINDOWRESIZE: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createWindow(); + break; + // 1 arg: worksheet + case WORKBOOK_NEWSHEET: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createWorksheet( rArgs, 0 ); + break; + + // *** Worksheet *** + + // no arguments + case WORKSHEET_ACTIVATE: + case WORKSHEET_CALCULATE: + case WORKSHEET_DEACTIVATE: + break; + // 1 arg: range + case WORKSHEET_CHANGE: + case WORKSHEET_SELECTIONCHANGE: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createRange( rArgs, 0 ); + break; + // 2 args: range, cancel + case WORKSHEET_BEFOREDOUBLECLICK: + case WORKSHEET_BEFORERIGHTCLICK: + aVbaArgs.realloc( 2 ); + aVbaArgs[ 0 ] = createRange( rArgs, 0 ); + // current cancel state will be inserted by caller + break; + // 1 arg: hyperlink + case WORKSHEET_FOLLOWHYPERLINK: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createHyperlink( rArgs, 0 ); + break; + } + + /* For workbook events associated to sheet events, the workbook event gets + the same arguments but with a Worksheet object in front of them. */ + if( bSheetEventAsBookEvent ) + { + sal_Int32 nLength = aVbaArgs.getLength(); + uno::Sequence< uno::Any > aVbaArgs2( nLength + 1 ); + aVbaArgs2[ 0 ] = createWorksheet( rArgs, 0 ); + for( sal_Int32 nIndex = 0; nIndex < nLength; ++nIndex ) + aVbaArgs2[ nIndex + 1 ] = aVbaArgs[ nIndex ]; + aVbaArgs = aVbaArgs2; + } + + return aVbaArgs; +} + +void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, bool /*bSuccess*/, bool bCancel ) throw (uno::RuntimeException) +{ + switch( rInfo.mnEventId ) + { + case WORKBOOK_OPEN: + mbOpened = true; + // register the listeners + if( !mxListener.is() ) + { + mxListener = new ScVbaEventsListener( *this, mxModel, mpDocShell ); + mxListener->startListening(); + } + break; + case WORKBOOK_BEFORECLOSE: + /* Execute Auto_Close only if not cancelled by event handler, but + before UI asks user whether to cancel closing the document. */ + if( !bCancel ) + rEventQueue.push_back( AUTO_CLOSE ); + break; + } +} + +::rtl::OUString ScVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +{ + bool bSheetEvent = false; + rInfo.maUserData >>= bSheetEvent; + SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1; + if( bSheetEvent && (nTab < 0) ) + throw lang::IllegalArgumentException(); + + String aCodeName; + if( bSheetEvent ) + mpDoc->GetCodeName( nTab, aCodeName ); + else + aCodeName = mpDoc->GetCodeName(); + return aCodeName; +} + +// private -------------------------------------------------------------------- + +SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) +{ + checkArgument( rArgs, nIndex ); + + // first try to extract a sheet index + SCTAB nTab = -1; + if( rArgs[ nIndex ] >>= nTab ) + return nTab; + + // next, try single range object + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); + if( xCellRangeAddressable.is() ) + return xCellRangeAddressable->getRangeAddress().Sheet; + + // at last, try range list + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + if( xRanges.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); + if( aRangeAddresses.getLength() > 0 ) + return aRangeAddresses[ 0 ].Sheet; + } + + throw lang::IllegalArgumentException(); +} + +bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false ); + if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) ) + { + bool bChanged = maOldSelection != pNewCellRanges->GetRangeList(); + maOldSelection = pNewCellRanges->GetRangeList(); + return bChanged; + } + maOldSelection.Clear(); + return true; +} + +uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + // Eventually we will be able to pull the Workbook/Worksheet objects + // directly from basic and register them as listeners + + // extract sheet index, will throw, if parameter is invalid + SCTAB nTab = getTabFromArgs( rArgs, nIndex ); + + // create Workbook + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); + aArgs[ 1 ] <<= mxModel; + uno::Reference< uno::XInterface > xWorkbook( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_SET_THROW ); + + // create WorkSheet + String aSheetName; + mpDoc->GetName( nTab, aSheetName ); + aArgs = uno::Sequence< uno::Any >( 3 ); + aArgs[ 0 ] <<= xWorkbook; + aArgs[ 1 ] <<= mxModel; + aArgs[ 2 ] <<= ::rtl::OUString( aSheetName ); + uno::Reference< uno::XInterface > xWorksheet( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Worksheet", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xWorksheet ); +} + +uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); + if ( !xRanges.is() && !xRange.is() ) + throw lang::IllegalArgumentException(); + + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent + if ( xRanges.is() ) + aArgs[ 1 ] <<= xRanges; + else + aArgs[ 1 ] <<= xRange; + uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xVbaRange ); +} + +uno::Any ScVbaEventsHelper::createHyperlink( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent + aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); + uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xHyperlink ); +} + +uno::Any ScVbaEventsHelper::createWindow() const throw (uno::RuntimeException) +{ + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= createVBAUnoAPIService( mpShell, "ooo.vba.Application" ); + aArgs[ 1 ] <<= mxModel; + uno::Reference< uno::XInterface > xWindow( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Window", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xWindow ); +} + +// ============================================================================ + +namespace vbaeventshelper +{ +namespace sdecl = comphelper::service_decl; +sdecl::class_<ScVbaEventsHelper, sdecl::with_args<true> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ScVbaEventsHelper", + "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ); +} + +// ============================================================================ diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx new file mode 100755 index 000000000000..a77f5128b3e9 --- /dev/null +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_VBAEVENTS_HXX +#define SC_VBAEVENTS_HXX + +#include <rtl/ref.hxx> +#include <vbahelper/vbaeventshelperbase.hxx> +#include "excelvbahelper.hxx" +#include "rangelst.hxx" + +namespace ooo { namespace vba { namespace excel { class XApplication; } } } + +class ScVbaEventsListener; + +// ============================================================================ + +class ScVbaEventsHelper : public VbaEventsHelperBase +{ +public: + ScVbaEventsHelper( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~ScVbaEventsHelper(); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) throw (css::uno::RuntimeException); + +protected: + virtual bool implEventsEnabled() throw (css::uno::RuntimeException); + virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); + virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + +private: + /** Extracts a sheet index from the first element of the passed sequence. The + element may be an integer, or a Calc range or ranges object. */ + static SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException); + /** Checks if selection has been changed compared to selection of last call. + @return true, if the selection has been changed. */ + bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + + /** Creates a VBA Worksheet object (the argument must contain a sheet index). */ + css::uno::Any createWorksheet( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Range object (the argument must contain a UNO range or UNO range list). */ + css::uno::Any createRange( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Hyperlink object (the argument must contain a UNO cell). */ + css::uno::Any createHyperlink( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Window object. */ + css::uno::Any createWindow() const throw (css::uno::RuntimeException); + +private: + mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication; + ::rtl::Reference< ScVbaEventsListener > mxListener; + ScDocShell* mpDocShell; + ScDocument* mpDoc; + ScRangeList maOldSelection; + bool mbOpened; +}; + +// ============================================================================ + +#endif diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx index 91d0429326dd..8dd67843ec00 100644 --- a/sc/source/ui/vba/vbaformatconditions.cxx +++ b/sc/source/ui/vba/vbaformatconditions.cxx @@ -45,11 +45,11 @@ static rtl::OUString FORMULA2( RTL_CONSTASCII_USTRINGPARAM("Formula2") ); static rtl::OUString STYLENAME( RTL_CONSTASCII_USTRINGPARAM("StyleName") ); static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFormat") ); -ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& xModel ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) +ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& /*xModel*/ ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) { mxRangeParent.set( xParent, uno::UNO_QUERY_THROW ); - uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), xContext, xModel ); - mxStyles.set( xWorkbook->Styles( uno::Any() ), uno::UNO_QUERY_THROW ); + uno::Reference< excel::XApplication> xApp( Application(), uno::UNO_QUERY_THROW ); + mxStyles.set( xApp->getThisWorkbook()->Styles( uno::Any() ), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XCellRangeAddressable > xCellRange( mxRangeParent->getCellRange(), uno::UNO_QUERY_THROW ); mxParentRangePropertySet.set( xCellRange, uno::UNO_QUERY_THROW ); diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 0cddacafd194..c70a7f83726d 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -80,6 +80,15 @@ ScVbaGlobals::getApplication() throw (uno::RuntimeException) return mxApplication; } + +uno::Reference<excel::XApplication > SAL_CALL +ScVbaGlobals::getExcel() throw (uno::RuntimeException) +{ + return getApplication(); +} + + + uno::Reference< excel::XWorkbook > SAL_CALL ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException) { @@ -219,6 +228,25 @@ ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException) } + +uno::Any SAL_CALL +ScVbaGlobals::getDebug() throw (uno::RuntimeException) +{ + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), aArgs, mxContext ); + return uno::Any( xVBADebug ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); +} + uno::Sequence< ::rtl::OUString > SAL_CALL ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) { @@ -233,6 +261,7 @@ ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) ) }; sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) ); sal_Int32 startIndex = serviceNames.getLength(); diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx index ae34d710240f..f22e5b19faa4 100644 --- a/sc/source/ui/vba/vbaglobals.hxx +++ b/sc/source/ui/vba/vbaglobals.hxx @@ -82,7 +82,8 @@ typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > Sc virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException ); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - + virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException); // XMultiServiceFactory diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx index a6e8a402425f..464b167df250 100644 --- a/sc/source/ui/vba/vbaname.cxx +++ b/sc/source/ui/vba/vbaname.cxx @@ -232,10 +232,8 @@ ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css: css::uno::Reference< ov::excel::XRange > ScVbaName::getRefersToRange() throw (css::uno::RuntimeException) { - // FIXME: pass proper Worksheet parent uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( - uno::Reference< XHelperInterface >(), mxContext, - mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); return xRange; } diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index d074f32b689d..9fd22bf89f7a 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -48,7 +48,7 @@ class NamesEnumeration : public EnumerationHelperImpl uno::WeakReference< XHelperInterface > m_xParent; uno::Reference< sheet::XNamedRanges > m_xNames; public: - NamesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel , const uno::Reference< sheet::XNamedRanges >& xNames ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ), m_xNames( xNames ) {} + NamesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel , const uno::Reference< sheet::XNamedRanges >& xNames ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ), m_xNames( xNames ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -173,11 +173,6 @@ ScVbaNames::getElementType() throw( css::uno::RuntimeException ) uno::Reference< container::XEnumeration > ScVbaNames::createEnumeration() throw (uno::RuntimeException) { - if ( mxNames.is() ) - { - uno::Reference< container::XEnumerationAccess > xAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xAccess->createEnumeration(); - } uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW ); return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); } diff --git a/sc/source/ui/vba/vbapivottables.cxx b/sc/source/ui/vba/vbapivottables.cxx index 05a4201da977..fcbf347a3cd4 100644 --- a/sc/source/ui/vba/vbapivottables.cxx +++ b/sc/source/ui/vba/vbapivottables.cxx @@ -42,7 +42,7 @@ uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XC class PivotTableEnumeration : public EnumerationHelperImpl { public: - PivotTableEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ) {} + PivotTableEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -59,7 +59,7 @@ uno::Reference< container::XEnumeration > ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new PivotTableEnumeration( mxContext, xEnumAccess->createEnumeration() ); + return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() ); } uno::Any diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index ccf5a3bc5b54..455af075306c 100644..100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -202,11 +202,10 @@ double lcl_Round2DecPlaces( double nVal ) return nVal; } -uno::Any lcl_makeRange( uno::Reference< uno::XComponentContext >& xContext, const uno::Any aAny, bool bIsRows, bool bIsColumns ) +uno::Any lcl_makeRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any aAny, bool bIsRows, bool bIsColumns ) { uno::Reference< table::XCellRange > xCellRange( aAny, uno::UNO_QUERY_THROW ); - // #FIXME need proper (WorkSheet) parent - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xCellRange, bIsRows, bIsColumns ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xCellRange, bIsRows, bIsColumns ) ) ); } uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSheetCellRanges >& xLocSheetCellRanges, ScDocShell* pDoc ) @@ -227,13 +226,11 @@ uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Re if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xTmpRange( new ScCellRangeObj( pDoc, *aCellRanges.First() ) ); - // #FIXME need proper (WorkSheet) parent xRange = new ScVbaRange( xParent, xContext, xTmpRange ); } else { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDoc, aCellRanges ) ); - // #FIXME need proper (WorkSheet) parent xRange = new ScVbaRange( xParent, xContext, xRanges ); } } @@ -269,12 +266,13 @@ SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) class SingleRangeEnumeration : public EnumerationHelper_BASE { + uno::Reference< XHelperInterface > m_xParent; uno::Reference< table::XCellRange > m_xRange; uno::Reference< uno::XComponentContext > mxContext; bool bHasMore; public: - SingleRangeEnumeration( const uno::Reference< css::uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) : m_xRange( xRange ), mxContext( xContext ), bHasMore( true ) { } + SingleRangeEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xRange( xRange ), mxContext( xContext ), bHasMore( true ) { } virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) { return bHasMore; } virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -292,11 +290,12 @@ typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumeratio class SingleRangeIndexAccess : public SingleRange_BASE { private: + uno::Reference< XHelperInterface > mxParent; uno::Reference< table::XCellRange > m_xRange; uno::Reference< uno::XComponentContext > mxContext; SingleRangeIndexAccess(); // not defined public: - SingleRangeIndexAccess( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ):m_xRange( xRange ), mxContext( xContext ) {} + SingleRangeIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ):mxParent( xParent ), m_xRange( xRange ), mxContext( xContext ) {} // XIndexAccess virtual ::sal_Int32 SAL_CALL getCount() throw (::uno::RuntimeException) { return 1; } virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) @@ -310,7 +309,7 @@ public: virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException) { return sal_True; } // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException) { return new SingleRangeEnumeration( mxContext, m_xRange ); } + virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException) { return new SingleRangeEnumeration( mxParent, mxContext, m_xRange ); } }; @@ -322,10 +321,10 @@ class RangesEnumerationImpl : public EnumerationHelperImpl bool mbIsColumns; public: - RangesEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, bool bIsRows, bool bIsColumns ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} + RangesEnumerationImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, bool bIsRows, bool bIsColumns ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { - return lcl_makeRange( m_xContext, m_xEnumeration->nextElement(), mbIsRows, mbIsColumns ); + return lcl_makeRange( m_xParent, m_xContext, m_xEnumeration->nextElement(), mbIsRows, mbIsColumns ); } }; @@ -335,7 +334,7 @@ class ScVbaRangeAreas : public ScVbaCollectionBaseImpl bool mbIsRows; bool mbIsColumns; public: - ScVbaRangeAreas( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, bool bIsRows, bool bIsColumns ) : ScVbaCollectionBaseImpl( uno::Reference< XHelperInterface >(), xContext, xIndexAccess ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} + ScVbaRangeAreas( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, bool bIsRows, bool bIsColumns ) : ScVbaCollectionBaseImpl( xParent, xContext, xIndexAccess ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} // XEnumerationAccess virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException); @@ -355,14 +354,13 @@ uno::Reference< container::XEnumeration > SAL_CALL ScVbaRangeAreas::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new RangesEnumerationImpl( mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns ); - + return new RangesEnumerationImpl( mxParent, mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns ); } uno::Any ScVbaRangeAreas::createCollectionObject( const uno::Any& aSource ) { - return lcl_makeRange( mxContext, aSource, mbIsRows, mbIsColumns ); + return lcl_makeRange( mxParent, mxContext, aSource, mbIsRows, mbIsColumns ); } // assume that xIf is infact a ScCellRangesBase @@ -618,6 +616,7 @@ public: class CellsEnumeration : public CellsEnumeration_BASE { + uno::WeakReference< XHelperInterface > mxParent; uno::Reference< uno::XComponentContext > mxContext; uno::Reference< XCollection > m_xAreas; vCellPos m_CellPositions; @@ -645,7 +644,7 @@ class CellsEnumeration : public CellsEnumeration_BASE } } public: - CellsEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCollection >& xAreas ): mxContext( xContext ), m_xAreas( xAreas ) + CellsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCollection >& xAreas ): mxParent( xParent ), mxContext( xContext ), m_xAreas( xAreas ) { sal_Int32 nItems = m_xAreas->getCount(); for ( sal_Int32 index=1; index <= nItems; ++index ) @@ -664,8 +663,7 @@ public: uno::Reference< table::XCellRange > xRangeArea = getArea( aPos.m_nArea ); uno::Reference< table::XCellRange > xCellRange( xRangeArea->getCellByPosition( aPos.m_nCol, aPos.m_nRow ), uno::UNO_QUERY_THROW ); - // #FIXME need proper (WorkSheet) parent - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xCellRange ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, xCellRange ) ) ); } }; @@ -1088,11 +1086,11 @@ public: return uno::Reference< sheet::XSheetCellCursor >( getSpreadSheet()->createCursorByRange( getSheetCellRange() ), uno::UNO_QUERY_THROW ); } - static uno::Reference< excel::XRange > createRangeFromRange( const uno::Reference<uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange, const uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable, sal_Int32 nStartColOffset = 0, sal_Int32 nStartRowOffset = 0, - sal_Int32 nEndColOffset = 0, sal_Int32 nEndRowOffset = 0 ) + static uno::Reference< excel::XRange > createRangeFromRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference<uno::XComponentContext >& xContext, + const uno::Reference< table::XCellRange >& xRange, const uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable, + sal_Int32 nStartColOffset = 0, sal_Int32 nStartRowOffset = 0, sal_Int32 nEndColOffset = 0, sal_Int32 nEndRowOffset = 0 ) { - // #FIXME need proper (WorkSheet) parent - return uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, + return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange->getCellRangeByPosition( xCellRangeAddressable->getRangeAddress().StartColumn + nStartColOffset, xCellRangeAddressable->getRangeAddress().StartRow + nStartRowOffset, @@ -1178,7 +1176,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S ScVbaRange* -getRangeForName( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) +getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) { ScRangeList aCellRanges; ScRange refRange; @@ -1189,10 +1187,13 @@ getRangeForName( const uno::Reference< XHelperInterface >& xParent, const uno::R if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocSh, *aCellRanges.First() ) ); - return new ScVbaRange( xParent, xContext, xRange ); + uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRange ); + return new ScVbaRange( xFixThisParent, xContext, xRange ); } uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocSh, aCellRanges ) ); - return new ScVbaRange( xParent, xContext, xRanges ); + + uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRanges ); + return new ScVbaRange( xFixThisParent, xContext, xRanges ); } // ---------------------------------------------------------------------------- @@ -1205,6 +1206,14 @@ inline table::CellRangeAddress lclGetRangeAddress( const uno::Reference< RangeTy return uno::Reference< sheet::XCellRangeAddressable >( rxCellRange, uno::UNO_QUERY_THROW )->getRangeAddress(); } +void lclClearRange( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException) +{ + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | DATETIME | STRING | ANNOTATION | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED; + uno::Reference< sheet::XSheetOperation > xSheetOperation( rxCellRange, uno::UNO_QUERY_THROW ); + xSheetOperation->clearContents( nFlags ); +} + uno::Reference< sheet::XSheetCellRange > lclExpandToMerged( const uno::Reference< table::XCellRange >& rxCellRange, bool bRecursive ) throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRange > xNewCellRange( rxCellRange, uno::UNO_QUERY_THROW ); @@ -1250,15 +1259,27 @@ void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, // Calc cannot merge over merged ranges, always unmerge first xMerge->merge( sal_False ); if( bMerge ) + { + // clear all contents of the covered cells (not the top-left cell) + table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange ); + sal_Int32 nLastColIdx = aRangeAddr.EndColumn - aRangeAddr.StartColumn; + sal_Int32 nLastRowIdx = aRangeAddr.EndRow - aRangeAddr.StartRow; + // clear cells of top row, right of top-left cell + if( nLastColIdx > 0 ) + lclClearRange( rxCellRange->getCellRangeByPosition( 1, 0, nLastColIdx, 0 ) ); + // clear all rows below top row + if( nLastRowIdx > 0 ) + lclClearRange( rxCellRange->getCellRangeByPosition( 0, 1, nLastColIdx, nLastRowIdx ) ); + // merge the range xMerge->merge( sal_True ); - // FIXME need to check whether all the cell contents are retained or lost by popping up a dialog + } } util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException) { /* 1) Check if range is completely inside one single merged range. To do this, try to extend from top-left cell only (not from entire range). - This will excude cases where this range consists of several merged + This will exclude cases where this range consists of several merged ranges (or parts of them). */ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange ); uno::Reference< table::XCellRange > xTopLeft( rxCellRange->getCellRangeByPosition( 0, 0, 0, 0 ), uno::UNO_SET_THROW ); @@ -1284,12 +1305,12 @@ util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxC // ---------------------------------------------------------------------------- css::uno::Reference< excel::XRange > -ScVbaRange::getRangeObjectForName( const css::uno::Reference< ov::XHelperInterface >& xParent, +ScVbaRange::getRangeObjectForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv ) throw ( uno::RuntimeException ) { table::CellRangeAddress refAddr; - return getRangeForName( xParent, xContext, sRangeName, pDocSh, refAddr, eConv ); + return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv ); } @@ -1348,13 +1369,13 @@ ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args, uno::Reference< container::XIndexAccess > xIndex; if ( mxRange.is() ) { - xIndex = new SingleRangeIndexAccess( mxContext, mxRange ); + xIndex = new SingleRangeIndexAccess( mxParent, mxContext, mxRange ); } else if ( mxRanges.is() ) { xIndex.set( mxRanges, uno::UNO_QUERY_THROW ); } - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange, sal_Bool bIsRows, sal_Bool bIsColumns ) throw( lang::IllegalArgumentException ) @@ -1367,8 +1388,8 @@ ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const if ( !xRange.is() ) throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "range is not set " ) ), uno::Reference< uno::XInterface >() , 1 ); - uno::Reference< container::XIndexAccess > xIndex( new SingleRangeIndexAccess( mxContext, xRange ) ); - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + uno::Reference< container::XIndexAccess > xIndex( new SingleRangeIndexAccess( mxParent, mxContext, xRange ) ); + m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } @@ -1377,7 +1398,7 @@ ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const { uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW ); - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + m_Areas = new ScVbaRangeAreas( xParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } @@ -1507,7 +1528,8 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) void ScVbaRange::Clear() throw (uno::RuntimeException) { - sal_Int32 nFlags = sheet::CellFlags::VALUE | sheet::CellFlags::STRING | sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR | sheet::CellFlags::FORMULA; + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; ClearContents( nFlags ); } @@ -1806,11 +1828,11 @@ ScVbaRange::Offset( const ::uno::Any &nRowOff, const uno::Any &nColOff ) throw ( if ( aCellRanges.Count() > 1 ) // Multi-Area { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) ); - return new ScVbaRange( getParent(), mxContext, xRanges ); + return new ScVbaRange( mxParent, mxContext, xRanges ); } // normal range uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) ); - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< excel::XRange > @@ -1831,7 +1853,7 @@ ScVbaRange::CurrentRegion() throw (uno::RuntimeException) helper.getSheetCellCursor(); xSheetCellCursor->collapseToCurrentRegion(); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW); - return RangeHelper::createRangeFromRange( mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); + return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); } uno::Reference< excel::XRange > @@ -1851,7 +1873,7 @@ ScVbaRange::CurrentArray() throw (uno::RuntimeException) helper.getSheetCellCursor(); xSheetCellCursor->collapseToCurrentArray(); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW); - return RangeHelper::createRangeFromRange( mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); + return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); } uno::Any @@ -2069,7 +2091,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells // #FIXE needs proper parent ( Worksheet ) - return uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, mxRange ) ); + return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) ); sal_Int32 nIndex = --nRow; if( bIsIndex && !bIsColumnIndex ) // .Cells(n) @@ -2087,7 +2109,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( getParent(), mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void @@ -2239,12 +2261,12 @@ ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException) throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() ); // return a normal range ( even for multi-selection uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange, true ); + return new ScVbaRange( mxParent, mxContext, xRange, true ); } // Rows() - no params if ( m_Areas->getCount() > 1 ) - return new ScVbaRange( getParent(), mxContext, mxRanges, true ); - return new ScVbaRange( getParent(), mxContext, mxRange, true ); + return new ScVbaRange( mxParent, mxContext, mxRanges, true ); + return new ScVbaRange( mxParent, mxContext, mxRange, true ); } uno::Reference< excel::XRange > @@ -2286,16 +2308,14 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException) throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() ); } // Columns() - no params - //return new ScVbaRange( getParent(), mxContext, mxRange, false, true ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange, false, true ); + return new ScVbaRange( mxParent, mxContext, xRange, false, true ); } void ScVbaRange::setMergeCells( const uno::Any& aIsMerged ) throw (script::BasicErrorException, uno::RuntimeException) { - bool bMerge = false; - aIsMerged >>= bMerge; + bool bMerge = extractBoolFromAny( aIsMerged ); if( mxRanges.is() ) { @@ -2473,7 +2493,7 @@ ScVbaRange::Resize( const uno::Any &RowSize, const uno::Any &ColumnSize ) throw xCursor->collapseToSize( nColumnSize, nRowSize ); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xCursor, ::uno::UNO_QUERY_THROW ); uno::Reference< table::XCellRange > xRange( xSheetRange->getSpreadsheet(), ::uno::UNO_QUERY_THROW ); - return new ScVbaRange( getParent(), mxContext,xRange->getCellRangeByPosition( + return new ScVbaRange( mxParent, mxContext,xRange->getCellRangeByPosition( xCellRangeAddressable->getRangeAddress().StartColumn, xCellRangeAddressable->getRangeAddress().StartRow, xCellRangeAddressable->getRangeAddress().EndColumn, @@ -2496,7 +2516,8 @@ ScVbaRange::setWrapText( const uno::Any& aIsWrapped ) throw (script::BasicErrorE } uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW ); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), aIsWrapped ); + bool bIsWrapped = extractBoolFromAny( aIsWrapped ); + xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), uno::Any( bIsWrapped ) ); } uno::Any @@ -2563,7 +2584,6 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI // xAddressable now for this range xAddressable.set( xReferrer, uno::UNO_QUERY_THROW ); - if( !Cell1.hasValue() ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Invalid Argument " ) ), @@ -2580,7 +2600,7 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI Cell1 >>= sName; RangeHelper referRange( xReferrer ); table::CellRangeAddress referAddress = referRange.getCellRangeAddressable()->getRangeAddress(); - return getRangeForName( getParent(), mxContext, sName, getScDocShell(), referAddress ); + return getRangeForName( mxContext, sName, getScDocShell(), referAddress ); } else @@ -2637,7 +2657,7 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI } } - return new ScVbaRange( getParent(), mxContext, xCellRange ); + return new ScVbaRange( mxParent, mxContext, xCellRange ); } @@ -2772,10 +2792,10 @@ ScVbaRange::getEntireColumnOrRow( bool bColumn ) throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) ); - return new ScVbaRange( getParent(), mxContext, xRanges, !bColumn, bColumn ); + return new ScVbaRange( mxParent, mxContext, xRanges, !bColumn, bColumn ); } uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) ); - return new ScVbaRange( getParent(), mxContext, xRange, !bColumn, bColumn ); + return new ScVbaRange( mxParent, mxContext, xRange, !bColumn, bColumn ); } uno::Reference< excel::XRange > SAL_CALL @@ -2876,13 +2896,11 @@ ScVbaRange::setHidden( const uno::Any& _hidden ) throw (uno::RuntimeException) return; } - sal_Bool bHidden = sal_False; - _hidden >>= bHidden; - + bool bHidden = extractBoolFromAny( _hidden ); try { uno::Reference< beans::XPropertySet > xProps = getRowOrColumnProps( mxRange, mbIsRows ); - xProps->setPropertyValue( ISVISIBLE, uno::makeAny( !bHidden ) ); + xProps->setPropertyValue( ISVISIBLE, uno::Any( !bHidden ) ); } catch( uno::Exception& e ) { @@ -2979,7 +2997,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L // return a Range object that represents the first cell where that information is found. rtl::OUString sWhat; sal_Int32 nWhat = 0; - float fWhat = 0.0; + double fWhat = 0.0; // string. if( What >>= sWhat ) @@ -3011,6 +3029,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L { uno::Reference< util::XSearchDescriptor > xDescriptor = xSearch->createSearchDescriptor(); xDescriptor->setSearchString( sSearch ); + xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHREGEXP ) ), uno::Any( true ) ); uno::Reference< excel::XRange > xAfterRange; uno::Reference< table::XCellRange > xStartCell; @@ -3116,12 +3135,11 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L ScGlobal::SetSearchItem( newOptions ); - uno::Reference< util::XSearchDescriptor > xSearchDescriptor( xDescriptor, uno::UNO_QUERY ); - uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xSearchDescriptor) : xSearch->findFirst( xSearchDescriptor ); + uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xDescriptor) : xSearch->findFirst( xDescriptor ); uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY ); if ( xCellRange.is() ) { - uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange ); + uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange ); if( xResultRange.is() ) { xResultRange->Select(); @@ -3148,7 +3166,7 @@ uno::Reference< table::XCellRange > processKey( const uno::Any& Key, uno::Refere table::CellRangeAddress aRefAddr; if ( !pDocSh ) throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort no docshell to calculate key param")), uno::Reference< uno::XInterface >() ); - xKeyRange = getRangeForName( uno::Reference< XHelperInterface >(), xContext, sRangeName, pDocSh, aRefAddr ); + xKeyRange = getRangeForName( xContext, sRangeName, pDocSh, aRefAddr ); } else throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort illegal type value for key param")), uno::Reference< uno::XInterface >() ); @@ -3582,7 +3600,7 @@ ScVbaRange::createEnumeration() throw (uno::RuntimeException) return new ColumnsRowEnumeration( mxContext, xRange, nElems ); } - return new CellsEnumeration( mxContext, m_Areas ); + return new CellsEnumeration( mxParent, mxContext, m_Areas ); } ::rtl::OUString SAL_CALL @@ -4073,15 +4091,14 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC uno::Reference< table::XCellRange > xRange = xReferrer->getReferredCells(); if ( xRange.is() ) { - // #FIXME need proper (WorkSheet) parent - uno::Reference< excel::XRange > xVbRange = new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xRange ); + uno::Reference< excel::XRange > xVbRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), xContext, xRange ); return xVbRange; } } } uno::Reference< sheet::XSpreadsheetView > xView( getCurrentExcelDoc(xContext)->getCurrentController(), uno::UNO_QUERY ); uno::Reference< table::XCellRange > xSheetRange( xView->getActiveSheet(), uno::UNO_QUERY_THROW ); - ScVbaRange* pRange = new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xSheetRange ); + ScVbaRange* pRange = new ScVbaRange( excel::getUnoSheetModuleObj( xSheetRange ), xContext, xSheetRange ); uno::Reference< excel::XRange > xVbSheetRange( pRange ); return pRange->Range( Cell1, Cell2, true ); } @@ -4569,7 +4586,7 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u // After the insert ( this range ) actually has moved ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getDocShellFromRange( mxRange ) , aRange ) ); - uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( getParent(), mxContext, xRange, mbIsRows, mbIsColumns ) ); + uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( mxParent, mxContext, xRange, mbIsRows, mbIsColumns ) ); xVbaRange->PasteSpecial( uno::Any(), uno::Any(), uno::Any(), uno::Any() ); } } @@ -4912,8 +4929,7 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::Ru if( m_Areas->getCount() > 1 ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() ); - sal_Bool bShowDetail = sal_False; - aShowDetail >>= bShowDetail; + bool bShowDetail = extractBoolFromAny( aShowDetail ); RangeHelper helper( mxRange ); uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor(); @@ -4955,18 +4971,18 @@ ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeExceptio if( aCellAddress.StartColumn ==0 && aCellAddress.EndColumn==0 && aCellAddress.StartRow==0 && aCellAddress.EndRow==0) { - return new ScVbaRange( getParent(),mxContext,mxRange ); + return new ScVbaRange( mxParent,mxContext,mxRange ); } else { ScRange refRange( static_cast< SCCOL >( aCellAddress.StartColumn ), static_cast< SCROW >( aCellAddress.StartRow ), static_cast< SCTAB >( aCellAddress.Sheet ), static_cast< SCCOL >( aCellAddress.EndColumn ), static_cast< SCROW >( aCellAddress.EndRow ), static_cast< SCTAB >( aCellAddress.Sheet ) ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) ); - return new ScVbaRange( getParent(),mxContext,xRange ); + return new ScVbaRange( mxParent, mxContext,xRange ); } } } - return new ScVbaRange( getParent(),mxContext,mxRange ); + return new ScVbaRange( mxParent, mxContext, mxRange ); } void SAL_CALL @@ -5359,7 +5375,7 @@ ScVbaRange::PreviousNext( bool bIsPrevious ) uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< excel::XRange > SAL_CALL @@ -5442,13 +5458,11 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue) throw if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), *aCellRanges.First() ) ); - // #FIXME need proper (WorkSheet) parent - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( getScDocShell(), aCellRanges ) ); - // #FIXME need proper (WorkSheet) parent - return new ScVbaRange( getParent(), mxContext, xRanges ); + return new ScVbaRange( mxParent, mxContext, xRanges ); } else if ( bIsSingleCell ) { diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index a9147a0d7840..e7488e434f30 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -145,7 +145,6 @@ public: bool isSingleCellRange(); static css::uno::Reference< ov::excel::XRange > getRangeObjectForName( - const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 365c8b35a00c..28469c4685a2 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -50,6 +50,7 @@ #include "vbanames.hxx" // Amelia Wang #include "nameuno.hxx" #include "docoptio.hxx" +#include "unonames.hxx" // Much of the impl. for the equivalend UNO module is // sc/source/ui/unoobj/docuno.cxx, viewuno.cxx @@ -208,7 +209,6 @@ ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args, uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext ) - { init(); } @@ -216,21 +216,24 @@ ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args, uno::Reference< excel::XWorksheet > ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ) ); - uno::Reference< sheet::XSpreadsheet > xSheet; + uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW ); uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - if ( xView.is() ) - xSheet = xView->getActiveSheet(); - return new ScVbaWorksheet( this, mxContext, xSheet, xModel ); + uno::Reference< beans::XPropertySet > xSheetProps( xView->getActiveSheet(), uno::UNO_QUERY_THROW ); + // #162503# return the original document module wrapper object, instead of a new instance + ::rtl::OUString aCodeName; + xSheetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= aCodeName; + ScDocShell* pShell = excel::getDocShell( xModel ); + if( !pShell ) + throw uno::RuntimeException(); + return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW ); } + uno::Any SAL_CALL ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException) { return Worksheets( aIndex ); } - - uno::Any SAL_CALL ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 9f9c5dacd796..7efee1505dcb 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -46,6 +46,10 @@ #include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/uri/XUriReference.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/script/ModuleType.hpp> #include <sfx2/objsh.hxx> #include <tools/urlobj.hxx> @@ -56,21 +60,100 @@ #include <vbahelper/vbahelper.hxx> #include <hash_map> +#include <vector> #include <osl/file.hxx> using namespace ::ooo::vba; using namespace ::com::sun::star; const sal_Int16 CUSTOM_CHAR = 5; +void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc ) +{ + uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); + ScDocShell* pShell = excel::getDocShell( xModel ); + if ( pShell ) + { + uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer(); + uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); + xVBACompat->setVBACompatibilityMode( sal_True ); + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + if( xLibContainer.is() ) + { + if( !xLibContainer->hasByName( aPrjName ) ) + xLibContainer->createLibrary( aPrjName ); + uno::Any aLibAny = xLibContainer->getByName( aPrjName ); + uno::Reference< container::XNameContainer > xLib; + aLibAny >>= xLib; + if( xLib.is() ) + { + uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); + uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW); + // bootstrap vbaglobals + xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals"))); + uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW ); + // set up the module info for the workbook and sheets in the nealy created + // spreadsheet + ScDocument* pDoc = pShell->GetDocument(); + String sCodeName = pDoc->GetCodeName(); + if ( sCodeName.Len() == 0 ) + { + sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") ); + pDoc->SetCodeName( sCodeName ); + } + + std::vector< rtl::OUString > sDocModuleNames; + sDocModuleNames.push_back( sCodeName ); + + uno::Reference<container::XNameAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() ); + + for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index ) + { + sDocModuleNames.push_back( sSheets[ index ] ); + } + + std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end(); + + for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it ) + { + script::ModuleInfo sModuleInfo; + + sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY ); + sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; + xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo ); + if( xLib->hasByName( *it ) ) + xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) ); + else + xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) ); + } + } + } + } +} + static uno::Any -getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Any& aApplication ) +getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent ) { // FIXME: fine as long as ScVbaWorkbook is stateless ... uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); if( !xModel.is() ) return uno::Any(); - ScVbaWorkbook *pWb = new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); + ScDocShell* pShell = excel::getDocShell( xModel ); + if ( pShell ) + { + String sCodeName = pShell->GetDocument()->GetCodeName(); + uno::Reference< uno::XInterface > xIf = getUnoDocModule( sCodeName, pShell ); + if ( xIf.is() ) + { + OSL_TRACE(" *** Returning Module uno Object *** "); + return uno::makeAny( xIf ); + } + } + + ScVbaWorkbook *pWb = new ScVbaWorkbook( xParent, xContext, xModel ); return uno::Any( uno::Reference< excel::XWorkbook > (pWb) ); } @@ -78,12 +161,12 @@ class WorkBookEnumImpl : public EnumerationHelperImpl { uno::Any m_aApplication; public: - WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_aApplication( aApplication ) {} + WorkBookEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return getWorkbook( m_xContext, xDoc, m_aApplication ); + return getWorkbook( m_xContext, xDoc, m_xParent ); } }; @@ -105,14 +188,14 @@ ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException) // safer to create an enumeration based on this objects state // rather than one effectively based of the desktop component uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new WorkBookEnumImpl( mxContext, xEnumerationAccess->createEnumeration(), Application() ); + return new WorkBookEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() ); } uno::Any ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) { uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW ); - return getWorkbook( mxContext, xDoc, Application() ); + return getWorkbook( mxContext, xDoc, mxParent ); } @@ -121,8 +204,10 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException) { uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); + // need to set up the document modules ( and vba mode ) here + setUpDocumentModules( xSpreadDoc ); if( xSpreadDoc.is() ) - return getWorkbook( mxContext, xSpreadDoc, Application() ); + return getWorkbook( mxContext, xSpreadDoc, mxParent ); return uno::Any(); } @@ -249,7 +334,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() ); uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); - uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, Application() ); + uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) xWBook->Activate(); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 5b1963e3d242..6ee6fa1f6b19 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XSheetCellRange.hpp> #include <com/sun/star/sheet/XSheetCellCursor.hpp> #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp> @@ -60,6 +61,7 @@ #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> #include <ooo/vba/excel/XlEnableSelection.hpp> +#include <ooo/vba/excel/XWorkbook.hpp> #include <ooo/vba/XControlProvider.hpp> #include <comphelper/processfactory.hxx> @@ -318,6 +320,40 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx } +uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xDBRangesIA( xModelProps->getPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DatabaseRanges" ) ) ), uno::UNO_QUERY_THROW ); + + for( sal_Int32 nIndex = 0, nCount = xDBRangesIA->getCount(); nIndex < nCount; ++nIndex ) + { + uno::Reference< sheet::XCellRangeReferrer > xDBRange( xDBRangesIA->getByIndex( nIndex ), uno::UNO_QUERY_THROW ); + // check if the database area is on this sheet + uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( xDBRange->getReferredCells(), uno::UNO_QUERY_THROW ); + if( getSheetID() == xRangeAddr->getRangeAddress().Sheet ) + return uno::Reference< beans::XPropertySet >( xDBRange, uno::UNO_QUERY_THROW ); + } + return uno::Reference< beans::XPropertySet >(); +} + +sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); + sal_Bool bAutoFilterMode = sal_False; + return + xDBRangeProps.is() && + (xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) && + bAutoFilterMode; +} + +void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); + if( xDBRangeProps.is() ) + xDBRangeProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ), uno::Any( bAutoFilterMode ) ); +} + uno::Reference< excel::XRange > ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException) { @@ -378,7 +414,7 @@ ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException) sal_Bool ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException) { - return false; + return sal_False; } sal_Bool @@ -391,7 +427,13 @@ ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException) sal_Bool ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException) { - return false; + return sal_False; +} + +sal_Bool +ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException) +{ + return sal_False; } void @@ -672,24 +714,26 @@ ScVbaWorksheet::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeExceptio } uno::Any SAL_CALL +ScVbaWorksheet::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) +{ + uno::Reference< excel::XWorkbook > xWorkbook( getParent(), uno::UNO_QUERY_THROW ); + return xWorkbook->Names( aIndex ); +} + +uno::Any SAL_CALL ScVbaWorksheet::OLEObjects( const uno::Any& Index ) throw (uno::RuntimeException) { - ScVbaOLEObjects* aOleObjects; uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW ); uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW ); uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPage, uno::UNO_QUERY_THROW ); - aOleObjects = new ScVbaOLEObjects( this, mxContext, xIndexAccess ); + uno::Reference< excel::XOLEObjects >xOleObjects( new ScVbaOLEObjects( this, mxContext, xIndexAccess ) ); if( Index.hasValue() ) - { - return aOleObjects->Item( Index, uno::Any() ); - } - else - { - return uno::makeAny( uno::Reference< excel::XOLEObjects> ( aOleObjects ) ); - } + return xOleObjects->Item( Index, uno::Any() ); + return uno::Any( xOleObjects ); } + uno::Any SAL_CALL ScVbaWorksheet::Shapes( const uno::Any& aIndex ) throw (uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index d07cc1a8d55c..78bcc2503a49 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -68,6 +68,9 @@ class ScVbaWorksheet : public WorksheetImpl_BASE css::uno::Reference< css::container::XNameAccess > getFormControls(); css::uno::Any getControlShape( const rtl::OUString& sName ); + + css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties() throw (css::uno::RuntimeException); + protected: ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ); @@ -95,6 +98,7 @@ public: virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectContents() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectDrawingObjects() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getProtectScenarios() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getUsedRange() throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL ChartObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( ) throw (css::uno::RuntimeException); @@ -106,6 +110,8 @@ public: virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException); virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoFilterMode() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); @@ -129,6 +135,7 @@ public: virtual css::uno::Any SAL_CALL PivotTables( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Comments( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL OLEObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Shapes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 60cf7b904026..7fa5196a6b04 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -52,6 +52,7 @@ #include "vbaglobals.hxx" #include "vbaworksheet.hxx" #include "vbaworkbook.hxx" +#include "unonames.hxx" using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -63,6 +64,27 @@ typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess // (as added ) of the items typedef std::vector< uno::Reference< sheet::XSpreadsheet > > SheetMap; + +// #FIXME #TODO the implementation of the Sheets collections sucks, +// e.g. there is no support for tracking sheets added/removed from the collection + +uno::Reference< uno::XInterface > +lcl_getModulAsUnoObject( const uno::Reference< sheet::XSpreadsheet >& xSheet, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) +{ + uno::Reference< uno::XInterface > xRet; + if ( !xSheet.is() ) + throw uno::RuntimeException(); + uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW ); + rtl::OUString sName; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= sName; + + ScDocShell* pShell = excel::getDocShell( xModel ); + + if ( pShell ) + xRet = getUnoDocModule( sName, pShell ); + return xRet; +} + class WorkSheetsEnumeration : public SheetEnumeration_BASE { SheetMap mSheetMap; @@ -145,14 +167,24 @@ public: class SheetsEnumeration : public EnumerationHelperImpl { uno::Reference< frame::XModel > m_xModel; - uno::WeakReference< XHelperInterface > m_xParent; public: - SheetsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ) {} + SheetsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< sheet::XSpreadsheet > xSheet( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( m_xParent, m_xContext, xSheet, m_xModel ) ) ); + uno::Reference< uno::XInterface > xIf = lcl_getModulAsUnoObject( xSheet, m_xModel ); + uno::Any aRet; + if ( !xIf.is() ) + { + // if the Sheet is in a document created by the api unfortunately ( at the + // moment, it actually wont have the special Document modules + uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( m_xParent, m_xContext, xSheet, m_xModel ) ); + aRet <<= xNewSheet; + } + else + aRet <<= xIf; + return aRet; } }; @@ -188,7 +220,18 @@ uno::Any ScVbaWorksheets::createCollectionObject( const uno::Any& aSource ) { uno::Reference< sheet::XSpreadsheet > xSheet( aSource, uno::UNO_QUERY ); - return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( getParent(), mxContext, xSheet, mxModel ) ) ); + uno::Reference< XInterface > xIf = lcl_getModulAsUnoObject( xSheet, mxModel ); + uno::Any aRet; + if ( !xIf.is() ) + { + // if the Sheet is in a document created by the api unfortunately ( at the + // moment, it actually wont have the special Document modules + uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( getParent(), mxContext, xSheet, mxModel ) ); + aRet <<= xNewSheet; + } + else + aRet <<= xIf; + return aRet; } // XWorksheets diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index db72d87f30a2..0f07b8772254 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -69,6 +69,8 @@ #include <com/sun/star/sheet/MemberResultFlags.hpp> #include <com/sun/star/awt/KeyModifier.hpp> #include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include "gridwin.hxx" #include "tabvwsh.hxx" @@ -119,6 +121,7 @@ #include "tabprotection.hxx" #include "postit.hxx" #include "dpcontrol.hxx" +#include "cellsuno.hxx" #include "drawview.hxx" #include <svx/sdrpagewindow.hxx> @@ -366,6 +369,32 @@ void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, c } } +sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell ) +{ + BOOL bFound = FALSE; + do + { + pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); + if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) + { + if ( rPosX <= 0 ) + return FALSE; // alles leer bis links + else + --rPosX; // weitersuchen + } + else if ( rpCell->GetCellType() == CELLTYPE_EDIT) + bFound = TRUE; + else if (rpCell->GetCellType() == CELLTYPE_FORMULA && + static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell()) + bFound = TRUE; + else + return FALSE; // andere Zelle + } + while ( !bFound ); + + return bFound; +} + // --------------------------------------------------------------------------- // WB_DIALOGCONTROL noetig fuer UNO-Controls ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ) @@ -2100,6 +2129,30 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) { nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen ScGlobal::OpenURL( aUrl, aTarget ); + + // fire worksheet_followhyperlink event + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + if( xVbaEvents.is() ) try + { + Point aPos = rMEvt.GetPosPixel(); + SCsCOL nPosX; + SCsROW nPosY; + SCTAB nTab = pViewData->GetTabNo(); + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + ScBaseCell* pCell = NULL; + if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) ) + { + ScAddress aCellPos( nPosX, nPosY, nTab ); + uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xCell; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs ); + } + } + catch( uno::Exception& ) + { + } + return; } } @@ -4818,26 +4871,9 @@ BOOL ScGridWindow::GetEditUrlOrError( BOOL bSpellErr, const Point& rPos, ScDocument* pDoc = pDocSh->GetDocument(); ScBaseCell* pCell = NULL; - BOOL bFound = FALSE; - do - { - pDoc->GetCell( nPosX, nPosY, nTab, pCell ); - if ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ) - { - if ( nPosX <= 0 ) - return FALSE; // alles leer bis links - else - --nPosX; // weitersuchen - } - else if ( pCell->GetCellType() == CELLTYPE_EDIT) - bFound = TRUE; - else if (pCell->GetCellType() == CELLTYPE_FORMULA && - static_cast<ScFormulaCell*>(pCell)->IsHyperLinkCell()) - bFound = TRUE; - else - return FALSE; // andere Zelle - } - while ( !bFound ); + BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ); + if( !bFound ) + return FALSE; ScHideTextCursor aHideCursor( pViewData, eWhich ); // before GetEditArea (MapMode is changed) diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index f8b5c25c4a70..ec584213898c 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -144,7 +144,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& Size aScrSize(nSizeX-1, nSizeY-1); // Check if the mouse cursor is clicking on the popup arrow box. - mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY())); + mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc)); mpFilterButton->setBoundingBox(aScrPos, aScrSize); Point aPopupPos; Size aPopupSize; @@ -309,10 +309,17 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) aPosRect, nOrient, nDimPos ); UpdateDragRect( bHasRange && bMove, aPosRect ); + BOOL bIsDataLayout; + sal_Int32 nDimFlags = 0; + String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout, &nDimFlags ); + bool bAllowed = !bHasRange || ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ); + if (bMove) // set mouse pointer { PointerStyle ePointer = POINTER_PIVOT_DELETE; - if ( bHasRange ) + if ( !bAllowed ) + ePointer = POINTER_NOTALLOWED; + else if ( bHasRange ) switch (nOrient) { case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break; @@ -327,15 +334,13 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) if (!bHasRange) nOrient = sheet::DataPilotFieldOrientation_HIDDEN; - BOOL bIsDataLayout; - String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout ); if ( bIsDataLayout && ( nOrient != sheet::DataPilotFieldOrientation_COLUMN && nOrient != sheet::DataPilotFieldOrientation_ROW ) ) { // removing data layout is not allowed pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED); } - else + else if ( bAllowed ) { ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() ); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index d8024e439173..ba73fbf00269 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -401,17 +401,13 @@ void __EXPORT ScGridWindow::Paint( const Rectangle& rRect ) nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX ); } - long nScrY = ScViewData::ToPixel( pDoc->GetRowHeight( nY1, nTab ), nPPTY ); - while ( nScrY <= aPixRect.Top() && nY1 < MAXROW ) - { - ++nY1; - nScrY += ScViewData::ToPixel( pDoc->GetRowHeight( nY1, nTab ), nPPTY ); - } + long nScrY = 0; + ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab); SCROW nY2 = nY1; - while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW ) + if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW) { ++nY2; - nScrY += ScViewData::ToPixel( pDoc->GetRowHeight( nY2, nTab ), nPPTY ); + ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab); } Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen @@ -750,6 +746,15 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( !bLogicText ) aOutputData.DrawStrings(FALSE); // in pixel MapMode + // edit cells and printer-metrics text must be before the buttons + // (DataPilot buttons contain labels in UI font) + + pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); + if ( bLogicText ) + aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set + aOutputData.DrawEdit(TRUE); + pContentDev->SetMapMode(MAP_PIXEL); + // Autofilter- und Pivot-Buttons DrawButtons( nX1, nY1, nX2, nY2, aTabInfo, pContentDev ); // Pixel @@ -759,14 +764,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( rOpts.GetOption( VOPT_NOTES ) ) aOutputData.DrawNoteMarks(); - // Edit-Zellen - - pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); - if ( bLogicText ) - aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set - aOutputData.DrawEdit(TRUE); - - pContentDev->SetMapMode(MAP_PIXEL); if ( !bGridFirst && ( bGrid || bPage ) ) { aOutputData.DrawGrid( bGrid, bPage ); @@ -1208,14 +1205,14 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2 { aComboButton.SetOutputDevice( pContentDev ); - ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY()); + ScDocument* pDoc = pViewData->GetDocument(); + ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc); SCCOL nCol; SCROW nRow; SCSIZE nArrY; SCSIZE nQuery; SCTAB nTab = pViewData->GetTabNo(); - ScDocument* pDoc = pViewData->GetDocument(); ScDBData* pDBData = NULL; ScQueryParam* pQueryParam = NULL; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 961572fc0185..7b27ddf3f8cc 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -489,6 +489,8 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) // Horizontale Linien // + bool bHiddenRow = true; + SCROW nHiddenEndRow = -1; nPosY = nScrY; for (nArrY=1; nArrY+1<nArrCount; nArrY++) { @@ -503,9 +505,17 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) { for (SCROW i = nYplus1; i <= MAXROW; ++i) { + if (i > nHiddenEndRow) + bHiddenRow = pDoc->RowHidden(i, nTab, nHiddenEndRow); + /* TODO: optimize the row break thing for large hidden + * segments where HasRowBreak() has to be called + * nevertheless for each row, as a row break is drawn also + * for hidden rows, above them. This needed to be done only + * once per hidden segment, maybe giving manual breaks + * priority. Something like GetNextRowBreak() and + * GetNextManualRowBreak(). */ nBreak = pDoc->HasRowBreak(i, nTab); - bool bHidden = pDoc->RowHidden(i, nTab); - if (nBreak || !bHidden) + if (!bHiddenRow || nBreak) break; } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index b0b040f9b5e0..6d40d304fb13 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -171,12 +171,11 @@ public: private: void SetHashText(); - long GetMaxDigitWidth(); + long GetMaxDigitWidth(); // in logic units long GetSignWidth(); long GetDotWidth(); long GetExpWidth(); void TextChanged(); - long ConvertWidthLogicToPixel( long nWidth ) const; }; //================================================================== @@ -518,6 +517,10 @@ void ScDrawStringsVars::SetHashText() void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) { + // #i113045# do the single-character width calculations in logic units + if (bPixelToLogic) + nWidth = pOutput->pRefDevice->PixelToLogic(Size(nWidth,0)).Width(); + if (!pCell) return; @@ -565,6 +568,12 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) else if (c == sal_Unicode('E')) ++nExpCount; } + + // #i112250# A small value might be formatted as "0" when only counting the digits, + // but fit into the column when considering the smaller width of the decimal separator. + if (aString.EqualsAscii("0") && fVal != 0.0) + nDecimalCount = 1; + if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) @@ -582,10 +591,6 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } long nActualTextWidth = pOutput->pFmtDevice->GetTextWidth(aString); - - if (bPixelToLogic) - nActualTextWidth = ConvertWidthLogicToPixel(nActualTextWidth); - if (nActualTextWidth > nWidth) { // Even after the decimal adjustment the text doesn't fit. Give up. @@ -594,6 +599,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } TextChanged(); + pLastCell = NULL; // #i113022# equal cell and format in another column may give different string } void ScDrawStringsVars::SetAutoText( const String& rAutoText ) @@ -638,9 +644,6 @@ long ScDrawStringsVars::GetMaxDigitWidth() long n = pOutput->pFmtDevice->GetTextWidth(String(cDigit)); nMaxDigitWidth = ::std::max(nMaxDigitWidth, n); } - - if (bPixelToLogic) - nMaxDigitWidth = ConvertWidthLogicToPixel(nMaxDigitWidth); return nMaxDigitWidth; } @@ -650,8 +653,6 @@ long ScDrawStringsVars::GetSignWidth() return nSignWidth; nSignWidth = pOutput->pFmtDevice->GetTextWidth(String('-')); - if (bPixelToLogic) - nSignWidth = ConvertWidthLogicToPixel(nSignWidth); return nSignWidth; } @@ -662,8 +663,6 @@ long ScDrawStringsVars::GetDotWidth() const ::rtl::OUString& sep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator; nDotWidth = pOutput->pFmtDevice->GetTextWidth(sep); - if (bPixelToLogic) - nDotWidth = ConvertWidthLogicToPixel(nDotWidth); return nDotWidth; } @@ -673,8 +672,6 @@ long ScDrawStringsVars::GetExpWidth() return nExpWidth; nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); - if (bPixelToLogic) - nExpWidth = ConvertWidthLogicToPixel(nExpWidth); return nExpWidth; } @@ -704,13 +701,6 @@ void ScDrawStringsVars::TextChanged() aTextSize = pRefDevice->LogicToPixel( aTextSize ); } -long ScDrawStringsVars::ConvertWidthLogicToPixel( long nWidth ) const -{ - Size aSize(nWidth, pOutput->pFmtDevice->GetTextHeight()); - aSize = pOutput->pRefDevice->LogicToPixel(aSize); - return aSize.Width(); -} - BOOL ScDrawStringsVars::HasEditCharacters() const { static const sal_Unicode pChars[] = diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 38d5144274c5..48ffd4fd39a4 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -108,7 +108,7 @@ SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) ) SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW)); } -SFX_IMPL_VIEWFACTORY( ScPreviewShell, ScResId(STR_NONAME) ) +SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" ) { SFX_VIEW_REGISTRATION(ScDocShell); } diff --git a/sc/source/ui/view/prevwsh2.cxx b/sc/source/ui/view/prevwsh2.cxx index 07af90f797aa..84868b5377de 100644 --- a/sc/source/ui/view/prevwsh2.cxx +++ b/sc/source/ui/view/prevwsh2.cxx @@ -126,10 +126,6 @@ //#define _GRAPH_HXX #define _SOUND_HXX -#if defined WIN -#define _MENUBTN_HXX -#endif - //svtools #define _SCRWIN_HXX #define _RULER_HXX diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index 1faa105d2bd7..d5816ecdd289 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -197,20 +197,27 @@ ScExtTabSettings& ScExtDocOptions::GetOrCreateTabSettings( SCTAB nTab ) return mxImpl->maTabSett.GetOrCreateTabSettings( nTab ); } -size_t ScExtDocOptions::GetCodeNameCount() const +SCTAB ScExtDocOptions::GetCodeNameCount() const { - return mxImpl->maCodeNames.size(); + return static_cast< SCTAB >( mxImpl->maCodeNames.size() ); } -const String& ScExtDocOptions::GetCodeName( size_t nIdx ) const +const String& ScExtDocOptions::GetCodeName( SCTAB nTab ) const { - DBG_ASSERT( nIdx < GetCodeNameCount(), "ScExtDocOptions::GetCodeName - invalid index" ); - return (nIdx < GetCodeNameCount()) ? mxImpl->maCodeNames[ nIdx ] : EMPTY_STRING; + DBG_ASSERT( (0 <= nTab) && (nTab < GetCodeNameCount()), "ScExtDocOptions::GetCodeName - invalid sheet index" ); + return ((0 <= nTab) && (nTab < GetCodeNameCount())) ? mxImpl->maCodeNames[ static_cast< size_t >( nTab ) ] : EMPTY_STRING; } -void ScExtDocOptions::AppendCodeName( const String& rCodeName ) +void ScExtDocOptions::SetCodeName( SCTAB nTab, const String& rCodeName ) { - mxImpl->maCodeNames.push_back( rCodeName ); + DBG_ASSERT( nTab >= 0, "ScExtDocOptions::SetCodeName - invalid sheet index" ); + if( nTab >= 0 ) + { + size_t nIndex = static_cast< size_t >( nTab ); + if( nIndex >= mxImpl->maCodeNames.size() ) + mxImpl->maCodeNames.resize( nIndex + 1 ); + mxImpl->maCodeNames[ nIndex ] = rCodeName; + } } // ============================================================================ diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 86f68a1878cc..90bfe0c24e5c 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1682,6 +1682,7 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection ) } TabChanged(); // DrawView + aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist if ( !bUnoRefDialog ) aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx index 1733cf2e19b5..2fc2bba072d9 100644 --- a/sc/source/ui/view/tabvwsh.cxx +++ b/sc/source/ui/view/tabvwsh.cxx @@ -102,7 +102,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL)) //-->Added by PengYunQuan for Validity Cell Range Picker } -SFX_IMPL_VIEWFACTORY( ScTabViewShell, ScResId(STR_NONAME) ) +SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" ) { SFX_VIEW_REGISTRATION(ScDocShell); } diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index ed09ec85ee8c..0835d08de9fd 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -173,13 +173,6 @@ void __EXPORT ScTabViewShell::Activate(BOOL bMDI) SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) ); bFirstActivate = FALSE; - if ( aPendingUserData.hasElements() ) - { - // #89897# read user data from print preview now, after ctor - DoReadUserDataSequence( aPendingUserData ); - aPendingUserData.realloc( 0 ); - } - // #116278# ReadExtOptions (view settings from Excel import) must also be done // after the ctor, because of the potential calls to Window::Show. // Even after the fix for #104887# (Window::Show no longer notifies the access @@ -1924,7 +1917,6 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, if ( pOldSh && pOldSh->ISA( ScPreviewShell ) ) { ScPreviewShell* pPreviewShell = ((ScPreviewShell*)pOldSh); - aPendingUserData = pPreviewShell->GetSourceData(); // used in Activate nForceDesignMode = pPreviewShell->GetSourceDesignMode(); } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c034836d4d4a..7b35328f68bb 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1696,50 +1696,32 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHO if (pView) ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY); - SCROW nY; - USHORT nScrPosY = 0; - if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (USHORT) aScrSize.Height(); - if (nDir==1) - nY = nPosY; // vorwaerts - else - nY = nPosY-1; // rueckwaerts - - BOOL bOut = FALSE; - for ( ; nScrPosY<=nScrSizeY && !bOut; nY+=nDir ) - { - SCsROW nRowNo = nY; - if ( nRowNo < 0 || nRowNo > MAXROW ) - bOut = TRUE; - else - { - USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo ); - if (nTSize) - { - long nSizeYPix = ToPixel( nTSize, nPPTY ); - nScrPosY = sal::static_int_cast<USHORT>( nScrPosY + (USHORT) nSizeYPix ); - } - else if ( nDir == 1 && nRowNo < MAXROW ) - { - // skip multiple hidden rows (forward only for now) - SCROW nNext = pDoc->FirstVisibleRow(nRowNo + 1, MAXROW, nTabNo); - if ( nNext > MAXROW ) - { - // same behavior as without the optimization: set bOut with nY=MAXROW+1 - nY = MAXROW+1; - bOut = TRUE; - } - else - nY = nNext - 1; // +=nDir advances to next visible row - } - } - } + SCROW nY; if (nDir==1) + { + // forward + nY = nPosY; + long nScrPosY = 0; + AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo); + // Original loop ended on last evaluated +1 or if that was MAXROW even + // on MAXROW+2. + nY += (nY == MAXROW ? 2 : 1); nY -= nPosY; + } else + { + // backward + nY = nPosY-1; + long nScrPosY = 0; + AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo); + // Original loop ended on last evaluated -1 or if that was 0 even on + // -2. + nY -= (nY == 0 ? 2 : 1); nY = (nPosY-1)-nY; + } if (nY>0) --nY; return nY; @@ -1855,16 +1837,10 @@ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, } if (nClickY > 0) - { - while ( rPosY<=MAXROW && nClickY >= nScrY ) - { - nScrY += ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY ); - ++rPosY; - } - --rPosY; - } + AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo ); else { + /* TODO: could need some "SubPixelsWhileBackward" method */ while ( rPosY>0 && nClickY < nScrY ) { --rPosY; @@ -1984,20 +1960,24 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) SCROW nOldPosY = pThisTab->nPosY[eWhich]; long nTPosY = pThisTab->nTPosY[eWhich]; long nPixPosY = pThisTab->nPixPosY[eWhich]; - SCROW i; + SCROW i, nHeightEndRow; if ( nNewPosY > nOldPosY ) for ( i=nOldPosY; i<nNewPosY; i++ ) { - long nThis = pDoc->GetRowHeight( i,nTabNo ); - nTPosY -= nThis; - nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); + long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow ); + SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i; + i = nHeightEndRow; + nTPosY -= nThis * nRows; + nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows; } else for ( i=nNewPosY; i<nOldPosY; i++ ) { - long nThis = pDoc->GetRowHeight( i,nTabNo ); - nTPosY += nThis; - nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); + long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow ); + SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i; + i = nHeightEndRow; + nTPosY += nThis * nRows; + nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows; } pThisTab->nPosY[eWhich] = nNewPosY; @@ -3118,5 +3098,82 @@ ScAddress ScViewData::GetCurPos() const } +// static +void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY, + SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo ) +{ + SCROW nRow = rPosY; + while (rScrY <= nEndPixels && nRow <= nEndRow) + { + SCROW nHeightEndRow; + USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow); + if (nHeightEndRow > nEndRow) + nHeightEndRow = nEndRow; + if (!nHeight) + nRow = nHeightEndRow + 1; + else + { + SCROW nRows = nHeightEndRow - nRow + 1; + sal_Int64 nPixel = ToPixel( nHeight, nPPTY); + sal_Int64 nAdd = nPixel * nRows; + if (nAdd + rScrY > nEndPixels) + { + sal_Int64 nDiff = rScrY + nAdd - nEndPixels; + nRows -= static_cast<SCROW>(nDiff / nPixel); + nAdd = nPixel * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rScrY <= nEndPixels) + { + ++nRows; + nAdd += nPixel; + } + } + rScrY += static_cast<long>(nAdd); + nRow += nRows; + } + } + if (nRow > rPosY) + --nRow; + rPosY = nRow; +} +// static +void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc, + SCTAB nTabNo ) +{ + SCROW nRow = rPosY; + while (rScrY <= nEndPixels && nRow >= nStartRow) + { + SCROW nHeightStartRow; + USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL); + if (nHeightStartRow < nStartRow) + nHeightStartRow = nStartRow; + if (!nHeight) + nRow = nHeightStartRow - 1; + else + { + SCROW nRows = nRow - nHeightStartRow + 1; + sal_Int64 nPixel = ToPixel( nHeight, nPPTY); + sal_Int64 nAdd = nPixel * nRows; + if (nAdd + rScrY > nEndPixels) + { + sal_Int64 nDiff = nAdd + rScrY - nEndPixels; + nRows -= static_cast<SCROW>(nDiff / nPixel); + nAdd = nPixel * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rScrY <= nEndPixels) + { + ++nRows; + nAdd += nPixel; + } + } + rScrY += static_cast<long>(nAdd); + nRow -= nRows; + } + } + if (nRow < rPosY) + ++nRow; + rPosY = nRow; +} diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 34fbbfdad5b5..a125cbea6f50 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -28,8 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - // INCLUDE --------------------------------------------------------------- #include "scitems.hxx" diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 24fab9ac2eba..3104b7ed8b8f 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -34,10 +34,6 @@ #define _SV_NOXSOUND -#ifdef WIN - #define _MENUBTN_HXX -#endif - #define _BASE_DLGS_HXX #define _BIGINT_HXX #define _CACHESTR_HXX diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index 855db09ff50c..a6b772cca012 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -92,6 +92,7 @@ <menu:menuitem menu:id=".uno:Move"/> <menu:menuitem menu:id=".uno:SelectTables"/> <menu:menuitem menu:id=".uno:Remove"/> + <menu:menuitem menu:id=".uno:TableEvents"/> </menu:menupopup> </menu:menu> <menu:menu menu:id=".uno:DelBreakMenu"> diff --git a/sc/uiconfig/scalc/toolbar/findbar.xml b/sc/uiconfig/scalc/toolbar/findbar.xml index 9ef9d8a1a78f..0338d3156195 100644 --- a/sc/uiconfig/scalc/toolbar/findbar.xml +++ b/sc/uiconfig/scalc/toolbar/findbar.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd"> <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar"> - <toolbar:toolbaritem xlink:href=".uno:FindText" toolbar:helpid="helpid:100105" /> - <toolbar:toolbaritem xlink:href=".uno:DownSearch" toolbar:helpid="helpid:100105" /> - <toolbar:toolbaritem xlink:href=".uno:UpSearch" toolbar:helpid="helpid:100105" /> - <toolbar:toolbaritem xlink:href=".uno:SearchDialog" toolbar:text="Find & Replace" toolbar:visible="false" toolbar:helpid="helpid:100105"/> + <toolbar:toolbaritem xlink:href=".uno:FindText"/> + <toolbar:toolbaritem xlink:href=".uno:DownSearch"/> + <toolbar:toolbaritem xlink:href=".uno:UpSearch"/> + <toolbar:toolbaritem xlink:href=".uno:SearchDialog" toolbar:visible="false"/> </toolbar:toolbar> diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index 980d271ae7c0..09578f6ef6a8 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -342,3 +342,23 @@ ALLTAR: $(MISC)$/linkinc.ls $(COMP) build_extn : $(SHL9TARGETN) $(PERL) createExtPackage.pl $(COMMONBIN)$/vbaapi.oxt $(SOLARBINDIR)$/oovbaapi.rdb $(LIBCOMPNAME) + +ALLTAR : $(MISC)/sc.component $(MISC)/scd.component $(MISC)/vbaobj.component + +$(MISC)/sc.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + sc.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt sc.component + +$(MISC)/scd.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + scd.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL2TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt scd.component + +$(MISC)/vbaobj.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + vbaobj.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL9TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt vbaobj.component diff --git a/sc/util/sc.component b/sc/util/sc.component new file mode 100644 index 000000000000..abd05aa579f2 --- /dev/null +++ b/sc/util/sc.component @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.Calc.FilterOptionsDialog"> + <service name="com.sun.star.ui.dialogs.FilterOptionsDialog"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.SpreadsheetDocument"> + <service name="com.sun.star.sheet.SpreadsheetDocument"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLContentExporter"> + <service name="com.sun.star.comp.Calc.XMLContentExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLExporter"> + <service name="com.sun.star.comp.Calc.XMLExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLMetaExporter"> + <service name="com.sun.star.comp.Calc.XMLMetaExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisContentExporter"> + <service name="com.sun.star.comp.Calc.XMLOasisContentExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisContentImporter"> + <service name="com.sun.star.comp.Calc.XMLOasisContentImporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisExporter"> + <service name="com.sun.star.comp.Calc.XMLOasisExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisImporter"> + <service name="com.sun.star.comp.Calc.XMLOasisImporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisMetaExporter"> + <service name="com.sun.star.comp.Calc.XMLOasisMetaExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisMetaImporter"> + <service name="com.sun.star.comp.Calc.XMLOasisMetaImporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisSettingsExporter"> + <service name="com.sun.star.comp.Calc.XMLOasisSettingsExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisSettingsImporter"> + <service name="com.sun.star.comp.Calc.XMLOasisSettingsImporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisStylesExporter"> + <service name="com.sun.star.comp.Calc.XMLOasisStylesExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLOasisStylesImporter"> + <service name="com.sun.star.comp.Calc.XMLOasisStylesImporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLSettingsExporter"> + <service name="com.sun.star.comp.Calc.XMLSettingsExporter"/> + </implementation> + <implementation name="com.sun.star.comp.Calc.XMLStylesExporter"> + <service name="com.sun.star.comp.Calc.XMLStylesExporter"/> + </implementation> + <implementation name="stardiv.StarCalc.ScAutoFormatsObj"> + <service name="com.sun.star.sheet.TableAutoFormats"/> + </implementation> + <implementation name="stardiv.StarCalc.ScFunctionAccess"> + <service name="com.sun.star.sheet.FunctionAccess"/> + </implementation> + <implementation name="stardiv.StarCalc.ScFunctionListObj"> + <service name="com.sun.star.sheet.FunctionDescriptions"/> + </implementation> + <implementation name="stardiv.StarCalc.ScRecentFunctionsObj"> + <service name="com.sun.star.sheet.RecentFunctions"/> + </implementation> + <implementation name="stardiv.StarCalc.ScSpreadsheetSettings"> + <service name="com.sun.star.sheet.GlobalSheetSettings"/> + </implementation> +</component> diff --git a/sc/util/scd.component b/sc/util/scd.component new file mode 100644 index 000000000000..df2e2f77e25f --- /dev/null +++ b/sc/util/scd.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.calc.FormatDetector"> + <service name="com.sun.star.frame.ExtendedTypeDetection"/> + </implementation> +</component> diff --git a/sc/util/vbaobj.component b/sc/util/vbaobj.component new file mode 100644 index 000000000000..52ad691822d0 --- /dev/null +++ b/sc/util/vbaobj.component @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="ScVbaApplication"> + <service name="ooo.vba.excel.Application"/> + </implementation> + <implementation name="ScVbaEventsHelper"> + <service name="com.sun.star.script.vba.VBASpreadsheetEventProcessor"/> + </implementation> + <implementation name="ScVbaGlobals"> + <service name="ooo.vba.excel.Globals"/> + </implementation> + <implementation name="ScVbaHyperlink"> + <service name="ooo.vba.excel.Hyperlink"/> + </implementation> + <implementation name="ScVbaTextFrame"> + <service name="ooo.vba.excel.TextFrame"/> + </implementation> + <implementation name="ScVbaWindow"> + <service name="ooo.vba.excel.Window"/> + </implementation> + <implementation name="ScVbaWorkbook"> + <service name="ooo.vba.excel.Workbook"/> + </implementation> + <implementation name="ScVbaWorksheet"> + <service name="ooo.vba.excel.Worksheet"/> + </implementation> + <implementation name="SvVbaRange"> + <service name="ooo.vba.excel.Range"/> + </implementation> +</component> diff --git a/scaddins/prj/d.lst b/scaddins/prj/d.lst index f31644cf5e8c..c1463ef39cbc 100644 --- a/scaddins/prj/d.lst +++ b/scaddins/prj/d.lst @@ -7,3 +7,5 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid ..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl ..\%__SRC%\bin\*.bin %_DEST%\bin%_EXT%\*.bin ..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res +..\%__SRC%\misc\analysis.component %_DEST%\xml%_EXT%\analysis.component +..\%__SRC%\misc\date.component %_DEST%\xml%_EXT%\date.component diff --git a/scaddins/source/analysis/analysis.component b/scaddins/source/analysis/analysis.component new file mode 100644 index 000000000000..af4d13fa43b9 --- /dev/null +++ b/scaddins/source/analysis/analysis.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.sheet.addin.AnalysisImpl"> + <service name="com.sun.star.sheet.AddIn"/> + <service name="com.sun.star.sheet.addin.Analysis"/> + </implementation> +</component> diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index 0d206d0286dd..2302bd9432c6 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -59,37 +59,6 @@ void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvType *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - -sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, registry::XRegistryKey* pRegistryKey ) -{ - if( pRegistryKey ) - { - try - { - STRING aImpl = STRFROMASCII( "/" ); - aImpl += AnalysisAddIn::getImplementationName_Static(); - aImpl += STRFROMASCII( "/UNO/SERVICES" ); - - REF( registry::XRegistryKey ) xNewKey( - reinterpret_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( aImpl ) ); - - SEQ( STRING ) aSequ = AnalysisAddIn::getSupportedServiceNames_Static(); - const STRING* pArray = aSequ.getConstArray(); - - for( sal_Int32 i = 0 ; i < aSequ.getLength() ; i++ ) - xNewKey->createKey( pArray[ i ] ); - - return sal_True; - } - catch( registry::InvalidRegistryException& ) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; -} - - void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ ) { void* pRet = 0; diff --git a/scaddins/source/analysis/makefile.mk b/scaddins/source/analysis/makefile.mk index a23f9886b9b1..774e9506b01a 100644 --- a/scaddins/source/analysis/makefile.mk +++ b/scaddins/source/analysis/makefile.mk @@ -133,3 +133,11 @@ $(BIN)$/analysisadd.rdb: $(ALLIDLFILES) touch $@ + +ALLTAR : $(MISC)/analysis.component + +$(MISC)/analysis.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + analysis.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt analysis.component diff --git a/scaddins/source/datefunc/date.component b/scaddins/source/datefunc/date.component new file mode 100644 index 000000000000..47e73d891017 --- /dev/null +++ b/scaddins/source/datefunc/date.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.sheet.addin.DateFunctionsImpl"> + <service name="com.sun.star.sheet.AddIn"/> + <service name="com.sun.star.sheet.addin.DateFunctions"/> + </implementation> +</component> diff --git a/scaddins/source/datefunc/datefunc.cxx b/scaddins/source/datefunc/datefunc.cxx index 988f132ff9f4..b1c38d83d6b5 100644 --- a/scaddins/source/datefunc/datefunc.cxx +++ b/scaddins/source/datefunc/datefunc.cxx @@ -244,35 +244,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -sal_Bool SAL_CALL component_writeInfo( - void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) -{ - if (pRegistryKey) - { - try - { - OUString aImpl = OUString::createFromAscii( "/" ); - aImpl += ScaDateAddIn::getImplementationName_Static(); - aImpl += OUString::createFromAscii( "/UNO/SERVICES" ); - - uno::Reference< registry::XRegistryKey > xNewKey( - reinterpret_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( aImpl ) ); - - uno::Sequence< OUString > aSequ = ScaDateAddIn::getSupportedServiceNames_Static(); - const OUString * pArray = aSequ.getConstArray(); - for( sal_Int32 i = 0; i < aSequ.getLength(); i++ ) - xNewKey->createKey( pArray[i] ); - - return sal_True; - } - catch (registry::InvalidRegistryException&) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; -} - void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) { diff --git a/scaddins/source/datefunc/datefunc.def b/scaddins/source/datefunc/datefunc.def index cc1b3562a3ef..17573d6f5e44 100644 --- a/scaddins/source/datefunc/datefunc.def +++ b/scaddins/source/datefunc/datefunc.def @@ -3,5 +3,4 @@ DESCRIPTION 'StarView 3.00 Uno BE Reflection data 551 ' HEAPSIZE 0 EXPORTS component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/scaddins/source/datefunc/makefile.mk b/scaddins/source/datefunc/makefile.mk index 8a2805d76f7d..afb221bd3be9 100644 --- a/scaddins/source/datefunc/makefile.mk +++ b/scaddins/source/datefunc/makefile.mk @@ -119,3 +119,11 @@ $(BIN)$/dateadd.rdb: $(ALLIDLFILES) touch $@ + +ALLTAR : $(MISC)/date.component + +$(MISC)/date.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + date.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt date.component diff --git a/sccomp/prj/d.lst b/sccomp/prj/d.lst index f31644cf5e8c..2af1e70a9424 100644 --- a/sccomp/prj/d.lst +++ b/sccomp/prj/d.lst @@ -7,3 +7,4 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid ..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl ..\%__SRC%\bin\*.bin %_DEST%\bin%_EXT%\*.bin ..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res +..\%__SRC%\misc\solver.component %_DEST%\xml%_EXT%\solver.component diff --git a/sccomp/source/solver/makefile.mk b/sccomp/source/solver/makefile.mk index 6b25f60c8762..b1c65e88c64c 100644 --- a/sccomp/source/solver/makefile.mk +++ b/sccomp/source/solver/makefile.mk @@ -75,3 +75,11 @@ RESLIB1SRSFILES=$(RESLIB1LIST) .INCLUDE : target.mk + +ALLTAR : $(MISC)/solver.component + +$(MISC)/solver.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + solver.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt solver.component diff --git a/sccomp/source/solver/solver.component b/sccomp/source/solver/solver.component new file mode 100644 index 000000000000..de9cb3bd511d --- /dev/null +++ b/sccomp/source/solver/solver.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.Calc.Solver"> + <service name="com.sun.star.sheet.Solver"/> + </implementation> +</component> diff --git a/sccomp/source/solver/solver.cxx b/sccomp/source/solver/solver.cxx index 6c04f79d7cf5..a4dd69cc4847 100644 --- a/sccomp/source/solver/solver.cxx +++ b/sccomp/source/solver/solver.cxx @@ -603,34 +603,6 @@ extern "C" // ------------------------------------------------------------------------- - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey ) - { - if (pRegistryKey) - { - try - { - uno::Reference<registry::XRegistryKey> xNewKey; - sal_Int32 nPos; - - xNewKey = reinterpret_cast< registry::XRegistryKey * >( pRegistryKey )->createKey( SolverComponent_getImplementationName() ); - xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); - const uno::Sequence< OUString > & rSNL1 = SolverComponent_getSupportedServiceNames(); - const OUString * pArray1 = rSNL1.getConstArray(); - for ( nPos = rSNL1.getLength(); nPos--; ) - xNewKey->createKey( pArray1[nPos] ); - - return sal_True; - } - catch (registry::InvalidRegistryException &) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; - } - - // ------------------------------------------------------------------------- - SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) { OUString aImplName( OUString::createFromAscii( pImplName ) ); |