diff options
author | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-15 17:21:37 +0100 |
---|---|---|
committer | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-15 17:21:37 +0100 |
commit | 5f1550dede6342d1029618c6e0d46e22b28e4edc (patch) | |
tree | d87feae3726392fa202d0aa554c7656cf4c2542e | |
parent | 3fc7dbadd28c1d3b2be4a133ef1590d21112d0a3 (diff) | |
parent | 94048c0ce1e62dc9db82f84cb511025269a60756 (diff) |
chart46: merge with DEV300_m97
263 files changed, 4486 insertions, 3849 deletions
diff --git a/chart2/inc/pch/precompiled_chart2.hxx b/chart2/inc/pch/precompiled_chart2.hxx index 06888d38d..608206e6a 100644..100755 --- a/chart2/inc/pch/precompiled_chart2.hxx +++ b/chart2/inc/pch/precompiled_chart2.hxx @@ -268,7 +268,7 @@ #include "unotools/configitem.hxx" #include "unotools/eventlisteneradapter.hxx" -#include "vcl/fldunit.hxx" +#include "tools/fldunit.hxx" #include "vos/mutex.hxx" //---MARKER--- diff --git a/chart2/prj/build.lst b/chart2/prj/build.lst index 3cdc9a26e..5526e2964 100644 --- a/chart2/prj/build.lst +++ b/chart2/prj/build.lst @@ -1,4 +1,4 @@ -ch chart2 : l10n comphelper cppu cppuhelper sal svtools svx tools vcl toolkit unotools sfx2 NULL +ch chart2 : l10n comphelper cppu cppuhelper sal svtools svx tools vcl toolkit unotools sfx2 LIBXSLT:libxslt NULL ch chart2 usr1 - all ch_mkout NULL ch chart2\inc nmake - all ch_inc NULL ch chart2\source\inc get - all ch_source_inc NULL @@ -24,3 +24,4 @@ ch chart2\source\controller\chartapiwrapper nmake - all ch_source_controlle ch chart2\source\controller\main nmake - all ch_source_controller_main ch_inc NULL ch chart2\source\controller\menus nmake - all ch_source_controller_menus ch_inc NULL ch chart2\prj get - all ch_prj NULL +ch chart2\qa\unoapi nmake - all ch_qa_unoapi NULL diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx index c24642658..cc9c7a9dc 100644..100755 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx @@ -57,31 +57,35 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" )); -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticAreaWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; + +struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer > +{ +}; + - return aPropSeq; -} } // anonymous namespace // -------------------------------------------------------------------------------- @@ -175,7 +179,7 @@ Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() const Sequence< beans::Property >& AreaWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticAreaWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 3af5120e6..baf1d58e2 100644..100755 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -352,33 +352,35 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT )); } -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticAxisWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer > +{ +}; } // anonymous namespace @@ -534,7 +536,6 @@ uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats() return uno::Reference< util::XNumberFormats >(); } -// static void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis ) { switch( eType ) @@ -642,7 +643,7 @@ Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() const Sequence< beans::Property >& AxisWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticAxisWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 2087720f1..ba8023a56 100644..100755 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -247,28 +247,30 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ) ); } -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticChartDocumentWrapperPropertyArray_Initializer { - static uno::Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer > +{ +}; } // anonymous namespace @@ -1580,7 +1582,7 @@ Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet() } const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticChartDocumentWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index f7eda5e3d..04a5f9401 100644..100755 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -173,45 +173,56 @@ void lcl_AddPropertiesToVector_SeriesOnly( | beans::PropertyAttribute::MAYBEDEFAULT )); } -const uno::Sequence< Property > & lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType ) +uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType ) { - static uno::Sequence< Property > aSeriesPropSeq; - static uno::Sequence< Property > aPointPropSeq; + ::std::vector< ::com::sun::star::beans::Property > aProperties; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - uno::Sequence< Property >& rPropSeq = - (_eType == DataSeriesPointWrapper::DATA_SERIES) ? aSeriesPropSeq : aPointPropSeq; - if( 0 == rPropSeq.getLength() ) + lcl_AddPropertiesToVector_PointProperties( aProperties ); + if( _eType == DataSeriesPointWrapper::DATA_SERIES ) { - // get properties - ::std::vector< ::com::sun::star::beans::Property > aProperties; - - lcl_AddPropertiesToVector_PointProperties( aProperties ); - if( _eType == DataSeriesPointWrapper::DATA_SERIES ) - { - lcl_AddPropertiesToVector_SeriesOnly( aProperties ); - WrappedStatisticProperties::addProperties( aProperties ); - } - WrappedSymbolProperties::addProperties( aProperties ); //for series and points - WrappedDataCaptionProperties::addProperties( aProperties ); //for series and points - - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::LineProperties::AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - // and sort them for access via bsearch - ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - - // transfer result to static Sequence - rPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + lcl_AddPropertiesToVector_SeriesOnly( aProperties ); + WrappedStatisticProperties::addProperties( aProperties ); } + WrappedSymbolProperties::addProperties( aProperties ); //for series and points + WrappedDataCaptionProperties::addProperties( aProperties ); //for series and points + + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - return rPropSeq; + ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); + + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +struct StaticSeriesWrapperPropertyArray_Initializer +{ + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); + return &aPropSeq; + } +}; + +struct StaticSeriesWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticSeriesWrapperPropertyArray_Initializer > +{ +}; + +struct StaticPointWrapperPropertyArray_Initializer +{ + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); + return &aPropSeq; + } +}; + +struct StaticPointWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticPointWrapperPropertyArray_Initializer > +{ +}; + //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- @@ -706,7 +717,10 @@ Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet() const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence() { - return lcl_GetPropertySequence( m_eType ); + if( m_eType == DATA_SERIES ) + return *StaticSeriesWrapperPropertyArray::get(); + else + return *StaticPointWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > DataSeriesPointWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 6f9694726..d9b942f86 100644..100755 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -432,15 +432,17 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticDiagramWrapperPropertyArray_Initializer { - static uno::Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); @@ -454,16 +456,16 @@ const uno::Sequence< Property > & lcl_GetPropertySequence() WrappedStockProperties::addProperties( aProperties ); WrappedAutomaticPositionProperties::addProperties( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticDiagramWrapperPropertyArray_Initializer > +{ +}; bool lcl_isXYChart( const Reference< chart2::XDiagram > xDiagram ) { @@ -568,7 +570,6 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) } typedef ::comphelper::MakeMap< ::rtl::OUString, ::rtl::OUString > tMakeStringStringMap; -//static const tMakeStringStringMap& lcl_getChartTypeNameMap() { static tMakeStringStringMap g_aChartTypeNameMap = @@ -2088,7 +2089,7 @@ Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticDiagramWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > DiagramWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 4d6346dcb..ea5d37a9d 100644..100755 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -59,30 +59,31 @@ namespace static const OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Grid" )); -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticGridWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer > +{ +}; } // anonymous namespace @@ -104,7 +105,6 @@ GridWrapper::GridWrapper( GridWrapper::~GridWrapper() {} -// static void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid ) { rnDimensionIndex = 1; @@ -179,7 +179,7 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() const Sequence< beans::Property >& GridWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticGridWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index 7d207fa6e..eb345c00e 100644..100755 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -246,35 +246,38 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT )); } -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticLegendWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; + +struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer > +{ +}; - return aPropSeq; -} } // anonymous namespace // -------------------------------------------------------------------------------- @@ -418,7 +421,7 @@ Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() const Sequence< beans::Property >& LegendWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticLegendWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > LegendWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index c2545e78f..802f2657d 100644..100755 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -56,31 +56,79 @@ namespace static const OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartLine" )); -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticMinMaxLineWrapperDefaults_Initializer { - static Sequence< Property > aPropSeq; + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + } +}; + +struct StaticMinMaxLineWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticMinMaxLineWrapperDefaults_Initializer > +{ +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticMinMaxLineWrapperPropertyArray_Initializer +{ + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticMinMaxLineWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticMinMaxLineWrapperPropertyArray_Initializer > +{ +}; + +struct StaticMinMaxLineWrapperInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( *StaticMinMaxLineWrapperPropertyArray::get() ); + return &aPropHelper; + } +}; + +struct StaticMinMaxLineWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticMinMaxLineWrapperInfoHelper_Initializer > +{ +}; + +struct StaticMinMaxLineWrapperInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticMinMaxLineWrapperInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticMinMaxLineWrapperInfo_Initializer > +{ +}; } // anonymous namespace @@ -94,7 +142,6 @@ namespace wrapper MinMaxLineWrapper::MinMaxLineWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : m_spChart2ModelContact( spChart2ModelContact ) , m_aEventListenerContainer( m_aMutex ) - , m_pPropertyArrayHelper() , m_aWrappedLineJointProperty( C2U("LineJoint"), uno::makeAny( drawing::LineJoint_NONE )) { } @@ -109,11 +156,6 @@ void SAL_CALL MinMaxLineWrapper::dispose() { Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); - - // /-- - MutexGuard aGuard( GetMutex()); - m_xInfo.clear(); - // \-- } void SAL_CALL MinMaxLineWrapper::addEventListener( @@ -132,34 +174,16 @@ void SAL_CALL MinMaxLineWrapper::removeEventListener( ::cppu::IPropertyArrayHelper& MinMaxLineWrapper::getInfoHelper() { - if(!m_pPropertyArrayHelper.get()) - { - // /-- - ::osl::MutexGuard aGuard( GetMutex() ); - if(!m_pPropertyArrayHelper.get()) - { - sal_Bool bSorted = sal_True; - m_pPropertyArrayHelper = ::boost::shared_ptr< ::cppu::OPropertyArrayHelper >( new ::cppu::OPropertyArrayHelper( lcl_GetPropertySequence(), bSorted ) ); - } - // \-- - } - return *m_pPropertyArrayHelper.get(); + return *StaticMinMaxLineWrapperInfoHelper::get(); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo() throw (uno::RuntimeException) { - if( !m_xInfo.is() ) - { - // /-- - ::osl::MutexGuard aGuard( GetMutex() ); - if( !m_xInfo.is() ) - m_xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); - // \-- - } - return m_xInfo; + return *StaticMinMaxLineWrapperInfo::get(); } + void SAL_CALL MinMaxLineWrapper::setPropertyValue( const ::rtl::OUString& rPropertyName, const uno::Any& rValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { @@ -355,26 +379,14 @@ void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const ::rtl::OUString& rP { this->setPropertyValue( rPropertyName, this->getPropertyDefault(rPropertyName) ); } + uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const ::rtl::OUString& rPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - LineProperties::AddDefaultsToMap( aStaticDefaults ); - } - - sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticMinMaxLineWrapperDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( getInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; } @@ -383,7 +395,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const ::rtl::OUString& void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) throw (uno::RuntimeException) { - const Sequence< beans::Property >& rPropSeq = lcl_GetPropertySequence(); + const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get(); for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++) { ::rtl::OUString aPropertyName( rPropSeq[nN].Name ); diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx index 5794143a4..7fcb86f75 100644..100755 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx @@ -123,12 +123,6 @@ private: //member ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySetInfo > - m_xInfo;//outer PropertySetInfo - - ::boost::shared_ptr< ::cppu::OPropertyArrayHelper > m_pPropertyArrayHelper; - WrappedIgnoreProperty m_aWrappedLineJointProperty; }; diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index f37668734..680f53e3c 100644..100755 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -182,35 +182,37 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticTitleWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer > +{ +}; } // anonymous namespace @@ -526,7 +528,7 @@ Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() const Sequence< beans::Property >& TitleWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticTitleWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > TitleWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index a52570300..791f0152e 100644..100755 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -57,32 +57,81 @@ namespace static const OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartArea" )); -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticUpDownBarWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer > +{ +}; + +struct StaticUpDownBarWrapperInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() ); + return &aPropHelper; + } +}; + +struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer > +{ +}; + +struct StaticUpDownBarWrapperInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer > +{ +}; + +struct StaticUpDownBarWrapperDefaults_Initializer +{ + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + } +}; + +struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer > +{ +}; } // anonymous namespace @@ -98,8 +147,6 @@ UpDownBarWrapper::UpDownBarWrapper( : m_spChart2ModelContact( spChart2ModelContact ) , m_aEventListenerContainer( m_aMutex ) , m_aPropertySetName( bUp ? C2U("WhiteDay") : C2U("BlackDay") ) - , m_xInfo(0) - , m_pPropertyArrayHelper() { } @@ -113,11 +160,6 @@ void SAL_CALL UpDownBarWrapper::dispose() { Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); - - // /-- - MutexGuard aGuard( GetMutex()); - m_xInfo.clear(); - // \-- } void SAL_CALL UpDownBarWrapper::addEventListener( @@ -136,33 +178,14 @@ void SAL_CALL UpDownBarWrapper::removeEventListener( ::cppu::IPropertyArrayHelper& UpDownBarWrapper::getInfoHelper() { - if(!m_pPropertyArrayHelper.get()) - { - // /-- - ::osl::MutexGuard aGuard( GetMutex() ); - if(!m_pPropertyArrayHelper.get()) - { - sal_Bool bSorted = sal_True; - m_pPropertyArrayHelper = ::boost::shared_ptr< ::cppu::OPropertyArrayHelper >( new ::cppu::OPropertyArrayHelper( lcl_GetPropertySequence(), bSorted ) ); - } - // \-- - } - return *m_pPropertyArrayHelper.get(); + return *StaticUpDownBarWrapperInfoHelper::get(); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo() throw (uno::RuntimeException) { - if( !m_xInfo.is() ) - { - // /-- - ::osl::MutexGuard aGuard( GetMutex() ); - if( !m_xInfo.is() ) - m_xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); - // \-- - } - return m_xInfo; + return *StaticUpDownBarWrapperInfo::get(); } void SAL_CALL UpDownBarWrapper::setPropertyValue( const ::rtl::OUString& rPropertyName, const uno::Any& rValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) @@ -320,27 +343,14 @@ void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const ::rtl::OUString& rPr { this->setPropertyValue( rPropertyName, this->getPropertyDefault(rPropertyName) ); } + uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const ::rtl::OUString& rPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - } - - sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( getInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; } @@ -349,7 +359,7 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const ::rtl::OUString& r void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) throw (uno::RuntimeException) { - const Sequence< beans::Property >& rPropSeq = lcl_GetPropertySequence(); + const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get(); for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++) { ::rtl::OUString aPropertyName( rPropSeq[nN].Name ); diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx index d978ae787..6d3b6bf8e 100644..100755 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx @@ -123,11 +123,6 @@ private: //member ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; rtl::OUString m_aPropertySetName; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySetInfo > - m_xInfo;//outer PropertySetInfo - ::boost::shared_ptr< ::cppu::OPropertyArrayHelper > m_pPropertyArrayHelper; - }; } // namespace wrapper diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx index f2f662bee..55f485126 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -59,31 +59,33 @@ namespace static const OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" )); -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticWallFloorWrapperPropertyArray_Initializer { - static Sequence< Property > aPropSeq; + Sequence< Property >* operator()() + { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); + return &aPropSeq; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::FillProperties::AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); -// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + //::chart::NamedProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer > +{ +}; } // anonymous namespace @@ -155,7 +157,7 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() { - return lcl_GetPropertySequence(); + return *StaticWallFloorWrapperPropertyArray::get(); } const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx index 99afc793f..8621c153e 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx @@ -131,7 +131,6 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList ) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -145,7 +144,6 @@ void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList ) { lcl_addWrappedProperties( rList ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx index b6efacc89..37ef37442 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -69,7 +69,6 @@ private: //member sal_Int32 m_nDimensionIndex; }; -//static void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -239,7 +238,6 @@ private: //member TitleHelper::eTitleType m_eTitleType; }; -//static void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -359,7 +357,6 @@ private: //member sal_Int32 m_nDimensionIndex; }; -//static void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx index 322c096c7..552d6c912 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx @@ -62,7 +62,6 @@ WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base() { } -//static void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList , ReferenceSizePropertyProvider* pRefSizePropProvider ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx index 7f64d4c9f..48bf0937f 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx @@ -119,7 +119,6 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedDataCaptionProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -133,7 +132,6 @@ void WrappedDataCaptionProperties::addProperties( ::std::vector< Property > & rO //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedDataCaptionProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -143,7 +141,6 @@ void WrappedDataCaptionProperties::addWrappedPropertiesForSeries( std::vector< W //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index 1788824cc..a360be847 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -116,7 +116,6 @@ WrappedScaleProperty::~WrappedScaleProperty() { } -//static void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx index 5e08685d7..b0d120c3f 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx @@ -141,7 +141,6 @@ enum //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -155,7 +154,6 @@ void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOut //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx index 27ded24a1..412c7854a 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx @@ -46,7 +46,6 @@ namespace chart namespace wrapper { -//static void WrappedSceneProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index a7f0fe578..ea5bedd5b 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -197,7 +197,6 @@ enum //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedSplineProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -226,12 +225,11 @@ void WrappedSplineProperties::addProperties( ::std::vector< Property > & rOutPro //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedSplineProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { rList.push_back( new WrappedSplineTypeProperty( spChart2ModelContact ) ); - rList.push_back( new WrappedSplineProperty<sal_Int32>( C2U("SplineOrder"), C2U("SplineOrder"), uno::makeAny(sal_Int32(2)), spChart2ModelContact ) ); + rList.push_back( new WrappedSplineProperty<sal_Int32>( C2U("SplineOrder"), C2U("SplineOrder"), uno::makeAny(sal_Int32(3)), spChart2ModelContact ) ); rList.push_back( new WrappedSplineProperty<sal_Int32>( C2U("SplineResolution"), C2U("CurveResolution"), uno::makeAny(sal_Int32(20)), spChart2ModelContact ) ); } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index ae27c41df..38c37ff5f 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -1032,7 +1032,6 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList }//anonymous namespace -//static void WrappedStatisticProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -1128,7 +1127,6 @@ void WrappedStatisticProperties::addProperties( ::std::vector< Property > & rOut //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -1138,7 +1136,6 @@ void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< Wra //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedStatisticProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index 5494b1783..ebff5a2df 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -291,7 +291,6 @@ enum //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedStockProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -313,7 +312,6 @@ void WrappedStockProperties::addProperties( ::std::vector< Property > & rOutProp //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedStockProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 3d6f9fc37..5a9365e6b 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -201,7 +201,6 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties ) { rOutProperties.push_back( @@ -236,7 +235,6 @@ void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutPro //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -246,7 +244,6 @@ void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< Wrappe //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) { @@ -573,8 +570,19 @@ void WrappedSymbolAndLinesProperty::setValueToSeries( if(!xSeriesPropertySet.is()) return; - drawing::LineStyle eLineStyle( bDrawLines ? drawing::LineStyle_SOLID : drawing::LineStyle_NONE ); - xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( eLineStyle ) ); + drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID ); + xSeriesPropertySet->getPropertyValue( C2U("LineStyle") ) >>= eOldLineStyle; + if( bDrawLines ) + { + //#i114298# don't overwrite dashed lines with solid lines here + if( eOldLineStyle == drawing::LineStyle_NONE ) + xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_SOLID ) ); + } + else + { + if( eOldLineStyle != drawing::LineStyle_NONE ) + xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_NONE ) ); + } } beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 7a7656122..8dff39a3e 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -388,7 +388,6 @@ bool SeriesHeader::HasFocus() const return m_spSeriesName->HasFocus(); } -// static Image SeriesHeader::GetChartTypeImage( const Reference< chart2::XChartType > & xChartType, bool bSwapXAndYAxis, diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 78849a202..99fcf9364 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -381,7 +381,6 @@ DialogModel::DialogModel( m_xContext( xContext ), m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ) { - createBackup(); } DialogModel::~DialogModel() @@ -724,20 +723,16 @@ bool DialogModel::setData( return true; } -// static OUString DialogModel::ConvertRoleFromInternalToUI( const OUString & rRoleString ) { return lcl_ConvertRole( rRoleString, true ); } -// static OUString DialogModel::GetRoleDataLabel() { return OUString( String( ::chart::SchResId( STR_OBJECT_DATALABELS ))); } -// static - sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) { static lcl_tRoleIndexMap aRoleIndexMap; @@ -754,20 +749,6 @@ sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternal // private methods -void DialogModel::createBackup() -{ - OSL_ENSURE( ! m_xBackupChartDocument.is(), "Cloning already cloned model" ); - try - { - Reference< util::XCloneable > xCloneable( m_xChartDocument, uno::UNO_QUERY_THROW ); - m_xBackupChartDocument.set( xCloneable->createClone(), uno::UNO_QUERY_THROW ); - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } -} - void DialogModel::applyInterpretedData( const InterpretedData & rNewData, const ::std::vector< Reference< XDataSeries > > & rSeriesToReUse, diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 05263d70a..8c5d29653 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -163,10 +163,6 @@ private: m_xChartDocument; ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > - m_xBackupChartDocument; - - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > m_xTemplate; diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 4159e5f4b..41b3061d4 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -332,7 +332,7 @@ rtl::OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural } return aRet; } -//static + rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID , const uno::Reference< frame::XModel >& xChartModel ) { @@ -373,7 +373,6 @@ rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID return aRet; } -//static OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) { OUString aRet; @@ -412,7 +411,6 @@ OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) return aRet; } -//static OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID , const Reference< frame::XModel >& xChartModel ) { @@ -432,7 +430,6 @@ OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID return aRet; } -//static rtl::OUString ObjectNameProvider::getGridName( const rtl::OUString& rObjectCID , const uno::Reference< frame::XModel >& xChartModel ) { @@ -709,7 +706,6 @@ rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, return aRet; } -// static rtl::OUString ObjectNameProvider::getSelectedObjectText( const rtl::OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ) { rtl::OUString aRet; @@ -762,8 +758,6 @@ rtl::OUString ObjectNameProvider::getSelectedObjectText( const rtl::OUString & r return aRet; } - -// static rtl::OUString ObjectNameProvider::getNameForCID( const rtl::OUString& rObjectCID, const uno::Reference< chart2::XChartDocument >& xChartDocument ) @@ -820,7 +814,6 @@ rtl::OUString ObjectNameProvider::getNameForCID( return getName( eType ); } -//static rtl::OUString ObjectNameProvider::getName_ObjectForSeries( ObjectType eObjectType, const rtl::OUString& rSeriesCID, @@ -839,7 +832,6 @@ rtl::OUString ObjectNameProvider::getName_ObjectForSeries( return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType ); } -//static rtl::OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) { OUString aRet = String(SchResId(STR_OBJECT_FOR_ALL_SERIES)); diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx index a970a2464..72e62701e 100644 --- a/chart2/source/controller/dialogs/dlg_DataSource.cxx +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -146,7 +146,6 @@ void DataSourceTabControl::EnableTabToggling() // ---------------------------------------- -// static USHORT DataSourceDialog::m_nLastPageId = 0; DataSourceDialog::DataSourceDialog( diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index 28c8e5a3c..04a6a8a1a 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -95,7 +95,6 @@ void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMi m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth ); } -//static double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( const Reference< frame::XModel >& xChartModel, const Reference< uno::XInterface >& xChartView, diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx index a3adf3d8e..5f71d5e29 100644 --- a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx @@ -67,7 +67,6 @@ NumberFormatDialog::~NumberFormatDialog() { } -//static SfxItemSet NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ) { static const USHORT nWhichPairs[] = diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx index 590fa36c7..424530637 100644 --- a/chart2/source/controller/dialogs/dlg_View3D.cxx +++ b/chart2/source/controller/dialogs/dlg_View3D.cxx @@ -57,7 +57,6 @@ using namespace ::com::sun::star::chart2; //------------------------------------------------------------------- //------------------------------------------------------------------- -// static USHORT View3DDialog::m_nLastPageId = 0; View3DDialog::View3DDialog(Window* pParent, const uno::Reference< frame::XModel > & xChartModel, XColorTable* pColorTable ) diff --git a/chart2/source/controller/dialogs/tp_DataLabel.src b/chart2/source/controller/dialogs/tp_DataLabel.src index 4907b3d8a..018f6ccf2 100644 --- a/chart2/source/controller/dialogs/tp_DataLabel.src +++ b/chart2/source/controller/dialogs/tp_DataLabel.src @@ -28,10 +28,6 @@ #include "TabPages.hrc" #include "res_DataLabel.hrc" -#ifndef _GLOBLMN_HRC -#include <svx/globlmn.hrc> -#endif - TabPage TP_DATA_DESCR { Hide = TRUE ; diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index adba51c46..34afdc32d 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -424,7 +424,6 @@ void DrawViewWrapper::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) } } -//static SdrObject* DrawViewWrapper::getSdrObject( const uno::Reference< drawing::XShape >& xShape ) { diff --git a/chart2/source/controller/inc/ConfigurationAccess.hxx b/chart2/source/controller/inc/ConfigurationAccess.hxx index 01be5921a..513ee3c7f 100644 --- a/chart2/source/controller/inc/ConfigurationAccess.hxx +++ b/chart2/source/controller/inc/ConfigurationAccess.hxx @@ -29,7 +29,7 @@ #define _CHART2_CONFIGURATIONACCESS_HXX // header for enum FieldUnit -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> //............................................................................. namespace chart diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index b819ff18a..8bda4ef11 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -239,7 +239,6 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) // -------------------------------------------------------------------------------- -//static void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItemSet &rSourceSet ) { SfxWhichIter aIter (rSourceSet); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 744727fab..e4a2d01bd 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -475,6 +475,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( rEvent.NewMode.equals(C2U("dirty")) ) { //the view has become dirty, we should repaint it if we have a window + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) m_pChartWindow->ForceInvalidate(); } @@ -518,8 +519,11 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent impl_initializeAccessible(); - if( m_pChartWindow ) - m_pChartWindow->Invalidate(); + { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + } } m_bConnectingToView = false; @@ -537,10 +541,10 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent //is called to attach the controller to a new model. //return true if attach was successfully, false otherwise (e.g. if you do not work with a model) - ::vos::OClearableGuard aGuard( Application::GetSolarMutex()); + ::vos::OClearableGuard aClearableGuard( Application::GetSolarMutex()); if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended? return sal_False; //behave passive if already disposed or suspended - aGuard.clear(); + aClearableGuard.clear(); TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex); @@ -612,8 +616,11 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent } //the frameloader is responsible to call xModel->connectController - if( m_pChartWindow ) - m_pChartWindow->Invalidate(); + { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + } uno::Reference< chart2::XUndoSupplier > xUndoSupplier( getModel(), uno::UNO_QUERY ); if( xUndoSupplier.is()) @@ -1106,6 +1113,7 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) else if(aCommand.equals("Update")) //Update Chart { ChartViewHelper::setViewToDirtyState( getModel() ); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) m_pChartWindow->Invalidate(); } @@ -1491,6 +1499,7 @@ uno::Reference< XAccessible > ChartController::CreateAccessible() void ChartController::impl_invalidateAccessible() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) { Reference< lang::XInitialization > xInit( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ); @@ -1503,6 +1512,7 @@ void ChartController::impl_invalidateAccessible() } void ChartController::impl_initializeAccessible() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) this->impl_initializeAccessible( Reference< lang::XInitialization >( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ) ); } @@ -1517,11 +1527,14 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn aArguments[1]=uno::makeAny(xModel); aArguments[2]=uno::makeAny(m_xChartView); uno::Reference< XAccessible > xParent; - if( m_pChartWindow ) { - Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow()); - if( pParentWin ) - xParent.set( pParentWin->GetAccessible()); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( m_pChartWindow ) + { + Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow()); + if( pParentWin ) + xParent.set( pParentWin->GetAccessible()); + } } aArguments[3]=uno::makeAny(xParent); aArguments[4]=uno::makeAny(m_xViewWindow); diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 9e1c003ab..be1ecd616 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -76,6 +76,7 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) { //the first marked object will be edited + ::vos::OGuard aGuard( Application::GetSolarMutex() ); SdrObject* pTextObj = m_pDrawViewWrapper->getTextEditObject(); if(!pTextObj) return; diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 5ce82dec7..c6c4b33a7 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -297,6 +297,7 @@ void ChartController::executeDispatch_ScaleText() void ChartController::executeDispatch_Paste() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) { Graphic aGraphic; @@ -581,7 +582,6 @@ void ChartController::executeDispatch_Cut() executeDispatch_Delete(); } -//static bool ChartController::isObjectDeleteable( const uno::Any& rSelection ) { ObjectIdentifier aSelOID( rSelection ); diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index dfc25bd4b..3fc4796ab 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -243,12 +243,12 @@ const short HITPIX=2; //hit-tolerance in pixel , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw (uno::RuntimeException) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - Window* pWindow = m_pChartWindow; - - if(xWindow.is() && pWindow) + + if(xWindow.is() && m_pChartWindow) { - Size aLogicSize = pWindow->PixelToLogic( Size( Width, Height ), MapMode( MAP_100TH_MM ) ); + Size aLogicSize = m_pChartWindow->PixelToLogic( Size( Width, Height ), MapMode( MAP_100TH_MM ) ); bool bIsEmbedded = true; //todo: for standalone chart: detect wether we are standalone @@ -263,8 +263,8 @@ const short HITPIX=2; //hit-tolerance in pixel MapMode aNewMapMode( MAP_100TH_MM, Point(0,0) , Fraction(nScaleXNumerator,nScaleXDenominator) , Fraction(nScaleYNumerator,nScaleYDenominator) ); - pWindow->SetMapMode(aNewMapMode); - pWindow->SetPosSizePixel( X, Y, Width, Height, Flags ); + m_pChartWindow->SetMapMode(aNewMapMode); + m_pChartWindow->SetPosSizePixel( X, Y, Width, Height, Flags ); //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY ); @@ -285,7 +285,7 @@ const short HITPIX=2; //hit-tolerance in pixel //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area if(m_pDrawViewWrapper) { - Rectangle aRect(Point(0,0), pWindow->GetOutputSize()); + Rectangle aRect(Point(0,0), m_pChartWindow->GetOutputSize()); m_pDrawViewWrapper->SetWorkArea( aRect ); } } @@ -293,9 +293,9 @@ const short HITPIX=2; //hit-tolerance in pixel { //change visarea ChartModelHelper::setPageSize( awt::Size( aLogicSize.Width(), aLogicSize.Height() ), getModel() ); - pWindow->SetPosSizePixel( X, Y, Width, Height, Flags ); + m_pChartWindow->SetPosSizePixel( X, Y, Width, Height, Flags ); } - pWindow->Invalidate(); + m_pChartWindow->Invalidate(); } } @@ -533,12 +533,11 @@ void ChartController::execute_Paint( const Rectangle& rRect ) if( xUpdatable.is() ) xUpdatable->update(); - Window* pWindow = m_pChartWindow; { ::vos::OGuard aGuard( Application::GetSolarMutex()); DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; if(pDrawViewWrapper) - pDrawViewWrapper->CompleteRedraw(pWindow, Region(rRect) ); + pDrawViewWrapper->CompleteRedraw(m_pChartWindow, Region(rRect) ); } } catch( uno::Exception & ex ) @@ -562,6 +561,8 @@ bool isDoubleClick( const MouseEvent& rMEvt ) void ChartController::startDoubleClickWaiting() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + m_bWaitingForDoubleClick = true; ULONG nDblClkTime = 500; @@ -587,6 +588,7 @@ IMPL_LINK( ChartController, DoubleClickWaitingHdl, void*, EMPTYARG ) if( !m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() ) { this->impl_selectObjectAndNotiy(); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pChartWindow ) { Window::PointerState aPointerState( m_pChartWindow->GetPointerState() ); @@ -615,17 +617,16 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) m_aSelection.remindSelectionBeforeMouseDown(); - Window* pWindow = m_pChartWindow; DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if(!pWindow || !pDrawViewWrapper ) + if(!m_pChartWindow || !pDrawViewWrapper ) return; - Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel()); + Point aMPos = m_pChartWindow->PixelToLogic(rMEvt.GetPosPixel()); if ( MOUSE_LEFT == rMEvt.GetButtons() ) { - pWindow->GrabFocus(); - pWindow->CaptureMouse(); + m_pChartWindow->GrabFocus(); + m_pChartWindow->CaptureMouse(); } if( pDrawViewWrapper->IsTextEdit() ) @@ -710,7 +711,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) && !rMEvt.IsRight() ) { //start drag - USHORT nDrgLog = (USHORT)pWindow->PixelToLogic(Size(DRGPIX,0)).Width(); + USHORT nDrgLog = (USHORT)m_pChartWindow->PixelToLogic(Size(DRGPIX,0)).Width(); SdrDragMethod* pDragMethod = NULL; //change selection to 3D scene if rotate mode @@ -750,9 +751,8 @@ void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) { ::vos::OGuard aGuard( Application::GetSolarMutex()); - Window* pWindow = m_pChartWindow; DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if(!pWindow || !pDrawViewWrapper) + if(!m_pChartWindow || !pDrawViewWrapper) return; if( m_pDrawViewWrapper->IsTextEdit() ) @@ -763,7 +763,7 @@ void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) if(pDrawViewWrapper->IsAction()) { - pDrawViewWrapper->MovAction( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pDrawViewWrapper->MovAction( m_pChartWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); } //?? pDrawViewWrapper->GetPageView()->DragPoly(); @@ -785,12 +785,11 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { ::vos::OGuard aGuard( Application::GetSolarMutex()); - Window* pWindow = m_pChartWindow; DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if(!pWindow || !pDrawViewWrapper) + if(!m_pChartWindow || !pDrawViewWrapper) return; - Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel()); + Point aMPos = m_pChartWindow->PixelToLogic(rMEvt.GetPosPixel()); if(pDrawViewWrapper->IsTextEdit()) { @@ -920,7 +919,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) } //@todo ForcePointer(&rMEvt); - pWindow->ReleaseMouse(); + m_pChartWindow->ReleaseMouse(); if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) bNotifySelectionChange = true; @@ -969,7 +968,9 @@ void ChartController::execute_DoubleClick( const Point* pMousePixel ) void ChartController::execute_Resize() { - m_pChartWindow->Invalidate(); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if(m_pChartWindow) + m_pChartWindow->Invalidate(); } void ChartController::execute_Activate() { @@ -992,13 +993,11 @@ void ChartController::execute_LoseFocus() void ChartController::execute_Command( const CommandEvent& rCEvt ) { - Window* pWindow = m_pChartWindow; - bool bIsAction = false; { ::vos::OGuard aGuard( Application::GetSolarMutex()); DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if(!pWindow || !pDrawViewWrapper) + if(!m_pChartWindow || !pDrawViewWrapper) return; bIsAction = m_pDrawViewWrapper->IsAction(); } @@ -1006,7 +1005,11 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) // pop-up menu if(rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bIsAction) { - m_pChartWindow->ReleaseMouse(); + { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if(m_pChartWindow) + m_pChartWindow->ReleaseMouse(); + } if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) impl_notifySelectionChangeListeners(); @@ -1020,7 +1023,9 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) { - aPos = m_pChartWindow->GetPointerState().maPos; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if(m_pChartWindow) + aPos = m_pChartWindow->GetPointerState().maPos; } aContextMenuHelper.completeAndExecute( aPos, aContextMenu ); } @@ -1290,7 +1295,11 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) - aPos = m_pChartWindow->GetPointerState().maPos; + { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if(m_pChartWindow) + aPos = m_pChartWindow->GetPointerState().maPos; + } aContextMenuHelper.completeAndExecute( aPos, xPopupMenu ); } } @@ -1301,6 +1310,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ( rCEvt.GetCommand() == COMMAND_INPUTCONTEXTCHANGE ) ) { //#i84417# enable editing with IME + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( m_pDrawViewWrapper ) m_pDrawViewWrapper->Command( rCEvt, m_pChartWindow ); } @@ -1310,9 +1320,8 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { bool bReturn=false; - Window* pWindow = m_pChartWindow; DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if(!pWindow || !pDrawViewWrapper) + if(!m_pChartWindow || !pDrawViewWrapper) return bReturn; // handle accelerators @@ -1335,14 +1344,17 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if( bReturn ) return bReturn; - if( pDrawViewWrapper->IsTextEdit() ) { - if( pDrawViewWrapper->KeyInput(rKEvt,pWindow) ) + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( pDrawViewWrapper->IsTextEdit() ) { - bReturn = true; - if( nCode == KEY_ESCAPE ) + if( pDrawViewWrapper->KeyInput(rKEvt,m_pChartWindow) ) { - this->EndTextEdit(); + bReturn = true; + if( nCode == KEY_ESCAPE ) + { + this->EndTextEdit(); + } } } } @@ -1434,12 +1446,16 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) // default 1 mm in each direction double fGrowAmountX = 200.0; double fGrowAmountY = 200.0; - if( bAlternate && pWindow ) + if( bAlternate && m_pChartWindow ) { // together with Alt-key: 1 px in each direction - Size aPixelSize = pWindow->PixelToLogic( Size( 2, 2 )); - fGrowAmountX = static_cast< double >( aPixelSize.Width()); - fGrowAmountY = static_cast< double >( aPixelSize.Height()); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( m_pChartWindow ) + { + Size aPixelSize = m_pChartWindow->PixelToLogic( Size( 2, 2 )); + fGrowAmountX = static_cast< double >( aPixelSize.Width()); + fGrowAmountY = static_cast< double >( aPixelSize.Height()); + } } if( nCode == KEY_SUBTRACT ) { @@ -1461,12 +1477,16 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) // default 1 mm double fShiftAmountX = 100.0; double fShiftAmountY = 100.0; - if( bAlternate && pWindow ) + if( bAlternate && m_pChartWindow ) { // together with Alt-key: 1 px - Size aPixelSize = pWindow->PixelToLogic( Size( 1, 1 )); - fShiftAmountX = static_cast< double >( aPixelSize.Width()); - fShiftAmountY = static_cast< double >( aPixelSize.Height()); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if(m_pChartWindow) + { + Size aPixelSize = m_pChartWindow->PixelToLogic( Size( 1, 1 )); + fShiftAmountX = static_cast< double >( aPixelSize.Width()); + fShiftAmountY = static_cast< double >( aPixelSize.Height()); + } } switch( nCode ) { @@ -1557,6 +1577,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) bReturn = executeDispatch_Delete(); if( ! bReturn ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); InfoBox( m_pChartWindow, String(SchResId( STR_ACTION_NOTPOSSIBLE ))).Execute(); } } @@ -1729,11 +1750,14 @@ bool ChartController::requestQuickHelp( void ChartController::impl_selectObjectAndNotiy() { - DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; - if( pDrawViewWrapper ) { - pDrawViewWrapper->SetDragMode( m_eDragMode ); - m_aSelection.applySelection( m_pDrawViewWrapper ); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if( pDrawViewWrapper ) + { + pDrawViewWrapper->SetDragMode( m_eDragMode ); + m_aSelection.applySelection( m_pDrawViewWrapper ); + } } impl_notifySelectionChangeListeners(); } @@ -1862,10 +1886,9 @@ bool ChartController::impl_DragDataPoint( const ::rtl::OUString & rCID, double f void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { ::vos::OGuard aGuard( Application::GetSolarMutex()); - Window* pWindow = m_pChartWindow; - if( m_pDrawViewWrapper && pWindow ) + if( m_pDrawViewWrapper && m_pChartWindow ) { - Point aMousePos( pWindow->PixelToLogic( rEvent.GetPosPixel())); + Point aMousePos( m_pChartWindow->PixelToLogic( rEvent.GetPosPixel())); sal_uInt16 nModifier = rEvent.GetModifier(); BOOL bLeftDown = rEvent.IsLeft(); @@ -1873,8 +1896,8 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { if( m_pDrawViewWrapper->IsTextEditHit( aMousePos, HITPIX) ) { - pWindow->SetPointer( m_pDrawViewWrapper->GetPreferedPointer( - aMousePos, pWindow, nModifier, bLeftDown ) ); + m_pChartWindow->SetPointer( m_pDrawViewWrapper->GetPreferedPointer( + aMousePos, m_pChartWindow, nModifier, bLeftDown ) ); return; } } @@ -1891,7 +1914,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { Pointer aPointer = m_pDrawViewWrapper->GetPreferedPointer( - aMousePos, pWindow, nModifier, bLeftDown ); + aMousePos, m_pChartWindow, nModifier, bLeftDown ); bool bForceArrowPointer = false; ObjectIdentifier aOID( m_aSelection.getSelectedOID() ); @@ -1924,9 +1947,9 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) } if( bForceArrowPointer ) - pWindow->SetPointer( Pointer( POINTER_ARROW )); + m_pChartWindow->SetPointer( Pointer( POINTER_ARROW )); else - pWindow->SetPointer( aPointer ); + m_pChartWindow->SetPointer( aPointer ); } else { @@ -1975,7 +1998,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) } break; } - pWindow->SetPointer( Pointer( ePointerStyle ) ); + m_pChartWindow->SetPointer( Pointer( ePointerStyle ) ); return; } @@ -1987,7 +2010,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { if( aHitObjectCID.equals(m_aSelection.getSelectedCID()) ) { - pWindow->SetPointer( Pointer( POINTER_ARROW )); + m_pChartWindow->SetPointer( Pointer( POINTER_ARROW )); return; } } @@ -1995,14 +2018,14 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) if( !aHitObjectCID.getLength() ) { //additional shape was hit - pWindow->SetPointer( POINTER_MOVE ); + m_pChartWindow->SetPointer( POINTER_MOVE ); } else if( ObjectIdentifier::isDragableObject( aHitObjectCID ) ) { if( (m_eDragMode == SDRDRAG_ROTATE) && SelectionHelper::isRotateableObject( aHitObjectCID , getModel() ) ) - pWindow->SetPointer( Pointer( POINTER_ROTATE ) ); + m_pChartWindow->SetPointer( Pointer( POINTER_ROTATE ) ); else { ObjectType eHitObjectType = ObjectIdentifier::getObjectType( aHitObjectCID ); @@ -2011,15 +2034,15 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) if( !ObjectIdentifier::areSiblings(aHitObjectCID,m_aSelection.getSelectedCID()) && !ObjectIdentifier::areIdenticalObjects(aHitObjectCID,m_aSelection.getSelectedCID()) ) { - pWindow->SetPointer( Pointer( POINTER_ARROW )); + m_pChartWindow->SetPointer( Pointer( POINTER_ARROW )); return; } } - pWindow->SetPointer( POINTER_MOVE ); + m_pChartWindow->SetPointer( POINTER_MOVE ); } } else - pWindow->SetPointer( Pointer( POINTER_ARROW )); + m_pChartWindow->SetPointer( Pointer( POINTER_ARROW )); } } } diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx index 645a06cdb..081bd3beb 100644 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ b/chart2/source/controller/main/ImplUndoManager.cxx @@ -143,7 +143,6 @@ OUString UndoElement::getActionString() const return m_aActionString; } -// static Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) { Reference< frame::XModel > xResult; @@ -155,7 +154,6 @@ Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XMod return xResult; } -// static void UndoElement::applyModelContentToModel( Reference< frame::XModel > & xInOutModelToChange, const Reference< frame::XModel > & xModelToCopyFrom, diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 372b8cfa7..ce64dbce5 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -630,13 +630,11 @@ ObjectHierarchy::ObjectHierarchy( ObjectHierarchy::~ObjectHierarchy() {} -// static ObjectHierarchy::tOID ObjectHierarchy::getRootNodeOID() { return ObjectIdentifier( C2U( "ROOT" ) ); } -// static bool ObjectHierarchy::isRootNode( const ObjectHierarchy::tOID& rOID ) { return ( rOID == ObjectHierarchy::getRootNodeOID() ); diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index 1e1e40795..2393126c0 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -335,7 +335,6 @@ bool Selection::isAdditionalShapeSelected() const //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject , rtl::OUString& rOutName , bool bGivenObjectMayBeResult ) @@ -369,7 +368,6 @@ bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject return true; } -//static bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject , ObjectIdentifier& rOutObject , bool bGivenObjectMayBeResult ) @@ -383,7 +381,6 @@ bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject return false; } -//static bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos , const rtl::OUString& rNameOfSelectedObject , const DrawViewWrapper& rDrawViewWrapper ) @@ -399,7 +396,6 @@ bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos return true; } -// static ::rtl::OUString SelectionHelper::getHitObjectCID( const Point& rMPos, DrawViewWrapper& rDrawViewWrapper, @@ -465,7 +461,6 @@ bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos // \\- solar mutex } -//static bool SelectionHelper::isRotateableObject( const ::rtl::OUString& rCID , const uno::Reference< frame::XModel >& xChartModel ) { @@ -497,7 +492,6 @@ bool SelectionHelper::getFrameDragSingles() return bFrameDragSingles; } -//static SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj ) { if(!pObj) @@ -553,7 +547,6 @@ SdrObject* SelectionHelper::getObjectToMark() return m_pMarkObj; } -//static E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj ) { //search wether the object or one of its children is a 3D object diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index 61527c291..848b3d09a 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -262,6 +262,7 @@ IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxNameDialog*, pDialog ) void ShapeController::executeDispatch_FormatLine() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -276,7 +277,6 @@ void ShapeController::executeDispatch_FormatLine() { pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); } - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -302,6 +302,7 @@ void ShapeController::executeDispatch_FormatLine() void ShapeController::executeDispatch_FormatArea() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -315,7 +316,6 @@ void ShapeController::executeDispatch_FormatArea() { pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); } - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -351,6 +351,7 @@ void ShapeController::executeDispatch_FormatArea() void ShapeController::executeDispatch_TextAttributes() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -363,7 +364,6 @@ void ShapeController::executeDispatch_TextAttributes() { pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); } - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -388,6 +388,7 @@ void ShapeController::executeDispatch_TextAttributes() void ShapeController::executeDispatch_TransformDialog() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -402,7 +403,6 @@ void ShapeController::executeDispatch_TransformDialog() pDrawViewWrapper->GetAttributes( aAttr ); // item set for position and size SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -427,7 +427,6 @@ void ShapeController::executeDispatch_TransformDialog() else { SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -446,6 +445,7 @@ void ShapeController::executeDispatch_TransformDialog() void ShapeController::executeDispatch_ObjectTitleDescription() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); @@ -456,7 +456,6 @@ void ShapeController::executeDispatch_ObjectTitleDescription() { String aTitle( pSelectedObj->GetTitle() ); String aDescription( pSelectedObj->GetDescription() ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -477,6 +476,7 @@ void ShapeController::executeDispatch_ObjectTitleDescription() void ShapeController::executeDispatch_RenameObject() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); @@ -486,7 +486,6 @@ void ShapeController::executeDispatch_RenameObject() if ( pSelectedObj ) { String aName( pSelectedObj->GetName() ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { @@ -509,10 +508,10 @@ void ShapeController::executeDispatch_RenameObject() void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL ); if ( pDrawViewWrapper ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); switch ( nId ) { case COMMAND_ID_BRING_TO_FRONT: @@ -558,6 +557,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) void ShapeController::executeDispatch_FontDialog() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -568,7 +568,6 @@ void ShapeController::executeDispatch_FontDialog() SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); pDrawViewWrapper->GetAttributes( aAttr ); ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); ::boost::scoped_ptr< ShapeFontDialog > pDlg( new ShapeFontDialog( pParent, &aAttr, &aViewElementListProvider ) ); if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) ) { @@ -581,6 +580,7 @@ void ShapeController::executeDispatch_FontDialog() void ShapeController::executeDispatch_ParagraphDialog() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pChartController ) { Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); @@ -606,7 +606,6 @@ void ShapeController::executeDispatch_ParagraphDialog() aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) ); aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); ::boost::scoped_ptr< ShapeParagraphDialog > pDlg( new ShapeParagraphDialog( pParent, &aNewAttr ) ); if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) ) { @@ -701,6 +700,7 @@ bool ShapeController::isBackwardPossible() { if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); if ( pDrawViewWrapper ) { @@ -719,6 +719,7 @@ bool ShapeController::isForwardPossible() { if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); if ( pDrawViewWrapper ) { diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.cxx b/chart2/source/controller/main/StatusBarCommandDispatch.cxx index 00cc9a844..1a1653571 100644 --- a/chart2/source/controller/main/StatusBarCommandDispatch.cxx +++ b/chart2/source/controller/main/StatusBarCommandDispatch.cxx @@ -40,9 +40,6 @@ // #include <vcl/svapp.hxx> // #endif -// for ressource strings STR_UNDO and STR_REDO -#include <sfx2/sfx.hrc> - #include "ResId.hxx" using namespace ::com::sun::star; diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index bb6034f88..b64d00884 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -38,9 +38,8 @@ #include <vcl/svapp.hxx> // for ressource strings STR_UNDO and STR_REDO -#include <sfx2/sfx.hrc> - -#include "ResId.hxx" +#include <svtools/svtools.hrc> +#include <svtools/svtdata.hxx> using namespace ::com::sun::star; @@ -86,13 +85,13 @@ void UndoCommandDispatch::fireStatusEvent( if( m_xUndoManager->undoPossible()) { // using assignment for broken gcc 3.3 - OUString aUndo = OUString( String( SchResId( STR_UNDO ))); + OUString aUndo = OUString( String( SvtResId( STR_UNDO ))); aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString()); } if( m_xUndoManager->redoPossible()) { // using assignment for broken gcc 3.3 - OUString aRedo = OUString( String( SchResId( STR_REDO ))); + OUString aRedo = OUString( String( SvtResId( STR_REDO ))); aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString()); } diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx index 45e6c3e8b..daab89462 100644 --- a/chart2/source/controller/main/UndoManager.cxx +++ b/chart2/source/controller/main/UndoManager.cxx @@ -408,7 +408,6 @@ sal_Int64 UndoManager::getSomething( const Sequence< sal_Int8 >& rId ) return 0; } -// static const Sequence< sal_Int8 >& UndoManager::getUnoTunnelId() { static Sequence< sal_Int8 >* pSeq = 0; @@ -425,7 +424,6 @@ const Sequence< sal_Int8 >& UndoManager::getUnoTunnelId() return *pSeq; } -// static UndoManager* UndoManager::getImplementation( const Reference< uno::XInterface > xObj ) { UndoManager* pRet = NULL; diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk index fbc888f38..41d7df24a 100644 --- a/chart2/source/controller/makefile.mk +++ b/chart2/source/controller/makefile.mk @@ -109,11 +109,10 @@ DEF1NAME= $(SHL1TARGET) # --- Resources --------------------------------------------------------------- -# sfx.srs is needed for the strings for UNDO and REDO in the UndoCommandDispatch RESLIB1LIST=\ $(SRS)$/chcdialogs.srs \ $(SRS)$/chcmenus.srs \ - $(SOLARCOMMONRESDIR)$/sfx.srs + RESLIB1NAME= $(TARGET) RESLIB1IMAGES=$(PRJ)$/res diff --git a/chart2/source/inc/OPropertySet.hxx b/chart2/source/inc/OPropertySet.hxx index 1ba9ece0b..da8fe058f 100644 --- a/chart2/source/inc/OPropertySet.hxx +++ b/chart2/source/inc/OPropertySet.hxx @@ -96,39 +96,6 @@ protected: */ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0; - // ____ XPropertySet ____ - /** sample implementation using the InfoHelper: - - <pre> - uno::Reference< beans::XPropertySetInfo > SAL_CALL - OPropertySet::getPropertySetInfo() - throw (uno::RuntimeException) - { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- - } - </pre> - - <p>(The reason why this isn't implemented here is, that the static - object is only valid per concrete PropertySet. Otherwise all - PropertySets derived from this base calss would have the same - properties.)</p> - - @see ::cppu::OPropertySetHelper - */ -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL -// getPropertySetInfo() -// throw (::com::sun::star::uno::RuntimeException) = 0; /** Try to convert the value <code>rValue</code> to the type required by the property associated with <code>nHandle</code>. diff --git a/chart2/source/model/inc/DataSeries.hxx b/chart2/source/model/inc/DataSeries.hxx index 9c56a74ac..7af7ecc58 100644 --- a/chart2/source/model/inc/DataSeries.hxx +++ b/chart2/source/model/inc/DataSeries.hxx @@ -198,10 +198,6 @@ protected: void fireModifyEvent(); - /** const variant of getInfoHelper() - */ - ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelperConst() const; - private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 90f0a681a..3a8624c7c 100644..100755 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -194,63 +194,86 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) -{ - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ); - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO ); - - float fDefaultCharHeight = 10.0; - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); - - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); -} +struct StaticAxisDefaults_Initializer +{ + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ); + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO ); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); + + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticAxisInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer > +{ +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticAxisInfo_Initializer { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; - return aArrayHelper; -} +struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer > +{ +}; typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType; typedef uno::Sequence< lcl_tSubGridType > lcl_tSubGridSeq; @@ -577,52 +600,23 @@ void Axis::fireModifyEvent() uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - LineProperties::AddDefaultsToMap( aStaticDefaults ); - - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticAxisInfoHelper::get(); } - // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - Axis::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticAxisInfo::get(); } // ================================================================================ diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx index 4a0bd372e..3fbc120d9 100644..100755 --- a/chart2/source/model/main/BaseCoordinateSystem.cxx +++ b/chart2/source/model/main/BaseCoordinateSystem.cxx @@ -69,35 +69,64 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticCooSysDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false ); + } +}; + +struct StaticCooSysDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCooSysDefaults_Initializer > +{ +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticCooSysInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticCooSysInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCooSysInfoHelper_Initializer > +{ +}; + +struct StaticCooSysInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCooSysInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticCooSysInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCooSysInfo_Initializer > +{ +}; } // anonymous namespace @@ -352,53 +381,25 @@ void BaseCoordinateSystem::fireModifyEvent() uno::Any BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticCooSysDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL BaseCoordinateSystem::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticCooSysInfoHelper::get(); } // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - BaseCoordinateSystem::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL BaseCoordinateSystem::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticCooSysInfo::get(); } using impl::BaseCoordinateSystem_Base; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 2f58c4271..63e1fe0ca 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -182,6 +182,16 @@ ChartModel::~ChartModel() m_xOldModelAgg->setDelegator( 0 ); } +void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ ) + throw (uno::Exception, uno::RuntimeException) +{ + //#i113722# avoid duplicate creation + + //maybe additional todo?: + //support argument "EmbeddedObject"? + //support argument "EmbeddedScriptSupport"? + //support argument "DocumentRecoverySupport"? +} //----------------------------------------------------------------- // private methods @@ -1288,7 +1298,8 @@ Reference< util::XNumberFormatsSupplier > ChartModel::impl_getNumberFormatsSuppl if( !m_xOwnNumberFormatsSupplier.is() ) { Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY ); - m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) ); + m_apSvNumberFormatter.reset( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) ); + m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( m_apSvNumberFormatter.get() ); //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo? } m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier; diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 275c611d9..b5828a0bd 100644..100755 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -38,6 +38,7 @@ #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/embed/XVisualObject.hpp> @@ -62,9 +63,9 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/datatransfer/XTransferable.hpp> -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_20) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_20 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 20 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 #include "comphelper/implbase_var.hxx" #endif #include <osl/mutex.hxx> @@ -74,6 +75,8 @@ // for auto_ptr #include <memory> +class SvNumberFormatter; + //============================================================================= /** this is an example implementation for the service ::com::sun::star::document::OfficeDocument */ @@ -85,7 +88,7 @@ namespace impl { // Note: needed for queryInterface (if it calls the base-class implementation) -typedef ::comphelper::WeakImplHelper20< +typedef ::comphelper::WeakImplHelper21< // ::com::sun::star::frame::XModel //comprehends XComponent (required interface), base of XChartDocument ::com::sun::star::util::XCloseable //comprehends XCloseBroadcaster ,::com::sun::star::frame::XStorable2 //(extension of XStorable) @@ -95,6 +98,7 @@ typedef ::comphelper::WeakImplHelper20< // ,::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface) // ,::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper ,::com::sun::star::lang::XServiceInfo + ,::com::sun::star::lang::XInitialization ,::com::sun::star::chart2::XChartDocument // derived from XModel ,::com::sun::star::chart2::data::XDataReceiver // public API ,::com::sun::star::chart2::XTitled @@ -157,6 +161,7 @@ private: m_xOwnNumberFormatsSupplier; ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; + std::auto_ptr< SvNumberFormatter > m_apSvNumberFormatter; // #i113784# avoid memory leak ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager > m_xChartTypeManager; @@ -246,6 +251,12 @@ public: APPHELPER_SERVICE_FACTORY_HELPER(ChartModel) //----------------------------------------------------------------- + // ::com::sun::star::lang::XInitialization + //----------------------------------------------------------------- + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- // ::com::sun::star::frame::XModel (required interface) //----------------------------------------------------------------- diff --git a/chart2/source/model/main/DataPoint.cxx b/chart2/source/model/main/DataPoint.cxx index 6672d23b7..ab57ff12b 100644..100755 --- a/chart2/source/model/main/DataPoint.cxx +++ b/chart2/source/model/main/DataPoint.cxx @@ -53,30 +53,48 @@ using ::rtl::OUString; namespace { -const Sequence< Property > & lcl_GetPropertySequence() + +struct StaticDataPointInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::DataPointProperties::AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; + +struct StaticDataPointInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataPointInfoHelper_Initializer > +{ +}; + +struct StaticDataPointInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataPointInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticDataPointInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataPointInfo_Initializer > +{ +}; - return aPropSeq; -} } // anonymous namespace // ____________________________________________________________ @@ -157,7 +175,7 @@ uno::Reference< util::XCloneable > SAL_CALL DataPoint::createClone() Reference< uno::XInterface > SAL_CALL DataPoint::getParent() throw (uno::RuntimeException) { - return Reference< uno::XInterface >( m_xParentProperties, uno::UNO_QUERY ); + return Reference< uno::XInterface >( m_xParentProperties.get(), uno::UNO_QUERY ); } void SAL_CALL DataPoint::setParent( @@ -165,7 +183,7 @@ void SAL_CALL DataPoint::setParent( throw (lang::NoSupportException, uno::RuntimeException) { - m_xParentProperties.set( Parent, uno::UNO_QUERY ); + m_xParentProperties = Reference< beans::XPropertySet >( Parent, uno::UNO_QUERY ); } // ____ OPropertySet ____ @@ -173,7 +191,7 @@ uno::Any DataPoint::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { // the value set at the data series is the default - uno::Reference< beans::XFastPropertySet > xFast( m_xParentProperties, uno::UNO_QUERY ); + uno::Reference< beans::XFastPropertySet > xFast( m_xParentProperties.get(), uno::UNO_QUERY ); if( !xFast.is()) { OSL_ENSURE( m_bNoParentPropAllowed, "data point needs a parent property set to provide values correctly" ); @@ -214,35 +232,14 @@ void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast( ::cppu::IPropertyArrayHelper & SAL_CALL DataPoint::getInfoHelper() { - return getInfoHelperConst(); -} - -::cppu::IPropertyArrayHelper & SAL_CALL DataPoint::getInfoHelperConst() const -{ - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticDataPointInfoHelper::get(); } // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - DataPoint::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL DataPoint::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticDataPointInfo::get(); } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/model/main/DataPoint.hxx b/chart2/source/model/main/DataPoint.hxx index 0749b90dd..1735305b9 100644..100755 --- a/chart2/source/model/main/DataPoint.hxx +++ b/chart2/source/model/main/DataPoint.hxx @@ -29,6 +29,7 @@ #include <osl/mutex.hxx> #include <cppuhelper/implbase5.hxx> +#include <cppuhelper/weakref.hxx> #include <comphelper/uno3.hxx> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/util/XCloneable.hpp> @@ -101,10 +102,6 @@ protected: throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); - /** const variant of getInfoHelper() - */ - ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelperConst() const; - // ____ XModifyBroadcaster ____ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) @@ -130,7 +127,7 @@ protected: void fireModifyEvent(); private: - ::com::sun::star::uno::Reference< + ::com::sun::star::uno::WeakReference< ::com::sun::star::beans::XPropertySet > m_xParentProperties; ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder; diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index f78d94ab7..f8548c4be 100644..100755 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -55,30 +55,73 @@ using ::osl::MutexGuard; namespace { -const uno::Sequence< Property > & lcl_GetPropertySequence() + +struct StaticDataSeriesDefaults_Initializer { - static uno::Sequence< Property > aPropSeq; + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::DataSeriesProperties::AddDefaultsToMap( rOutMap ); + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); + } +}; + +struct StaticDataSeriesDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDataSeriesDefaults_Initializer > +{ +}; + +struct StaticDataSeriesInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties ); ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticDataSeriesInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper_Initializer > +{ +}; + +struct StaticDataSeriesInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataSeriesInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticDataSeriesInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo_Initializer > +{ +}; void lcl_SetParent( const uno::Reference< uno::XInterface > & xChildInterface, @@ -245,60 +288,24 @@ Sequence< OUString > DataSeries::getSupportedServiceNames_Static() uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - DataSeriesProperties::AddDefaultsToMap( aStaticDefaults ); - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - - float fDefaultCharHeight = 10.0; - ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) - throw beans::UnknownPropertyException(); - + const tPropertyValueMap& rStaticDefaults = *StaticDataSeriesDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) + return uno::Any(); return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticDataSeriesInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - DataSeries::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticDataSeriesInfo::get(); } void SAL_CALL DataSeries::getFastPropertyValue diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 994a67f57..f4946cb09 100644..100755 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -42,6 +42,7 @@ #include "DisposeHelper.hxx" #include "BaseGFXHelper.hxx" #include <basegfx/numeric/ftools.hxx> +#include <rtl/instance.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> @@ -177,42 +178,71 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticDiagramDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); + } +}; + +struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer > +{ +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticDiagramInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::SceneProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer > +{ +}; + +struct StaticDiagramInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer > +{ +}; /// clones a UNO-sequence of UNO-References typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef; @@ -608,54 +638,24 @@ Sequence< OUString > Diagram::getSupportedServiceNames_Static() uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - ::chart::SceneProperties::AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticDiagramInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - Diagram::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticDiagramInfo::get(); } // ____ XFastPropertySet ____ diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx index 8a0158f80..76d319aa7 100644..100755 --- a/chart2/source/model/main/FormattedString.cxx +++ b/chart2/source/model/main/FormattedString.cxx @@ -47,37 +47,64 @@ using ::osl::MutexGuard; namespace { -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticFormattedStringDefaults_Initializer { - static Sequence< Property > aPropSeq; + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); + } +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer > +{ +}; + +struct StaticFormattedStringInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticFormattedStringInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticFormattedStringInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticFormattedStringInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticFormattedStringInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticFormattedStringInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticFormattedStringInfo_Initializer > +{ +}; } // anonymous namespace @@ -201,50 +228,25 @@ Sequence< OUString > FormattedString::getSupportedServiceNames_Static() uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) - throw beans::UnknownPropertyException(); - + const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) + return uno::Any(); return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL FormattedString::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticFormattedStringInfoHelper::get(); } // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - FormattedString::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL FormattedString::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticFormattedStringInfo::get(); } // ================================================================================ diff --git a/chart2/source/model/main/GridProperties.cxx b/chart2/source/model/main/GridProperties.cxx index a691d8825..9f43d00b9 100644..100755 --- a/chart2/source/model/main/GridProperties.cxx +++ b/chart2/source/model/main/GridProperties.cxx @@ -71,50 +71,73 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_addDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) +struct StaticGridDefaults_Initializer { - ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false ); - // override other defaults - ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( - rOutMap, ::chart::LineProperties::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30 -} + // override other defaults + ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( + rOutMap, ::chart::LineProperties::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30 + } +}; -const Sequence< Property > & lcl_getPropertySequence() +struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticGridInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +}; + +struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_getPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticGridInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer > +{ +}; } // anonymous namespace @@ -149,45 +172,23 @@ GridProperties::~GridProperties() uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - lcl_addDefaultsToMap( aStaticDefaults ); - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticGridInfoHelper::get(); } // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - GridProperties::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - lcl_getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticGridInfo::get(); } // ____ XCloneable ____ diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index 46ec4fca4..1f73f69ba 100644..100755 --- a/chart2/source/model/main/Legend.cxx +++ b/chart2/source/model/main/Legend.cxx @@ -107,28 +107,47 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticLegendDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_PREFERRED_EXPANSION, chart2::LegendExpansion_HIGH ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true ); - - float fDefaultCharHeight = 10.0; - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); + + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_PREFERRED_EXPANSION, chart2::LegendExpansion_HIGH ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true ); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticLegendDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLegendDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticLegendInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); @@ -136,25 +155,30 @@ const Sequence< Property > & lcl_GetPropertySequence() ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticLegendInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer > +{ +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticLegendInfo_Initializer { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLegendInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; - return aArrayHelper; -} +struct StaticLegendInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLegendInfo_Initializer > +{ +}; } // anonymous namespace @@ -309,52 +333,23 @@ Sequence< OUString > Legend::getSupportedServiceNames_Static() Any Legend::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - // call last to overwrite some character property defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) - return Any(); - + const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) + return uno::Any(); return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL Legend::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticLegendInfoHelper::get(); } - // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - Legend::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL Legend::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticLegendInfo::get(); } // implement XServiceInfo methods basing upon getSupportedServiceNames_Static diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 00b6643b0..8612e2431 100644..100755 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -53,47 +53,71 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.PageBackground" )); -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticPageBackgroundDefaults_Initializer { - // override other defaults - ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + + // override other defaults + ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticPageBackgroundInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticPageBackgroundInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer > +{ +}; } // anonymous namespace @@ -132,55 +156,25 @@ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone() uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - // overrides defaults of FillProperties - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticPageBackgroundInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - PageBackground::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticPageBackgroundInfo::get(); } - // ____ XModifyBroadcaster ____ void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) diff --git a/chart2/source/model/main/StockBar.cxx b/chart2/source/model/main/StockBar.cxx index ecba210ae..9b878f202 100644..100755 --- a/chart2/source/model/main/StockBar.cxx +++ b/chart2/source/model/main/StockBar.cxx @@ -57,46 +57,70 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.StockBar" )); -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticStockBarInfoHelper_Initializer { - static uno::Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticStockBarInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockBarInfoHelper_Initializer > { - // override other defaults - ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticStockBarInfo_Initializer { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockBarInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; - return aArrayHelper; -} +struct StaticStockBarInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockBarInfo_Initializer > +{ +}; + +struct StaticStockBarDefaults_Initializer +{ + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + + // override other defaults + ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white + } +}; + +struct StaticStockBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockBarDefaults_Initializer > +{ +}; } // anonymous namespace @@ -144,55 +168,25 @@ uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone() uno::Any StockBar::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - - // overrides a line property - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticStockBarDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticStockBarInfoHelper::get(); } // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - StockBar::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - lcl_getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticStockBarInfo::get(); } - // ____ XModifyBroadcaster ____ void SAL_CALL StockBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx index 8c58abf15..71989263c 100644..100755 --- a/chart2/source/model/main/Title.cxx +++ b/chart2/source/model/main/Title.cxx @@ -156,62 +156,87 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticTitleDefaults_Initializer { - // ParagraphProperties - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_ADJUST, - ::com::sun::star::style::ParagraphAdjust_CENTER ); - // PROP_TITLE_PARA_LAST_LINE_ADJUST - - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_LEFT_MARGIN, 0 ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_RIGHT_MARGIN, 0 ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_TOP_MARGIN, 0 ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_IS_HYPHENATION, true ); - - // own properties - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_TITLE_TEXT_ROTATION, 0.0 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_TEXT_STACKED, false ); - - // override other defaults - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + + // ParagraphProperties + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_ADJUST, + ::com::sun::star::style::ParagraphAdjust_CENTER ); + // PROP_TITLE_PARA_LAST_LINE_ADJUST + + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_LEFT_MARGIN, 0 ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_RIGHT_MARGIN, 0 ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_TOP_MARGIN, 0 ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_IS_HYPHENATION, true ); + + // own properties + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_TITLE_TEXT_ROTATION, 0.0 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_TEXT_STACKED, false ); + + // override other defaults + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + } +}; + +struct StaticTitleDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticTitleDefaults_Initializer > +{ +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticTitleInfoHelper_Initializer { - static uno::Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +}; + +struct StaticTitleInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticTitleInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticTitleInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticTitleInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticTitleInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticTitleInfo_Initializer > +{ +}; } // anonymous namespace @@ -283,54 +308,23 @@ void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XForm uno::Any Title::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - - // initialize defaults - // Note: this should be last to override defaults of the previously - // added defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticTitleDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL Title::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticTitleInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - Title::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL Title::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticTitleInfo::get(); } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/model/main/Wall.cxx b/chart2/source/model/main/Wall.cxx index 8e68dbf70..dd7a5540d 100644..100755 --- a/chart2/source/model/main/Wall.cxx +++ b/chart2/source/model/main/Wall.cxx @@ -59,46 +59,70 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Wall" )); -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticWallDefaults_Initializer { - // override other defaults - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + + // override other defaults + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticWallInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticWallInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer > +{ +}; } // anonymous namespace @@ -135,55 +159,23 @@ uno::Reference< util::XCloneable > SAL_CALL Wall::createClone() uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - - // initialize defaults - // Note: this should be last to override defaults of the previously - // added defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticWallInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - Wall::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticWallInfo::get(); } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index bcc50306a..71710dd4d 100644..100755 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -70,43 +70,64 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticAreaChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AREA_TEMPLATE_DIMENSION, 2 ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AREA_TEMPLATE_DIMENSION, 2 ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticAreaChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAreaChartTypeTemplateDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticAreaChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticAreaChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAreaChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticAreaChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -133,49 +154,23 @@ AreaChartTypeTemplate::~AreaChartTypeTemplate() uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticAreaChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - AreaChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticAreaChartTypeTemplateInfo::get(); } sal_Int32 AreaChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 2235cb544..c6055343f 100644..100755 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -77,44 +77,65 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticBarChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_BAR_TEMPLATE_DIMENSION, 2 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_BAR_TEMPLATE_DIMENSION, 2 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticBarChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBarChartTypeTemplateDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticBarChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticBarChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBarChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticBarChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBarChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticBarChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBarChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -226,49 +247,23 @@ Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForNe uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticBarChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticBarChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - BarChartTypeTemplate::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticBarChartTypeTemplateInfo::get(); } void SAL_CALL BarChartTypeTemplate::applyStyle( diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx index 173847850..149e0b7f6 100644..100755 --- a/chart2/source/model/template/BubbleChartType.cxx +++ b/chart2/source/model/template/BubbleChartType.cxx @@ -56,33 +56,62 @@ void lcl_AddPropertiesToVector( { } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & /*rOutMap*/ ) +struct StaticBubbleChartTypeDefaults_Initializer { -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & /*rOutMap*/ ) + { + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticBubbleChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticBubbleChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -177,53 +206,24 @@ OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel() uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticBubbleChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - BubbleChartType::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticBubbleChartTypeInfo::get(); } uno::Sequence< ::rtl::OUString > BubbleChartType::getSupportedServiceNames_Static() diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index 1cf108a80..482606b8c 100644..100755 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -65,42 +65,63 @@ void lcl_AddPropertiesToVector( { } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & /*rOutMap*/ ) +struct StaticBubbleChartTypeTemplateDefaults_Initializer { -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & /*rOutMap*/ ) + { + } +}; + +struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer > +{ +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticBubbleChartTypeTemplateInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticBubbleChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -123,49 +144,23 @@ BubbleChartTypeTemplate::~BubbleChartTypeTemplate() uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticBubbleChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - BubbleChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticBubbleChartTypeTemplateInfo::get(); } sal_Int32 BubbleChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx index e7a69c8d0..567ddf936 100644..100755 --- a/chart2/source/model/template/CandleStickChartType.cxx +++ b/chart2/source/model/template/CandleStickChartType.cxx @@ -95,39 +95,67 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap, - ::osl::Mutex & rMutex ) +struct StaticCandleStickChartTypeDefaults_Initializer { - ::osl::MutexGuard aGuard( rMutex ); - // must match default in CTOR! - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + // must match default in CTOR! + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); + } +}; + +struct StaticCandleStickChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCandleStickChartTypeDefaults_Initializer > +{ +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticCandleStickChartTypeInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticCandleStickChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCandleStickChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticCandleStickChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCandleStickChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticCandleStickChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCandleStickChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -261,53 +289,24 @@ OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel() uno::Any CandleStickChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults, GetMutex() ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticCandleStickChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - CandleStickChartType::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticCandleStickChartTypeInfo::get(); } void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast( diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx index 48b6a67f3..16f680e49 100644..100755 --- a/chart2/source/model/template/ChartType.cxx +++ b/chart2/source/model/template/ChartType.cxx @@ -230,34 +230,51 @@ uno::Any ChartType::GetDefaultValue( sal_Int32 /* nHandle */ ) const return uno::Any(); } -// ____ OPropertySet ____ -::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper() +namespace { - // using assignment for broken gcc 3.3 - static ::cppu::OPropertyArrayHelper aArrayHelper = ::cppu::OPropertyArrayHelper( - Sequence< beans::Property >(), /* bSorted */ sal_True ); - - return aArrayHelper; -} +struct StaticChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + // using assignment for broken gcc 3.3 + static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper( + Sequence< beans::Property >() ); + return &aPropHelper; + } +}; -// ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ChartType::getPropertySetInfo() - throw (uno::RuntimeException) +struct StaticChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticChartTypeInfoHelper_Initializer > { - static uno::Reference< beans::XPropertySetInfo > xInfo; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) +struct StaticChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; } +}; + +struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticChartTypeInfo_Initializer > +{ +}; + +} - return xInfo; - // \-- +// ____ OPropertySet ____ +::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper() +{ + return *StaticChartTypeInfoHelper::get(); +} + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL ChartType::getPropertySetInfo() + throw (uno::RuntimeException) +{ + return *StaticChartTypeInfo::get(); } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 659e3c8cc..8671145d8 100644..100755 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -895,7 +895,6 @@ void ChartTypeTemplate::createChartTypes( } } -//static void ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( const Sequence< Reference< XChartType > > & rOldChartTypesSeq, const Reference< XChartType > & xNewChartType ) diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 3c73d4878..aeb93d3e3 100644..100755 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -67,40 +67,70 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticColumnChartTypeDefaults_Initializer { - Sequence< sal_Int32 > aSeq(2); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + Sequence< sal_Int32 > aSeq(2); - aSeq[0] = aSeq[1] = 0; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); + aSeq[0] = aSeq[1] = 0; + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); - aSeq[0] = aSeq[1] = 100; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); -} + aSeq[0] = aSeq[1] = 100; + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); + } +}; + +struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer > +{ +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticColumnChartTypeInfoHelper_Initializer { - static Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticColumnChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -138,51 +168,23 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone() uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - return aArrayHelper; + return *StaticColumnChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ColumnChartType::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticColumnChartTypeInfo::get(); } // diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 4b9d6233d..9a362e602 100644..100755 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -76,43 +76,64 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticColumnLineChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_COL_LINE_NUMBER_OF_LINES, 1 ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_COL_LINE_NUMBER_OF_LINES, 1 ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticColumnLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnLineChartTypeTemplateDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticColumnLineChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticColumnLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnLineChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticColumnLineChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnLineChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticColumnLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnLineChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -139,49 +160,23 @@ ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate() uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticColumnLineChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticColumnLineChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ColumnLineChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticColumnLineChartTypeTemplateInfo::get(); } void ColumnLineChartTypeTemplate::createChartTypes( diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 45242e592..d361058b1 100644..100755 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -329,7 +329,6 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData( // convenience methods -// static OUString DataInterpreter::GetRole( const Reference< data::XDataSequence > & xSeq ) { OUString aResult; @@ -348,7 +347,6 @@ OUString DataInterpreter::GetRole( const Reference< data::XDataSequence > & xSeq return aResult; } -// static void DataInterpreter::SetRole( const Reference< data::XDataSequence > & xSeq, const OUString & rRole ) { if( ! xSeq.is()) @@ -364,7 +362,6 @@ void DataInterpreter::SetRole( const Reference< data::XDataSequence > & xSeq, co } } -// static uno::Any DataInterpreter::GetProperty( const Sequence< beans::PropertyValue > & aArguments, const OUString & rName ) @@ -377,7 +374,6 @@ uno::Any DataInterpreter::GetProperty( return uno::Any(); } -// static bool DataInterpreter::HasCategories( const Sequence< beans::PropertyValue > & rArguments, const Sequence< Reference< data::XLabeledDataSequence > > & rData ) diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx index 9da596241..a560f6991 100644..100755 --- a/chart2/source/model/template/LineChartType.cxx +++ b/chart2/source/model/template/LineChartType.cxx @@ -78,39 +78,69 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticLineChartTypeDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 ); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 ); - // todo: check whether order 3 means polygons of order 3 or 2. (see - // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 ); -} + // todo: check whether order 3 means polygons of order 3 or 2. (see + // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticLineChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticLineChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticLineChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticLineChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -150,52 +180,23 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone() uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticLineChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - LineChartType::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticLineChartTypeInfo::get(); } uno::Sequence< ::rtl::OUString > LineChartType::getSupportedServiceNames_Static() diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index 34f9c09f3..ea7ecbaf7 100644..100755 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -88,48 +88,69 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticLineChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 ); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 ); - // todo: check whether order 3 means polygons of order 3 or 2. (see - // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 ); -} + // todo: check whether order 3 means polygons of order 3 or 2. (see + // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeTemplateDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticLineChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticLineChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -161,49 +182,23 @@ LineChartTypeTemplate::~LineChartTypeTemplate() uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL LineChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticLineChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - LineChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticLineChartTypeTemplateInfo::get(); } sal_Int32 LineChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx index 4452a7ae9..00f4d3b1a 100644..100755 --- a/chart2/source/model/template/NetChartType.cxx +++ b/chart2/source/model/template/NetChartType.cxx @@ -108,31 +108,51 @@ uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const return uno::Any(); } +namespace +{ + +struct StaticNetChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + // using assignment for broken gcc 3.3 + static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper( + Sequence< beans::Property >() ); + return &aPropHelper; + } +}; + +struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticNetChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer > +{ +}; + +} + // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper() { - uno::Sequence< beans::Property > aProps; - static ::cppu::OPropertyArrayHelper aArrayHelper(aProps); - return aArrayHelper; + return *StaticNetChartTypeInfoHelper::get(); } // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - NetChartType_Base::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticNetChartTypeInfo::get(); } //----------------------------------------------------------------------------- diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx index 11011372a..062e1f686 100644..100755 --- a/chart2/source/model/template/PieChartType.cxx +++ b/chart2/source/model/template/PieChartType.cxx @@ -67,34 +67,64 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticPieChartTypeDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIECHARTTYPE_USE_RINGS, false ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIECHARTTYPE_USE_RINGS, false ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticPieChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPieChartTypeDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticPieChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticPieChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPieChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticPieChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPieChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticPieChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -174,53 +204,24 @@ Reference< chart2::XCoordinateSystem > SAL_CALL uno::Any PieChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL PieChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticPieChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - PieChartType::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticPieChartTypeInfo::get(); } uno::Sequence< ::rtl::OUString > PieChartType::getSupportedServiceNames_Static() diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 474f8eaee..8a4847c78 100644..100755 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -100,46 +100,67 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticPieChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_OFFSET_MODE, chart2::PieChartOffsetMode_NONE ); - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_OFFSET_MODE, chart2::PieChartOffsetMode_NONE ); + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false ); + } +}; + +struct StaticPieChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPieChartTypeTemplateDefaults_Initializer > +{ +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticPieChartTypeTemplateInfoHelper_Initializer { - static uno::Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticPieChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPieChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticPieChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPieChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticPieChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -168,52 +189,25 @@ PieChartTypeTemplate::~PieChartTypeTemplate() uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticPieChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - PieChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticPieChartTypeTemplateInfo::get(); } - // ____ ChartTypeTemplate ____ sal_Int32 PieChartTypeTemplate::getDimension() const { diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx index 2577219fd..24f844b20 100644..100755 --- a/chart2/source/model/template/ScatterChartType.cxx +++ b/chart2/source/model/template/ScatterChartType.cxx @@ -82,39 +82,69 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticScatterChartTypeDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 ); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 ); - // todo: check whether order 3 means polygons of order 3 or 2. (see - // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 ); -} + // todo: check whether order 3 means polygons of order 3 or 2. (see + // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticScatterChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticScatterChartTypeInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; + +struct StaticScatterChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeInfoHelper_Initializer > +{ +}; + +struct StaticScatterChartTypeInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticScatterChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeInfo_Initializer > +{ +}; } // anonymous namespace @@ -231,53 +261,24 @@ uno::Sequence< ::rtl::OUString > SAL_CALL ScatterChartType::getSupportedOptional uno::Any ScatterChartType::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartType::getInfoHelper() { - static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); - - return aArrayHelper; + return *StaticScatterChartTypeInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ScatterChartType::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartType::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticScatterChartTypeInfo::get(); } uno::Sequence< ::rtl::OUString > ScatterChartType::getSupportedServiceNames_Static() diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index 00a85f2b4..7f30625f5 100644..100755 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -90,48 +90,69 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticScatterChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 ); + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 ); - // todo: check whether order 3 means polygons of order 3 or 2. (see - // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 ); -} + // todo: check whether order 3 means polygons of order 3 or 2. (see + // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticScatterChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeTemplateDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticScatterChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticScatterChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeTemplateInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticScatterChartTypeTemplateInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticScatterChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace @@ -162,49 +183,23 @@ ScatterChartTypeTemplate::~ScatterChartTypeTemplate() uno::Any ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticScatterChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ScatterChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticScatterChartTypeTemplateInfo::get(); } sal_Int32 ScatterChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index 4f319607b..1246acc6f 100644..100755 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -104,46 +104,66 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticStockChartTypeTemplateDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false ); + } +}; -const Sequence< Property > & lcl_GetPropertySequence() +struct StaticStockChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockChartTypeTemplateDefaults_Initializer > { - static Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticStockChartTypeTemplateInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticStockChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockChartTypeTemplateInfoHelper_Initializer > +{ +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticStockChartTypeTemplateInfo_Initializer { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockChartTypeTemplateInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; - return aArrayHelper; -} +struct StaticStockChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockChartTypeTemplateInfo_Initializer > +{ +}; } // anonymous namespace // ---------------------------------------- @@ -180,49 +200,23 @@ StockChartTypeTemplate::~StockChartTypeTemplate() uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticStockChartTypeTemplateDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticStockChartTypeTemplateInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - StockChartTypeTemplate::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL StockChartTypeTemplate::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticStockChartTypeTemplateInfo::get(); } sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension ) diff --git a/chart2/source/model/template/_serviceregistration_charttypes.cxx b/chart2/source/model/template/_serviceregistration_charttypes.cxx index b026b910b..1c564ed79 100644..100755 --- a/chart2/source/model/template/_serviceregistration_charttypes.cxx +++ b/chart2/source/model/template/_serviceregistration_charttypes.cxx @@ -130,7 +130,6 @@ static struct ::cppu::ImplementationEntry g_entries_chart2_charttypes[] = } // anonymous namespace -// static struct ::cppu::ImplementationEntry * ChartTypeEntriesForServiceRegistration::getImplementationEntries() { diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index d3a8e186f..0a204cee5 100644..100755 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -66,19 +66,16 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -//static Reference< chart2::XScaling > AxisHelper::createLinearScaling() { return new LinearScaling( 1.0, 0.0 ); } -//static Reference< chart2::XScaling > AxisHelper::createLogarithmicScaling( double fBase ) { return new LogarithmicScaling( fBase ); } -//static ScaleData AxisHelper::createDefaultScale() { ScaleData aScaleData; @@ -91,7 +88,6 @@ ScaleData AxisHelper::createDefaultScale() return aScaleData; } -//static void AxisHelper::removeExplicitScaling( ScaleData& rScaleData ) { uno::Any aEmpty; @@ -102,7 +98,6 @@ void AxisHelper::removeExplicitScaling( ScaleData& rScaleData ) rScaleData.TimeIncrement = aDefaultScale.TimeIncrement; } -//static bool AxisHelper::isLogarithmic( const Reference< XScaling >& xScaling ) { bool bReturn = false; @@ -290,7 +285,6 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( return nNumberFormatKey; } -//static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex , sal_Int32 nAxisIndex // 0==main or 1==secondary axis @@ -359,7 +353,6 @@ Reference< XAxis > AxisHelper::createAxis( return xAxis; } -//static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMainAxis , const Reference< chart2::XDiagram >& xDiagram , const Reference< uno::XComponentContext >& xContext @@ -378,7 +371,6 @@ Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex, bool bMain nDimensionIndex, nAxisIndex, xCooSys, xContext, pRefSizeProvider ); } -//static void AxisHelper::showAxis( sal_Int32 nDimensionIndex, bool bMainAxis , const Reference< chart2::XDiagram >& xDiagram , const Reference< uno::XComponentContext >& xContext @@ -401,7 +393,6 @@ void AxisHelper::showAxis( sal_Int32 nDimensionIndex, bool bMainAxis AxisHelper::makeAxisVisible( xAxis ); } -//static void AxisHelper::showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid , const Reference< XDiagram >& xDiagram , const Reference< uno::XComponentContext >& /*xContext*/ ) @@ -431,7 +422,6 @@ void AxisHelper::showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bo } } -//static void AxisHelper::makeAxisVisible( const Reference< XAxis >& xAxis ) { Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY ); @@ -443,7 +433,6 @@ void AxisHelper::makeAxisVisible( const Reference< XAxis >& xAxis ) } } -//static void AxisHelper::makeGridVisible( const Reference< beans::XPropertySet >& xGridProperties ) { if( xGridProperties.is() ) @@ -453,14 +442,12 @@ void AxisHelper::makeGridVisible( const Reference< beans::XPropertySet >& xGridP } } -//static void AxisHelper::hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis , const Reference< XDiagram >& xDiagram ) { AxisHelper::makeAxisInvisible( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); } -//static void AxisHelper::makeAxisInvisible( const Reference< XAxis >& xAxis ) { Reference< beans::XPropertySet > xProps( xAxis, uno::UNO_QUERY ); @@ -470,7 +457,6 @@ void AxisHelper::makeAxisInvisible( const Reference< XAxis >& xAxis ) } } -//static void AxisHelper::hideAxisIfNoDataIsAttached( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram ) { //axis is hidden if no data is attached anymore but data is available @@ -514,7 +500,6 @@ void AxisHelper::hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bo } } -//static void AxisHelper::makeGridInvisible( const Reference< beans::XPropertySet >& xGridProperties ) { if( xGridProperties.is() ) @@ -548,7 +533,6 @@ sal_Bool AxisHelper::isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIn return bRet; } -//static Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemByIndex( const Reference< XDiagram >& xDiagram, sal_Int32 nIndex ) { @@ -561,7 +545,6 @@ Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemByIndex( return NULL; } -//static Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, bool bMainAxis , const Reference< XDiagram >& xDiagram ) { @@ -577,7 +560,6 @@ Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, bool bMainAxi return xRet; } -//static Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex , const Reference< XCoordinateSystem >& xCooSys ) { @@ -593,7 +575,6 @@ Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAx return xRet; } -//static Reference< XAxis > AxisHelper::getCrossingMainAxis( const Reference< XAxis >& xAxis , const Reference< XCoordinateSystem >& xCooSys ) { @@ -615,7 +596,6 @@ Reference< XAxis > AxisHelper::getCrossingMainAxis( const Reference< XAxis >& xA return AxisHelper::getAxis( nDimensionIndex, 0, xCooSys ); } -//static Reference< XAxis > AxisHelper::getParallelAxis( const Reference< XAxis >& xAxis , const Reference< XDiagram >& xDiagram ) { @@ -642,7 +622,6 @@ sal_Bool AxisHelper::isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis return AxisHelper::isAxisVisible( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); } -//static sal_Bool AxisHelper::isAxisVisible( const Reference< XAxis >& xAxis ) { sal_Bool bRet = false; @@ -668,7 +647,6 @@ sal_Bool AxisHelper::areAxisLabelsVisible( const Reference< beans::XPropertySet return bRet; } -//static sal_Bool AxisHelper::isGridVisible( const Reference< beans::XPropertySet >& xGridProperies ) { sal_Bool bRet = false; @@ -682,7 +660,6 @@ sal_Bool AxisHelper::isGridVisible( const Reference< beans::XPropertySet >& xGri return bRet; } -//static Reference< beans::XPropertySet > AxisHelper::getGridProperties( const Reference< XCoordinateSystem >& xCooSys , sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex, sal_Int32 nSubGridIndex ) @@ -705,7 +682,6 @@ Reference< beans::XPropertySet > AxisHelper::getGridProperties( return xRet; } -//static sal_Int32 AxisHelper::getDimensionIndexOfAxis( const Reference< XAxis >& xAxis , const Reference< XDiagram >& xDiagram ) @@ -717,7 +693,6 @@ sal_Int32 AxisHelper::getDimensionIndexOfAxis( return nDimensionIndex; } -//static bool AxisHelper::getIndicesForAxis( const Reference< XAxis >& xAxis , const Reference< XCoordinateSystem >& xCooSys @@ -750,7 +725,6 @@ bool AxisHelper::getIndicesForAxis( return false; } -//static bool AxisHelper::getIndicesForAxis( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex ) { @@ -777,7 +751,6 @@ bool AxisHelper::getIndicesForAxis( const Reference< XAxis >& xAxis, const Refer return false; } -//static std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys , bool bOnlyVisible /* = false */ ) @@ -824,7 +797,6 @@ std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem( return aAxisVector; } -//static Sequence< Reference< XAxis > > AxisHelper::getAllAxesOfDiagram( const Reference< XDiagram >& xDiagram , bool bOnlyVisible ) @@ -846,7 +818,6 @@ Sequence< Reference< XAxis > > AxisHelper::getAllAxesOfDiagram( return ContainerHelper::ContainerToSequence( aAxisVector ); } -//static Sequence< Reference< beans::XPropertySet > > AxisHelper::getAllGrids( const Reference< XDiagram >& xDiagram ) { Sequence< Reference< XAxis > > aAllAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); @@ -875,7 +846,6 @@ Sequence< Reference< beans::XPropertySet > > AxisHelper::getAllGrids( const Refe return ContainerHelper::ContainerToSequence( aGridVector ); } -//static void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityList , const Reference< XDiagram>& xDiagram, sal_Bool bAxis ) { @@ -895,7 +865,6 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityL rPossibilityList[nIndex] = rPossibilityList[nIndex-3]; } -//static bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& xCooSys ) { Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY ); @@ -924,7 +893,6 @@ bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& x return false; } -//static bool AxisHelper::shouldAxisBeDisplayed( const Reference< XAxis >& xAxis , const Reference< XCoordinateSystem >& xCooSys ) { @@ -950,7 +918,6 @@ bool AxisHelper::shouldAxisBeDisplayed( const Reference< XAxis >& xAxis return bRet; } -//static void AxisHelper::getAxisOrGridExcistence( Sequence< sal_Bool >& rExistenceList , const Reference< XDiagram>& xDiagram, sal_Bool bAxis ) { @@ -976,7 +943,6 @@ void AxisHelper::getAxisOrGridExcistence( Sequence< sal_Bool >& rExistenceList } } -//static bool AxisHelper::changeVisibilityOfAxes( const Reference< XDiagram >& xDiagram , const Sequence< sal_Bool >& rOldExistenceList , const Sequence< sal_Bool >& rNewExistenceList @@ -1000,7 +966,6 @@ bool AxisHelper::changeVisibilityOfAxes( const Reference< XDiagram >& xDiagram return bChanged; } -//static bool AxisHelper::changeVisibilityOfGrids( const Reference< XDiagram >& xDiagram , const Sequence< sal_Bool >& rOldExistenceList , const Sequence< sal_Bool >& rNewExistenceList @@ -1021,7 +986,6 @@ bool AxisHelper::changeVisibilityOfGrids( const Reference< XDiagram >& xDiagram return bChanged; } -//static Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis( const Reference< XAxis >& xAxis , const Reference< XDiagram >& xDiagram ) diff --git a/chart2/source/tools/CharacterProperties.cxx b/chart2/source/tools/CharacterProperties.cxx index 4f5611218..6895b9aaa 100644..100755 --- a/chart2/source/tools/CharacterProperties.cxx +++ b/chart2/source/tools/CharacterProperties.cxx @@ -561,7 +561,6 @@ bool CharacterProperties::IsCharacterPropertyHandle( sal_Int32 nHandle ) nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); } -// static awt::FontDescriptor CharacterProperties::createFontDescriptorFromPropertySet( const uno::Reference< beans::XMultiPropertySet > & xMultiPropSet ) { diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 5a3e55fa7..287f6da49 100644..100755 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -54,21 +54,18 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -//static uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeHighlighter( const uno::Reference< view::XSelectionSupplier > & xSelectionSupplier ) { return new RangeHighlighter( xSelectionSupplier ); } -//static uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider( const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel ) { return new InternalDataProvider( xChartDoc, bConnectToModel ); } -//static uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< frame::XModel >& xModel ) { uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); @@ -77,7 +74,6 @@ uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< return NULL; } -// static uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< chart2::XChartDocument >& xChartDoc ) { try @@ -92,7 +88,6 @@ uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< return NULL; } -//static uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel ) { uno::Reference< XCoordinateSystem > XCooSys; @@ -106,7 +101,6 @@ uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( return XCooSys; } -// static ::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries( const uno::Reference< XChartDocument > & xChartDoc ) { @@ -119,7 +113,6 @@ uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( return aResult; } -// static ::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries( const uno::Reference< frame::XModel > & xModel ) { diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index 7f83e62d9..27598d76e 100644..100755 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -459,7 +459,6 @@ bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XC return sal_False; } -//static sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType ) { sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey @@ -480,7 +479,6 @@ sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno:: return nRet; } -//static sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType ) { sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40 diff --git a/chart2/source/tools/ChartViewHelper.cxx b/chart2/source/tools/ChartViewHelper.cxx index b77a23ace..aa0afdd58 100644..100755 --- a/chart2/source/tools/ChartViewHelper.cxx +++ b/chart2/source/tools/ChartViewHelper.cxx @@ -45,7 +45,6 @@ namespace chart using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; -//static void ChartViewHelper::setViewToDirtyState( const uno::Reference< frame::XModel >& xChartModel ) { try diff --git a/chart2/source/tools/ColorPerPointHelper.cxx b/chart2/source/tools/ColorPerPointHelper.cxx index 17e4670f3..55059b834 100644..100755 --- a/chart2/source/tools/ColorPerPointHelper.cxx +++ b/chart2/source/tools/ColorPerPointHelper.cxx @@ -42,7 +42,6 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -//static bool ColorPerPointHelper::hasPointOwnColor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xDataSeriesProperties @@ -72,7 +71,6 @@ bool ColorPerPointHelper::hasPointOwnColor( return false; } -// static bool ColorPerPointHelper::hasPointOwnProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesProperties diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx index 7281030a6..b4dd0afa6 100644..100755 --- a/chart2/source/tools/CommonConverters.cxx +++ b/chart2/source/tools/CommonConverters.cxx @@ -474,7 +474,6 @@ uno::Sequence< rtl::OUString > DataSequenceToStringSequence( const uno::Reference< data::XDataSequence >& xDataSequence ) { uno::Sequence< rtl::OUString > aResult; - OSL_ASSERT( xDataSequence.is()); if(!xDataSequence.is()) return aResult; diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 38a923520..51ee6d9de 100644..100755 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -81,7 +81,6 @@ using ::com::sun::star::chart2::XAnyDescriptionAccess; namespace chart { -// static DiagramHelper::tTemplateWithServiceName DiagramHelper::getTemplateForDiagram( const Reference< XDiagram > & xDiagram, @@ -140,7 +139,6 @@ DiagramHelper::tTemplateWithServiceName return aResult; } -// static void DiagramHelper::setVertical( const Reference< XDiagram > & xDiagram, bool bVertical /* = true */ ) @@ -218,7 +216,6 @@ void DiagramHelper::setVertical( } } -//static bool DiagramHelper::getVertical( const uno::Reference< chart2::XDiagram > & xDiagram, bool& rbFound, bool& rbAmbiguous ) { @@ -256,7 +253,6 @@ bool DiagramHelper::getVertical( const uno::Reference< chart2::XDiagram > & xDia return bValue; } -//static void DiagramHelper::setStackMode( const Reference< XDiagram > & xDiagram, StackMode eStackMode, @@ -348,8 +344,6 @@ void DiagramHelper::setStackMode( } } -//static - StackMode DiagramHelper::getStackMode( const Reference< XDiagram > & xDiagram, bool& rbFound, bool& rbAmbiguous ) { rbFound=false; @@ -391,7 +385,6 @@ StackMode DiagramHelper::getStackMode( const Reference< XDiagram > & xDiagram, b return eGlobalStackMode; } -// static StackMode DiagramHelper::getStackModeFromChartType( const Reference< XChartType > & xChartType, bool& rbFound, bool& rbAmbiguous, @@ -475,7 +468,6 @@ StackMode DiagramHelper::getStackModeFromChartType( return eStackMode; } -// static sal_Int32 DiagramHelper::getDimension( const Reference< XDiagram > & xDiagram ) { // -1: not yet set @@ -508,7 +500,6 @@ sal_Int32 DiagramHelper::getDimension( const Reference< XDiagram > & xDiagram ) return nResult; } -// static void DiagramHelper::setDimension( const Reference< XDiagram > & xDiagram, sal_Int32 nNewDimensionCount ) @@ -569,7 +560,6 @@ void DiagramHelper::setDimension( } } -// static void DiagramHelper::replaceCoordinateSystem( const Reference< XDiagram > & xDiagram, const Reference< XCoordinateSystem > & xCooSysToReplace, @@ -605,7 +595,6 @@ void DiagramHelper::replaceCoordinateSystem( } } -//static bool DiagramHelper::isSeriesAttachedToMainAxis( const uno::Reference< chart2::XDataSeries >& xDataSeries ) { @@ -613,7 +602,6 @@ bool DiagramHelper::isSeriesAttachedToMainAxis( return (nAxisIndex==0); } -//static bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis , const uno::Reference< chart2::XDataSeries >& xDataSeries , const uno::Reference< chart2::XDiagram >& xDiagram @@ -659,7 +647,6 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis return bChanged; } -//static uno::Reference< XAxis > DiagramHelper::getAttachedAxis( const uno::Reference< XDataSeries >& xSeries, const uno::Reference< XDiagram >& xDiagram ) @@ -667,7 +654,6 @@ uno::Reference< XAxis > DiagramHelper::getAttachedAxis( return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), xDiagram ); } -//static uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries( const uno::Reference< chart2::XDiagram >& xDiagram , const uno::Reference< XDataSeries >& xGivenDataSeries ) @@ -717,7 +703,6 @@ uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries( return 0; } -// static ::std::vector< Reference< XDataSeries > > DiagramHelper::getDataSeriesFromDiagram( const Reference< XDiagram > & xDiagram ) @@ -864,7 +849,6 @@ std::vector< Reference< XAxis > > lcl_getAxisHoldingCategoriesFromDiagram( } // anonymous namespace -//static bool DiagramHelper::isCategoryDiagram( const Reference< XDiagram >& xDiagram ) { @@ -903,7 +887,6 @@ bool DiagramHelper::isCategoryDiagram( return false; } -// static void DiagramHelper::setCategoriesToDiagram( const Reference< chart2::data::XLabeledDataSequence >& xCategories, const Reference< XDiagram >& xDiagram, @@ -935,7 +918,6 @@ void DiagramHelper::setCategoriesToDiagram( } } -// static Reference< data::XLabeledDataSequence > DiagramHelper::getCategoriesFromDiagram( const Reference< XDiagram > & xDiagram ) @@ -1030,7 +1012,6 @@ Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( return aRet; } -//static Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories( const Reference< XChartDocument >& xChartDoc ) { @@ -1232,7 +1213,6 @@ sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberF return nRet; } -// static Sequence< Reference< XChartType > > DiagramHelper::getChartTypesFromDiagram( const Reference< XDiagram > & xDiagram ) @@ -1262,7 +1242,6 @@ Sequence< Reference< XChartType > > return ContainerHelper::ContainerToSequence( aResult ); } -//static bool DiagramHelper::areChartTypesCompatible( const Reference< ::chart2::XChartType >& xFirstType, const Reference< ::chart2::XChartType >& xSecondType ) { @@ -1522,7 +1501,6 @@ bool DiagramHelper::isPieOrDonutChart( const ::com::sun::star::uno::Reference< return false; } -// static sal_Int32 DiagramHelper::getGeometry3D( const uno::Reference< chart2::XDiagram > & xDiagram, bool& rbFound, bool& rbAmbiguous ) @@ -1569,7 +1547,6 @@ sal_Int32 DiagramHelper::getGeometry3D( return nCommonGeom; } -// static void DiagramHelper::setGeometry3D( const Reference< chart2::XDiagram > & xDiagram, sal_Int32 nNewGeometry ) @@ -1585,7 +1562,6 @@ void DiagramHelper::setGeometry3D( } } -//static sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment( const Reference< chart2::XDiagram > & xDiagram, const Reference< chart2::XChartType >& xChartType ) @@ -1613,7 +1589,6 @@ sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment( return nResult; } -//static DiagramPositioningMode DiagramHelper::getDiagramPositioningMode( const uno::Reference< chart2::XDiagram > & xDiagram ) { @@ -1645,7 +1620,6 @@ void lcl_ensureRange0to1( double& rValue ) rValue=1.0; } -//static bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel, const awt::Rectangle& rPosRect /*100th mm*/ ) { @@ -1691,7 +1665,6 @@ bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel > return bChanged; } -//static awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference< frame::XModel >& xChartModel ) { awt::Rectangle aRet(-1,-1,-1,-1); @@ -1708,8 +1681,8 @@ awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aRelSize; awt::Size aAbsSize( - aRelSize.Primary * aPageSize.Width, - aRelSize.Secondary * aPageSize.Height ); + static_cast< sal_Int32 >( aRelSize.Primary * aPageSize.Width ), + static_cast< sal_Int32 >( aRelSize.Secondary * aPageSize.Height )); awt::Point aAbsPos( static_cast< sal_Int32 >( aRelPos.Primary * aPageSize.Width ), @@ -1722,7 +1695,6 @@ awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference return aRet; } -//static bool DiagramHelper::switchDiagramPositioningToExcludingPositioning( const uno::Reference< frame::XModel >& xChartModel , bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning ) diff --git a/chart2/source/tools/ErrorBar.cxx b/chart2/source/tools/ErrorBar.cxx index 6d1658fc9..934744fdf 100644..100755 --- a/chart2/source/tools/ErrorBar.cxx +++ b/chart2/source/tools/ErrorBar.cxx @@ -107,49 +107,72 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticErrorBarDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_STYLE, ::com::sun::star::chart::ErrorBarStyle::NONE ); - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_POS_ERROR, 0.0 ); - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_NEG_ERROR, 0.0 ); - ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_WEIGHT, 1.0 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_POS_ERROR, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_NEG_ERROR, true ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_STYLE, ::com::sun::star::chart::ErrorBarStyle::NONE ); + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_POS_ERROR, 0.0 ); + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_NEG_ERROR, 0.0 ); + ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_ERROR_BAR_WEIGHT, 1.0 ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_POS_ERROR, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_ERROR_BAR_SHOW_NEG_ERROR, true ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticErrorBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticErrorBarDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticErrorBarInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticErrorBarInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticErrorBarInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticErrorBarInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticErrorBarInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticErrorBarInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticErrorBarInfo_Initializer > +{ +}; bool lcl_isInternalData( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq ) { @@ -208,50 +231,23 @@ uno::Reference< util::XCloneable > SAL_CALL ErrorBar::createClone() uno::Any ErrorBar::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - LineProperties::AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticErrorBarDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL ErrorBar::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticErrorBarInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - ErrorBar::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL ErrorBar::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticErrorBarInfo::get(); } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index d77d03e0a..f99a15de3 100644..100755 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -87,9 +87,9 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: { uno::Reference< data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); - if( xDataProvider.is() ) + OUString aCatgoriesRange( DataSourceHelper::getRangeFromValues( m_xOriginalCategories ) ); + if( xDataProvider.is() && aCatgoriesRange.getLength() ) { - OUString aCatgoriesRange( DataSourceHelper::getRangeFromValues( m_xOriginalCategories ) ); const bool bFirstCellAsLabel = false; const bool bHasCategories = false; const uno::Sequence< sal_Int32 > aSequenceMapping; @@ -410,7 +410,6 @@ Sequence< OUString > lcl_getExplicitSimpleCategories( return aRet; } -//static Sequence< OUString > ExplicitCategoriesProvider::getExplicitSimpleCategories( const SplitCategoriesProvider& rSplitCategoriesProvider ) { @@ -574,7 +573,6 @@ std::vector< ComplexCategory > ExplicitCategoriesProvider::getCategoriesByLevel return aRet; } -// static OUString ExplicitCategoriesProvider::getCategoryByIndex( const Reference< XCoordinateSystem >& xCooSysModel , const uno::Reference< frame::XModel >& xChartModel diff --git a/chart2/source/tools/FillProperties.cxx b/chart2/source/tools/FillProperties.cxx index c0fe6ae4d..0837f5a3b 100644..100755 --- a/chart2/source/tools/FillProperties.cxx +++ b/chart2/source/tools/FillProperties.cxx @@ -136,7 +136,6 @@ void lcl_AddPropertiesToVector_without_BitmapProperties( ::std::vector< ::com::s | beans::PropertyAttribute::MAYBEDEFAULT )); } -//static void lcl_AddPropertiesToVector_only_BitmapProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ) { rOutProperties.push_back( diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 79a181d26..78a9a9e3f 100644..100755 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -379,11 +379,13 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum if( xSeq.is() ) aDataSeq = xSeq->getData(); sal_Int32 nLength = aDataSeq.getLength(); - if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) + sal_Int32 nCatLength = static_cast< sal_Int32 >(aNewCategories.size()); + if( nCatLength < nLength ) aNewCategories.resize( nLength ); - + else if( nLength < nCatLength ) + aDataSeq.realloc( nCatLength ); transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(), - aNewCategories.begin(), lcl_setAnyAtLevel(nL) ); + aNewCategories.begin(), lcl_setStringAtLevel(nL) ); } if( !nLevelCount ) { diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx index 2c699badb..af730925b 100644..100755 --- a/chart2/source/tools/LegendHelper.cxx +++ b/chart2/source/tools/LegendHelper.cxx @@ -46,7 +46,6 @@ namespace chart //............................................................................. -//static Reference< chart2::XLegend > LegendHelper::showLegend( const Reference< frame::XModel >& xModel , const uno::Reference< uno::XComponentContext >& xContext ) { @@ -78,7 +77,6 @@ Reference< chart2::XLegend > LegendHelper::showLegend( const Reference< frame::X return xLegend; } -//static void LegendHelper::hideLegend( const Reference< frame::XModel >& xModel ) { uno::Reference< chart2::XLegend > xLegend = LegendHelper::getLegend( xModel, 0, false ); @@ -89,7 +87,6 @@ void LegendHelper::hideLegend( const Reference< frame::XModel >& xModel ) } } -// static uno::Reference< chart2::XLegend > LegendHelper::getLegend( const uno::Reference< frame::XModel >& xModel , const uno::Reference< uno::XComponentContext >& xContext @@ -127,7 +124,6 @@ uno::Reference< chart2::XLegend > LegendHelper::getLegend( return xResult; } -// static bool LegendHelper::hasLegend( const uno::Reference< chart2::XDiagram > & xDiagram ) { bool bReturn = false; diff --git a/chart2/source/tools/LineProperties.cxx b/chart2/source/tools/LineProperties.cxx index 359b3a167..5d3d9a97b 100644..100755 --- a/chart2/source/tools/LineProperties.cxx +++ b/chart2/source/tools/LineProperties.cxx @@ -108,7 +108,6 @@ void LineProperties::AddDefaultsToMap( ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND ); } -//static bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xLineProperties ) { @@ -137,7 +136,6 @@ bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference< return bRet; } -//static void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xLineProperties ) { @@ -162,7 +160,6 @@ void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference< } } -//static void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xLineProperties ) { diff --git a/chart2/source/tools/NamedFillProperties.cxx b/chart2/source/tools/NamedFillProperties.cxx index 16df852d2..6cc08f083 100644..100755 --- a/chart2/source/tools/NamedFillProperties.cxx +++ b/chart2/source/tools/NamedFillProperties.cxx @@ -93,7 +93,6 @@ void NamedFillProperties::AddDefaultsToMap( { } -// static OUString NamedFillProperties::GetPropertyNameForHandle( sal_Int32 nHandle ) { //will return e.g. "FillGradientName" for PROP_FILL_GRADIENT_NAME diff --git a/chart2/source/tools/NamedLineProperties.cxx b/chart2/source/tools/NamedLineProperties.cxx index c7ef7ed79..e6b47e9b9 100644..100755 --- a/chart2/source/tools/NamedLineProperties.cxx +++ b/chart2/source/tools/NamedLineProperties.cxx @@ -81,7 +81,6 @@ void NamedLineProperties::AddDefaultsToMap( { } -// static OUString NamedLineProperties::GetPropertyNameForHandle( sal_Int32 nHandle ) { //will return e.g. "LineDashName" for PROP_LINE_DASH_NAME diff --git a/chart2/source/tools/NamedProperties.cxx b/chart2/source/tools/NamedProperties.cxx index 44840de15..e22c7f3d5 100644..100755 --- a/chart2/source/tools/NamedProperties.cxx +++ b/chart2/source/tools/NamedProperties.cxx @@ -47,7 +47,6 @@ void NamedProperties::AddPropertiesToVector( NamedLineProperties::AddPropertiesToVector( rOutProperties ); } -// static OUString NamedProperties::GetPropertyNameForHandle( sal_Int32 nHandle ) { OUString aName = NamedFillProperties::GetPropertyNameForHandle( nHandle ); diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index b7721e14c..bb91f50d5 100644..100755 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -340,7 +340,6 @@ bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const return bReturn; } -//static OUString ObjectIdentifier::createClassifiedIdentifierForObject( const Reference< uno::XInterface >& xObject , const Reference< frame::XModel >& xChartModel ) @@ -424,14 +423,12 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( return aRet; } -//static OUString ObjectIdentifier::createClassifiedIdentifierForParticle( const OUString& rParticle ) { return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, OUString() ); } -//static OUString ObjectIdentifier::createClassifiedIdentifierForParticles( const OUString& rParentParticle , const OUString& rChildParticle @@ -458,7 +455,6 @@ OUString ObjectIdentifier::createClassifiedIdentifierForParticles( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createParticleForDiagram( const Reference< XDiagram >& /*xDiagram*/ , const Reference< frame::XModel >& /*xChartModel*/ ) @@ -468,7 +464,6 @@ OUString ObjectIdentifier::createParticleForDiagram( return aRet; } -//static OUString ObjectIdentifier::createParticleForCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys , const Reference< frame::XModel >& xChartModel ) @@ -497,7 +492,6 @@ OUString ObjectIdentifier::createParticleForCoordinateSystem( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createParticleForAxis( sal_Int32 nDimensionIndex , sal_Int32 nAxisIndex ) @@ -511,7 +505,6 @@ OUString ObjectIdentifier::createParticleForAxis( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createParticleForGrid( sal_Int32 nDimensionIndex , sal_Int32 nAxisIndex ) @@ -525,7 +518,6 @@ OUString ObjectIdentifier::createParticleForGrid( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createClassifiedIdentifierForGrid( const Reference< XAxis >& xAxis , const Reference< frame::XModel >& xChartModel @@ -544,7 +536,6 @@ OUString ObjectIdentifier::createClassifiedIdentifierForGrid( return aGridCID; } -//static OUString ObjectIdentifier::createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex ) @@ -565,7 +556,6 @@ OUString ObjectIdentifier::createParticleForSeries( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createParticleForLegend( const Reference< XLegend >& /*xLegend*/ , const Reference< frame::XModel >& xChartModel ) @@ -583,7 +573,6 @@ OUString ObjectIdentifier::createParticleForLegend( return aRet.makeStringAndClear(); } -//static OUString ObjectIdentifier::createClassifiedIdentifier( enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES , const OUString& rParticleID )//e.g. SeriesID @@ -592,7 +581,6 @@ OUString ObjectIdentifier::createClassifiedIdentifier( eObjectType, rParticleID, m_aEmptyString ); } -//static OUString ObjectIdentifier::createClassifiedIdentifierWithParent( enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID , const OUString& rParticleID //e.g. Point Index or SubGrid Index @@ -619,13 +607,11 @@ OUString ObjectIdentifier::createClassifiedIdentifierWithParent( return aRet.makeStringAndClear(); } -//static const OUString& ObjectIdentifier::getPieSegmentDragMethodServiceName() { return m_aPieSegmentDragMethodServiceName; } -//static OUString ObjectIdentifier::createPieSegmentDragParameterString( sal_Int32 nOffsetPercent , const awt::Point& rMinimumPosition @@ -643,7 +629,6 @@ OUString ObjectIdentifier::createPieSegmentDragParameterString( return aRet.makeStringAndClear(); } -//static bool ObjectIdentifier::parsePieSegmentDragParameterString( const OUString& rDragParameterString , sal_Int32& rOffsetPercent @@ -681,7 +666,6 @@ bool ObjectIdentifier::parsePieSegmentDragParameterString( return true; } -//static OUString ObjectIdentifier::getDragMethodServiceName( const OUString& rCID ) { OUString aRet; @@ -707,7 +691,6 @@ OUString ObjectIdentifier::getDragMethodServiceName( const OUString& rCID ) return aRet; } -//static OUString ObjectIdentifier::getDragParameterString( const OUString& rCID ) { OUString aRet; @@ -733,7 +716,6 @@ OUString ObjectIdentifier::getDragParameterString( const OUString& rCID ) return aRet; } -//static bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier ) { ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier ); @@ -768,7 +750,6 @@ bool ObjectIdentifier::isDragableObject() return bReturn; } -//static bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier ) { ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier ); @@ -783,7 +764,6 @@ bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier return false; } -//static bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier ) { //the name of a shape is it's ClassifiedIdentifier @@ -846,7 +826,6 @@ bool ObjectIdentifier::areIdenticalObjects( const OUString& rCID1, const OUStrin return false; } -//static OUString ObjectIdentifier::getStringForType( ObjectType eObjectType ) { OUString aRet; @@ -933,7 +912,6 @@ OUString ObjectIdentifier::getStringForType( ObjectType eObjectType ) return aRet; } -//static ObjectType ObjectIdentifier::getObjectType( const OUString& rCID ) { ObjectType eRet; @@ -1020,7 +998,6 @@ ObjectType ObjectIdentifier::getObjectType() return eObjectType; } -//static OUString ObjectIdentifier::createDataCurveCID( const OUString& rSeriesParticle , sal_Int32 nCurveIndex @@ -1031,7 +1008,6 @@ OUString ObjectIdentifier::createDataCurveCID( return createClassifiedIdentifierWithParent( eType, aParticleID, rSeriesParticle ); } -//static OUString ObjectIdentifier::createDataCurveEquationCID( const OUString& rSeriesParticle , sal_Int32 nCurveIndex ) @@ -1040,7 +1016,6 @@ OUString ObjectIdentifier::createDataCurveEquationCID( return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION, aParticleID, rSeriesParticle ); } -//static OUString ObjectIdentifier::addChildParticle( const rtl::OUString& rParticle, const rtl::OUString& rChildParticle ) { OUStringBuffer aRet(rParticle); @@ -1053,7 +1028,6 @@ OUString ObjectIdentifier::addChildParticle( const rtl::OUString& rParticle, con return aRet.makeStringAndClear(); } -//static rtl::OUString ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ) { OUStringBuffer aRet( getStringForType( eObjectType ) ); @@ -1065,7 +1039,6 @@ rtl::OUString ObjectIdentifier::createChildParticleWithIndex( ObjectType eObject return aRet.makeStringAndClear(); } -//static sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const rtl::OUString& rParticleOrCID ) { sal_Int32 nRet = -1; @@ -1077,7 +1050,6 @@ sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const rtl::OUString& rPar return nRet; } -//static OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType , const rtl::OUString& rSeriesParticle , const rtl::OUString& rDragMethodServiceName @@ -1091,14 +1063,12 @@ OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType , rDragMethodServiceName, rDragParameterString ); } -//static OUString ObjectIdentifier::createPointCID( const OUString& rPointCID_Stub, sal_Int32 nIndex ) { OUString aRet(rPointCID_Stub); return aRet+=OUString::valueOf( nIndex ); } -//static OUString ObjectIdentifier::getParticleID( const OUString& rCID ) { OUString aRet; @@ -1108,7 +1078,6 @@ OUString ObjectIdentifier::getParticleID( const OUString& rCID ) return aRet; } -//static OUString ObjectIdentifier::getFullParentParticle( const OUString& rCID ) { OUString aRet; @@ -1127,7 +1096,6 @@ OUString ObjectIdentifier::getFullParentParticle( const OUString& rCID ) return aRet; } -//static OUString ObjectIdentifier::getObjectID( const rtl::OUString& rCID ) { OUString aRet; @@ -1143,7 +1111,6 @@ OUString ObjectIdentifier::getObjectID( const rtl::OUString& rCID ) return aRet; } -//static bool ObjectIdentifier::isCID( const OUString& rName ) { return rName.getLength() && rName.match( m_aProtocol ); @@ -1157,7 +1124,6 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY )); } -//static Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( const OUString& rObjectCID , const Reference< frame::XModel >& xChartModel ) @@ -1340,7 +1306,6 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( return xObjectProperties; } -//static Reference< XAxis > ObjectIdentifier::getAxisForCID( const OUString& rObjectCID , const Reference< frame::XModel >& xChartModel ) @@ -1356,7 +1321,6 @@ Reference< XAxis > ObjectIdentifier::getAxisForCID( return AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ); } -//static Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID( const OUString& rObjectCID , const Reference< frame::XModel >& xChartModel ) @@ -1383,7 +1347,6 @@ Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID( return xSeries; } -//static Reference< XDiagram > ObjectIdentifier::getDiagramForCID( const rtl::OUString& rObjectCID , const uno::Reference< frame::XModel >& xChartModel ) @@ -1415,7 +1378,6 @@ TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rC return eRet; } -// static OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID ) { sal_Int32 nDiagramIndex = -1; @@ -1430,7 +1392,6 @@ OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID ) return ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex ); } -//static OUString ObjectIdentifier::getMovedSeriesCID( const ::rtl::OUString& rObjectCID, sal_Bool bForward ) { sal_Int32 nDiagramIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CID/D=") ) ); diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx index 85e47db4d..6026e57e3 100644..100755 --- a/chart2/source/tools/RegressionCurveCalculator.cxx +++ b/chart2/source/tools/RegressionCurveCalculator.cxx @@ -55,7 +55,6 @@ RegressionCurveCalculator::RegressionCurveCalculator() : RegressionCurveCalculator::~RegressionCurveCalculator() {} -// static bool RegressionCurveCalculator::isLinearScaling( const Reference< chart2::XScaling > & xScaling ) { @@ -67,7 +66,6 @@ bool RegressionCurveCalculator::isLinearScaling( return (xServiceName.is() && xServiceName->getServiceName().equals( aLinScalingServiceName )); } -// static bool RegressionCurveCalculator::isLogarithmicScaling( const Reference< chart2::XScaling > & xScaling ) { diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index e14d2236f..2ac3755b1 100644..100755 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -88,7 +88,6 @@ namespace chart { //............................................................................. -// static Reference< XRegressionCurve > RegressionCurveHelper::createMeanValueLine( const Reference< XComponentContext > & xContext ) { @@ -96,7 +95,6 @@ Reference< XRegressionCurve > RegressionCurveHelper::createMeanValueLine( new MeanValueRegressionCurve( xContext )); } -// static Reference< XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServiceName( const Reference< XComponentContext > & xContext, ::rtl::OUString aServiceName ) @@ -134,7 +132,6 @@ Reference< XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServ // ------------------------------------------------------------ -// static Reference< XRegressionCurveCalculator > RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( ::rtl::OUString aServiceName ) { @@ -170,7 +167,6 @@ Reference< XRegressionCurveCalculator > RegressionCurveHelper::createRegressionC return xResult; } -// static void RegressionCurveHelper::initializeCurveCalculator( const Reference< XRegressionCurveCalculator > & xOutCurveCalculator, const Reference< data::XDataSource > & xSource, @@ -235,7 +231,6 @@ void RegressionCurveHelper::initializeCurveCalculator( xOutCurveCalculator->recalculateRegression( aXValues, aYValues ); } -// static void RegressionCurveHelper::initializeCurveCalculator( const Reference< XRegressionCurveCalculator > & xOutCurveCalculator, const Reference< XDataSeries > & xSeries, @@ -251,7 +246,6 @@ void RegressionCurveHelper::initializeCurveCalculator( // ---------------------------------------- -// static bool RegressionCurveHelper::hasMeanValueLine( const uno::Reference< XRegressionCurveContainer > & xRegCnt ) { @@ -276,7 +270,6 @@ bool RegressionCurveHelper::hasMeanValueLine( return false; } -// static bool RegressionCurveHelper::isMeanValueLine( const uno::Reference< chart2::XRegressionCurve > & xRegCurve ) { @@ -288,7 +281,6 @@ bool RegressionCurveHelper::isMeanValueLine( return false; } -// static uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getMeanValueLine( const uno::Reference< chart2::XRegressionCurveContainer > & xRegCnt ) @@ -314,7 +306,6 @@ uno::Reference< chart2::XRegressionCurve > return uno::Reference< chart2::XRegressionCurve >(); } -// static void RegressionCurveHelper::addMeanValueLine( uno::Reference< XRegressionCurveContainer > & xRegCnt, const uno::Reference< XComponentContext > & xContext, @@ -339,7 +330,6 @@ void RegressionCurveHelper::addMeanValueLine( } } -// static void RegressionCurveHelper::removeMeanValueLine( Reference< XRegressionCurveContainer > & xRegCnt ) { @@ -487,7 +477,6 @@ void RegressionCurveHelper::removeEquations( } } -// static void RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( tRegressionType eType, uno::Reference< XRegressionCurveContainer > & xRegCnt, @@ -510,7 +499,6 @@ void RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( } } -// static uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveNotMeanValueLine( const Reference< XRegressionCurveContainer > & xRegCnt ) { @@ -538,7 +526,6 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveN return NULL; } -// static RegressionCurveHelper::tRegressionType RegressionCurveHelper::getRegressionType( const Reference< XRegressionCurve > & xCurve ) { @@ -586,7 +573,6 @@ RegressionCurveHelper::tRegressionType RegressionCurveHelper::getRegressionType( return eResult; } -// static RegressionCurveHelper::tRegressionType RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( const Reference< XRegressionCurveContainer > & xRegCnt ) { @@ -650,7 +636,6 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR return aResult; } -// static ::std::vector< Reference< chart2::XRegressionCurve > > RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( const Reference< chart2::XDiagram > & xDiagram ) @@ -676,7 +661,6 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR return aResult; } -// static void RegressionCurveHelper::resetEquationPosition( const Reference< chart2::XRegressionCurve > & xCurve ) { diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx index 5b5c436a7..bf807aa00 100644..100755 --- a/chart2/source/tools/RegressionCurveModel.cxx +++ b/chart2/source/tools/RegressionCurveModel.cxx @@ -63,37 +63,63 @@ static const OUString lcl_aImplementationName_Potential( static const OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.RegressionCurve" )); -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticXXXDefaults_Initializer { - static uno::Sequence< Property > aPropSeq; + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + } +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticXXXDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticXXXDefaults_Initializer > +{ +}; + +struct StaticRegressionCurveInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } +}; - return aPropSeq; -} +struct StaticRegressionCurveInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionCurveInfoHelper_Initializer > +{ +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticRegressionCurveInfo_Initializer { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionCurveInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; - return aArrayHelper; -} +struct StaticRegressionCurveInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionCurveInfo_Initializer > +{ +}; } // anonymous namespace @@ -240,49 +266,23 @@ void RegressionCurveModel::fireModifyEvent() uno::Any RegressionCurveModel::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - LineProperties::AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticXXXDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL RegressionCurveModel::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticRegressionCurveInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - RegressionCurveModel::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL RegressionCurveModel::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticRegressionCurveInfo::get(); } // ================================================================================ diff --git a/chart2/source/tools/RegressionEquation.cxx b/chart2/source/tools/RegressionEquation.cxx index 4ca34a8e3..0390f0fa6 100644..100755 --- a/chart2/source/tools/RegressionEquation.cxx +++ b/chart2/source/tools/RegressionEquation.cxx @@ -118,32 +118,51 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID )); } -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticRegressionEquationDefaults_Initializer { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false ); -// ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, ::rtl::OUString( sal_Unicode( '\n' ))); - - // override other defaults - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); - - float fDefaultCharHeight = 10.0; - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); -} + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::LineProperties::AddDefaultsToMap( rOutMap ); + ::chart::FillProperties::AddDefaultsToMap( rOutMap ); + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); + + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false ); + //::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, ::rtl::OUString( sal_Unicode( '\n' ))); + + // override other defaults + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); + } +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticRegressionEquationDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticRegressionEquationDefaults_Initializer > { - static uno::Sequence< Property > aPropSeq; +}; - // /-- - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +struct StaticRegressionEquationInfoHelper_Initializer +{ + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } + +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); ::chart::LineProperties::AddPropertiesToVector( aProperties ); @@ -151,25 +170,31 @@ const uno::Sequence< Property > & lcl_GetPropertySequence() ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticRegressionEquationInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionEquationInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticRegressionEquationInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionEquationInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticRegressionEquationInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionEquationInfo_Initializer > +{ +}; } // anonymous namespace @@ -206,56 +231,25 @@ uno::Reference< util::XCloneable > SAL_CALL RegressionEquation::createClone() uno::Any RegressionEquation::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - LineProperties::AddDefaultsToMap( aStaticDefaults ); - FillProperties::AddDefaultsToMap( aStaticDefaults ); - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - - // overrides a line property - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticRegressionEquationDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL RegressionEquation::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticRegressionEquationInfoHelper::get(); } // ____ XPropertySet ____ -Reference< beans::XPropertySetInfo > SAL_CALL - RegressionEquation::getPropertySetInfo() +Reference< beans::XPropertySetInfo > SAL_CALL RegressionEquation::getPropertySetInfo() throw (uno::RuntimeException) { - static Reference< beans::XPropertySetInfo > xInfo; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - lcl_getInfoHelper()); - } - - return xInfo; - // \-- + return *StaticRegressionEquationInfo::get(); } - // ____ XModifyBroadcaster ____ void SAL_CALL RegressionEquation::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) diff --git a/chart2/source/tools/RelativePositionHelper.cxx b/chart2/source/tools/RelativePositionHelper.cxx index 368c27983..41022f0aa 100644..100755 --- a/chart2/source/tools/RelativePositionHelper.cxx +++ b/chart2/source/tools/RelativePositionHelper.cxx @@ -36,7 +36,6 @@ using namespace ::com::sun::star; namespace chart { -// static chart2::RelativePosition RelativePositionHelper::getReanchoredPosition( const chart2::RelativePosition & rPosition, const chart2::RelativeSize & rObjectSize, @@ -132,7 +131,6 @@ chart2::RelativePosition RelativePositionHelper::getReanchoredPosition( } -// static awt::Point RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( awt::Point aPoint , awt::Size aObjectSize @@ -191,7 +189,6 @@ awt::Point RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( return aResult; } -// static awt::Point RelativePositionHelper::getCenterOfAnchoredObject( awt::Point aPoint , awt::Size aUnrotatedObjectSize diff --git a/chart2/source/tools/RelativeSizeHelper.cxx b/chart2/source/tools/RelativeSizeHelper.cxx index cd10a5b03..330ce339f 100644..100755 --- a/chart2/source/tools/RelativeSizeHelper.cxx +++ b/chart2/source/tools/RelativeSizeHelper.cxx @@ -45,7 +45,6 @@ using ::rtl::OUString; namespace chart { -// static double RelativeSizeHelper::calculate( double fValue, const Size & rOldReferenceSize, @@ -61,7 +60,6 @@ double RelativeSizeHelper::calculate( * fValue; } -// static void RelativeSizeHelper::adaptFontSizes( const Reference< XPropertySet > & xTargetProperties, const Size & rOldReferenceSize, diff --git a/chart2/source/tools/StatisticsHelper.cxx b/chart2/source/tools/StatisticsHelper.cxx index 19747b530..d0cc9f9cd 100644..100755 --- a/chart2/source/tools/StatisticsHelper.cxx +++ b/chart2/source/tools/StatisticsHelper.cxx @@ -181,7 +181,6 @@ void lcl_setXMLRangePropertyAtDataSequence( namespace chart { -// static double StatisticsHelper::getVariance( const Sequence< double > & rData, bool bUnbiasedEstimator /* = false */ ) @@ -190,7 +189,6 @@ double StatisticsHelper::getVariance( return lcl_getVariance( rData, nValCount, bUnbiasedEstimator ); } -// static double StatisticsHelper::getStandardDeviation( const Sequence< double > & rData ) { double fResult = getVariance( rData ); @@ -200,7 +198,6 @@ double StatisticsHelper::getStandardDeviation( const Sequence< double > & rData return fResult; } -// static double StatisticsHelper::getStandardError( const Sequence< double > & rData ) { sal_Int32 nValCount; @@ -221,7 +218,6 @@ double StatisticsHelper::getStandardError( const Sequence< double > & rData ) return fResult; } -// static Reference< chart2::data::XLabeledDataSequence > StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( const Reference< chart2::data::XDataSource > & xDataSource, bool bPositiveValue, @@ -240,7 +236,6 @@ Reference< chart2::data::XLabeledDataSequence > StatisticsHelper::getErrorLabele return xResult; } -// static Reference< chart2::data::XDataSequence > StatisticsHelper::getErrorDataSequenceFromDataSource( const Reference< chart2::data::XDataSource > & xDataSource, bool bPositiveValue, @@ -256,7 +251,6 @@ Reference< chart2::data::XDataSequence > StatisticsHelper::getErrorDataSequenceF return xLSeq->getValues(); } -// static double StatisticsHelper::getErrorFromDataSource( const Reference< chart2::data::XDataSource > & xDataSource, sal_Int32 nIndex, @@ -286,7 +280,6 @@ double StatisticsHelper::getErrorFromDataSource( return fResult; } -// static void StatisticsHelper::setErrorDataSequence( const Reference< chart2::data::XDataSource > & xDataSource, const Reference< chart2::data::XDataProvider > & xDataProvider, @@ -318,7 +311,6 @@ void StatisticsHelper::setErrorDataSequence( } } -// static Reference< beans::XPropertySet > StatisticsHelper::addErrorBars( const Reference< chart2::XDataSeries > & xDataSeries, const Reference< uno::XComponentContext > & xContext, @@ -348,7 +340,6 @@ Reference< beans::XPropertySet > StatisticsHelper::addErrorBars( return xErrorBar; } -// static Reference< beans::XPropertySet > StatisticsHelper::getErrorBars( const Reference< chart2::XDataSeries > & xDataSeries, bool bYError /* = true */ ) @@ -363,7 +354,6 @@ Reference< beans::XPropertySet > StatisticsHelper::getErrorBars( return xErrorBar; } -// static bool StatisticsHelper::hasErrorBars( const Reference< chart2::XDataSeries > & xDataSeries, bool bYError /* = true */ ) @@ -376,7 +366,6 @@ bool StatisticsHelper::hasErrorBars( nStyle != ::com::sun::star::chart::ErrorBarStyle::NONE ); } -// static void StatisticsHelper::removeErrorBars( const Reference< chart2::XDataSeries > & xDataSeries, bool bYError /* = true */ ) @@ -387,7 +376,6 @@ void StatisticsHelper::removeErrorBars( ::com::sun::star::chart::ErrorBarStyle::NONE )); } -// static bool StatisticsHelper::usesErrorBarRanges( const Reference< chart2::XDataSeries > & xDataSeries, bool bYError /* = true */ ) diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index ac40ff6fb..d1b20e9b1 100644..100755 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -1172,7 +1172,6 @@ void ThreeDHelper::setCameraDistance( } } -//static double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance ) { double fRet = fCameraDistance; @@ -1188,7 +1187,6 @@ double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance ) return fRet; } -//static double ThreeDHelper::PerspectiveToCameraDistance( double fPerspective ) { double fRet = fPerspective; @@ -1204,7 +1202,6 @@ double ThreeDHelper::PerspectiveToCameraDistance( double fPerspective ) return fRet; } -//static ThreeDLookScheme ThreeDHelper::detectScheme( const uno::Reference< XDiagram >& xDiagram ) { ThreeDLookScheme aScheme = ThreeDLookScheme_Unknown; @@ -1278,7 +1275,6 @@ void ThreeDHelper::setScheme( const uno::Reference< XDiagram >& xDiagram, ThreeD } -//static void ThreeDHelper::set3DSettingsToDefault( const uno::Reference< beans::XPropertySet >& xSceneProperties ) { Reference< beans::XPropertyState > xState( xSceneProperties, uno::UNO_QUERY ); @@ -1291,7 +1287,6 @@ void ThreeDHelper::set3DSettingsToDefault( const uno::Reference< beans::XPropert ThreeDHelper::setDefaultIllumination( xSceneProperties ); } -//static void ThreeDHelper::setDefaultRotation( const uno::Reference< beans::XPropertySet >& xSceneProperties, bool bPieOrDonut ) { if( !xSceneProperties.is() ) @@ -1307,14 +1302,12 @@ void ThreeDHelper::setDefaultRotation( const uno::Reference< beans::XPropertySet uno::makeAny( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation ))); } -//static void ThreeDHelper::setDefaultRotation( const uno::Reference< beans::XPropertySet >& xSceneProperties ) { bool bPieOrDonut( DiagramHelper::isPieOrDonutChart( uno::Reference< XDiagram >(xSceneProperties, uno::UNO_QUERY) ) ); ThreeDHelper::setDefaultRotation( xSceneProperties, bPieOrDonut ); } -//static void ThreeDHelper::setDefaultIllumination( const uno::Reference< beans::XPropertySet >& xSceneProperties ) { if( !xSceneProperties.is() ) @@ -1341,7 +1334,6 @@ void ThreeDHelper::setDefaultIllumination( const uno::Reference< beans::XPropert lcl_setLightsForScheme( xSceneProperties, aScheme ); } -//static void ThreeDHelper::getRoundedEdgesAndObjectLines( const uno::Reference< XDiagram > & xDiagram , sal_Int32& rnRoundedEdges, sal_Int32& rnObjectLines ) @@ -1441,7 +1433,6 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines( ASSERT_EXCEPTION( e ); } } -//static void ThreeDHelper::setRoundedEdgesAndObjectLines( const uno::Reference< XDiagram > & xDiagram , sal_Int32 nRoundedEdges, sal_Int32 nObjectLines ) @@ -1471,7 +1462,6 @@ void ThreeDHelper::setRoundedEdgesAndObjectLines( } } -//static CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( const Reference< beans::XPropertySet >& xSceneProperties ) { CuboidPlanePosition eRet(CuboidPlanePosition_Left); @@ -1488,7 +1478,6 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeft return eRet; } -//static CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( const Reference< beans::XPropertySet >& xSceneProperties ) { CuboidPlanePosition eRet(CuboidPlanePosition_Back); @@ -1505,7 +1494,6 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBack return eRet; } -//static CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( const Reference< beans::XPropertySet >& xSceneProperties ) { CuboidPlanePosition eRet(CuboidPlanePosition_Bottom); diff --git a/chart2/source/tools/WrappedIgnoreProperty.cxx b/chart2/source/tools/WrappedIgnoreProperty.cxx index aa1915669..64b5171dc 100644..100755 --- a/chart2/source/tools/WrappedIgnoreProperty.cxx +++ b/chart2/source/tools/WrappedIgnoreProperty.cxx @@ -92,7 +92,6 @@ beans::PropertyState WrappedIgnoreProperty::getPropertyState( const Reference< b : beans::PropertyState_DIRECT_VALUE ); } -//static void WrappedIgnoreProperties::addIgnoreLineProperties( std::vector< WrappedProperty* >& rList ) { rList.push_back( new WrappedIgnoreProperty( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) ) ); @@ -104,14 +103,12 @@ void WrappedIgnoreProperties::addIgnoreLineProperties( std::vector< WrappedPrope rList.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_ROUND ) ) ); } -//static void WrappedIgnoreProperties::addIgnoreFillProperties( std::vector< WrappedProperty* >& rList ) { addIgnoreFillProperties_without_BitmapProperties( rList ); addIgnoreFillProperties_only_BitmapProperties( rList ); } -//static void WrappedIgnoreProperties::addIgnoreFillProperties_without_BitmapProperties( ::std::vector< WrappedProperty* >& rList ) { rList.push_back( new WrappedIgnoreProperty( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_SOLID ) ) ); @@ -126,7 +123,6 @@ void WrappedIgnoreProperties::addIgnoreFillProperties_without_BitmapProperties( rList.push_back( new WrappedIgnoreProperty( C2U( "FillBackground" ), uno::makeAny( sal_Bool(sal_False) ) ) ); } -//static void WrappedIgnoreProperties::addIgnoreFillProperties_only_BitmapProperties( ::std::vector< WrappedProperty* >& rList ) { // rList.push_back( new WrappedIgnoreProperty( C2U( "FillBitmapName" ), uno::makeAny( ::rtl::OUString() ) ) ); diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index f66d16d0c..65faf9fed 100644..100755 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -66,8 +66,7 @@ Reference< beans::XPropertyState > WrappedPropertySet::getInnerPropertyState() void WrappedPropertySet::clearWrappedPropertySet() { - // /-- - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence //delete all wrapped properties if(m_pWrappedPropertyMap) @@ -84,22 +83,27 @@ void WrappedPropertySet::clearWrappedPropertySet() DELETEZ(m_pWrappedPropertyMap); m_xInfo = NULL; - // \-- } //XPropertySet Reference< beans::XPropertySetInfo > SAL_CALL WrappedPropertySet::getPropertySetInfo( ) throw (uno::RuntimeException) { - if( !m_xInfo.is() ) + Reference< beans::XPropertySetInfo > xInfo = m_xInfo; + if( !xInfo.is() ) { - // /-- - ::osl::MutexGuard aGuard( m_aMutex ); - if( !m_xInfo.is() ) + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence + xInfo = m_xInfo; + if( !xInfo.is() ) { - m_xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + m_xInfo = xInfo; } - // \-- + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); } return m_xInfo; } @@ -435,16 +439,21 @@ Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence ::cppu::IPropertyArrayHelper& WrappedPropertySet::getInfoHelper() { - if(!m_pPropertyArrayHelper) + ::cppu::OPropertyArrayHelper* p = m_pPropertyArrayHelper; + if(!p) { - // /-- - ::osl::MutexGuard aGuard( m_aMutex ); - if(!m_pPropertyArrayHelper) + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence + p = m_pPropertyArrayHelper; + if(!p) { - sal_Bool bSorted = sal_True; - m_pPropertyArrayHelper = new ::cppu::OPropertyArrayHelper( getPropertySequence(), bSorted ); + p = new ::cppu::OPropertyArrayHelper( getPropertySequence(), sal_True ); + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + m_pPropertyArrayHelper = p; } - // \-- + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); } return *m_pPropertyArrayHelper; } @@ -453,14 +462,15 @@ Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap() { - if(!m_pWrappedPropertyMap) + tWrappedPropertyMap* p = m_pWrappedPropertyMap; + if(!p) { - // /-- - ::osl::MutexGuard aGuard( m_aMutex ); - if(!m_pWrappedPropertyMap) + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence + p = m_pWrappedPropertyMap; + if(!p) { std::vector< WrappedProperty* > aPropList( createWrappedProperties() ); - m_pWrappedPropertyMap = new tWrappedPropertyMap(); + p = new tWrappedPropertyMap(); for( std::vector< WrappedProperty* >::const_iterator aIt = aPropList.begin(); aIt!=aPropList.end(); ++aIt ) { @@ -474,18 +484,24 @@ tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap() OSL_ENSURE( false, "missing property in property list" ); delete pProperty;//we are owner or the created WrappedProperties } - else if( m_pWrappedPropertyMap->find( nHandle ) != m_pWrappedPropertyMap->end() ) + else if( p->find( nHandle ) != p->end() ) { //duplicate Wrapped property OSL_ENSURE( false, "duplicate Wrapped property" ); delete pProperty;//we are owner or the created WrappedProperties } else - (*m_pWrappedPropertyMap)[ nHandle ] = pProperty; + (*p)[ nHandle ] = pProperty; } } + + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + m_pWrappedPropertyMap = p; } - // \-- + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); } return *m_pWrappedPropertyMap; } diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx new file mode 100644 index 000000000..3edd4776c --- /dev/null +++ b/chart2/source/view/axes/TickmarkHelper.cxx @@ -0,0 +1,934 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "TickmarkHelper.hxx" +#include "ViewDefines.hxx" +#include <rtl/math.hxx> +#include <tools/debug.hxx> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; + +TickInfo::TickInfo() +: fScaledTickValue( 0.0 ) +, fUnscaledTickValue( 0.0 ) +, aTickScreenPosition(0.0,0.0) +, bPaintIt( true ) +, xTextShape( NULL ) +, nFactorForLimitedTextWidth(1) +{ +} + +void TickInfo::updateUnscaledValue( const uno::Reference< XScaling >& xInverseScaling ) +{ + if( xInverseScaling.is() ) + this->fUnscaledTickValue = xInverseScaling->doScaling( this->fScaledTickValue ); + else + this->fUnscaledTickValue = this->fScaledTickValue; +} + +sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const +{ + //return the positive distance between the two first tickmarks in screen values + + B2DVector aDistance = rOherTickInfo.aTickScreenPosition - aTickScreenPosition; + sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength()); + if(nRet<0) + nRet *= -1; + return nRet; +} + +PureTickIter::PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ) + : m_rTickVector(rTickInfoVector) + , m_aTickIter(m_rTickVector.begin()) +{ +} +PureTickIter::~PureTickIter() +{ +} +TickInfo* PureTickIter::firstInfo() +{ + m_aTickIter = m_rTickVector.begin(); + if(m_aTickIter!=m_rTickVector.end()) + return &*m_aTickIter; + return 0; +} +TickInfo* PureTickIter::nextInfo() +{ + m_aTickIter++; + if(m_aTickIter!=m_rTickVector.end()) + return &*m_aTickIter; + return 0; +} + +EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) + : m_pSimpleTicks(&rTicks) + , m_pInfoTicks(0) + , m_rIncrement(rIncrement) + , m_nMinDepth(0), m_nMaxDepth(0) + , m_nTickCount(0), m_pnPositions(NULL) + , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) + , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) +{ + initIter( nMinDepth, nMaxDepth ); +} + +EquidistantTickIter::EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) + : m_pSimpleTicks(NULL) + , m_pInfoTicks(&rTicks) + , m_rIncrement(rIncrement) + , m_nMinDepth(0), m_nMaxDepth(0) + , m_nTickCount(0), m_pnPositions(NULL) + , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) + , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) +{ + initIter( nMinDepth, nMaxDepth ); +} + +void EquidistantTickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth ) +{ + m_nMaxDepth = nMaxDepth; + if(nMaxDepth<0 || m_nMaxDepth>getMaxDepth()) + m_nMaxDepth=getMaxDepth(); + + sal_Int32 nDepth = 0; + for( nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) + m_nTickCount += getTickCount(nDepth); + + if(!m_nTickCount) + return; + + m_pnPositions = new sal_Int32[m_nMaxDepth+1]; + + m_pnPreParentCount = new sal_Int32[m_nMaxDepth+1]; + m_pbIntervalFinished = new bool[m_nMaxDepth+1]; + m_pnPreParentCount[0] = 0; + m_pbIntervalFinished[0] = false; + double fParentValue = getTickValue(0,0); + for( nDepth = 1; nDepth<=m_nMaxDepth ;nDepth++ ) + { + m_pbIntervalFinished[nDepth] = false; + + sal_Int32 nPreParentCount = 0; + sal_Int32 nCount = getTickCount(nDepth); + for(sal_Int32 nN = 0; nN<nCount; nN++) + { + if(getTickValue(nDepth,nN) < fParentValue) + nPreParentCount++; + else + break; + } + m_pnPreParentCount[nDepth] = nPreParentCount; + if(nCount) + { + double fNextParentValue = getTickValue(nDepth,0); + if( fNextParentValue < fParentValue ) + fParentValue = fNextParentValue; + } + } +} + +EquidistantTickIter::~EquidistantTickIter() +{ + delete[] m_pnPositions; + delete[] m_pnPreParentCount; + delete[] m_pbIntervalFinished; +} + +sal_Int32 EquidistantTickIter::getStartDepth() const +{ + //find the depth of the first visible tickmark: + //it is the depth of the smallest value + sal_Int32 nReturnDepth=0; + double fMinValue = DBL_MAX; + for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) + { + sal_Int32 nCount = getTickCount(nDepth); + if( !nCount ) + continue; + double fThisValue = getTickValue(nDepth,0); + if(fThisValue<fMinValue) + { + nReturnDepth = nDepth; + fMinValue = fThisValue; + } + } + return nReturnDepth; +} + +double* EquidistantTickIter::firstValue() +{ + if( gotoFirst() ) + { + m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); + return &m_fCurrentValue; + } + return NULL; +} + +TickInfo* EquidistantTickIter::firstInfo() +{ + if( m_pInfoTicks && gotoFirst() ) + return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; + return NULL; +} + +sal_Int32 EquidistantTickIter::getIntervalCount( sal_Int32 nDepth ) +{ + if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<0) + return 0; + + if(!nDepth) + return m_nTickCount; + + return m_rIncrement.SubIncrements[nDepth-1].IntervalCount; +} + +bool EquidistantTickIter::isAtLastPartTick() +{ + if(!m_nCurrentDepth) + return false; + sal_Int32 nIntervalCount = getIntervalCount( m_nCurrentDepth ); + if(!nIntervalCount || nIntervalCount == 1) + return true; + if( m_pbIntervalFinished[m_nCurrentDepth] ) + return false; + sal_Int32 nPos = m_pnPositions[m_nCurrentDepth]+1; + if(m_pnPreParentCount[m_nCurrentDepth]) + nPos += nIntervalCount-1 - m_pnPreParentCount[m_nCurrentDepth]; + bool bRet = nPos && nPos % (nIntervalCount-1) == 0; + if(!nPos && !m_pnPreParentCount[m_nCurrentDepth] + && m_pnPositions[m_nCurrentDepth-1]==-1 ) + bRet = true; + return bRet; +} + +bool EquidistantTickIter::gotoFirst() +{ + if( m_nMaxDepth<0 ) + return false; + if( !m_nTickCount ) + return false; + + for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) + m_pnPositions[nDepth] = -1; + + m_nCurrentPos = 0; + m_nCurrentDepth = getStartDepth(); + m_pnPositions[m_nCurrentDepth] = 0; + return true; +} + +bool EquidistantTickIter::gotoNext() +{ + if( m_nCurrentPos < 0 ) + return false; + m_nCurrentPos++; + + if( m_nCurrentPos >= m_nTickCount ) + return false; + + if( m_nCurrentDepth==m_nMaxDepth && isAtLastPartTick() ) + { + do + { + m_pbIntervalFinished[m_nCurrentDepth] = true; + m_nCurrentDepth--; + } + while( m_nCurrentDepth && isAtLastPartTick() ); + } + else if( m_nCurrentDepth<m_nMaxDepth ) + { + do + { + m_nCurrentDepth++; + } + while( m_nCurrentDepth<m_nMaxDepth ); + } + m_pbIntervalFinished[m_nCurrentDepth] = false; + m_pnPositions[m_nCurrentDepth] = m_pnPositions[m_nCurrentDepth]+1; + return true; +} + +bool EquidistantTickIter::gotoIndex( sal_Int32 nTickIndex ) +{ + if( nTickIndex < 0 ) + return false; + if( nTickIndex >= m_nTickCount ) + return false; + + if( nTickIndex < m_nCurrentPos ) + if( !gotoFirst() ) + return false; + + while( nTickIndex > m_nCurrentPos ) + if( !gotoNext() ) + return false; + + return true; +} + +sal_Int32 EquidistantTickIter::getCurrentIndex() const +{ + return m_nCurrentPos; +} +sal_Int32 EquidistantTickIter::getMaxIndex() const +{ + return m_nTickCount-1; +} + +double* EquidistantTickIter::nextValue() +{ + if( gotoNext() ) + { + m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); + return &m_fCurrentValue; + } + return NULL; +} + +TickInfo* EquidistantTickIter::nextInfo() +{ + if( m_pInfoTicks && gotoNext() && + static_cast< sal_Int32 >( + (*m_pInfoTicks)[m_nCurrentDepth].size()) > m_pnPositions[m_nCurrentDepth] ) + { + return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; + } + return NULL; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +double TickmarkHelper::getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ) +{ + //the returned value will be <= fMin and on a Major Tick given by rIncrement + if(rIncrement.Distance<=0.0) + return fMin; + + double fRet = rIncrement.BaseValue + + floor( approxSub( fMin, rIncrement.BaseValue ) + / rIncrement.Distance) + *rIncrement.Distance; + + if( fRet > fMin ) + { + if( !approxEqual(fRet, fMin) ) + fRet -= rIncrement.Distance; + } + return fRet; +} +double TickmarkHelper::getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ) +{ + //the returned value will be >= fMax and on a Major Tick given by rIncrement + if(rIncrement.Distance<=0.0) + return fMax; + + double fRet = rIncrement.BaseValue + + floor( approxSub( fMax, rIncrement.BaseValue ) + / rIncrement.Distance) + *rIncrement.Distance; + + if( fRet < fMax ) + { + if( !approxEqual(fRet, fMax) ) + fRet += rIncrement.Distance; + } + return fRet; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +TickmarkHelper::TickmarkHelper( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : m_rScale( rScale ) + , m_rIncrement( rIncrement ) + , m_xInverseScaling(NULL) + , m_pfCurrentValues(NULL) +{ + //@todo: make sure that the scale is valid for the scaling + + m_pfCurrentValues = new double[getTickDepth()]; + + if( m_rScale.Scaling.is() ) + { + m_xInverseScaling = m_rScale.Scaling->getInverseScaling(); + DBG_ASSERT( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" ); + } + + double fMin = m_fScaledVisibleMin = m_rScale.Minimum; + if( m_xInverseScaling.is() ) + { + m_fScaledVisibleMin = m_rScale.Scaling->doScaling(m_fScaledVisibleMin); + if(m_rIncrement.PostEquidistant ) + fMin = m_fScaledVisibleMin; + } + + double fMax = m_fScaledVisibleMax = m_rScale.Maximum; + if( m_xInverseScaling.is() ) + { + m_fScaledVisibleMax = m_rScale.Scaling->doScaling(m_fScaledVisibleMax); + if(m_rIncrement.PostEquidistant ) + fMax = m_fScaledVisibleMax; + } + + //-- + m_fOuterMajorTickBorderMin = TickmarkHelper::getMinimumAtIncrement( fMin, m_rIncrement ); + m_fOuterMajorTickBorderMax = TickmarkHelper::getMaximumAtIncrement( fMax, m_rIncrement ); + //-- + + m_fOuterMajorTickBorderMin_Scaled = m_fOuterMajorTickBorderMin; + m_fOuterMajorTickBorderMax_Scaled = m_fOuterMajorTickBorderMax; + if(!m_rIncrement.PostEquidistant && m_xInverseScaling.is() ) + { + m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); + + //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax + //it is assumed here, that the original range in the given Scale is valid + if( !rtl::math::isFinite(m_fOuterMajorTickBorderMin_Scaled) ) + { + m_fOuterMajorTickBorderMin += m_rIncrement.Distance; + m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + } + if( !rtl::math::isFinite(m_fOuterMajorTickBorderMax_Scaled) ) + { + m_fOuterMajorTickBorderMax -= m_rIncrement.Distance; + m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); + } + } +} + +TickmarkHelper* TickmarkHelper::createShiftedTickmarkHelper() const +{ + ExplicitIncrementData aShiftedIncrement( m_rIncrement ); + aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; + return new TickmarkHelper( m_rScale, aShiftedIncrement ); +} + +TickmarkHelper::~TickmarkHelper() +{ + delete[] m_pfCurrentValues; +} + +sal_Int32 TickmarkHelper::getTickDepth() const +{ + return m_rIncrement.SubIncrements.getLength() + 1; +} + +sal_Int32 TickmarkHelper::getMaxTickCount( sal_Int32 nDepth ) const +{ + //return the maximum amount of ticks + //possibly open intervals at the two ends of the region are handled as if they were completely visible + //(this is necessary for calculating the sub ticks at the borders correctly) + + if( nDepth >= getTickDepth() ) + return 0; + if( m_fOuterMajorTickBorderMax < m_fOuterMajorTickBorderMin ) + return 0; + if( m_rIncrement.Distance<=0.0) + return 0; + + double fSub; + if(m_rIncrement.PostEquidistant ) + fSub = approxSub( m_fScaledVisibleMax, m_fScaledVisibleMin ); + else + fSub = approxSub( m_rScale.Maximum, m_rScale.Minimum ); + + if (!isFinite(fSub)) + return 0; + + sal_Int32 nIntervalCount = static_cast<sal_Int32>( fSub / m_rIncrement.Distance ); + + nIntervalCount+=3; + for(sal_Int32 nN=0; nN<nDepth-1; nN++) + { + if( m_rIncrement.SubIncrements[nN].IntervalCount>1 ) + nIntervalCount *= m_rIncrement.SubIncrements[nN].IntervalCount; + } + + sal_Int32 nTickCount = nIntervalCount; + if(nDepth>0 && m_rIncrement.SubIncrements[nDepth-1].IntervalCount>1) + nTickCount = nIntervalCount * (m_rIncrement.SubIncrements[nDepth-1].IntervalCount-1); + + return nTickCount; +} + +double* TickmarkHelper::getMajorTick( sal_Int32 nTick ) const +{ + m_pfCurrentValues[0] = m_fOuterMajorTickBorderMin + nTick*m_rIncrement.Distance; + + if(m_pfCurrentValues[0]>m_fOuterMajorTickBorderMax) + { + if( !approxEqual(m_pfCurrentValues[0],m_fOuterMajorTickBorderMax) ) + return NULL; + } + if(m_pfCurrentValues[0]<m_fOuterMajorTickBorderMin) + { + if( !approxEqual(m_pfCurrentValues[0],m_fOuterMajorTickBorderMin) ) + return NULL; + } + + //return always the value after scaling + if(!m_rIncrement.PostEquidistant && m_xInverseScaling.is() ) + m_pfCurrentValues[0] = m_rScale.Scaling->doScaling( m_pfCurrentValues[0] ); + + return &m_pfCurrentValues[0]; +} + +double* TickmarkHelper::getMinorTick( sal_Int32 nTick, sal_Int32 nDepth + , double fStartParentTick, double fNextParentTick ) const +{ + //check validity of arguments + { + //DBG_ASSERT( fStartParentTick < fNextParentTick, "fStartParentTick >= fNextParentTick"); + if(fStartParentTick >= fNextParentTick) + return NULL; + if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<=0) + return NULL; + + //subticks are only calculated if they are laying between parent ticks: + if(nTick<=0) + return NULL; + if(nTick>=m_rIncrement.SubIncrements[nDepth-1].IntervalCount) + return NULL; + } + + bool bPostEquidistant = m_rIncrement.SubIncrements[nDepth-1].PostEquidistant; + + double fAdaptedStartParent = fStartParentTick; + double fAdaptedNextParent = fNextParentTick; + + if( !bPostEquidistant && m_xInverseScaling.is() ) + { + fAdaptedStartParent = m_xInverseScaling->doScaling(fStartParentTick); + fAdaptedNextParent = m_xInverseScaling->doScaling(fNextParentTick); + } + + double fDistance = (fAdaptedNextParent - fAdaptedStartParent)/m_rIncrement.SubIncrements[nDepth-1].IntervalCount; + + m_pfCurrentValues[nDepth] = fAdaptedStartParent + nTick*fDistance; + + //return always the value after scaling + if(!bPostEquidistant && m_xInverseScaling.is() ) + m_pfCurrentValues[nDepth] = m_rScale.Scaling->doScaling( m_pfCurrentValues[nDepth] ); + + if( !isWithinOuterBorder( m_pfCurrentValues[nDepth] ) ) + return NULL; + + return &m_pfCurrentValues[nDepth]; +} + +bool TickmarkHelper::isWithinOuterBorder( double fScaledValue ) const +{ + if(fScaledValue>m_fOuterMajorTickBorderMax_Scaled) + return false; + if(fScaledValue<m_fOuterMajorTickBorderMin_Scaled) + return false; + + return true; +} + + +bool TickmarkHelper::isVisible( double fScaledValue ) const +{ + if(fScaledValue>m_fScaledVisibleMax) + { + if( !approxEqual(fScaledValue,m_fScaledVisibleMax) ) + return false; + } + if(fScaledValue<m_fScaledVisibleMin) + { + if( !approxEqual(fScaledValue,m_fScaledVisibleMin) ) + return false; + } + return true; +} + +void TickmarkHelper::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + uno::Sequence< uno::Sequence< double > > aAllTicks; + + //create point sequences for each tick depth + sal_Int32 nDepthCount = this->getTickDepth(); + sal_Int32 nMaxMajorTickCount = this->getMaxTickCount( 0 ); + + aAllTicks.realloc(nDepthCount); + aAllTicks[0].realloc(nMaxMajorTickCount); + + sal_Int32 nRealMajorTickCount = 0; + double* pValue = NULL; + for( sal_Int32 nMajorTick=0; nMajorTick<nMaxMajorTickCount; nMajorTick++ ) + { + pValue = this->getMajorTick( nMajorTick ); + if(!pValue) + continue; + aAllTicks[0][nRealMajorTickCount] = *pValue; + nRealMajorTickCount++; + } + if(!nRealMajorTickCount) + return; + aAllTicks[0].realloc(nRealMajorTickCount); + + if(nDepthCount>0) + this->addSubTicks( 1, aAllTicks ); + + //so far we have added all ticks between the outer major tick marks + //this was necessary to create sub ticks correctly + //now we reduce all ticks to the visible ones that lie between the real borders + sal_Int32 nDepth = 0; + sal_Int32 nTick = 0; + for( nDepth = 0; nDepth < nDepthCount; nDepth++) + { + sal_Int32 nInvisibleAtLowerBorder = 0; + sal_Int32 nInvisibleAtUpperBorder = 0; + //we need only to check all ticks within the first major interval at each border + sal_Int32 nCheckCount = 1; + for(sal_Int32 nN=0; nN<nDepth; nN++) + { + if( m_rIncrement.SubIncrements[nN].IntervalCount>1 ) + nCheckCount *= m_rIncrement.SubIncrements[nN].IntervalCount; + } + uno::Sequence< double >& rTicks = aAllTicks[nDepth]; + sal_Int32 nCount = rTicks.getLength(); + //check lower border + for( nTick=0; nTick<nCheckCount && nTick<nCount; nTick++) + { + if( !isVisible( rTicks[nTick] ) ) + nInvisibleAtLowerBorder++; + } + //check upper border + for( nTick=nCount-1; nTick>nCount-1-nCheckCount && nTick>=0; nTick--) + { + if( !isVisible( rTicks[nTick] ) ) + nInvisibleAtUpperBorder++; + } + //resize sequence + if( !nInvisibleAtLowerBorder && !nInvisibleAtUpperBorder) + continue; + if( !nInvisibleAtLowerBorder ) + rTicks.realloc(nCount-nInvisibleAtUpperBorder); + else + { + sal_Int32 nNewCount = nCount-nInvisibleAtUpperBorder-nInvisibleAtLowerBorder; + if(nNewCount<0) + nNewCount=0; + + uno::Sequence< double > aOldTicks(rTicks); + rTicks.realloc(nNewCount); + for(nTick = 0; nTick<nNewCount; nTick++) + rTicks[nTick] = aOldTicks[nInvisibleAtLowerBorder+nTick]; + } + } + + //fill return value + rAllTickInfos.resize(aAllTicks.getLength()); + for( nDepth=0 ;nDepth<aAllTicks.getLength(); nDepth++ ) + { + sal_Int32 nCount = aAllTicks[nDepth].getLength(); + rAllTickInfos[nDepth].resize( nCount ); + for(sal_Int32 nN = 0; nN<nCount; nN++) + { + rAllTickInfos[nDepth][nN].fScaledTickValue = aAllTicks[nDepth][nN]; + } + } +} + +void TickmarkHelper::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + std::auto_ptr< TickmarkHelper > apShiftedTickmarkHelper( createShiftedTickmarkHelper() ); + apShiftedTickmarkHelper->getAllTicks( rAllTickInfos ); +} + +void TickmarkHelper::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence< double > >& rParentTicks ) const +{ + EquidistantTickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 ); + double* pfNextParentTick = aIter.firstValue(); + if(!pfNextParentTick) + return; + double fLastParentTick = *pfNextParentTick; + pfNextParentTick = aIter.nextValue(); + if(!pfNextParentTick) + return; + + sal_Int32 nMaxSubTickCount = this->getMaxTickCount( nDepth ); + if(!nMaxSubTickCount) + return; + + uno::Sequence< double > aSubTicks(nMaxSubTickCount); + sal_Int32 nRealSubTickCount = 0; + sal_Int32 nIntervalCount = m_rIncrement.SubIncrements[nDepth-1].IntervalCount; + + double* pValue = NULL; + for(; pfNextParentTick; fLastParentTick=*pfNextParentTick, pfNextParentTick = aIter.nextValue()) + { + for( sal_Int32 nPartTick = 1; nPartTick<nIntervalCount; nPartTick++ ) + { + pValue = this->getMinorTick( nPartTick, nDepth + , fLastParentTick, *pfNextParentTick ); + if(!pValue) + continue; + + aSubTicks[nRealSubTickCount] = *pValue; + nRealSubTickCount++; + } + } + + aSubTicks.realloc(nRealSubTickCount); + rParentTicks[nDepth] = aSubTicks; + if(m_rIncrement.SubIncrements.getLength()>nDepth) + addSubTicks( nDepth+1, rParentTicks ); +} + +//----------------------------------------------------------------------------- +// ___TickmarkHelper_2D___ +//----------------------------------------------------------------------------- +TickmarkHelper_2D::TickmarkHelper_2D( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement + //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ) + , const B2DVector& rStartScreenPos, const B2DVector& rEndScreenPos + , const B2DVector& rAxisLineToLabelLineShift ) + : TickmarkHelper( rScale, rIncrement ) + , m_aAxisStartScreenPosition2D(rStartScreenPos) + , m_aAxisEndScreenPosition2D(rEndScreenPos) + , m_aAxisLineToLabelLineShift(rAxisLineToLabelLineShift) + , m_fStrech_LogicToScreen(1.0) + , m_fOffset_LogicToScreen(0.0) +{ + double fWidthY = m_fScaledVisibleMax - m_fScaledVisibleMin; + if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation ) + { + m_fStrech_LogicToScreen = 1.0/fWidthY; + m_fOffset_LogicToScreen = -m_fScaledVisibleMin; + } + else + { + B2DVector aSwap(m_aAxisStartScreenPosition2D); + m_aAxisStartScreenPosition2D = m_aAxisEndScreenPosition2D; + m_aAxisEndScreenPosition2D = aSwap; + + m_fStrech_LogicToScreen = -1.0/fWidthY; + m_fOffset_LogicToScreen = -m_fScaledVisibleMax; + } +} + +TickmarkHelper* TickmarkHelper_2D::createShiftedTickmarkHelper() const +{ + ExplicitIncrementData aShiftedIncrement( m_rIncrement ); + aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; + + ::basegfx::B2DVector aStart( m_aAxisStartScreenPosition2D ); + ::basegfx::B2DVector aEnd( m_aAxisEndScreenPosition2D ); + if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation ) + std::swap( aStart, aEnd ); + + return new TickmarkHelper_2D( m_rScale, aShiftedIncrement, aStart, aEnd, m_aAxisLineToLabelLineShift ); +} + +TickmarkHelper_2D::~TickmarkHelper_2D() +{ +} + +bool TickmarkHelper_2D::isHorizontalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() ); +} +bool TickmarkHelper_2D::isVerticalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() ); +} + +sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter ) +{ + //return the positive distance between the two first tickmarks in screen values + //if there are less than two tickmarks -1 is returned + + const TickInfo* pFirstTickInfo = rIter.firstInfo(); + const TickInfo* pSecondTickInfo = rIter.nextInfo(); + if(!pSecondTickInfo || !pFirstTickInfo) + return -1; + + return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo ); +} + +B2DVector TickmarkHelper_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const +{ + B2DVector aRet(m_aAxisStartScreenPosition2D); + aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D) + *((fScaledLogicTickValue+m_fOffset_LogicToScreen)*m_fStrech_LogicToScreen); + return aRet; +} + +void TickmarkHelper_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints + , sal_Int32 nSequenceIndex + , double fScaledLogicTickValue, double fInnerDirectionSign + , const TickmarkProperties& rTickmarkProperties + , bool bPlaceAtLabels ) const +{ + if( fInnerDirectionSign==0.0 ) + fInnerDirectionSign = 1.0; + + B2DVector aTickScreenPosition = this->getTickScreenPosition2D(fScaledLogicTickValue); + if( bPlaceAtLabels ) + aTickScreenPosition += m_aAxisLineToLabelLineShift; + + B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; + aMainDirection.normalize(); + B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); + aOrthoDirection *= fInnerDirectionSign; + aOrthoDirection.normalize(); + + B2DVector aStart = aTickScreenPosition + aOrthoDirection*rTickmarkProperties.RelativePos; + B2DVector aEnd = aStart - aOrthoDirection*rTickmarkProperties.Length; + + rPoints[nSequenceIndex].realloc(2); + rPoints[nSequenceIndex][0].X = static_cast<sal_Int32>(aStart.getX()); + rPoints[nSequenceIndex][0].Y = static_cast<sal_Int32>(aStart.getY()); + rPoints[nSequenceIndex][1].X = static_cast<sal_Int32>(aEnd.getX()); + rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY()); +} + +B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const +{ + bool bFarAwayLabels = false; + if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos + || ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == rAxisProperties.m_eLabelPos ) + bFarAwayLabels = true; + + double fInnerDirectionSign = rAxisProperties.m_fInnerDirectionSign; + if( fInnerDirectionSign==0.0 ) + fInnerDirectionSign = 1.0; + + B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; + aMainDirection.normalize(); + B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); + aOrthoDirection *= fInnerDirectionSign; + aOrthoDirection.normalize(); + + B2DVector aStart(0,0), aEnd(0,0); + if( bFarAwayLabels ) + { + TickmarkProperties aProps( AxisProperties::getBiggestTickmarkProperties() ); + aStart = aOrthoDirection*aProps.RelativePos; + aEnd = aStart - aOrthoDirection*aProps.Length; + } + else + { + for( sal_Int32 nN=rAxisProperties.m_aTickmarkPropertiesList.size();nN--;) + { + const TickmarkProperties& rProps = rAxisProperties.m_aTickmarkPropertiesList[nN]; + B2DVector aNewStart = aOrthoDirection*rProps.RelativePos; + B2DVector aNewEnd = aNewStart - aOrthoDirection*rProps.Length; + if(aNewStart.getLength()>aStart.getLength()) + aStart=aNewStart; + if(aNewEnd.getLength()>aEnd.getLength()) + aEnd=aNewEnd; + } + } + + B2DVector aLabelDirection(aStart); + if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) + aLabelDirection = aEnd; + + B2DVector aOrthoLabelDirection(aOrthoDirection); + if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) + aOrthoLabelDirection*=-1.0; + aOrthoLabelDirection.normalize(); + if( bIncludeSpaceBetweenTickAndText ) + aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING; + if( bFarAwayLabels && bIncludeFarAwayDistanceIfSo ) + aLabelDirection += m_aAxisLineToLabelLineShift; + return aLabelDirection; +} + +void TickmarkHelper_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const +{ + rPoints[0].realloc(2); + rPoints[0][0].X = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getX()); + rPoints[0][0].Y = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getY()); + rPoints[0][1].X = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getX()); + rPoints[0][1].Y = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getY()); +} + +void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + //get the transformed screen values for all tickmarks in rAllTickInfos + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); + for( ; aDepthIter != aDepthEnd; aDepthIter++ ) + { + ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + TickInfo& rTickInfo = (*aTickIter); + rTickInfo.aTickScreenPosition = + this->getTickScreenPosition2D( rTickInfo.fScaledTickValue ); + } + } +} + +//----------------------------------------------------------------------------- +// ___TickmarkHelper_3D___ +//----------------------------------------------------------------------------- +TickmarkHelper_3D::TickmarkHelper_3D( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : TickmarkHelper( rScale, rIncrement ) +{ +} + +TickmarkHelper* TickmarkHelper_3D::createShiftedTickmarkHelper() const +{ + ExplicitIncrementData aShiftedIncrement( m_rIncrement ); + aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; + return new TickmarkHelper_3D( m_rScale, aShiftedIncrement ); +} + +TickmarkHelper_3D::~TickmarkHelper_3D() +{ +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 2d4ec8d70..88b525fca 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -157,7 +157,6 @@ TickmarkProperties AxisProperties::makeTickmarkPropertiesForComplexCategories( return aTickmarkProperties; } -//static TickmarkProperties AxisProperties::getBiggestTickmarkProperties() { TickmarkProperties aTickmarkProperties; diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index ce0fb0c84..435b9d328 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -192,7 +192,6 @@ VCartesianGrid::~VCartesianGrid() m_pPosHelper = NULL; } -//static void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList , const Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList ) { diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index 5c03445ac..23585d0c9 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -61,7 +61,6 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -//static VCoordinateSystem* VCoordinateSystem::createCoordinateSystem( const Reference< XCoordinateSystem >& xCooSysModel ) { diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index d6558af64..1a2363117 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -77,7 +77,6 @@ void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::st aTickFactory.getAllTicks( rAllTickInfos ); } -//static void VPolarGrid::createLinePointSequence_ForAngleAxis( drawing::PointSequenceSequence& rPoints , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 2d4b41609..93d4634f3 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -2137,7 +2137,6 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForCh return std::vector< ViewLegendEntry >(); } -//static VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( const uno::Reference<XChartType>& xChartTypeModel , sal_Int32 nDimensionCount diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 2aa7bfd75..e189e53bc 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -65,7 +65,7 @@ ChartItemPool::ChartItemPool(): SvULongs aTmp; ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS,aTmp); ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); + ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxUInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); //legend @@ -217,7 +217,6 @@ SfxMapUnit ChartItemPool::GetMetric(USHORT /* nWhich */) const return SFX_MAPUNIT_100TH_MM; } -// static SfxItemPool* ChartItemPool::CreateChartItemPool() { return new ChartItemPool(); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 4b759469f..72abc7abd 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -118,7 +118,6 @@ using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Any; using rtl::OUString; -//static const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId() { static uno::Sequence<sal_Int8> * pSeq = 0; @@ -135,7 +134,6 @@ const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId() return *pSeq; } -//static ExplicitValueProvider* ExplicitValueProvider::getExplicitValueProvider( const Reference< uno::XInterface >& xChartView ) { @@ -1839,7 +1837,6 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } -//static sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem @@ -1908,7 +1905,6 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe return nFormat; } -//static awt::Rectangle ExplicitValueProvider::addAxisTitleSizes( const Reference< frame::XModel >& xChartModel , const Reference< uno::XInterface >& xChartView @@ -1976,7 +1972,6 @@ awt::Rectangle ExplicitValueProvider::addAxisTitleSizes( return aRet; } -//static awt::Rectangle ExplicitValueProvider::substractAxisTitleSizes( const Reference< frame::XModel >& xChartModel , const Reference< uno::XInterface >& xChartView diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 8cf9da5cc..8d24fcab5 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -370,7 +370,6 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const rtl::OUString& rName ) return getNamedSdrObject( rName, GetPage(0) ); } -//static SdrObject* DrawModelWrapper::getNamedSdrObject( const String& rObjectCID, SdrObjList* pSearchList ) { if(!pSearchList || rObjectCID.Len()==0) @@ -390,7 +389,6 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const String& rObjectCID, SdrObj return 0; } -//static bool DrawModelWrapper::removeShape( const uno::Reference< drawing::XShape >& xShape ) { uno::Reference< container::XChild > xChild( xShape, uno::UNO_QUERY ); diff --git a/chart2/source/view/main/LabelPositionHelper.cxx b/chart2/source/view/main/LabelPositionHelper.cxx index d03442b4c..7ff9454e9 100644 --- a/chart2/source/view/main/LabelPositionHelper.cxx +++ b/chart2/source/view/main/LabelPositionHelper.cxx @@ -67,7 +67,6 @@ awt::Point LabelPositionHelper::transformSceneToScreenPosition( const drawing::P rScenePosition3D, m_xLogicTarget, m_pShapeFactory, m_nDimensionCount ); } -//static void LabelPositionHelper::changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment) { //HorizontalAdjustment @@ -107,7 +106,6 @@ void lcl_doDynamicFontResize( uno::Any* pAOldAndNewFontHeightAny } } -//static void LabelPositionHelper::doDynamicFontResize( tAnySequence& rPropValues , const tNameSequence& rPropNames , const uno::Reference< beans::XPropertySet >& xAxisModelProps @@ -431,7 +429,6 @@ void lcl_correctRotation_Right_Bottom( double& rfXCorrection, double& rfYCorrect }//end anonymous namespace -//static void LabelPositionHelper::correctPositionForRotation( const uno::Reference< drawing::XShape >& xShape2DText , LabelAlignment eLabelAlignment, const double fRotationAngle, bool bRotateAroundCenter ) { diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 766ea382a..6c5a28857 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -212,7 +212,6 @@ drawing::Position3D PlottingPositionHelper::transformScaledLogicToScene( return SequenceToPosition3D(aSeq); } -//static awt::Point PlottingPositionHelper::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D , const uno::Reference< drawing::XShapes >& xSceneTarget , ShapeFactory* pShapeFactory diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index 4fc2ad83d..a605eaace 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -58,7 +58,6 @@ void lcl_overwriteOrAppendValues( } // anonymous namespace -//static void PropertyMapper::setMappedProperties( const uno::Reference< beans::XPropertySet >& xTarget , const uno::Reference< beans::XPropertySet >& xSource @@ -193,7 +192,6 @@ uno::Any* PropertyMapper::getValuePointerForLimitedSpace( tAnySequence& rPropVal //Schatten UNO_NAME_CHAR_SHADOWED bool */ -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForCharacterProperties() { //shape property -- chart model object property @@ -260,7 +258,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForCharacterProper return m_aShapePropertyMapForCharacterProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForParagraphProperties() { //shape property -- chart model object property @@ -277,7 +274,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForParagraphProper return m_aShapePropertyMapForParagraphProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillProperties() { //shape property -- chart model object property @@ -306,7 +302,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillProperties( return m_aShapePropertyMapForFillProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineProperties() { //shape property -- chart model object property @@ -322,7 +317,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineProperties( return m_aShapePropertyMapForLineProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillAndLineProperties() { static tMakePropertyNameMap m_aShapePropertyMapForFillAndLineProperties = @@ -334,7 +328,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillAndLineProp return m_aShapePropertyMapForFillAndLineProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForTextShapeProperties() { static tMakePropertyNameMap m_aShapePropertyMapForTextShapeProperties = @@ -357,7 +350,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForTextShapeProper return m_aShapePropertyMapForTextShapeProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineSeriesProperties() { //shape property -- chart model object property @@ -374,7 +366,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineSeriesPrope return m_aShapePropertyMapForLineSeriesProperties; } -//static const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFilledSeriesProperties() { //shape property -- chart model object property @@ -410,7 +401,6 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFilledSeriesPro return m_aShapePropertyMapForFilledSeriesProperties; } -// static void PropertyMapper::setMultiProperties( const tNameSequence& rNames , const tAnySequence& rValues diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index e4985fdaf..3a1d38077 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -80,7 +80,6 @@ namespace chart //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -//static void ShapeFactory::setShapeName( const uno::Reference< drawing::XShape >& xShape , const rtl::OUString& rName ) { @@ -104,7 +103,6 @@ void ShapeFactory::setShapeName( const uno::Reference< drawing::XShape >& xShape //----------------------------------------------------------------------------- -//static rtl::OUString ShapeFactory::getShapeName( const uno::Reference< drawing::XShape >& xShape ) { rtl::OUString aRet; @@ -1961,7 +1959,6 @@ uno::Reference< drawing::XShape > return xShape; } -//static rtl::OUString ShapeFactory::getStackedString( const rtl::OUString& rString, bool bStacked ) { sal_Int32 nLen = rString.getLength(); @@ -1982,7 +1979,6 @@ rtl::OUString ShapeFactory::getStackedString( const rtl::OUString& rString, bool return aStackStr.makeStringAndClear(); } -//static bool ShapeFactory::hasPolygonAnyLines( drawing::PolyPolygonShape3D& rPoly) { // #i67757# check all contained polygons, if at least one polygon contains 2 or more points, return true @@ -1992,7 +1988,6 @@ bool ShapeFactory::hasPolygonAnyLines( drawing::PolyPolygonShape3D& rPoly) return false; } -//static bool ShapeFactory::isPolygonEmptyOrSinglePoint( drawing::PolyPolygonShape3D& rPoly) { // true, if empty polypolygon or one polygon with one point @@ -2000,7 +1995,6 @@ bool ShapeFactory::isPolygonEmptyOrSinglePoint( drawing::PolyPolygonShape3D& rPo ((rPoly.SequenceX.getLength() == 1) && (rPoly.SequenceX[0].getLength() <= 1)); } -//static void ShapeFactory::closePolygon( drawing::PolyPolygonShape3D& rPoly) { DBG_ASSERT( rPoly.SequenceX.getLength() <= 1, "ShapeFactory::closePolygon - single polygon expected" ); @@ -2011,7 +2005,6 @@ void ShapeFactory::closePolygon( drawing::PolyPolygonShape3D& rPoly) AddPointToPoly( rPoly, aFirst ); } -//static awt::Size ShapeFactory::calculateNewSizeRespectingAspectRatio( const awt::Size& rTargetSize , const awt::Size& rSourceSizeWithCorrectAspectRatio ) @@ -2027,7 +2020,6 @@ awt::Size ShapeFactory::calculateNewSizeRespectingAspectRatio( return aNewSize; } -//static awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( const awt::Point& rTargetAreaPosition , const awt::Size& rTargetAreaSize @@ -2039,7 +2031,6 @@ awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( return aNewPosition; } -//static ::basegfx::B2IRectangle ShapeFactory::getRectangleOfShape( const uno::Reference< drawing::XShape >& xShape ) { @@ -2055,7 +2046,6 @@ awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( } -//static awt::Size ShapeFactory::getSizeAfterRotation( const uno::Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) { diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index b4850724e..0654c5cee 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -651,7 +651,6 @@ void VLegend::setDefaultWritingMode( sal_Int16 nDefaultWritingMode ) // ---------------------------------------- -// static bool VLegend::isVisible( const Reference< XLegend > & xLegend ) { if( ! xLegend.is()) diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index 13200fc2d..3da38e924 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -104,7 +104,6 @@ void lcl_setPropetiesToShape( namespace chart { -// static Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( const Reference< drawing::XShapes > xSymbolContainer, chart2::LegendSymbolStyle eStyle, diff --git a/sc/inc/addruno.hxx b/sc/inc/addruno.hxx index 2cf8eca6e..3e17398a0 100644 --- a/sc/inc/addruno.hxx +++ b/sc/inc/addruno.hxx @@ -47,7 +47,7 @@ private: sal_Int32 nRefSheet; sal_Bool bIsRange; - sal_Bool ParseUIString( const String& rUIString ); + sal_Bool ParseUIString( const String& rUIString, ::formula::FormulaGrammar::AddressConvention eConv = ::formula::FormulaGrammar::CONV_OOO ); public: diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx index 73615c5cc..8fbb1179d 100644 --- a/sc/inc/cellsuno.hxx +++ b/sc/inc/cellsuno.hxx @@ -205,7 +205,6 @@ private: const ScPatternAttr* GetCurrentAttrsFlat(); const ScPatternAttr* GetCurrentAttrsDeep(); SfxItemSet* GetCurrentDataSet(bool bNoDflt = false); - const ScMarkData* GetMarkData(); void ForgetMarkData(); void ForgetCurrentAttrs(); @@ -218,6 +217,8 @@ private: const ScAddress* pLastPos); protected: + const ScMarkData* GetMarkData(); + // GetItemPropertyMap for derived classes must contain all entries, including base class virtual const SfxItemPropertyMap* GetItemPropertyMap(); virtual ::com::sun::star::beans::PropertyState GetOnePropertyState( @@ -815,7 +816,7 @@ public: //! really derive cell from range? -class ScCellObj : public ScCellRangeObj, +class SC_DLLPUBLIC ScCellObj : public ScCellRangeObj, public com::sun::star::text::XText, public com::sun::star::container::XEnumerationAccess, public com::sun::star::table::XCell, @@ -874,6 +875,8 @@ public: const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar ); const ScAddress& GetPosition() const { return aCellPos; } + void InputEnglishString( const ::rtl::OUString& rText ); + // XText virtual void SAL_CALL insertTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 82ddefbaa..3e54db1b2 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -556,7 +556,7 @@ public: SC_DLLPUBLIC BOOL HasTable( SCTAB nTab ) const; SC_DLLPUBLIC BOOL GetName( SCTAB nTab, String& rName ) const; SC_DLLPUBLIC BOOL GetCodeName( SCTAB nTab, String& rName ) const; - SC_DLLPUBLIC BOOL SetCodeName( SCTAB nTab, String& rName ); + SC_DLLPUBLIC BOOL SetCodeName( SCTAB nTab, const String& rName ); SC_DLLPUBLIC BOOL GetTable( const String& rName, SCTAB& rTab ) const; SC_DLLPUBLIC inline SCTAB GetTableCount() const { return nMaxTableNumber; } SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; } @@ -748,6 +748,7 @@ public: bool HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents = false ) const; bool HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents = false ) const; // on any sheet + bool HasAnyCalcNotification() const; BOOL HasCalcNotification( SCTAB nTab ) const; void SetCalcNotification( SCTAB nTab ); void ResetCalcNotifications(); @@ -926,8 +927,8 @@ public: /** Shrink a range to only include used data area. */ bool ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const; - void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, - SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown ) const; + SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown ) const; SC_DLLPUBLIC BOOL GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; SC_DLLPUBLIC BOOL GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; SC_DLLPUBLIC BOOL GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow, @@ -1512,6 +1513,8 @@ public: BOOL ContinueOnlineSpelling(); // TRUE = etwas gefunden + void RepaintRange( const ScRange& rRange ); + BOOL IsIdleDisabled() const { return bIdleDisabled; } void DisableIdle(BOOL bDo) { bIdleDisabled = bDo; } diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 19448b08c..45c20c78e 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -105,6 +105,7 @@ private: com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xDrawMarkerTab; com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xDrawDashTab; com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xChartDataProv; + com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xObjProvider; ::cppu::OInterfaceContainerHelper maChangesListeners; @@ -134,6 +135,8 @@ public: void AfterXMLLoading(sal_Bool bRet); ScSheetSaveData* GetSheetSaveData(); + void RepaintRange( const ScRange& rRange ); + bool HasChangesListeners() const; void NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges, diff --git a/sc/inc/fmtuno.hxx b/sc/inc/fmtuno.hxx index df5ef5b5e..31ec6dde2 100644 --- a/sc/inc/fmtuno.hxx +++ b/sc/inc/fmtuno.hxx @@ -95,7 +95,6 @@ public: void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc, formula::FormulaGrammar::Grammar eGrammar) const; - void DataChanged(); // XSheetConditionalEntries virtual void SAL_CALL addNew( const ::com::sun::star::uno::Sequence< @@ -157,13 +156,11 @@ class ScTableConditionalEntry : public cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo > { private: - ScTableConditionalFormat* pParent; ScCondFormatEntryItem aData; ScTableConditionalEntry(); // disabled public: - ScTableConditionalEntry(ScTableConditionalFormat* pPar, - const ScCondFormatEntryItem& aItem); + ScTableConditionalEntry(const ScCondFormatEntryItem& aItem); virtual ~ScTableConditionalEntry(); void GetData(ScCondFormatEntryItem& rData) const; @@ -241,7 +238,6 @@ public: ScValidationData* CreateValidationData( ScDocument* pDoc, formula::FormulaGrammar::Grammar eGrammar ) const; - void DataChanged(); // XSheetCondition virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator() diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 0b69bf5f7..4edd8aa73 100644..100755 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -218,7 +218,7 @@ #include <vcl/dndhelp.hxx> #include <vcl/edit.hxx> #include <vcl/field.hxx> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <vcl/gdimtf.hxx> #include <vcl/inputctx.hxx> #include <vcl/jobset.hxx> @@ -235,7 +235,7 @@ #include <vcl/svapp.hxx> #include <vcl/vclevent.hxx> #include <vcl/window.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vos/macros.hxx> #include <vos/object.hxx> #include <vos/types.hxx> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 28b876104..d4bfa1f1d 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -928,7 +928,6 @@ #define STR_REPLCELLSWARN (STR_START + 91) #define SCSTR_DPFUNCLISTBOX (STR_START + 92) -#define STR_PRINT_NOTHING (STR_START + 93) #define SCSTR_ALLFILTER (STR_START + 94) #define SCSTR_MOREBTN_MOREOPTIONS (STR_START + 95) #define SCSTR_MOREBTN_FEWEROPTIONS (STR_START + 96) diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 8ceacba61..4f77b7a57 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -610,6 +610,7 @@ #define SC_UNONAME_ADDRESS "Address" #define SC_UNONAME_UIREPR "UserInterfaceRepresentation" #define SC_UNONAME_PERSREPR "PersistentRepresentation" +#define SC_UNONAME_XLA1REPR "XLA1Representation" #define SC_UNONAME_REFSHEET "ReferenceSheet" // --> PB 2004-08-23 #i33095# Security Options diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx index 9d3d82270..2da833ac1 100644 --- a/sc/inc/viewuno.hxx +++ b/sc/inc/viewuno.hxx @@ -225,7 +225,8 @@ public: void SelectionChanged(); void VisAreaChanged(); - void SheetChanged(); + // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet + void SheetChanged( bool bSameTabButMoved = false ); bool IsMouseListening() const; sal_Bool MousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); sal_Bool MouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); diff --git a/sc/prj/build.lst b/sc/prj/build.lst index 08d9f97b2..f5ab2a5f7 100644 --- a/sc/prj/build.lst +++ b/sc/prj/build.lst @@ -1,4 +1,4 @@ -sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula MDDS:mdds oox NULL +sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula MDDS:mdds oox LIBXSLT:libxslt NULL sc sc usr1 - all sc_mkout NULL sc sc\inc nmake - all sc_inc NULL sc sc\prj get - all sc_prj NULL diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 56774ab29..f96916555 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1432,7 +1432,7 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified ) } } - pSh->Broadcast( ScPaintHint( aRange, PAINT_GRID ) ); + pDoc->RepaintRange( aRange ); } } } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index ef4917126..695160ca0 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -169,8 +169,7 @@ void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, BOOL bRemove RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aEnd.Col(), aOldRange.aEnd.Row(), aOldRange.aStart.Tab(), SC_MF_AUTO ); - if (pShell) - pShell->Broadcast( ScPaintHint( aOldRange, PAINT_GRID ) ); + RepaintRange( aOldRange ); } } } @@ -544,6 +543,14 @@ bool ScDocument::HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents ) return false; } +bool ScDocument::HasAnyCalcNotification() const +{ + for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++) + if (pTab[nTab] && pTab[nTab]->GetCalcNotification()) + return true; + return false; +} + BOOL ScDocument::HasCalcNotification( SCTAB nTab ) const { if (VALIDTAB(nTab) && pTab[nTab]) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index cbd55fd5f..d2cbca2c4 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -505,7 +505,7 @@ double ScDocument::RoundValueAsShown( double fVal, ULONG nFormat ) && nType != NUMBERFORMAT_TIME && nType != NUMBERFORMAT_DATETIME ) { short nPrecision; - if ( nFormat ) + if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) { nPrecision = (short)GetFormatTable()->GetFormatPrecision( nFormat ); switch ( nType ) @@ -524,7 +524,12 @@ double ScDocument::RoundValueAsShown( double fVal, ULONG nFormat ) } } else + { nPrecision = (short)GetDocOptions().GetStdPrecision(); + // #i115512# no rounding for automatic decimals + if (nPrecision == static_cast<short>(SvNumberFormatter::UNLIMITED_PRECISION)) + return fVal; + } double fRound = ::rtl::math::round( fVal, nPrecision ); if ( ::rtl::math::approxEqual( fVal, fRound ) ) return fVal; // durch Rundung hoechstens Fehler diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index bc2bf8c34..8b806b26e 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -94,6 +94,7 @@ #include "sc.hrc" #include "charthelper.hxx" #include "dpobject.hxx" +#include "docuno.hxx" #define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue() @@ -902,6 +903,16 @@ void ScDocument::RemoveAutoSpellObj() pTab[nTab]->RemoveAutoSpellObj(); } +void ScDocument::RepaintRange( const ScRange& rRange ) +{ + if ( bIsVisible && pShell ) + { + ScModelObj* pModel = ScModelObj::getImplementation( pShell->GetModel() ); + if ( pModel ) + pModel->RepaintRange( rRange ); // locked repaints are checked there + } +} + //------------------------------------------------------------------------ BOOL ScDocument::IdleCheckLinks() // TRUE = demnaechst wieder versuchen diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 76952fb3e..8daad951c 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -158,7 +158,7 @@ BOOL ScDocument::GetName( SCTAB nTab, String& rName ) const return FALSE; } -BOOL ScDocument::SetCodeName( SCTAB nTab, String& rName ) +BOOL ScDocument::SetCodeName( SCTAB nTab, const String& rName ) { if (VALIDTAB(nTab)) { diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index f350e8649..4f445e899 100755..100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -201,8 +201,11 @@ ScDPItemData::ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nD ScBaseCell* pCell = pDoc->GetCell( aPos ); if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() ) + { SetString ( aDocStr ); //[SODC_19347] add liyi //bErr = TRUE; //[SODC_19347] del liyi + mbFlag |= MK_ERR; + } else if ( pDoc->HasValueData( nCol, nRow, nDocTab ) ) { double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nDocTab)); @@ -672,8 +675,15 @@ bool ScDPTableDataCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, BOO { ScQueryEntry& rEntry = rParam.GetEntry(i); // we can only handle one single direct query - SCROW nId = GetItemDataId( (SCCOL)rEntry.nField, nRow, FALSE ); - const ScDPItemData* pCellData = GetItemDataById( (SCCOL)rEntry.nField, nId); + // #i115431# nField in QueryParam is the sheet column, not the field within the source range + SCCOL nQueryCol = (SCCOL)rEntry.nField; + if ( nQueryCol < rParam.nCol1 ) + nQueryCol = rParam.nCol1; + if ( nQueryCol > rParam.nCol2 ) + nQueryCol = rParam.nCol2; + SCCOL nSourceField = nQueryCol - rParam.nCol1; + SCROW nId = GetItemDataId( nSourceField, nRow, FALSE ); + const ScDPItemData* pCellData = GetItemDataById( nSourceField, nId ); BOOL bOk = FALSE; BOOL bTestEqual = FALSE; diff --git a/sc/source/core/data/makefile.mk b/sc/source/core/data/makefile.mk index 95ce6bcec..51c01febc 100755..100644 --- a/sc/source/core/data/makefile.mk +++ b/sc/source/core/data/makefile.mk @@ -140,6 +140,7 @@ EXCEPTIONSFILES= \ $(SLO)$/documen3.obj \ $(SLO)$/documen5.obj \ $(SLO)$/documen6.obj \ + $(SLO)$/documen8.obj \ $(SLO)$/documen9.obj \ $(SLO)$/dpcachetable.obj \ $(SLO)$/dptablecache.obj \ diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 79f9e0714..d90f5b94a 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -762,10 +762,13 @@ void ScPostIt::RemoveCaption() { pDrawPage->RecalcObjOrdNums(); // create drawing undo action (before removing the object to have valid draw page in undo action) - if( pDrawLayer && pDrawLayer->IsRecording() ) + bool bRecording = ( pDrawLayer && pDrawLayer->IsRecording() ); + if( bRecording ) pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoDeleteObject( *maNoteData.mpCaption ) ); // remove the object from the drawing page, delete if undo is disabled - pDrawPage->RemoveObject( maNoteData.mpCaption->GetOrdNum() ); + SdrObject* pObj = pDrawPage->RemoveObject( maNoteData.mpCaption->GetOrdNum() ); + if( !bRecording ) + SdrObject::Free( pObj ); } } maNoteData.mpCaption = 0; diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index a747307fa..f55fff64b 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -136,6 +136,13 @@ BOOL __EXPORT ScStyleSheet::SetParent( const String& rParentName ) { SfxItemSet& rParentSet = pStyle->GetItemSet(); GetItemSet().SetParent( &rParentSet ); + + // #i113491# Drag&Drop in the stylist's hierarchical view doesn't execute a slot, + // so the repaint has to come from here (after modifying the ItemSet). + // RepaintRange checks the document's IsVisible flag and locked repaints. + ScDocument* pDoc = static_cast<ScStyleSheetPool&>(GetPool()).GetDocument(); + if (pDoc) + pDoc->RepaintRange( ScRange( 0,0,0, MAXCOL,MAXROW,MAXTAB ) ); } } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index ff8022681..4d1fe0248 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1267,11 +1267,7 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW { UpdatePageBreaks(NULL); - SfxObjectShell* pDocSh = pDocument->GetDocumentShell(); - if (pDocSh) - pDocSh->Broadcast( ScPaintHint( - ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), - PAINT_GRID ) ); + pDocument->RepaintRange( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab) ); } } } diff --git a/sc/source/core/inc/core_pch.hxx b/sc/source/core/inc/core_pch.hxx index 5461e8c46..4e045c530 100644 --- a/sc/source/core/inc/core_pch.hxx +++ b/sc/source/core/inc/core_pch.hxx @@ -125,7 +125,7 @@ #include <vcl/outdev.hxx> #include <vcl/pointr.hxx> #include <vcl/ptrstyle.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/event.hxx> #include <tools/ownlist.hxx> #include <svl/itempool.hxx> diff --git a/sc/source/core/tool/formulaparserpool.cxx b/sc/source/core/tool/formulaparserpool.cxx index 251f037f8..1a743dd7a 100644 --- a/sc/source/core/tool/formulaparserpool.cxx +++ b/sc/source/core/tool/formulaparserpool.cxx @@ -33,7 +33,6 @@ #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sheet/XFilterFormulaParser.hpp> #include <rtl/instance.hxx> #include <comphelper/processfactory.hxx> @@ -62,27 +61,19 @@ public: const OUString& rNamespace ); private: - typedef ::std::hash_map< - OUString, - Reference< XSingleComponentFactory >, - OUStringHash, - ::std::equal_to< OUString > > FactoryMap; + typedef ::std::hash_map< OUString, Reference< XSingleComponentFactory >, OUStringHash > FactoryMap; - Reference< XComponentContext > mxContext; /// Default context of global process factory. + Reference< XComponentContext > mxContext; /// Global component context. FactoryMap maFactories; /// All parser factories, mapped by formula namespace. }; -ScParserFactoryMap::ScParserFactoryMap() +ScParserFactoryMap::ScParserFactoryMap() : + mxContext( ::comphelper::getProcessComponentContext() ) { - try + if( mxContext.is() ) try { - // get process factory and default component context - Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), UNO_SET_THROW ); - Reference< XPropertySet > xPropSet( xFactory, UNO_QUERY_THROW ); - mxContext.set( xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), UNO_QUERY_THROW ); - // enumerate all implementations of the FormulaParser service - Reference< XContentEnumerationAccess > xFactoryEA( xFactory, UNO_QUERY_THROW ); + Reference< XContentEnumerationAccess > xFactoryEA( mxContext->getServiceManager(), UNO_QUERY_THROW ); Reference< XEnumeration > xEnum( xFactoryEA->createContentEnumeration( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.FilterFormulaParser" ) ) ), UNO_SET_THROW ); while( xEnum->hasMoreElements() ) try // single try/catch for every element { diff --git a/sc/source/core/tool/progress.cxx b/sc/source/core/tool/progress.cxx index 9d1c5bcae..10d824251 100644 --- a/sc/source/core/tool/progress.cxx +++ b/sc/source/core/tool/progress.cxx @@ -46,6 +46,7 @@ #include "global.hxx" #include "globstr.hrc" +using namespace com::sun::star; static ScProgress theDummyInterpretProgress; @@ -78,6 +79,14 @@ BOOL lcl_IsHiddenDocument( SfxObjectShell* pObjSh ) return FALSE; } +bool lcl_HasControllersLocked( SfxObjectShell& rObjSh ) +{ + uno::Reference<frame::XModel> xModel( rObjSh.GetBaseModel() ); + if (xModel.is()) + return xModel->hasControllersLocked(); + return false; +} + ScProgress::ScProgress( SfxObjectShell* pObjSh, const String& rText, ULONG nRange, BOOL bAllDocs, BOOL bWait ) { @@ -104,10 +113,12 @@ ScProgress::ScProgress( SfxObjectShell* pObjSh, const String& rText, pProgress = NULL; } else if ( pObjSh && ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED || - pObjSh->GetProgress() ) ) + pObjSh->GetProgress() || + lcl_HasControllersLocked(*pObjSh) ) ) { // #62808# no own progress for embedded objects, // #73633# no second progress if the document already has one + // #163566# no progress while controllers are locked (repaint disabled) pProgress = NULL; } diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 0c6153857..ca7a5fb82 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -84,8 +84,7 @@ #include <math.h> -#include <oox/core/tokens.hxx> - +using namespace ::oox; using ::rtl::OString; static String lcl_GetVbaTabName( SCTAB n ) @@ -222,7 +221,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) else { if( IsDocumentEncrypted() ) - Add( new XclExpFilePass( GetRoot() ) ); + Add( new XclExpFileEncryption( GetRoot() ) ); Add( new XclExpInterfaceHdr( nCodePage ) ); Add( new XclExpUInt16Record( EXC_ID_MMS, 0 ) ); Add( new XclExpInterfaceEnd ); @@ -791,7 +790,7 @@ void ExcDocument::WriteXml( SvStream& rStrm ) { InitializeSave(); - XclExpXmlStream aStrm( ::comphelper::getProcessServiceFactory(), rStrm, GetRoot() ); + XclExpXmlStream aStrm( ::comphelper::getProcessComponentContext(), rStrm, GetRoot() ); sax_fastparser::FSHelperPtr& rWorkbook = aStrm.GetCurrentStream(); rWorkbook->startElement( XML_workbook, diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx index cd95b023e..159e88f97 100644 --- a/sc/source/filter/excel/excel.cxx +++ b/sc/source/filter/excel/excel.cxx @@ -31,6 +31,8 @@ #include <sfx2/docfile.hxx> #include <sfx2/objsh.hxx> #include <sfx2/app.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/request.hxx> #include <sot/storage.hxx> #include <sot/exchange.hxx> #include <tools/globname.hxx> @@ -92,17 +94,24 @@ FltError ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& rMedium, ScDocument aArgs[ 0 ] <<= getProcessServiceFactory(); aArgs[ 1 ] <<= aArgSeq; uno::Reference< document::XImporter > xImporter( ScfApiHelper::CreateInstanceWithArgs( - CREATE_OUSTRING( "com.sun.star.comp.oox.ExcelBiffFilter" ), aArgs ), uno::UNO_QUERY_THROW ); + CREATE_OUSTRING( "com.sun.star.comp.oox.xls.ExcelBiffFilter" ), aArgs ), uno::UNO_QUERY_THROW ); xImporter->setTargetDocument( xComponent ); MediaDescriptor aMediaDesc; SfxItemSet* pItemSet = rMedium.GetItemSet(); if( pItemSet ) { - if( const SfxStringItem* pItem = static_cast< const SfxStringItem* >( pItemSet->GetItem( SID_FILE_NAME ) ) ) - aMediaDesc[ MediaDescriptor::PROP_URL() ] <<= ::rtl::OUString( pItem->GetValue() ); - if( const SfxStringItem* pItem = static_cast< const SfxStringItem* >( pItemSet->GetItem( SID_PASSWORD ) ) ) - aMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= ::rtl::OUString( pItem->GetValue() ); + SFX_ITEMSET_ARG( pItemSet, pFileNameItem, SfxStringItem, SID_FILE_NAME, sal_False); + if( pFileNameItem ) + aMediaDesc[ MediaDescriptor::PROP_URL() ] <<= ::rtl::OUString( pFileNameItem->GetValue() ); + + SFX_ITEMSET_ARG( pItemSet, pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False); + if( pPasswordItem ) + aMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= ::rtl::OUString( pPasswordItem->GetValue() ); + + SFX_ITEMSET_ARG( pItemSet, pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False); + if( pEncryptionDataItem ) + aMediaDesc[ MediaDescriptor::PROP_ENCRYPTIONDATA() ] = pEncryptionDataItem->GetValue(); } aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] <<= rMedium.GetInputStream(); aMediaDesc[ MediaDescriptor::PROP_INTERACTIONHANDLER() ] <<= rMedium.GetInteractionHandler(); diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index a601d7663..b8ae9df6a 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -30,10 +30,9 @@ #include "excimp8.hxx" -#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> - #include <scitems.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/mediadescriptor.hxx> #include <unotools/fltrcfg.hxx> #include <svtools/wmf.hxx> @@ -42,6 +41,11 @@ #include <sfx2/docfile.hxx> #include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <sfx2/app.hxx> +#include <sfx2/docinf.hxx> +#include <sfx2/frame.hxx> + #include <editeng/brshitem.hxx> #include <editeng/editdata.hxx> #include <editeng/editeng.hxx> @@ -54,19 +58,16 @@ #include <editeng/crsditem.hxx> #include <editeng/flditem.hxx> #include <svx/xflclit.hxx> -#include <filter/msfilter/svxmsbas.hxx> -#include <basic/basmgr.hxx> #include <vcl/graph.hxx> #include <vcl/bmpacc.hxx> #include <sot/exchange.hxx> -#include <sfx2/docinf.hxx> +#include <svl/stritem.hxx> #include <tools/string.hxx> #include <tools/urlobj.hxx> #include <rtl/math.hxx> -#include <rtl/ustrbuf.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/charclass.hxx> #include <drwlayer.hxx> @@ -102,10 +103,11 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <cppuhelper/component_context.hxx> -#include <sfx2/app.hxx> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> using namespace com::sun::star; +using namespace ::comphelper; using ::rtl::OUString; @@ -232,18 +234,49 @@ void ImportExcel8::ReadBasic( void ) { SfxObjectShell* pShell = GetDocShell(); SotStorageRef xRootStrg = GetRootStorage(); - SvtFilterOptions* pFilterOpt = SvtFilterOptions::Get(); - if( pShell && xRootStrg.Is() && pFilterOpt ) + if( pShell && xRootStrg.Is() ) try { - bool bLoadCode = pFilterOpt->IsLoadExcelBasicCode(); - bool bLoadExecutable = pFilterOpt->IsLoadExcelBasicExecutable(); - bool bLoadStrg = pFilterOpt->IsLoadExcelBasicStorage(); - if( bLoadCode || bLoadStrg ) + uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW ); + uno::Reference< lang::XMultiComponentFactory > xFactory( xContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Sequence< beans::NamedValue > aArgSeq( 1 ); + aArgSeq[ 0 ].Name = CREATE_OUSTRING( "ColorPalette" ); + aArgSeq[ 0 ].Value <<= GetPalette().CreateColorSequence(); + + uno::Sequence< uno::Any > aArgs( 2 ); + // framework calls filter objects with factory as first argument + aArgs[ 0 ] <<= xFactory; + aArgs[ 1 ] <<= aArgSeq; + + uno::Reference< document::XImporter > xImporter( xFactory->createInstanceWithArgumentsAndContext( + CREATE_OUSTRING( "com.sun.star.comp.oox.xls.ExcelVbaProjectFilter" ), aArgs, xContext ), uno::UNO_QUERY_THROW ); + + uno::Reference< lang::XComponent > xComponent( pShell->GetModel(), uno::UNO_QUERY_THROW ); + xImporter->setTargetDocument( xComponent ); + + MediaDescriptor aMediaDesc; + SfxMedium& rMedium = GetMedium(); + SfxItemSet* pItemSet = rMedium.GetItemSet(); + if( pItemSet ) { - SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg ); - bool bAsComment = !bLoadExecutable; - aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); + SFX_ITEMSET_ARG( pItemSet, pFileNameItem, SfxStringItem, SID_FILE_NAME, sal_False ); + if( pFileNameItem ) + aMediaDesc[ MediaDescriptor::PROP_URL() ] <<= ::rtl::OUString( pFileNameItem->GetValue() ); + SFX_ITEMSET_ARG( pItemSet, pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False ); + if( pPasswordItem ) + aMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= ::rtl::OUString( pPasswordItem->GetValue() ); + SFX_ITEMSET_ARG( pItemSet, pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False ); + if( pEncryptionDataItem ) + aMediaDesc[ MediaDescriptor::PROP_ENCRYPTIONDATA() ] = pEncryptionDataItem->GetValue(); } + aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] <<= rMedium.GetInputStream(); + aMediaDesc[ MediaDescriptor::PROP_INTERACTIONHANDLER() ] <<= rMedium.GetInteractionHandler(); + + // call the filter + uno::Reference< document::XFilter > xFilter( xImporter, uno::UNO_QUERY_THROW ); + xFilter->filter( aMediaDesc.getAsConstPropertyValueList() ); + } + catch( uno::Exception& ) + { } } diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index bee06f17e..ab3eeadd9 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -96,11 +96,9 @@ #include "xcl97rec.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::com::sun::star::uno::Sequence; - - using ::rtl::OString; //--------------------------------------------------------- class ExcDummy_00 - diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 82aced900..480394bc3 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -55,7 +55,7 @@ #include "xestyle.hxx" #include "xename.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index a49ec43c2..df4340afc 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -64,7 +64,7 @@ #include "xename.hxx" #include "xestyle.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::rtl::OUString; diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 17124e8e6..4305bab5e 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -1759,7 +1759,11 @@ void XclExpFmlaCompImpl::AppendTrailingParam( XclExpFuncData& rFuncData ) break; - default:; + default: + // #i108420# function without parameters stored as macro call needs the external name reference + if( (nParamCount == 0) && rFuncData.IsMacroFunc() ) + AppendDefaultParam( rFuncData ); + } } diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx index 2278fcbe8..bcf208f00 100644 --- a/sc/source/filter/excel/xename.cxx +++ b/sc/source/filter/excel/xename.cxx @@ -41,9 +41,10 @@ // for filter manager #include "excrecds.hxx" -#include <oox/core/tokens.hxx> #include <formula/grammar.hxx> +using namespace ::oox; + using ::rtl::OString; // ============================================================================ diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx index 9a65c7ee3..c4ae747c4 100644 --- a/sc/source/filter/excel/xepage.cxx +++ b/sc/source/filter/excel/xepage.cxx @@ -48,7 +48,7 @@ #include <set> #include <limits> -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::std::set; diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx index 3ee7c6bd2..83ab0f883 100644 --- a/sc/source/filter/excel/xepivot.cxx +++ b/sc/source/filter/excel/xepivot.cxx @@ -51,7 +51,7 @@ #include "xestring.hxx" #include "xelink.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::com::sun::star::sheet::DataPilotFieldOrientation; using ::com::sun::star::sheet::DataPilotFieldOrientation_HIDDEN; diff --git a/sc/source/filter/excel/xerecord.cxx b/sc/source/filter/excel/xerecord.cxx index 4daee33a6..712a025aa 100644 --- a/sc/source/filter/excel/xerecord.cxx +++ b/sc/source/filter/excel/xerecord.cxx @@ -30,7 +30,7 @@ #include "xerecord.hxx" #include "xeroot.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; // Base classes to export Excel records ======================================= diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index 50e07ae1f..acd1fb051 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -28,7 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include <rtl/random.h> #include <sfx2/docfile.hxx> +#include <sfx2/request.hxx> +#include <sfx2/frame.hxx> #include <sfx2/sfxsids.hrc> #include <unotools/saveopt.hxx> #include <svl/itemset.hxx> @@ -51,6 +54,8 @@ #include "document.hxx" #include "scextopt.hxx" +using namespace ::com::sun::star; + // Global data ================================================================ XclExpRootData::XclExpRootData( XclBiff eBiff, SfxMedium& rMedium, @@ -241,23 +246,66 @@ bool XclExpRoot::IsDocumentEncrypted() const if (pDocProt && pDocProt->isProtected() && pDocProt->isOptionEnabled(ScDocProtection::STRUCTURE)) return true; - if (GetPassword().Len() > 0) + if ( GetEncryptionData().getLength() > 0 ) // Password is entered directly into the save dialog. return true; return false; } -String XclExpRoot::GetPassword() const +uno::Sequence< beans::NamedValue > XclExpRoot::GenerateEncryptionData( const ::rtl::OUString& aPass ) const { - if( SfxItemSet* pItemSet = GetMedium().GetItemSet() ) + uno::Sequence< beans::NamedValue > aEncryptionData; + + if ( aPass.getLength() > 0 && aPass.getLength() < 16 ) { - const SfxPoolItem* pItem = 0; - if( pItemSet->GetItemState( SID_PASSWORD, TRUE, &pItem ) == SFX_ITEM_SET ) - if( const SfxStringItem* pStrItem = dynamic_cast< const SfxStringItem* >( pItem ) ) - return pStrItem->GetValue(); + TimeValue aTime; + osl_getSystemTime( &aTime ); + rtlRandomPool aRandomPool = rtl_random_createPool (); + rtl_random_addBytes ( aRandomPool, &aTime, 8 ); + + sal_uInt8 pnDocId[16]; + rtl_random_getBytes( aRandomPool, pnDocId, 16 ); + + rtl_random_destroyPool( aRandomPool ); + + sal_uInt16 pnPasswd[16]; + memset( pnPasswd, 0, sizeof( pnPasswd ) ); + for (xub_StrLen nChar = 0; nChar < aPass.getLength(); ++nChar ) + pnPasswd[nChar] = aPass.getStr()[nChar]; + + ::msfilter::MSCodec_Std97 aCodec; + aCodec.InitKey( pnPasswd, pnDocId ); + aEncryptionData = aCodec.GetEncryptionData(); } - return String::EmptyString(); + + return aEncryptionData; +} + +uno::Sequence< beans::NamedValue > XclExpRoot::GetEncryptionData() const +{ + uno::Sequence< beans::NamedValue > aEncryptionData; + SFX_ITEMSET_ARG( GetMedium().GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False ); + if ( pEncryptionDataItem ) + pEncryptionDataItem->GetValue() >>= aEncryptionData; + else + { + // try to get the encryption data from the password + SFX_ITEMSET_ARG( GetMedium().GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False ); + if ( pPasswordItem && pPasswordItem->GetValue().Len() ) + aEncryptionData = GenerateEncryptionData( pPasswordItem->GetValue() ); + } + + return aEncryptionData; +} + +uno::Sequence< beans::NamedValue > XclExpRoot::GenerateDefaultEncryptionData() const +{ + uno::Sequence< beans::NamedValue > aEncryptionData; + if ( GetDefaultPassword().Len() > 0 ) + aEncryptionData = GenerateEncryptionData( GetDefaultPassword() ); + + return aEncryptionData; } XclExpRootData::XclExpLinkMgrRef XclExpRoot::GetLocalLinkMgrRef() const diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 51d6d3a1d..6ed27a587 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -32,6 +32,8 @@ #include <utility> #include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/random.h> #include <sax/fshelper.hxx> #include <unotools/streamwrap.hxx> @@ -45,26 +47,24 @@ #include "rangelst.hxx" #include "compiler.hxx" -#include <oox/core/tokens.hxx> +#include <oox/xls/excelvbaproject.hxx> #include <formula/grammar.hxx> #define DEBUG_XL_ENCRYPTION 0 -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::io::XOutputStream; -using ::com::sun::star::io::XStream; -using ::com::sun::star::lang::XComponent; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::lang::XServiceInfo; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::UNO_QUERY; using ::rtl::OString; using ::rtl::OUString; +using ::rtl::OUStringBuffer; using ::utl::OStreamWrapper; using ::std::vector; -using namespace formula; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sheet; +using namespace ::com::sun::star::uno; +using namespace ::formula; +using namespace ::oox; // ============================================================================ @@ -484,17 +484,16 @@ void XclExpStream::WriteRawZeroBytes( sal_Size nBytes ) // ============================================================================ -XclExpBiff8Encrypter::XclExpBiff8Encrypter( const XclExpRoot& rRoot, const sal_uInt8 nDocId[16], - const sal_uInt8 nSalt[16] ) : +XclExpBiff8Encrypter::XclExpBiff8Encrypter( const XclExpRoot& rRoot ) : mrRoot(rRoot), mnOldPos(STREAM_SEEK_TO_END), mbValid(false) { - String aPass = rRoot.GetPassword(); - if (aPass.Len() == 0) + Sequence< NamedValue > aEncryptionData = rRoot.GetEncryptionData(); + if( !aEncryptionData.hasElements() ) // Empty password. Get the default biff8 password. - aPass = rRoot.GetDefaultPassword(); - Init(aPass, nDocId, nSalt); + aEncryptionData = rRoot.GenerateDefaultEncryptionData(); + Init( aEncryptionData ); } XclExpBiff8Encrypter::~XclExpBiff8Encrypter() @@ -506,9 +505,22 @@ bool XclExpBiff8Encrypter::IsValid() const return mbValid; } -void XclExpBiff8Encrypter::GetSaltDigest( sal_uInt8 nSaltDigest[16] ) const +void XclExpBiff8Encrypter::GetSaltDigest( sal_uInt8 pnSaltDigest[16] ) const { - memcpy(nSaltDigest, mnSaltDigest, 16); + if ( sizeof( mpnSaltDigest ) == 16 ) + memcpy( pnSaltDigest, mpnSaltDigest, 16 ); +} + +void XclExpBiff8Encrypter::GetSalt( sal_uInt8 pnSalt[16] ) const +{ + if ( sizeof( mpnSalt ) == 16 ) + memcpy( pnSalt, mpnSalt, 16 ); +} + +void XclExpBiff8Encrypter::GetDocId( sal_uInt8 pnDocId[16] ) const +{ + if ( sizeof( mpnDocId ) == 16 ) + memcpy( pnDocId, mpnDocId, 16 ); } void XclExpBiff8Encrypter::Encrypt( SvStream& rStrm, sal_uInt8 nData ) @@ -565,46 +577,42 @@ void XclExpBiff8Encrypter::Encrypt( SvStream& rStrm, sal_Int32 nData ) Encrypt(rStrm, static_cast<sal_uInt32>(nData)); } -void XclExpBiff8Encrypter::Init( const String& aPass, const sal_uInt8 nDocId[16], - const sal_uInt8 nSalt[16] ) +void XclExpBiff8Encrypter::Init( const Sequence< NamedValue >& rEncryptionData ) { - memset(mnSaltDigest, 0, sizeof(mnSaltDigest)); + mbValid = false; - xub_StrLen nLen = aPass.Len(); - bool bValid = (0 < nLen) && (nLen < 16); - if ( bValid ) + if( maCodec.InitCodec( rEncryptionData ) ) { - // transform String to sal_uInt16 array - memset(mnPassw, 0, sizeof(mnPassw)); - for (xub_StrLen nChar = 0; nChar < nLen; ++nChar) - mnPassw[nChar] = static_cast<sal_uInt16>(aPass.GetChar(nChar)); + maCodec.GetDocId( mpnDocId ); - // copy document ID - memcpy(mnDocId, nDocId, sizeof(mnDocId)); + // generate the salt here + TimeValue aTime; + osl_getSystemTime( &aTime ); + rtlRandomPool aRandomPool = rtl_random_createPool (); + rtl_random_addBytes( aRandomPool, &aTime, 8 ); + rtl_random_getBytes( aRandomPool, mpnSalt, 16 ); + rtl_random_destroyPool( aRandomPool ); - // init codec - maCodec.InitKey(mnPassw, mnDocId); + memset( mpnSaltDigest, 0, sizeof( mpnSaltDigest ) ); // generate salt hash. ::msfilter::MSCodec_Std97 aCodec; - aCodec.InitKey(mnPassw, mnDocId); - aCodec.CreateSaltDigest(nSalt, mnSaltDigest); + aCodec.InitCodec( rEncryptionData ); + aCodec.CreateSaltDigest( mpnSalt, mpnSaltDigest ); // verify to make sure it's in good shape. - bValid = maCodec.VerifyKey(nSalt, mnSaltDigest); + mbValid = maCodec.VerifyKey( mpnSalt, mpnSaltDigest ); } - - mbValid = bValid; } sal_uInt32 XclExpBiff8Encrypter::GetBlockPos( sal_Size nStrmPos ) const { - return static_cast<sal_uInt32>(nStrmPos / EXC_ENCR_BLOCKSIZE); + return static_cast< sal_uInt32 >( nStrmPos / EXC_ENCR_BLOCKSIZE ); } sal_uInt16 XclExpBiff8Encrypter::GetOffsetInBlock( sal_Size nStrmPos ) const { - return static_cast<sal_uInt16>(nStrmPos % EXC_ENCR_BLOCKSIZE); + return static_cast< sal_uInt16 >( nStrmPos % EXC_ENCR_BLOCKSIZE ); } void XclExpBiff8Encrypter::EncryptBytes( SvStream& rStrm, vector<sal_uInt8>& aBytes ) @@ -671,9 +679,9 @@ void XclExpBiff8Encrypter::EncryptBytes( SvStream& rStrm, vector<sal_uInt8>& aBy mnOldPos = nStrmPos; } -rtl::OUString XclXmlUtils::GetStreamName( const char* sStreamDir, const char* sStream, sal_Int32 nId ) +OUString XclXmlUtils::GetStreamName( const char* sStreamDir, const char* sStream, sal_Int32 nId ) { - rtl::OUStringBuffer sBuf; + OUStringBuffer sBuf; if( sStreamDir ) sBuf.appendAscii( sStreamDir ); sBuf.appendAscii( sStream ); @@ -683,7 +691,7 @@ rtl::OUString XclXmlUtils::GetStreamName( const char* sStreamDir, const char* sS return sBuf.makeStringAndClear(); } -rtl::OString XclXmlUtils::ToOString( const Color& rColor ) +OString XclXmlUtils::ToOString( const Color& rColor ) { char buf[9]; sprintf( buf, "%.2X%.2X%.2X%.2X", rColor.GetTransparency(), rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); @@ -691,37 +699,37 @@ rtl::OString XclXmlUtils::ToOString( const Color& rColor ) return OString( buf ); } -rtl::OString XclXmlUtils::ToOString( const ::rtl::OUString& s ) +OString XclXmlUtils::ToOString( const OUString& s ) { return OUStringToOString( s, RTL_TEXTENCODING_UTF8 ); } -rtl::OString XclXmlUtils::ToOString( const String& s ) +OString XclXmlUtils::ToOString( const String& s ) { - return rtl::OString( s.GetBuffer(), s.Len(), RTL_TEXTENCODING_UTF8 ); + return OString( s.GetBuffer(), s.Len(), RTL_TEXTENCODING_UTF8 ); } -rtl::OString XclXmlUtils::ToOString( const ScAddress& rAddress ) +OString XclXmlUtils::ToOString( const ScAddress& rAddress ) { String sAddress; rAddress.Format( sAddress, SCA_VALID, NULL, ScAddress::Details( FormulaGrammar::CONV_XL_A1 ) ); return ToOString( sAddress ); } -rtl::OString XclXmlUtils::ToOString( const ScfUInt16Vec& rBuffer ) +OString XclXmlUtils::ToOString( const ScfUInt16Vec& rBuffer ) { const sal_uInt16* pBuffer = &rBuffer [0]; - return ::rtl::OString( pBuffer, rBuffer.size(), RTL_TEXTENCODING_UTF8 ); + return OString( pBuffer, rBuffer.size(), RTL_TEXTENCODING_UTF8 ); } -rtl::OString XclXmlUtils::ToOString( const ScRange& rRange ) +OString XclXmlUtils::ToOString( const ScRange& rRange ) { String sRange; rRange.Format( sRange, SCA_VALID, NULL, ScAddress::Details( FormulaGrammar::CONV_XL_A1 ) ); return ToOString( sRange ); } -rtl::OString XclXmlUtils::ToOString( const ScRangeList& rRangeList ) +OString XclXmlUtils::ToOString( const ScRangeList& rRangeList ) { String s; rRangeList.Format( s, SCA_VALID, NULL, FormulaGrammar::CONV_XL_A1, ' ' ); @@ -741,12 +749,12 @@ static ScAddress lcl_ToAddress( const XclAddress& rAddress ) return aAddress; } -rtl::OString XclXmlUtils::ToOString( const XclAddress& rAddress ) +OString XclXmlUtils::ToOString( const XclAddress& rAddress ) { return ToOString( lcl_ToAddress( rAddress ) ); } -rtl::OString XclXmlUtils::ToOString( const XclExpString& s ) +OString XclXmlUtils::ToOString( const XclExpString& s ) { DBG_ASSERT( !s.IsRich(), "XclXmlUtils::ToOString(XclExpString): rich text string found!" ); return ToOString( s.GetUnicodeBuffer() ); @@ -762,7 +770,7 @@ static ScRange lcl_ToRange( const XclRange& rRange ) return aRange; } -rtl::OString XclXmlUtils::ToOString( const XclRangeList& rRanges ) +OString XclXmlUtils::ToOString( const XclRangeList& rRanges ) { ScRangeList aRanges; for( XclRangeList::const_iterator i = rRanges.begin(), end = rRanges.end(); @@ -791,7 +799,7 @@ OUString XclXmlUtils::ToOUString( const String& s ) return OUString( s.GetBuffer(), s.Len() ); } -rtl::OUString XclXmlUtils::ToOUString( ScDocument& rDocument, const ScAddress& rAddress, ScTokenArray* pTokenArray ) +OUString XclXmlUtils::ToOUString( ScDocument& rDocument, const ScAddress& rAddress, ScTokenArray* pTokenArray ) { ScCompiler aCompiler( &rDocument, rAddress, *pTokenArray); aCompiler.SetGrammar(FormulaGrammar::GRAM_NATIVE_XL_A1); @@ -813,8 +821,8 @@ const char* XclXmlUtils::ToPsz( bool b ) // ============================================================================ -XclExpXmlStream::XclExpXmlStream( const Reference< XMultiServiceFactory >& rSMgr, SvStream& rStrm, const XclExpRoot& rRoot ) - : XmlFilterBase( rSMgr ) +XclExpXmlStream::XclExpXmlStream( const Reference< XComponentContext >& rxContext, SvStream& rStrm, const XclExpRoot& rRoot ) + : XmlFilterBase( rxContext ) , mrRoot( rRoot ) { Sequence< PropertyValue > aArgs( 1 ); @@ -970,7 +978,7 @@ sax_fastparser::FSHelperPtr XclExpXmlStream::CreateOutputStream ( const Reference< XOutputStream >& xParentRelation, const char* sContentType, const char* sRelationshipType, - ::rtl::OUString* pRelationshipId ) + OUString* pRelationshipId ) { OUString sRelationshipId; if (xParentRelation.is()) @@ -1019,7 +1027,12 @@ bool XclExpXmlStream::exportDocument() throw() return false; } -::rtl::OUString XclExpXmlStream::implGetImplementationName() const +::oox::ole::VbaProject* XclExpXmlStream::implCreateVbaProject() const +{ + return new ::oox::xls::ExcelVbaProject( getComponentContext(), Reference< XSpreadsheetDocument >( getModel(), UNO_QUERY ) ); +} + +OUString XclExpXmlStream::implGetImplementationName() const { return CREATE_OUSTRING( "TODO" ); } diff --git a/sc/source/filter/excel/xestring.cxx b/sc/source/filter/excel/xestring.cxx index 93126d51e..4058ae36a 100644 --- a/sc/source/filter/excel/xestring.cxx +++ b/sc/source/filter/excel/xestring.cxx @@ -35,7 +35,7 @@ #include "xestyle.hxx" #include "xestring.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::rtl::OUString; diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 3800c2faa..5e37dbd88 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -55,7 +55,7 @@ #include "globstr.hrc" #include "xestring.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::rtl::OUString; diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 964497622..41c2f7690 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -43,7 +43,7 @@ #include "xecontent.hxx" #include "xeescher.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::rtl::OUString; diff --git a/sc/source/filter/excel/xeview.cxx b/sc/source/filter/excel/xeview.cxx index 5120b6f40..eaf644467 100644 --- a/sc/source/filter/excel/xeview.cxx +++ b/sc/source/filter/excel/xeview.cxx @@ -34,7 +34,7 @@ #include "xelink.hxx" #include "xestyle.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 1b3efb20a..15b08afde 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -917,14 +917,13 @@ void XclImpWebQuery::ReadWqtables( XclImpStream& rStrm ) String aTables( rStrm.ReadUniString() ); const sal_Unicode cSep = ';'; - aTables.SearchAndReplaceAll( ',', cSep ); String aQuotedPairs( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) ); - xub_StrLen nTokenCnt = aTables.GetQuotedTokenCount( aQuotedPairs, cSep ); + xub_StrLen nTokenCnt = aTables.GetQuotedTokenCount( aQuotedPairs, ',' ); maTables.Erase(); xub_StrLen nStringIx = 0; for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken ) { - String aToken( aTables.GetQuotedToken( 0, aQuotedPairs, cSep, nStringIx ) ); + String aToken( aTables.GetQuotedToken( 0, aQuotedPairs, ',', nStringIx ) ); sal_Int32 nTabNum = CharClass::isAsciiNumeric( aToken ) ? aToken.ToInt32() : 0; if( nTabNum > 0 ) ScGlobal::AddToken( maTables, ScfTools::GetNameFromHTMLIndex( static_cast< sal_uInt32 >( nTabNum ) ), cSep ); @@ -1118,7 +1117,7 @@ ErrCode XclImpDecryptHelper::ReadFilepass( XclImpStream& rStrm ) // request and verify a password (decrypter implements IDocPasswordVerifier) if( xDecr.is() ) - rStrm.GetRoot().RequestPassword( *xDecr ); + rStrm.GetRoot().RequestEncryptionData( *xDecr ); // return error code (success, wrong password, etc.) return xDecr.is() ? xDecr->GetError() : EXC_ENCR_ERROR_UNSUPP_CRYPT; diff --git a/sc/source/filter/excel/xiroot.cxx b/sc/source/filter/excel/xiroot.cxx index 29822a790..d2535764f 100644 --- a/sc/source/filter/excel/xiroot.cxx +++ b/sc/source/filter/excel/xiroot.cxx @@ -107,7 +107,7 @@ void XclImpRoot::SetAppFontEncoding( rtl_TextEncoding eAppFontEnc ) SetTextEncoding( eAppFontEnc ); } -void XclImpRoot::InitializeTable( SCTAB /*nScTab*/ ) +void XclImpRoot::InitializeTable( SCTAB nScTab ) { if( GetBiff() <= EXC_BIFF4 ) { @@ -119,6 +119,8 @@ void XclImpRoot::InitializeTable( SCTAB /*nScTab*/ ) GetXFRangeBuffer().Initialize(); GetPageSettings().Initialize(); GetTabViewSettings().Initialize(); + // delete the automatically generated codename + GetDoc().SetCodeName( nScTab, String::EmptyString() ); } void XclImpRoot::FinalizeTable() diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx index 84f28383e..eb3f3849e 100644 --- a/sc/source/filter/excel/xistream.cxx +++ b/sc/source/filter/excel/xistream.cxx @@ -28,6 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include <comphelper/docpasswordhelper.hxx> +#include <comphelper/sequenceashashmap.hxx> + #include "xistream.hxx" #include "xlstring.hxx" #include "xiroot.hxx" @@ -38,6 +41,8 @@ using ::rtl::OString; using ::rtl::OUString; using ::rtl::OUStringToOString; +using namespace ::com::sun::star; + // ============================================================================ // Decryption // ============================================================================ @@ -69,9 +74,16 @@ XclImpDecrypterRef XclImpDecrypter::Clone() const return xNewDecr; } -::comphelper::DocPasswordVerifierResult XclImpDecrypter::verifyPassword( const OUString& rPassword ) +::comphelper::DocPasswordVerifierResult XclImpDecrypter::verifyPassword( const ::rtl::OUString& rPassword, uno::Sequence< beans::NamedValue >& o_rEncryptionData ) +{ + o_rEncryptionData = OnVerifyPassword( rPassword ); + mnError = o_rEncryptionData.getLength() ? ERRCODE_NONE : ERRCODE_ABORT; + return o_rEncryptionData.getLength() ? ::comphelper::DocPasswordVerifierResult_OK : ::comphelper::DocPasswordVerifierResult_WRONG_PASSWORD; +} + +::comphelper::DocPasswordVerifierResult XclImpDecrypter::verifyEncryptionData( const uno::Sequence< beans::NamedValue >& rEncryptionData ) { - bool bValid = OnVerify( rPassword ); + bool bValid = OnVerifyEncryptionData( rEncryptionData ); mnError = bValid ? ERRCODE_NONE : ERRCODE_ABORT; return bValid ? ::comphelper::DocPasswordVerifierResult_OK : ::comphelper::DocPasswordVerifierResult_WRONG_PASSWORD; } @@ -110,7 +122,6 @@ sal_uInt16 XclImpDecrypter::Read( SvStream& rStrm, void* pData, sal_uInt16 nByte // ---------------------------------------------------------------------------- XclImpBiff5Decrypter::XclImpBiff5Decrypter( sal_uInt16 nKey, sal_uInt16 nHash ) : - maPassword( 16 ), mnKey( nKey ), mnHash( nHash ) { @@ -118,12 +129,12 @@ XclImpBiff5Decrypter::XclImpBiff5Decrypter( sal_uInt16 nKey, sal_uInt16 nHash ) XclImpBiff5Decrypter::XclImpBiff5Decrypter( const XclImpBiff5Decrypter& rSrc ) : XclImpDecrypter( rSrc ), - maPassword( rSrc.maPassword ), + maEncryptionData( rSrc.maEncryptionData ), mnKey( rSrc.mnKey ), mnHash( rSrc.mnHash ) { if( IsValid() ) - maCodec.InitKey( &maPassword.front() ); + maCodec.InitCodec( maEncryptionData ); } XclImpBiff5Decrypter* XclImpBiff5Decrypter::OnClone() const @@ -131,24 +142,59 @@ XclImpBiff5Decrypter* XclImpBiff5Decrypter::OnClone() const return new XclImpBiff5Decrypter( *this ); } -bool XclImpBiff5Decrypter::OnVerify( const OUString& rPassword ) +uno::Sequence< beans::NamedValue > XclImpBiff5Decrypter::OnVerifyPassword( const ::rtl::OUString& rPassword ) { + maEncryptionData.realloc( 0 ); + /* Convert password to a byte string. TODO: this needs some finetuning according to the spec... */ OString aBytePassword = OUStringToOString( rPassword, osl_getThreadTextEncoding() ); sal_Int32 nLen = aBytePassword.getLength(); if( (0 < nLen) && (nLen < 16) ) { - // copy byte string to sal_uInt8 array - maPassword.clear(); - maPassword.resize( 16, 0 ); - memcpy( &maPassword.front(), aBytePassword.getStr(), static_cast< size_t >( nLen ) ); + // init codec + maCodec.InitKey( (sal_uInt8*)aBytePassword.getStr() ); + + if ( maCodec.VerifyKey( mnKey, mnHash ) ) + { + maEncryptionData = maCodec.GetEncryptionData(); + + // since the export uses Std97 encryption always we have to request it here + ::std::vector< sal_uInt16 > aPassVect( 16 ); + ::std::vector< sal_uInt16 >::iterator aIt = aPassVect.begin(); + for( sal_Int32 nInd = 0; nInd < nLen; ++nInd, ++aIt ) + *aIt = static_cast< sal_uInt16 >( rPassword.getStr()[nInd] ); + + uno::Sequence< sal_Int8 > aDocId = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); + OSL_ENSURE( aDocId.getLength() == 16, "Unexpected length of the senquence!" ); + + ::msfilter::MSCodec_Std97 aCodec97; + aCodec97.InitKey( &aPassVect.front(), (sal_uInt8*)aDocId.getConstArray() ); + + // merge the EncryptionData, there should be no conflicts + ::comphelper::SequenceAsHashMap aEncryptionHash( maEncryptionData ); + aEncryptionHash.update( ::comphelper::SequenceAsHashMap( aCodec97.GetEncryptionData() ) ); + aEncryptionHash >> maEncryptionData; + } + } + + return maEncryptionData; +} +bool XclImpBiff5Decrypter::OnVerifyEncryptionData( const uno::Sequence< beans::NamedValue >& rEncryptionData ) +{ + maEncryptionData.realloc( 0 ); + + if( rEncryptionData.getLength() ) + { // init codec - maCodec.InitKey( &maPassword.front() ); - return maCodec.VerifyKey( mnKey, mnHash ); + maCodec.InitCodec( rEncryptionData ); + + if ( maCodec.VerifyKey( mnKey, mnHash ) ) + maEncryptionData = rEncryptionData; } - return false; + + return maEncryptionData.getLength(); } void XclImpBiff5Decrypter::OnUpdate( sal_Size /*nOldStrmPos*/, sal_Size nNewStrmPos, sal_uInt16 nRecSize ) @@ -168,7 +214,6 @@ sal_uInt16 XclImpBiff5Decrypter::OnRead( SvStream& rStrm, sal_uInt8* pnData, sal XclImpBiff8Decrypter::XclImpBiff8Decrypter( sal_uInt8 pnSalt[ 16 ], sal_uInt8 pnVerifier[ 16 ], sal_uInt8 pnVerifierHash[ 16 ] ) : - maPassword( 16, 0 ), maSalt( pnSalt, pnSalt + 16 ), maVerifier( pnVerifier, pnVerifier + 16 ), maVerifierHash( pnVerifierHash, pnVerifierHash + 16 ) @@ -177,13 +222,13 @@ XclImpBiff8Decrypter::XclImpBiff8Decrypter( sal_uInt8 pnSalt[ 16 ], XclImpBiff8Decrypter::XclImpBiff8Decrypter( const XclImpBiff8Decrypter& rSrc ) : XclImpDecrypter( rSrc ), - maPassword( rSrc.maPassword ), + maEncryptionData( rSrc.maEncryptionData ), maSalt( rSrc.maSalt ), maVerifier( rSrc.maVerifier ), maVerifierHash( rSrc.maVerifierHash ) { if( IsValid() ) - maCodec.InitKey( &maPassword.front(), &maSalt.front() ); + maCodec.InitCodec( maEncryptionData ); } XclImpBiff8Decrypter* XclImpBiff8Decrypter::OnClone() const @@ -191,25 +236,44 @@ XclImpBiff8Decrypter* XclImpBiff8Decrypter::OnClone() const return new XclImpBiff8Decrypter( *this ); } -bool XclImpBiff8Decrypter::OnVerify( const OUString& rPassword ) +uno::Sequence< beans::NamedValue > XclImpBiff8Decrypter::OnVerifyPassword( const ::rtl::OUString& rPassword ) { + maEncryptionData.realloc( 0 ); + sal_Int32 nLen = rPassword.getLength(); if( (0 < nLen) && (nLen < 16) ) { // copy string to sal_uInt16 array - maPassword.clear(); - maPassword.resize( 16, 0 ); + ::std::vector< sal_uInt16 > aPassVect( 16 ); const sal_Unicode* pcChar = rPassword.getStr(); const sal_Unicode* pcCharEnd = pcChar + nLen; - ::std::vector< sal_uInt16 >::iterator aIt = maPassword.begin(); + ::std::vector< sal_uInt16 >::iterator aIt = aPassVect.begin(); for( ; pcChar < pcCharEnd; ++pcChar, ++aIt ) *aIt = static_cast< sal_uInt16 >( *pcChar ); // init codec - maCodec.InitKey( &maPassword.front(), &maSalt.front() ); - return maCodec.VerifyKey( &maVerifier.front(), &maVerifierHash.front() ); + maCodec.InitKey( &aPassVect.front(), &maSalt.front() ); + if ( maCodec.VerifyKey( &maVerifier.front(), &maVerifierHash.front() ) ) + maEncryptionData = maCodec.GetEncryptionData(); + } + + return maEncryptionData; +} + +bool XclImpBiff8Decrypter::OnVerifyEncryptionData( const uno::Sequence< beans::NamedValue >& rEncryptionData ) +{ + maEncryptionData.realloc( 0 ); + + if( rEncryptionData.getLength() ) + { + // init codec + maCodec.InitCodec( rEncryptionData ); + + if ( maCodec.VerifyKey( &maVerifier.front(), &maVerifierHash.front() ) ) + maEncryptionData = rEncryptionData; } - return false; + + return maEncryptionData.getLength(); } void XclImpBiff8Decrypter::OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 /*nRecSize*/ ) diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index b1ce3a08e..d72d90099 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -88,6 +88,19 @@ ColorData XclImpPalette::GetColorData( sal_uInt16 nXclIndex ) const return GetDefColorData( nXclIndex ); } +::com::sun::star::uno::Sequence< sal_Int32 > XclImpPalette::CreateColorSequence() const +{ + sal_Int32 nCount = static_cast< sal_Int32 >( maColorTable.size() ); + ::com::sun::star::uno::Sequence< sal_Int32 > aSeq( nCount ); + if( nCount > 0 ) + { + sal_Int32* pnSeqColor = aSeq.getArray(); + for( ColorDataVec::const_iterator aIt = maColorTable.begin(), aEnd = maColorTable.end(); aIt != aEnd; ++aIt, ++pnSeqColor ) + *pnSeqColor = static_cast< sal_Int32 >( *aIt ); + } + return aSeq; +} + void XclImpPalette::ReadPalette( XclImpStream& rStrm ) { sal_uInt16 nCount; diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index b35ebd4e5..fb55a9e67 100644..100755 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -393,7 +393,7 @@ static const XclFunctionInfo saFuncTable_Odf[] = EXC_FUNCENTRY_ODF( ocVariationen2, 2, 2, 0, "PERMUTATIONA" ), EXC_FUNCENTRY_ODF( ocPhi, 1, 1, 0, "PHI" ), EXC_FUNCENTRY_ODF( ocZGZ, 3, 3, 0, "RRI" ), - EXC_FUNCENTRY_ODF( ocTable, 1, 1, 0, "SHEET" ), + EXC_FUNCENTRY_ODF( ocTable, 0, 1, 0, "SHEET" ), EXC_FUNCENTRY_ODF( ocTables, 0, 1, 0, "SHEETS" ), EXC_FUNCENTRY_ODF( ocNoName, 1, MX, 0, "SKEWP" ), EXC_FUNCENTRY_ODF( ocUnichar, 1, 1, 0, "UNICHAR" ), diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx index e32b5651b..b37497596 100644 --- a/sc/source/filter/excel/xlroot.cxx +++ b/sc/source/filter/excel/xlroot.cxx @@ -71,6 +71,8 @@ using ::com::sun::star::frame::XFrame; using ::com::sun::star::frame::XFramesSupplier; using ::com::sun::star::lang::XMultiServiceFactory; +using namespace ::com::sun::star; + // Global data ================================================================ #ifdef DBG_UTIL @@ -240,11 +242,11 @@ sal_Int32 XclRoot::GetHmmFromPixelY( double fPixelY ) const return static_cast< sal_Int32 >( fPixelY * mrData.mfScreenPixelY + 0.5 ); } -String XclRoot::RequestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const +uno::Sequence< beans::NamedValue > XclRoot::RequestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier ) const { ::std::vector< OUString > aDefaultPasswords; aDefaultPasswords.push_back( mrData.maDefPassword ); - return ScfApiHelper::QueryPasswordForMedium( mrData.mrMedium, rVerifier, &aDefaultPasswords ); + return ScfApiHelper::QueryEncryptionDataForMedium( mrData.mrMedium, rVerifier, &aDefaultPasswords ); } bool XclRoot::HasVbaStorage() const diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index e2bb19dce..e1e41082d 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -695,9 +695,9 @@ const OUString XclTools::maSbMacroSuffix( RTL_CONSTASCII_USTRINGPARAM( "?languag OUString XclTools::GetSbMacroUrl( const String& rMacroName, SfxObjectShell* pDocShell ) { OSL_ENSURE( rMacroName.Len() > 0, "XclTools::GetSbMacroUrl - macro name is empty" ); - ::ooo::vba::VBAMacroResolvedInfo aMacroInfo = ::ooo::vba::resolveVBAMacro( pDocShell, rMacroName, false ); - if( aMacroInfo.IsResolved() ) - return ::ooo::vba::makeMacroURL( aMacroInfo.ResolvedMacro() ); + ::ooo::vba::MacroResolvedInfo aMacroInfo = ::ooo::vba::resolveVBAMacro( pDocShell, rMacroName, false ); + if( aMacroInfo.mbFound ) + return ::ooo::vba::makeMacroURL( aMacroInfo.msResolvedMacro ); return OUString(); } diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index 559c0b853..7187078f2 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -38,6 +38,8 @@ #include <tools/urlobj.hxx> #include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/request.hxx> +#include <sfx2/frame.hxx> #include <sfx2/sfxsids.hrc> #include <svl/stritem.hxx> #include <svl/itemset.hxx> @@ -59,6 +61,8 @@ using ::com::sun::star::lang::XServiceName; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER; +using namespace ::com::sun::star; + // Static helper functions ==================================================== OUString ScfApiHelper::GetServiceName( Reference< XInterface > xInt ) @@ -136,25 +140,33 @@ Reference< XInterface > ScfApiHelper::CreateInstanceWithArgs( return CreateInstanceWithArgs( ::comphelper::getProcessServiceFactory(), rServiceName, rArgs ); } -String ScfApiHelper::QueryPasswordForMedium( SfxMedium& rMedium, +uno::Sequence< beans::NamedValue > ScfApiHelper::QueryEncryptionDataForMedium( SfxMedium& rMedium, ::comphelper::IDocPasswordVerifier& rVerifier, const ::std::vector< OUString >* pDefaultPasswords ) { - OUString aMediaPassword; - SfxItemSet* pItemSet = rMedium.GetItemSet(); - const SfxPoolItem *pPasswordItem; - if( pItemSet && (SFX_ITEM_SET == pItemSet->GetItemState( SID_PASSWORD, TRUE, &pPasswordItem )) ) - aMediaPassword = static_cast< const SfxStringItem* >( pPasswordItem )->GetValue(); + uno::Sequence< beans::NamedValue > aEncryptionData; + SFX_ITEMSET_ARG( rMedium.GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False); + if ( pEncryptionDataItem ) + pEncryptionDataItem->GetValue() >>= aEncryptionData; + + ::rtl::OUString aPassword; + SFX_ITEMSET_ARG( rMedium.GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False); + if ( pPasswordItem ) + aPassword = pPasswordItem->GetValue(); + OUString aDocName = INetURLObject( rMedium.GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET ); bool bIsDefaultPassword = false; - OUString aPassword = ::comphelper::DocPasswordHelper::requestAndVerifyDocPassword( - rVerifier, aMediaPassword, rMedium.GetInteractionHandler(), aDocName, + aEncryptionData = ::comphelper::DocPasswordHelper::requestAndVerifyDocPassword( + rVerifier, aEncryptionData, aPassword, rMedium.GetInteractionHandler(), aDocName, ::comphelper::DocPasswordRequestType_MS, pDefaultPasswords, &bIsDefaultPassword ); - if( !bIsDefaultPassword && (aPassword.getLength() > 0) && pItemSet ) - pItemSet->Put( SfxStringItem( SID_PASSWORD, aPassword ) ); + rMedium.GetItemSet()->ClearItem( SID_PASSWORD ); + rMedium.GetItemSet()->ClearItem( SID_ENCRYPTIONDATA ); + + if( !bIsDefaultPassword && (aEncryptionData.getLength() > 0) ) + rMedium.GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) ); - return aPassword; + return aEncryptionData; } // Property sets ============================================================== diff --git a/sc/source/filter/inc/fapihelper.hxx b/sc/source/filter/inc/fapihelper.hxx index c6c3483c6..2d05eab71 100644 --- a/sc/source/filter/inc/fapihelper.hxx +++ b/sc/source/filter/inc/fapihelper.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <tools/color.hxx> #include <comphelper/types.hxx> #include "ftools.hxx" @@ -106,9 +107,9 @@ public: const ::rtl::OUString& rServiceName, const UnoAnySequence& rArgs ); - /** Opens a password dialog and returns the entered password. - @return The entered password or an empty string on 'Cancel' or any error. */ - static String QueryPasswordForMedium( SfxMedium& rMedium, + /** Opens a password dialog and returns the encryption data. + @return The encryption data or an empty sequence on 'Cancel' or any error. */ + static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > QueryEncryptionDataForMedium( SfxMedium& rMedium, ::comphelper::IDocPasswordVerifier& rVerifier, const ::std::vector< ::rtl::OUString >* pDefaultPasswords = 0 ); }; diff --git a/sc/source/filter/inc/filt_pch.hxx b/sc/source/filter/inc/filt_pch.hxx index 0f1c7543e..b9521637f 100644 --- a/sc/source/filter/inc/filt_pch.hxx +++ b/sc/source/filter/inc/filt_pch.hxx @@ -126,7 +126,7 @@ #include <tools/fract.hxx> #include <vcl/bitmap.hxx> #include <vcl/mapmod.hxx> -#include <vcl/mapunit.hxx> +#include <tools/mapunit.hxx> #include <vcl/region.hxx> #include <svl/lstner.hxx> #include <patattr.hxx> @@ -182,7 +182,7 @@ #include <vcl/window.hxx> #include <vcl/pointr.hxx> #include <vcl/ptrstyle.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/inputctx.hxx> #include <vcl/event.hxx> #include <tools/ownlist.hxx> @@ -253,7 +253,7 @@ #include <vcl/menu.hxx> #include <vcl/combobox.hxx> #include <vcl/combobox.h> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hdl> #include <com/sun/star/awt/XWindow.hpp> diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 82db77305..5f4e7f4a0 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -478,11 +478,11 @@ public: // ============================================================================ -class XclExpFilePass : public XclExpRecord +class XclExpFileEncryption : public XclExpRecord { public: - explicit XclExpFilePass( const XclExpRoot& rRoot ); - virtual ~XclExpFilePass(); + explicit XclExpFileEncryption( const XclExpRoot& rRoot ); + virtual ~XclExpFileEncryption(); private: virtual void WriteBody( XclExpStream& rStrm ); diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx index 980590f9d..ba51abdef 100644 --- a/sc/source/filter/inc/xeroot.hxx +++ b/sc/source/filter/inc/xeroot.hxx @@ -28,6 +28,8 @@ #ifndef SC_XEROOT_HXX #define SC_XEROOT_HXX +#include <com/sun/star/beans/NamedValue.hpp> + #include "xlroot.hxx" // Forward declarations of objects in public use ============================== @@ -158,7 +160,9 @@ public: bool IsDocumentEncrypted() const; - String GetPassword() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateEncryptionData( const ::rtl::OUString& aPass ) const; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetEncryptionData() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateDefaultEncryptionData() const; private: diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx index a8fae8fdf..e662756fc 100644 --- a/sc/source/filter/inc/xestream.hxx +++ b/sc/source/filter/inc/xestream.hxx @@ -30,11 +30,14 @@ #ifndef SC_XESTREAM_HXX #define SC_XESTREAM_HXX +#include <com/sun/star/beans/NamedValue.hpp> + #include <map> #include <stack> #include <string> #include <oox/core/xmlfilterbase.hxx> +#include <oox/token/tokens.hxx> #include <sax/fshelper.hxx> #include "xlstream.hxx" @@ -216,13 +219,14 @@ private: class XclExpBiff8Encrypter { public: - explicit XclExpBiff8Encrypter( const XclExpRoot& rRoot, const sal_uInt8 nDocId[16], - const sal_uInt8 nSalt[16] ); + explicit XclExpBiff8Encrypter( const XclExpRoot& rRoot ); ~XclExpBiff8Encrypter(); bool IsValid() const; - void GetSaltDigest( sal_uInt8 nSaltDigest[16] ) const; + void GetSaltDigest( sal_uInt8 pnSaltDigest[16] ) const; + void GetSalt( sal_uInt8 pnSalt[16] ) const; + void GetDocId( sal_uInt8 pnDocId[16] ) const; void Encrypt( SvStream& rStrm, sal_uInt8 nData ); void Encrypt( SvStream& rStrm, sal_uInt16 nData ); @@ -238,17 +242,16 @@ public: void EncryptBytes( SvStream& rStrm, ::std::vector<sal_uInt8>& aBytes ); private: - void Init( const String& aPass, const sal_uInt8 nDocId[16], - const sal_uInt8 nSalt[16] ); + void Init( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData ); sal_uInt32 GetBlockPos( sal_Size nStrmPos ) const; sal_uInt16 GetOffsetInBlock( sal_Size nStrmPos ) const; private: ::msfilter::MSCodec_Std97 maCodec; /// Crypto algorithm implementation. - sal_uInt16 mnPassw[16]; /// Cached password data for copy construction. - sal_uInt8 mnDocId[16]; /// Cached document ID for copy construction. - sal_uInt8 mnSaltDigest[16]; + sal_uInt8 mpnDocId[16]; + sal_uInt8 mpnSalt[16]; + sal_uInt8 mpnSaltDigest[16]; const XclExpRoot& mrRoot; sal_Size mnOldPos; /// Last known stream position @@ -304,7 +307,7 @@ public: class XclExpXmlStream : public oox::core::XmlFilterBase { public: - XclExpXmlStream( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr, SvStream& rStrm, const XclExpRoot& rRoot ); + XclExpXmlStream( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, SvStream& rStrm, const XclExpRoot& rRoot ); virtual ~XclExpXmlStream(); /** Returns the filter root data. */ @@ -340,6 +343,7 @@ public: void Trace( const char* format, ...); private: + virtual ::oox::ole::VbaProject* implCreateVbaProject() const; virtual ::rtl::OUString implGetImplementationName() const; typedef std::map< ::rtl::OUString, diff --git a/sc/source/filter/inc/xistream.hxx b/sc/source/filter/inc/xistream.hxx index de4e86bf0..894b6515e 100644 --- a/sc/source/filter/inc/xistream.hxx +++ b/sc/source/filter/inc/xistream.hxx @@ -64,10 +64,9 @@ public: /** Creates a (ref-counted) copy of this decrypter object. */ XclImpDecrypterRef Clone() const; - /** Implementation of the ::comphelper::IDocPasswordVerifier interface, - calls the new virtual function implVerify(). */ - virtual ::comphelper::DocPasswordVerifierResult - verifyPassword( const ::rtl::OUString& rPassword ); + /** Implementation of the ::comphelper::IDocPasswordVerifier interface */ + virtual ::comphelper::DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData ); + virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ); /** Updates the decrypter on start of a new record or after seeking stream. */ void Update( SvStream& rStrm, sal_uInt16 nRecSize ); @@ -84,7 +83,10 @@ private: virtual XclImpDecrypter* OnClone() const = 0; /** Derived classes implement password verification and initialization of the decoder. */ - virtual bool OnVerify( const ::rtl::OUString& rPassword ) = 0; + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > + OnVerifyPassword( const ::rtl::OUString& rPassword ) = 0; + virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ) = 0; + /** Implementation of updating the decrypter. */ virtual void OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize ) = 0; /** Implementation of the decryption. */ @@ -111,7 +113,9 @@ private: /** Implementation of cloning this object. */ virtual XclImpBiff5Decrypter* OnClone() const; /** Implements password verification and initialization of the decoder. */ - virtual bool OnVerify( const ::rtl::OUString& rPassword ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > + OnVerifyPassword( const ::rtl::OUString& rPassword ); + virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ); /** Implementation of updating the decrypter. */ virtual void OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize ); /** Implementation of the decryption. */ @@ -119,7 +123,7 @@ private: private: ::msfilter::MSCodec_XorXLS95 maCodec; /// Crypto algorithm implementation. - ::std::vector< sal_uInt8 > maPassword; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData; sal_uInt16 mnKey; sal_uInt16 mnHash; }; @@ -140,7 +144,9 @@ private: /** Implementation of cloning this object. */ virtual XclImpBiff8Decrypter* OnClone() const; /** Implements password verification and initialization of the decoder. */ - virtual bool OnVerify( const ::rtl::OUString& rPassword ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > + OnVerifyPassword( const ::rtl::OUString& rPassword ); + virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ); /** Implementation of updating the decrypter. */ virtual void OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize ); /** Implementation of the decryption. */ @@ -153,7 +159,7 @@ private: private: ::msfilter::MSCodec_Std97 maCodec; /// Crypto algorithm implementation. - ::std::vector< sal_uInt16 > maPassword; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData; ::std::vector< sal_uInt8 > maSalt; ::std::vector< sal_uInt8 > maVerifier; ::std::vector< sal_uInt8 > maVerifierHash; diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx index 1d3047eb5..a5fba6f0d 100644 --- a/sc/source/filter/inc/xistyle.hxx +++ b/sc/source/filter/inc/xistyle.hxx @@ -64,6 +64,9 @@ public: @return The color from current or default palette or COL_AUTO, if nothing else found. */ inline Color GetColor( sal_uInt16 nXclIndex ) const { return Color( GetColorData( nXclIndex ) ); } + /** Returns the palette colors as UNO sequence. */ + ::com::sun::star::uno::Sequence< sal_Int32 > + CreateColorSequence() const; /** Reads a PALETTE record. */ void ReadPalette( XclImpStream& rStrm ); diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx index ecc8ab9af..f7e351f81 100644 --- a/sc/source/filter/inc/xlescher.hxx +++ b/sc/source/filter/inc/xlescher.hxx @@ -29,7 +29,7 @@ #define SC_XLESCHER_HXX #include <tools/gen.hxx> -#include <vcl/mapunit.hxx> +#include <tools/mapunit.hxx> #include "fapihelper.hxx" #include "xladdress.hxx" #include "xlstyle.hxx" diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx index cabdbfb9f..4153b2dd4 100644 --- a/sc/source/filter/inc/xlroot.hxx +++ b/sc/source/filter/inc/xlroot.hxx @@ -28,6 +28,8 @@ #ifndef SC_XLROOT_HXX #define SC_XLROOT_HXX +#include <com/sun/star/beans/NamedValue.hpp> + #include <i18npool/lang.h> #include <sot/storage.hxx> #include "xlconst.hxx" @@ -196,7 +198,8 @@ public: /** Returns the default password used for stream encryption. */ inline const String& GetDefaultPassword() const { return mrData.maDefPassword; } /** Requests and verifies a password from the medium or the user. */ - String RequestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > + RequestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier ) const; /** Returns the OLE2 root storage of the imported/exported file. @return Pointer to root storage or 0, if the file is a simple stream. */ diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index cc0939990..f8be09d80 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -77,7 +77,7 @@ #include "patattr.hxx" #include "tabprotection.hxx" -#include <oox/core/tokens.hxx> +using namespace ::oox; using ::rtl::OString; using ::rtl::OUString; @@ -1251,27 +1251,18 @@ void XclDelta::SaveXml( XclExpXmlStream& rStrm ) // ============================================================================ -XclExpFilePass::XclExpFilePass( const XclExpRoot& rRoot ) : +XclExpFileEncryption::XclExpFileEncryption( const XclExpRoot& rRoot ) : XclExpRecord(0x002F, 54), mrRoot(rRoot) { } -XclExpFilePass::~XclExpFilePass() +XclExpFileEncryption::~XclExpFileEncryption() { } -void XclExpFilePass::WriteBody( XclExpStream& rStrm ) +void XclExpFileEncryption::WriteBody( XclExpStream& rStrm ) { - static const sal_uInt8 nDocId[] = { - 0x17, 0xf7, 0x01, 0x08, 0xea, 0xad, 0x30, 0x5c, - 0x1a, 0x95, 0xa5, 0x75, 0xd6, 0x79, 0xcd, 0x8d }; - - - static const sal_uInt8 nSalt[] = { - 0xa4, 0x5b, 0xf7, 0xe9, 0x9f, 0x55, 0x21, 0xc5, - 0xc5, 0x56, 0xa8, 0x0d, 0x39, 0x05, 0x3a, 0xb4 }; - // 0x0000 - neither standard nor strong encryption // 0x0001 - standard or strong encryption rStrm << static_cast<sal_uInt16>(0x0001); @@ -1281,13 +1272,17 @@ void XclExpFilePass::WriteBody( XclExpStream& rStrm ) sal_uInt16 nStdEnc = 0x0001; rStrm << nStdEnc << nStdEnc; - sal_uInt8 nSaltHash[16]; - XclExpEncrypterRef xEnc( new XclExpBiff8Encrypter(mrRoot, nDocId, nSalt) ); - xEnc->GetSaltDigest(nSaltHash); - - rStrm.Write(nDocId, 16); - rStrm.Write(nSalt, 16); - rStrm.Write(nSaltHash, 16); + sal_uInt8 pnDocId[16]; + sal_uInt8 pnSalt[16]; + sal_uInt8 pnSaltHash[16]; + XclExpEncrypterRef xEnc( new XclExpBiff8Encrypter(mrRoot) ); + xEnc->GetDocId(pnDocId); + xEnc->GetSalt(pnSalt); + xEnc->GetSaltDigest(pnSaltHash); + + rStrm.Write(pnDocId, 16); + rStrm.Write(pnSalt, 16); + rStrm.Write(pnSaltHash, 16); rStrm.SetEncrypter(xEnc); } diff --git a/sc/source/filter/xml/XMLCodeNameProvider.cxx b/sc/source/filter/xml/XMLCodeNameProvider.cxx index d65800c49..f9a43f7ff 100755..100644 --- a/sc/source/filter/xml/XMLCodeNameProvider.cxx +++ b/sc/source/filter/xml/XMLCodeNameProvider.cxx @@ -156,7 +156,7 @@ uno::Sequence< OUString > SAL_CALL XMLCodeNameProvider::getElementNames( ) uno::Type SAL_CALL XMLCodeNameProvider::getElementType( ) throw (uno::RuntimeException) { - return uno::Type(); + return getCppuType( static_cast< uno::Sequence< beans::PropertyValue >* >( 0 ) ); } ::sal_Bool SAL_CALL XMLCodeNameProvider::hasElements() diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 43b196146..6a247dd27 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4338,15 +4338,20 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& ++nPropsToAdd; } + bool bVBACompat = false; uno::Reference <container::XNameAccess> xCodeNameAccess; DBG_ASSERT( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" ); if( pDoc && pDoc->IsInVBAMode() ) { + // VBA compatibility mode + bVBACompat = true; + ++nPropsToAdd; + // code names xCodeNameAccess = new XMLCodeNameProvider( pDoc ); - if( xCodeNameAccess.is() && xCodeNameAccess->hasElements() ) + if( xCodeNameAccess->hasElements() ) ++nPropsToAdd; else - xCodeNameAccess = 0; + xCodeNameAccess.clear(); } if( nPropsToAdd > 0 ) @@ -4359,10 +4364,17 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear(); ++nCount; } + if( bVBACompat ) + { + rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode")); + rProps[nCount].Value <<= bVBACompat; + ++nCount; + } if( xCodeNameAccess.is() ) { rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScriptConfiguration")); rProps[nCount].Value <<= xCodeNameAccess; + ++nCount; } } } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 51ee66cfc..ba146bace 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -2219,6 +2219,7 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa { sal_Int32 nCount(aConfigProps.getLength()); rtl::OUString sCTName(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesProtectionKey")); + rtl::OUString sVBName(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode")); rtl::OUString sSCName(RTL_CONSTASCII_USTRINGPARAM("ScriptConfiguration")); for (sal_Int32 i = nCount - 1; i >= 0; --i) { @@ -2243,26 +2244,15 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa } } } - else if (aConfigProps[i].Name == sSCName) + // store the following items for later use (after document is loaded) + else if ((aConfigProps[i].Name == sVBName) || (aConfigProps[i].Name == sSCName)) { - uno::Type aType = aConfigProps[i].Value.getValueType(); - uno::Reference<beans::XPropertySet> xImportInfo = - getImportInfo(); - - if (xImportInfo.is() && - (aType.equals(getCppuType( - (uno::Reference<container::XNameContainer> *)0 ) ) || - aType.equals(getCppuType( - (uno::Reference<container::XNameAccess> *)0 ) ) ) ) + uno::Reference< beans::XPropertySet > xImportInfo = getImportInfo(); + if (xImportInfo.is()) { - uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = - xImportInfo->getPropertySetInfo(); - if (xPropertySetInfo.is() && - xPropertySetInfo->hasPropertyByName(sSCName) ) - { - xImportInfo->setPropertyValue(sSCName, - aConfigProps[i].Value ); - } + uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo(); + if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName(aConfigProps[i].Name)) + xImportInfo->setPropertyValue( aConfigProps[i].Name, aConfigProps[i].Value ); } } } diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index 327bf6728..3695e4156 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -65,6 +65,7 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/packages/zip/ZipIOException.hpp> #include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <svx/xmleohlp.hxx> #include <rtl/logfile.hxx> @@ -426,6 +427,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError) { MAP_LEN( "StreamRelPath" ), 0, &::getCppuType( (rtl::OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "StreamName" ), 0, &::getCppuType( (rtl::OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "BuildId" ), 0, &::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "VBACompatibilityMode" ), 0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "ScriptConfiguration" ), 0, &::getCppuType((uno::Reference<container::XNameAccess> *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, { NULL, 0, 0, NULL, 0, 0 } @@ -643,6 +645,24 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError) uno::Reference <container::XNameAccess> xCodeNameAccess; if( aAny >>= xCodeNameAccess ) XMLCodeNameProvider::set( xCodeNameAccess, &rDoc ); + + // VBA compatibility + bool bVBACompat = false; + if ( (xInfoSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode"))) >>= bVBACompat) && bVBACompat ) + { + /* Set library container to VBA compatibility mode, this + forces loading the Basic project, which in turn creates the + VBA Globals object and does all related initialization. */ + if ( xModelSet.is() ) try + { + uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW ); + xVBACompat->setVBACompatibilityMode( sal_True ); + } + catch( uno::Exception& ) + { + } + } } // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 0f8fb4050..765dc8de3 100755 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -770,11 +770,11 @@ ScTextWnd::ScTextWnd( Window* pParent ) __EXPORT ScTextWnd::~ScTextWnd() { - delete pEditView; - delete pEditEngine; while (!maAccTextDatas.empty()) { maAccTextDatas.back()->Dispose(); } + delete pEditView; + delete pEditEngine; } void __EXPORT ScTextWnd::Paint( const Rectangle& rRec ) diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index ae3b9ec79..be9bf5de3 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -134,7 +134,8 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDesc nDragHandleY( 0 ), nDragSourceFlags( 0 ), bDragWasInternal( FALSE ), - bUsedForLink( FALSE ) + bUsedForLink( FALSE ), + bUseInApi( false ) { DBG_ASSERT(pDoc->IsClipboard(), "wrong document"); @@ -540,6 +541,11 @@ void ScTransferObj::SetDragWasInternal() bDragWasInternal = TRUE; } +void ScTransferObj::SetUseInApi( bool bSet ) +{ + bUseInApi = bSet; +} + ScDocument* ScTransferObj::GetSourceDocument() { ScDocShell* pSourceDocSh = GetSourceDocShell(); diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 5bc12d7b4..6dbfdc668 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -35,7 +35,7 @@ #include <vcl/outdev.hxx> #include <vcl/settings.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/decoview.hxx> #include "strload.hxx" #include "global.hxx" diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 35d68e4b3..6e7c3fa2f 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -851,13 +851,13 @@ BOOL ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, BOOL bApi return TRUE; } -void ScDocFunc::NotifyInputHandler( const ScAddress& /* rPos */ ) +void ScDocFunc::NotifyInputHandler( const ScAddress& rPos ) { ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); if ( pViewSh && pViewSh->GetViewData()->GetDocShell() == &rDocShell ) { ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); - if ( pInputHdl ) + if ( pInputHdl && pInputHdl->GetCursorPos() == rPos ) { sal_Bool bIsEditMode(pInputHdl->IsEditMode()); @@ -986,7 +986,7 @@ ScTokenArray* lcl_ScDocFunc_CreateTokenArrayXML( const String& rText, const Stri ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos, - const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) + const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar, short* pRetFormatType ) { ScDocument* pDoc = rDocShell.GetDocument(); ScBaseCell* pNewCell = NULL; @@ -1020,7 +1020,12 @@ ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos, sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US); double fVal; if ( pFormatter->IsNumberFormat( rText, nEnglish, fVal ) ) + { pNewCell = new ScValueCell( fVal ); + // return the format type from the English format, so a localized format can be created + if ( pRetFormatType ) + *pRetFormatType = pFormatter->GetType( nEnglish ); + } else if ( rText.Len() ) pNewCell = ScBaseCell::CreateTextCell( rText, pDoc ); @@ -2650,8 +2655,7 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); if ( xVBAModuleInfo.is() ) { - String sCodeName( genModuleName ); - rDoc.SetCodeName( nTab, sCodeName ); + rDoc.SetCodeName( nTab, genModuleName ); script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName ); xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo ); xLib->insertByName( genModuleName, aSourceAny ); @@ -3122,6 +3126,8 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa ScSizeMode eMode, USHORT nSizeTwips, BOOL bRecord, BOOL bApi ) { + ScDocShellModificator aModificator( rDocShell ); + if (!nRangeCnt) return TRUE; @@ -3283,6 +3289,7 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa pDoc->UpdatePageBreaks( nTab ); rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_ALL); + aModificator.SetDocumentModified(); return bSuccess; } @@ -4862,9 +4869,11 @@ BOOL ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter, } // Update hat sein eigenes Undo - - pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen - pLink->Update(); // kein SetInCreate -> Update ausfuehren + if (pDoc->IsExecuteLinkEnabled()) + { + pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen + pLink->Update(); // kein SetInCreate -> Update ausfuehren + } pLink->SetDoInsert(TRUE); // Default = TRUE SfxBindings* pBindings = rDocShell.GetViewBindings(); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 7554e189a..eb4714080 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -72,7 +72,6 @@ #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> @@ -554,6 +553,13 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); } break; + case SFX_EVENT_CLOSEDOC: + { + // #163655# prevent event processing after model is disposed + aDocument.SetVbaEventProcessor( uno::Reference< script::vba::XVBAEventProcessor >() ); + uno::Reference< lang::XEventListener >( xVbaEvents, uno::UNO_QUERY_THROW )->disposing( lang::EventObject() ); + } + break; } } } @@ -619,25 +625,6 @@ 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: @@ -2618,6 +2605,7 @@ void ScDocShell::SetDocumentModified( BOOL bIsModified /* = TRUE */ ) if ( pPaintLockData && bIsModified ) { //! BCA_BRDCST_ALWAYS etc. also needed here? + aDocument.InvalidateTableArea(); // #i105279# needed here aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); pPaintLockData->SetModified(); // spaeter... diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index cc46724b7..4fb205fac 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -55,7 +55,6 @@ using namespace ::com::sun::star; #include <svtools/sfxecode.hxx> #include <svx/ofaitem.hxx> #include <sot/formats.hxx> -#include <svtools/printdlg.hxx> #include <svl/whiter.hxx> #include <vcl/msgbox.hxx> #include <vcl/waitobj.hxx> @@ -1821,373 +1820,6 @@ void ScDocShell::GetStatePageStyle( SfxViewShell& /* rCaller */, } } -void lcl_GetPrintData( ScDocShell* pDocShell /*in*/, - ScDocument* pDocument /*in*/, SfxPrinter* pPrinter /*in*/, - PrintDialog* pPrintDialog /*in*/, bool bForceSelected /*in*/, - ScMarkData* pMarkData /*inout*/, bool& rbHasOptions /*out*/, - ScPrintOptions& rOptions /*out*/, bool& rbAllTabs /*out*/, - long& rnTotalPages /*out*/, long aPageArr[] /*out*/, - MultiSelection& rPageRanges /*out*/, ScRange** ppMarkedRange /*out*/ ) -{ - // get settings from print options sub-dialog - const SfxItemSet& rOptionSet = pPrinter->GetOptions(); - const SfxPoolItem* pItem; - rbHasOptions = ( rOptionSet.GetItemState( SID_SCPRINTOPTIONS, FALSE, &pItem ) == SFX_ITEM_SET ); - if ( rbHasOptions ) - { - rOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions(); - } - else - { - // use configuration - rOptions = SC_MOD()->GetPrintOptions(); - } - - // update all pending row heights with a single progress bar, - // instead of a separate progress for each sheet from ScPrintFunc - pDocShell->UpdatePendingRowHeights( MAXTAB, true ); - - // get number of total pages - rnTotalPages = 0; - SCTAB nTabCount = pDocument->GetTableCount(); - for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab ) - { - ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, NULL, &rOptions ); - long nThisTab = aPrintFunc.GetTotalPages(); - aPageArr[nTab] = nThisTab; - rnTotalPages += nThisTab; - } - - rPageRanges.SetTotalRange( Range( 0, RANGE_MAX ) ); - rPageRanges.Select( Range( 1, rnTotalPages ) ); - - rbAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() ); - if ( bForceSelected ) - { - rbAllTabs = false; - } - - if ( ( pPrintDialog && pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_SELECTED_CELLS ) || bForceSelected ) - { - if ( pMarkData && ( pMarkData->IsMarked() || pMarkData->IsMultiMarked() ) ) - { - pMarkData->MarkToMulti(); - *ppMarkedRange = new ScRange; - pMarkData->GetMultiMarkArea( **ppMarkedRange ); - pMarkData->MarkToSimple(); - } - } - - PrintDialogRange eDlgOption = pPrintDialog ? pPrintDialog->GetCheckedRange() : PRINTDIALOG_ALL; - if ( eDlgOption == PRINTDIALOG_RANGE ) - { - rPageRanges = MultiSelection( pPrintDialog->GetRangeText() ); - } - - // get number of total pages if selection - if ( !rbAllTabs ) - { - rnTotalPages = 0; - for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab ) - { - if ( *ppMarkedRange ) // selected range is used instead of print ranges -> page count is different - { - ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, *ppMarkedRange, &rOptions ); - aPageArr[nTab] = aPrintFunc.GetTotalPages(); - } - if ( !pMarkData || pMarkData->GetTableSelect( nTab ) ) - { - rnTotalPages += aPageArr[nTab]; - } - } - if ( eDlgOption == PRINTDIALOG_ALL || bForceSelected ) - { - rPageRanges.Select( Range( 1, rnTotalPages ) ); - } - } -} - -bool ScDocShell::CheckPrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData, bool bForceSelected, bool bIsAPI ) -{ - SfxPrinter* pPrinter = GetPrinter(); - if ( !pPrinter ) - { - return false; - } - - bool bHasOptions = false; - ScPrintOptions aOptions; - bool bAllTabs = true; - long nTotalPages = 0; - long aPageArr[MAXTABCOUNT]; // pages per sheet - MultiSelection aPageRanges; // pages to print - ScRange* pMarkedRange = NULL; - - lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected, - pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages, - aPageArr, aPageRanges, &pMarkedRange ); - - delete pMarkedRange; - - if ( nTotalPages == 0 ) - { - if ( !bIsAPI ) - { - WarningBox aWarningBox( GetActiveDialogParent(), WinBits( WB_OK ), - String( ScResId( STR_PRINT_NOTHING ) ) ); - aWarningBox.Execute(); - } - return false; - } - - return true; -} - -void ScDocShell::PreparePrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData ) -{ - SfxPrinter* pPrinter = GetPrinter(); - if ( !pPrinter ) - { - return; - } - - delete pOldJobSetup; // gesetzt nur bei Fehler in StartJob() - pOldJobSetup = new ScJobSetup( pPrinter ); // Einstellungen merken - - // Einstellungen fuer die erste gedruckte Seite muessen hier (vor StartJob) gesetzt werden - //! Selection etc. mit Print() zusammenfassen !!! - //! Seiten nur einmal zaehlen - - bool bHasOptions = false; - ScPrintOptions aOptions; - bool bAllTabs = true; - long nTotalPages = 0; - long aPageArr[MAXTABCOUNT]; // pages per sheet - MultiSelection aPageRanges; // pages to print - ScRange* pMarkedRange = NULL; - - lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, false, - pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages, - aPageArr, aPageRanges, &pMarkedRange ); - - BOOL bFound = FALSE; // erste Seite gefunden - long nTabStart = 0; - SCTAB nTabCount = aDocument.GetTableCount(); - for ( SCTAB nTab=0; nTab<nTabCount && !bFound; nTab++ ) - { - if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) ) - { - long nNext = nTabStart + aPageArr[nTab]; - BOOL bSelected = FALSE; - for (long nP=nTabStart+1; nP<=nNext; nP++) // 1-basiert - if (aPageRanges.IsSelected( nP )) // eine Seite von dieser Tabelle selektiert? - bSelected = TRUE; - - if (bSelected) - { - ScPrintFunc aPrintFunc( this, pPrinter, nTab ); - - aPrintFunc.ApplyPrintSettings(); // dann Settings fuer diese Tabelle - bFound = TRUE; - } - nTabStart = nNext; - } - } - - delete pMarkedRange; -} - -BOOL lcl_HasTransparent( ScDocument* pDoc, SCTAB nTab, const ScRange* pRange ) -{ - BOOL bFound = FALSE; - ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); - if (pDrawLayer) - { - SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); - DBG_ASSERT(pPage,"Page ?"); - if (pPage) - { - Rectangle aMMRect; - if ( pRange ) - aMMRect = pDoc->GetMMRect( pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row(), nTab ); - - SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); - SdrObject* pObject = aIter.Next(); - while (pObject && !bFound) - { - if (pObject->IsTransparent()) - { - if ( pRange ) - { - Rectangle aObjRect = pObject->GetLogicRect(); - if ( aObjRect.IsOver( aMMRect ) ) - bFound = TRUE; - } - else - bFound = TRUE; - } - - pObject = aIter.Next(); - } - } - } - - return bFound; -} - -void ScDocShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog, - ScMarkData* pMarkData, Window* pDialogParent, BOOL bForceSelected, BOOL bIsAPI ) -{ - SfxPrinter* pPrinter = GetPrinter(); - if ( !pPrinter ) - { - return; - } - - bool bHasOptions = false; - ScPrintOptions aOptions; - bool bAllTabs = true; - long nTotalPages = 0; - long aPageArr[MAXTABCOUNT]; // pages per sheet - MultiSelection aPageRanges; // pages to print - ScRange* pMarkedRange = NULL; - - lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected, - pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages, - aPageArr, aPageRanges, &pMarkedRange ); - - USHORT nCollateCopies = 1; - if ( pPrintDialog && pPrintDialog->IsCollateEnabled() && pPrintDialog->IsCollateChecked() ) - nCollateCopies = pPrintDialog->GetCopyCount(); - - // test if printed range contains transparent objects - - BOOL bHasTransp = FALSE; - BOOL bAnyPrintRanges = aDocument.HasPrintRange(); - ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); - SCTAB nTabCount = aDocument.GetTableCount(); - for ( SCTAB nTab=0; nTab<nTabCount && !bHasTransp; nTab++ ) - { - if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) ) - { - SfxStyleSheetBase* pStyleSheet = pStylePool->Find( - aDocument.GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ); - if ( pStyleSheet ) - { - const SfxItemSet& rSet = pStyleSheet->GetItemSet(); - if ( ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_CHARTS)).GetValue() == VOBJ_MODE_SHOW || - ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_OBJECTS)).GetValue() == VOBJ_MODE_SHOW || - ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_DRAWINGS)).GetValue() == VOBJ_MODE_SHOW ) - { - if ( pMarkedRange ) - bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, pMarkedRange ); - else if ( aDocument.GetPrintRangeCount(nTab) ) - { - USHORT nRangeCount = aDocument.GetPrintRangeCount(nTab); - for (USHORT i=0; i<nRangeCount; i++) - bHasTransp = bHasTransp || - lcl_HasTransparent( &aDocument, nTab, aDocument.GetPrintRange( nTab, i ) ); - } - else if (!bAnyPrintRanges || aDocument.IsPrintEntireSheet(nTab)) - bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, NULL ); - } - } - } - } - - BOOL bContinue = pPrinter->InitJob( pDialogParent, !bIsAPI && bHasTransp ); - - if ( bContinue ) - { - for ( USHORT n=0; n<nCollateCopies; n++ ) - { - long nTabStart = 0; - long nDisplayStart = 0; - long nAttrPage = 1; - long nPrinted = 0; - - for ( SCTAB nTab=0; nTab<nTabCount; nTab++ ) - { - if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) ) - { - FmFormView* pDrawView = NULL; - Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX ); - - // #114135# - ScDrawLayer* pModel = aDocument.GetDrawLayer(); // ist nicht NULL - - if(pModel) - { - pDrawView = new FmFormView( pModel, pPrinter ); - pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab)); - pDrawView->SetPrintPreview( TRUE ); - } - - ScPrintFunc aPrintFunc( this, pPrinter, nTab, nAttrPage, nTotalPages, pMarkedRange, &aOptions ); - aPrintFunc.SetDrawView( pDrawView ); - nPrinted += aPrintFunc.DoPrint( aPageRanges, nTabStart, nDisplayStart, TRUE, &rProgress, NULL ); - - nTabStart += aPageArr[nTab]; - if ( aDocument.NeedPageResetAfterTab(nTab) ) - nDisplayStart = 0; - else - nDisplayStart += aPageArr[nTab]; - nAttrPage = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage - - delete pDrawView; - } - } - - if ( n+1 < nCollateCopies && - (pPrinter->GetDuplexMode() == DUPLEX_SHORTEDGE || pPrinter->GetDuplexMode() == DUPLEX_LONGEDGE) && - ( nPrinted % 2 ) == 1 ) - { - // #105584# when several collated copies are printed in duplex mode, and there is - // an odd number of pages, print an empty page between copies, so the first page of - // the second copy isn't printed on the back of the last page of the first copy. - // (same as in Writer ViewShell::Prt) - - // FIXME: needs to be adapted to XRenderable interface - #if 0 - pPrinter->StartPage(); - pPrinter->EndPage(); - #endif - } - } - } - - delete pMarkedRange; - - if (pOldJobSetup) - { - pPrinter->SetOrientation( pOldJobSetup->eOrientation ); - pPrinter->SetPaperBin ( pOldJobSetup->nPaperBin ); - pPrinter->SetPaper ( pOldJobSetup->ePaper ); - - if ( PAPER_USER == pOldJobSetup->ePaper ) - { - pPrinter->SetMapMode( pOldJobSetup->aUserMapMode ); - pPrinter->SetPaperSizeUser( pOldJobSetup->aUserSize ); - } - - delete pOldJobSetup; - pOldJobSetup = NULL; - } - - if ( bHasOptions ) - { - // remove PrintOptions from printer ItemSet, - // so next time the options from the configuration are used - - SfxItemSet aSet( pPrinter->GetOptions() ); - aSet.ClearItem( SID_SCPRINTOPTIONS ); - pPrinter->SetOptions( aSet ); - } - - PostPaintGridAll(); //! nur wenn geaendert -} - void ScDocShell::GetState( SfxItemSet &rSet ) { SfxWhichIter aIter(rSet); diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx index a61add16b..42be09305 100644 --- a/sc/source/ui/inc/anyrefdg.hxx +++ b/sc/source/ui/inc/anyrefdg.hxx @@ -29,7 +29,7 @@ #define SC_ANYREFDG_HXX #ifndef _IMAGEBTN_HXX -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #endif #ifndef _EDIT_HXX #include <vcl/edit.hxx> diff --git a/sc/source/ui/inc/crdlg.hxx b/sc/source/ui/inc/crdlg.hxx index a19d7b41a..206374f8a 100644 --- a/sc/source/ui/inc/crdlg.hxx +++ b/sc/source/ui/inc/crdlg.hxx @@ -30,7 +30,7 @@ #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> #include "scui_def.hxx" //CHINA001 diff --git a/sc/source/ui/inc/delcldlg.hxx b/sc/source/ui/inc/delcldlg.hxx index e9775fc8c..86c6cfc25 100644 --- a/sc/source/ui/inc/delcldlg.hxx +++ b/sc/source/ui/inc/delcldlg.hxx @@ -30,7 +30,7 @@ #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> diff --git a/sc/source/ui/inc/delcodlg.hxx b/sc/source/ui/inc/delcodlg.hxx index 64428e538..cd1383e0c 100644 --- a/sc/source/ui/inc/delcodlg.hxx +++ b/sc/source/ui/inc/delcodlg.hxx @@ -30,7 +30,7 @@ #include <vcl/dialog.hxx> #include <vcl/fixed.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include "global.hxx" //------------------------------------------------------------------------ diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index 8158707f2..772b7fa60 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -92,7 +92,8 @@ public: // creates a new cell for use with PutCell ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, - const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ); + const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar, + short* pRetFormatType = NULL ); bool ShowNote( const ScAddress& rPos, bool bShow = true ); inline bool HideNote( const ScAddress& rPos ) { return ShowNote( rPos, false ); } diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index b1b1b0b8b..44e11718e 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -45,7 +45,6 @@ class ScEditEngineDefaulter; class FontList; -class PrintDialog; class SfxStyleSheetBasePool; class SfxStyleSheetHint; struct ChartSelectionInfo; @@ -303,13 +302,6 @@ public: void DoRecalc( BOOL bApi ); void DoHardRecalc( BOOL bApi ); - bool CheckPrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData, - bool bForceSelected, bool bIsAPI ); - void PreparePrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData ); - void Print( SfxProgress& rProgress, PrintDialog* pPrintDialog, - ScMarkData* pMarkData, Window* pDialogParent, - BOOL bForceSelected, BOOL bIsAPI ); - void UpdateOle( const ScViewData* pViewData, BOOL bSnapSize = FALSE ); BOOL IsOle(); diff --git a/sc/source/ui/inc/dwfunctr.hxx b/sc/source/ui/inc/dwfunctr.hxx index 1e9b34d7a..286828015 100644 --- a/sc/source/ui/inc/dwfunctr.hxx +++ b/sc/source/ui/inc/dwfunctr.hxx @@ -37,7 +37,7 @@ #endif #ifndef _IMAGEBTN_HXX //autogen -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #endif #ifndef _COMBOBOX_HXX //autogen diff --git a/sc/source/ui/inc/groupdlg.hxx b/sc/source/ui/inc/groupdlg.hxx index 63697683d..77ceecf47 100644 --- a/sc/source/ui/inc/groupdlg.hxx +++ b/sc/source/ui/inc/groupdlg.hxx @@ -30,7 +30,7 @@ #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> //------------------------------------------------------------------------ diff --git a/sc/source/ui/inc/imoptdlg.hxx b/sc/source/ui/inc/imoptdlg.hxx index 4d4bd2527..39c5c40be 100644 --- a/sc/source/ui/inc/imoptdlg.hxx +++ b/sc/source/ui/inc/imoptdlg.hxx @@ -32,7 +32,7 @@ #include <vcl/fixed.hxx> #include <vcl/combobox.hxx> #include <vcl/lstbox.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <svx/txencbox.hxx> #include "scdllapi.h" #include "global.hxx" diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index d90a3d716..d31fca3e2 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -168,6 +168,8 @@ public: const String& GetEditString(); const String& GetFormString() const { return aFormText; } + const ScAddress& GetCursorPos() const { return aCursorPos; } + BOOL GetTextAndFields( ScEditEngineDefaulter& rDestEngine ); BOOL KeyInput( const KeyEvent& rKEvt, BOOL bStartEdit = FALSE ); diff --git a/sc/source/ui/inc/inscldlg.hxx b/sc/source/ui/inc/inscldlg.hxx index 55480d22d..34600b4ec 100644 --- a/sc/source/ui/inc/inscldlg.hxx +++ b/sc/source/ui/inc/inscldlg.hxx @@ -29,7 +29,7 @@ #define SC_INSCLDLG_HXX #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> diff --git a/sc/source/ui/inc/inscodlg.hxx b/sc/source/ui/inc/inscodlg.hxx index 90f3ecb3d..c65962558 100644 --- a/sc/source/ui/inc/inscodlg.hxx +++ b/sc/source/ui/inc/inscodlg.hxx @@ -29,7 +29,7 @@ #define SC_INSCODLG_HXX #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> #include "global.hxx" diff --git a/sc/source/ui/inc/mtrindlg.hxx b/sc/source/ui/inc/mtrindlg.hxx index 18110d512..08c26fb83 100644 --- a/sc/source/ui/inc/mtrindlg.hxx +++ b/sc/source/ui/inc/mtrindlg.hxx @@ -30,7 +30,7 @@ #include <vcl/dialog.hxx> #include <vcl/field.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx index 3881497ec..63924a168 100644 --- a/sc/source/ui/inc/mvtabdlg.hxx +++ b/sc/source/ui/inc/mvtabdlg.hxx @@ -31,7 +31,7 @@ #include "address.hxx" #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/lstbox.hxx> #include <vcl/fixed.hxx> diff --git a/sc/source/ui/inc/namecrea.hxx b/sc/source/ui/inc/namecrea.hxx index b89fe0797..b3db3bf69 100644 --- a/sc/source/ui/inc/namecrea.hxx +++ b/sc/source/ui/inc/namecrea.hxx @@ -29,7 +29,7 @@ #define SC_NAMECREA_HXX #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> #include "scui_def.hxx" //CHINA001 diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx index 7fc73e9d6..8c0d425c1 100644 --- a/sc/source/ui/inc/namepast.hxx +++ b/sc/source/ui/inc/namepast.hxx @@ -29,7 +29,7 @@ #define SC_NAMEPAST_HXX #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx index eb533079a..9fe815b02 100644 --- a/sc/source/ui/inc/prevwsh.hxx +++ b/sc/source/ui/inc/prevwsh.hxx @@ -116,11 +116,7 @@ public: virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); virtual USHORT SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); - virtual PrintDialog* CreatePrintDialog( Window* pParent ); virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ); - virtual void PreparePrint( PrintDialog* pPrintDialog = NULL ); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ); - virtual USHORT Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog = NULL ); void AddAccessibilityObject( SfxListener& rObject ); void RemoveAccessibilityObject( SfxListener& rObject ); diff --git a/sc/source/ui/inc/scendlg.hxx b/sc/source/ui/inc/scendlg.hxx index 6f42535c7..a1ca9c38b 100644 --- a/sc/source/ui/inc/scendlg.hxx +++ b/sc/source/ui/inc/scendlg.hxx @@ -32,7 +32,7 @@ #include <vcl/dialog.hxx> #include <vcl/edit.hxx> #include <vcl/fixed.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <svtools/svmedit.hxx> #include <svtools/ctrlbox.hxx> diff --git a/sc/source/ui/inc/strindlg.hxx b/sc/source/ui/inc/strindlg.hxx index ac7c61902..c60209c91 100644 --- a/sc/source/ui/inc/strindlg.hxx +++ b/sc/source/ui/inc/strindlg.hxx @@ -31,7 +31,7 @@ #include <vcl/dialog.hxx> #include <vcl/fixed.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/edit.hxx> #include <layout/layout.hxx> diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx index fd9e6e7aa..178543df1 100644 --- a/sc/source/ui/inc/tabbgcolordlg.hxx +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -32,7 +32,8 @@ #define SC_TABBGCOLORDLG_HXX #include <vcl/dialog.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/fixed.hxx> +#include <vcl/button.hxx> #include <svtools/valueset.hxx> //------------------------------------------------------------------------ diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index d97a600b7..497caaded 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -287,7 +287,8 @@ public: BOOL IsMinimized() const { return bMinimized; } - void TabChanged(); + // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet + void TabChanged( bool bSameTabButMoved = false ); void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll ); SC_DLLPUBLIC void RefreshZoom(); void SetPagebreakMode( BOOL bSet ); @@ -387,10 +388,8 @@ public: void SetNewStartIfMarking(); - //<!--Added by PengYunQuan for Validity Cell Range Picker - //void SetTabNo( SCTAB nTab, BOOL bNew = FALSE, BOOL bExtendSelection = FALSE ); - SC_DLLPUBLIC void SetTabNo( SCTAB nTab, BOOL bNew = FALSE, BOOL bExtendSelection = FALSE ); - //-->Added by PengYunQuan for Validity Cell Range Picker + // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet + SC_DLLPUBLIC void SetTabNo( SCTAB nTab, BOOL bNew = FALSE, BOOL bExtendSelection = FALSE, bool bSameTabButMoved = false ); void SelectNextTab( short nDir, BOOL bExtendSelection = FALSE ); void ActivateView( BOOL bActivate, BOOL bFirst ); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 68cbfe5d5..621e9a167 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -369,13 +369,7 @@ public: virtual USHORT SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsApi=false ); - virtual PrintDialog* CreatePrintDialog( Window* pParent ); virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ); - virtual void PreparePrint( PrintDialog* pPrintDialog = NULL ); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, - PrintDialog *pPrintDialog, - BOOL bSilent, BOOL bIsAPI ); - virtual USHORT Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog = NULL ); void ConnectObject( SdrOle2Obj* pObj ); BOOL ActivateObject( SdrOle2Obj* pObj, long nVerb ); diff --git a/sc/source/ui/inc/tphf.hxx b/sc/source/ui/inc/tphf.hxx index 32dba2482..79db18ba7 100644 --- a/sc/source/ui/inc/tphf.hxx +++ b/sc/source/ui/inc/tphf.hxx @@ -29,7 +29,7 @@ #define SC_TPHF_HXX -#include <svx/hdft2.hxx> +#include <svx/hdft.hxx> class ScStyleDlg; diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index e4db2bdd8..c27b59f80 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -64,6 +64,7 @@ private: BOOL bDragWasInternal; BOOL bUsedForLink; bool bHasFiltered; // if has filtered rows + bool bUseInApi; // to recognize clipboard content copied from API void InitDocShell(); static void StripRefs( ScDocument* pDoc, SCCOL nStartX, SCROW nStartY, @@ -93,6 +94,7 @@ public: SCTAB GetVisibleTab() const { return nVisibleTab; } USHORT GetDragSourceFlags() const { return nDragSourceFlags; } bool HasFilteredRows() const { return bHasFiltered; } + bool GetUseInApi() const { return bUseInApi; } ScDocShell* GetSourceDocShell(); ScDocument* GetSourceDocument(); ScMarkData GetSourceMarkData(); @@ -103,6 +105,7 @@ public: void SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark ); void SetDragSourceFlags( USHORT nFlags ); void SetDragWasInternal(); + SC_DLLPUBLIC void SetUseInApi( bool bSet ); static SC_DLLPUBLIC ScTransferObj* GetOwnClipboard( Window* pUIWin ); diff --git a/sc/source/ui/inc/ui_pch.hxx b/sc/source/ui/inc/ui_pch.hxx index cfa1ac075..4a6dfaf79 100644 --- a/sc/source/ui/inc/ui_pch.hxx +++ b/sc/source/ui/inc/ui_pch.hxx @@ -81,7 +81,7 @@ #include <vcl/outdev.hxx> #include <vcl/pointr.hxx> #include <vcl/ptrstyle.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/event.hxx> #include <limits.h> #include <tools/errinf.hxx> @@ -185,7 +185,6 @@ #include <sfx2/ipfrm.hxx> #include <docsh.hxx> //REMOVE #include <sfx2/interno.hxx> -#include <vcl/wintypes.hxx> #include <sfx2/docfac.hxx> #include <scitems.hxx> #include <vcl/virdev.hxx> @@ -208,7 +207,7 @@ #include <svl/stritem.hxx> #include <collect.hxx> #include <svx/svdsob.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <svx/svdobj.hxx> #include <svx/svdglue.hxx> #include <svx/svdlayer.hxx> diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 1f969dafb..d30c32b72 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -53,6 +53,7 @@ class SfxItemSet; class SvxBorderLine; class SvxBoxItem; class SvxBoxInfoItem; +class SfxStyleSheetBase; class SfxStyleSheet; class SfxPoolItem; class EditTextObject; @@ -187,8 +188,8 @@ public: const SfxStyleSheet* GetStyleSheetFromMarked(); void SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, BOOL bRecord = TRUE ); - void RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet ); - void UpdateStyleSheetInUse( SfxStyleSheet* pStyleSheet ); + void RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ); + void UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ); void SetNumberFormat( short nFormatType, ULONG nAdd = 0 ); void SetNumFmtByStr( const String& rCode ); diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index fb62eaba6..628b50bfd 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -49,7 +49,7 @@ #include <svl/zforlist.hxx> #include <vcl/msgbox.hxx> #include <comphelper/processfactory.hxx> - +#include <sfx2/sfxresid.hxx> #include "sc.hrc" #include "scmod.hxx" #include "attrib.hxx" @@ -251,7 +251,7 @@ IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG ) { if ( !bFmtInserted && pSelFmtData ) { - String aStrStandard( ScResId(STR_STANDARD) ); + String aStrStandard( SfxResId(STR_STANDARD) ); String aFormatName; ScStringInputDlg* pDlg; BOOL bOk = FALSE; diff --git a/sc/source/ui/src/scstring.src b/sc/source/ui/src/scstring.src index f7c44c1fc..ef43dd3fa 100644 --- a/sc/source/ui/src/scstring.src +++ b/sc/source/ui/src/scstring.src @@ -553,11 +553,6 @@ String STR_REPLCELLSWARN Text [ en-US ] = "You are pasting data into cells that already contain data.\nDo you really want to overwrite the existing data?"; }; -String STR_PRINT_NOTHING -{ - Text [ en-US ] = "There is nothing to print. The selected print range or sheet is empty."; -}; - String SCSTR_ALLFILTER { Text [ en-US ] = "All"; @@ -749,22 +744,13 @@ StringArray SCSTR_PRINT_OPTIONS { < "Pages"; >; < "~Include output of empty pages"; >; - < "If checked empty pages that have no cell contents or draw objects are not printed."; >; - < "Sheets"; >; - < "Print ~only selected sheets"; >; - < "If checked only contents from selected sheets are printed, even if you specify a wider range in the Format - Print Ranges dialog. Content from sheets that are not selected will not be printed."; >; < "Print content"; >; < "~All sheets"; >; - < "The printout will be created from all sheets in the document."; >; < "~Selected sheets"; >; - < "The printout will be created only from the currently selected sheets."; >; < "Selected cells"; >; - < "The printout will be created only from the currently selected cells."; >; < "Thereof print"; >; < "All ~pages"; >; - < "Print all pages of the printable content."; >; < "Pa~ges"; >; - < "Print only some pages of the printable content."; >; < "%PRODUCTNAME %s"; >; }; }; diff --git a/sc/source/ui/unoobj/addruno.cxx b/sc/source/ui/unoobj/addruno.cxx index 4bea38e7c..d5ab13c39 100644 --- a/sc/source/ui/unoobj/addruno.cxx +++ b/sc/source/ui/unoobj/addruno.cxx @@ -69,7 +69,7 @@ void ScAddressConversionObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) } } -sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString ) +sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString, ::formula::FormulaGrammar::AddressConvention eConv ) { if (!pDocShell) return sal_False; @@ -78,7 +78,7 @@ sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString ) sal_Bool bSuccess = sal_False; if ( bIsRange ) { - USHORT nResult = aRange.ParseAny( rUIString, pDoc ); + USHORT nResult = aRange.ParseAny( rUIString, pDoc, eConv ); if ( nResult & SCA_VALID ) { if ( ( nResult & SCA_TAB_3D ) == 0 ) @@ -92,7 +92,7 @@ sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString ) } else { - USHORT nResult = aRange.aStart.Parse( rUIString, pDoc ); + USHORT nResult = aRange.aStart.Parse( rUIString, pDoc, eConv ); if ( nResult & SCA_VALID ) { if ( ( nResult & SCA_TAB_3D ) == 0 ) @@ -118,6 +118,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAddressConversionObj::getProp {MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_XLA1REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, {0,0,0,0,0,0} }; static uno::Reference<beans::XPropertySetInfo> aRef(new SfxItemPropertySetInfo( aPropertyMap )); @@ -131,6 +132,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAddressConversionObj::getProp {MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_XLA1REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 }, {0,0,0,0,0,0} }; static uno::Reference<beans::XPropertySetInfo> aRef(new SfxItemPropertySetInfo( aPropertyMap )); @@ -190,8 +192,11 @@ void SAL_CALL ScAddressConversionObj::setPropertyValue( const rtl::OUString& aPr bSuccess = ParseUIString( aUIString ); } } - else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) ) + else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XLA1REPR ) ) { + ::formula::FormulaGrammar::AddressConvention eConv = aNameStr.EqualsAscii( SC_UNONAME_XLA1REPR ) ? + ::formula::FormulaGrammar::CONV_OOO : ::formula::FormulaGrammar::CONV_XL_A1; + // parse the file format string rtl::OUString sRepresentation; if (aValue >>= sRepresentation) @@ -212,7 +217,7 @@ void SAL_CALL ScAddressConversionObj::setPropertyValue( const rtl::OUString& aPr } // parse the rest like a UI string - bSuccess = ParseUIString( aUIString ); + bSuccess = ParseUIString( aUIString, eConv ); } } else @@ -265,17 +270,23 @@ uno::Any SAL_CALL ScAddressConversionObj::getPropertyValue( const rtl::OUString& aRange.aStart.Format( aFormatStr, nFlags, pDoc ); aRet <<= rtl::OUString( aFormatStr ); } - else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) ) + else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XLA1REPR ) ) { + ::formula::FormulaGrammar::AddressConvention eConv = aNameStr.EqualsAscii( SC_UNONAME_XLA1REPR ) ? + ::formula::FormulaGrammar::CONV_OOO : ::formula::FormulaGrammar::CONV_XL_A1; + // generate file format string - always include sheet String aFormatStr; - aRange.aStart.Format( aFormatStr, SCA_VALID | SCA_TAB_3D, pDoc ); + aRange.aStart.Format( aFormatStr, SCA_VALID | SCA_TAB_3D, pDoc, eConv ); if ( bIsRange ) { // manually concatenate range so both parts always have the sheet name aFormatStr.Append( (sal_Unicode) ':' ); String aSecond; - aRange.aEnd.Format( aSecond, SCA_VALID | SCA_TAB_3D, pDoc ); + USHORT nFlags = SCA_VALID; + if( eConv != ::formula::FormulaGrammar::CONV_XL_A1 ) + nFlags |= SCA_TAB_3D; + aRange.aEnd.Format( aSecond, nFlags, pDoc, eConv ); aFormatStr.Append( aSecond ); } aRet <<= rtl::OUString( aFormatStr ); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 54bfeb7dc..23bde9d8b 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6272,6 +6272,53 @@ void ScCellObj::SetFormulaWithGrammar( const ::rtl::OUString& rFormula, } } +void ScCellObj::InputEnglishString( const ::rtl::OUString& rText ) +{ + // This is like a mixture of setFormula and property FormulaLocal: + // The cell's number format is checked for "text", a new cell format may be set, + // but all parsing is in English. + + ScDocShell* pDocSh = GetDocShell(); + if ( pDocSh ) + { + String aString(rText); + ScDocument* pDoc = pDocSh->GetDocument(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos ); + if ( pFormatter->GetType( nOldFormat ) == NUMBERFORMAT_TEXT ) + { + SetString_Impl(aString, FALSE, FALSE); // text cell + } + else + { + ScDocFunc aFunc(*pDocSh); + short nFormatType = 0; + ScBaseCell* pNewCell = aFunc.InterpretEnglishString( aCellPos, aString, + EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1, &nFormatType ); + if (pNewCell) + { + if ( ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 && nFormatType != 0 ) + { + // apply a format for the recognized type and the old format's language + sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat( *pFormatter, nOldFormat, nFormatType ); + if ( nNewFormat != nOldFormat ) + { + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); + // ATTR_LANGUAGE_FORMAT remains unchanged + aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE ); + } + } + // put the cell into the document + // (after applying the format, so possible formula recalculation already uses the new format) + (void)aFunc.PutCell( aCellPos, pNewCell, TRUE ); + } + else + SetString_Impl(aString, FALSE, FALSE); // no cell from InterpretEnglishString, probably empty string + } + } +} + // XText uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor() @@ -8482,8 +8529,7 @@ void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn rtl::OUString aCodeName; if ( pDocSh && ( aValue >>= aCodeName ) ) { - String sNewName( aCodeName ); - pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName ); + pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), aCodeName ); } } else diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 5d8e320f2..eb0306ab7 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -225,53 +225,53 @@ ScPrintUIOptions::ScPrintUIOptions() sal_Bool bSuppress = rPrintOpt.GetSkipEmpty(); ResStringArray aStrings( ScResId( SCSTR_PRINT_OPTIONS ) ); - DBG_ASSERT( aStrings.Count() >= 19, "resource incomplete" ); - if( aStrings.Count() < 19 ) // bad resource ? + DBG_ASSERT( aStrings.Count() >= 10, "resource incomplete" ); + if( aStrings.Count() < 10 ) // bad resource ? return; m_aUIProperties.realloc( 8 ); // create Section for spreadsheet (results in an extra tab page in dialog) SvtModuleOptions aOpt; - String aAppGroupname( aStrings.GetString( 18 ) ); + String aAppGroupname( aStrings.GetString( 9 ) ); aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), aOpt.GetModuleName( SvtModuleOptions::E_SCALC ) ); - m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); + m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) ); // create subgroup for pages m_aUIProperties[1].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ), rtl::OUString() ); // create a bool option for empty pages m_aUIProperties[2].Value = getBoolControlOpt( rtl::OUString( aStrings.GetString( 1 ) ), - rtl::OUString( aStrings.GetString( 2 ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsIncludeEmptyPages:CheckBox" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsIncludeEmptyPages" ) ), ! bSuppress ); // create Subgroup for print content vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); - m_aUIProperties[3].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 6 ) ), + m_aUIProperties[3].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 2 ) ), rtl::OUString(), aPrintRangeOpt ); // create a choice for the content to create - uno::Sequence< rtl::OUString > aChoices( 3 ), aHelpTexts( 3 ); - aChoices[0] = aStrings.GetString( 7 ); - aHelpTexts[0] = aStrings.GetString( 8 ); - aChoices[1] = aStrings.GetString( 9 ); - aHelpTexts[1] = aStrings.GetString( 10 ); - aChoices[2] = aStrings.GetString( 11 ); - aHelpTexts[2] = aStrings.GetString( 12 ); + uno::Sequence< rtl::OUString > aChoices( 3 ), aHelpIds( 3 ); + aChoices[0] = aStrings.GetString( 3 ); + aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) ); + aChoices[1] = aStrings.GetString( 4 ); + aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) ); + aChoices[2] = aStrings.GetString( 5 ); + aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) ); m_aUIProperties[4].Value = getChoiceControlOpt( rtl::OUString(), - aHelpTexts, + aHelpIds, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ), aChoices, nContent ); // create Subgroup for print range aPrintRangeOpt.mbInternalOnly = sal_True; - m_aUIProperties[5].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 13 ) ), + m_aUIProperties[5].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 6 ) ), rtl::OUString(), aPrintRangeOpt ); @@ -279,13 +279,13 @@ ScPrintUIOptions::ScPrintUIOptions() // create a choice for the range to print rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); aChoices.realloc( 2 ); - aHelpTexts.realloc( 2 ); - aChoices[0] = aStrings.GetString( 14 ); - aHelpTexts[0] = aStrings.GetString( 15 ); - aChoices[1] = aStrings.GetString( 16 ); - aHelpTexts[1] = aStrings.GetString( 17 ); + aHelpIds.realloc( 2 ); + aChoices[0] = aStrings.GetString( 7 ); + aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0" ) ); + aChoices[1] = aStrings.GetString( 8 ); + aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1" ) ); m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(), - aHelpTexts, + aHelpIds, aPrintRangeName, aChoices, 0 ); @@ -293,24 +293,11 @@ ScPrintUIOptions::ScPrintUIOptions() // create a an Edit dependent on "Pages" selected vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); m_aUIProperties[7].Value = getEditControlOpt( rtl::OUString(), - rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageRange:Edit" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), rtl::OUString(), aPageRangeOpt ); - - // "Print only selected sheets" isn't needed because of the "Selected Sheets" choice in "Print content" -#if 0 - // create subgroup for sheets - m_aUIProperties[8].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 3 ) ), rtl::OUString() ); - - // create a bool option for selected pages only - m_aUIProperties[9].Value = getBoolControlOpt( rtl::OUString( aStrings.GetString( 4 ) ), - rtl::OUString( aStrings.GetString( 5 ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsOnlySelectedSheets" ) ), - i_bSelectedOnly - ); -#endif } void ScPrintUIOptions::SetDefaults() @@ -449,6 +436,12 @@ ScSheetSaveData* ScModelObj::GetSheetSaveData() return NULL; } +void ScModelObj::RepaintRange( const ScRange& rRange ) +{ + if (pDocShell) + pDocShell->PostPaint( rRange, PAINT_GRID ); +} + uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) { @@ -590,8 +583,21 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) DELETEZ( pPrintFuncCache ); // handle "OnCalculate" sheet events (search also for VBA event handlers) - if ( pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) ) - HandleCalculateEvents(); + if ( pDocShell ) + { + ScDocument* pDoc = pDocShell->GetDocument(); + if ( pDoc->GetVbaEventProcessor().is() ) + { + // If the VBA event processor is set, HasAnyCalcNotification is much faster than HasAnySheetEventScript + if ( pDoc->HasAnyCalcNotification() && pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) ) + HandleCalculateEvents(); + } + else + { + if ( pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE ) ) + HandleCalculateEvents(); + } + } } } else if ( rHint.ISA( ScPointerChangedHint ) ) @@ -1959,6 +1965,7 @@ uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance( case SC_SERVICE_MARKERTAB: xRet.set(xDrawMarkerTab); break; case SC_SERVICE_DASHTAB: xRet.set(xDrawDashTab); break; case SC_SERVICE_CHDATAPROV: xRet.set(xChartDataProv); break; + case SC_SERVICE_VBAOBJECTPROVIDER: xRet.set(xObjProvider); break; } // #i64497# If a chart is in a temporary document during clipoard paste, @@ -1984,6 +1991,7 @@ uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance( case SC_SERVICE_MARKERTAB: xDrawMarkerTab.set(xRet); break; case SC_SERVICE_DASHTAB: xDrawDashTab.set(xRet); break; case SC_SERVICE_CHDATAPROV: xChartDataProv.set(xRet); break; + case SC_SERVICE_VBAOBJECTPROVIDER: xObjProvider.set(xRet); break; } } } diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 38bda7df8..946cc2425 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -236,16 +236,11 @@ ScTableConditionalFormat::~ScTableConditionalFormat() void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry) { - ScTableConditionalEntry* pNew = new ScTableConditionalEntry(this, aEntry); + ScTableConditionalEntry* pNew = new ScTableConditionalEntry(aEntry); pNew->acquire(); aEntries.Insert( pNew, LIST_APPEND ); } -void ScTableConditionalFormat::DataChanged() -{ - // wenn's mal das "lebende Objekt" ist, muss hier was passieren... -} - // XSheetConditionalFormat ScTableConditionalEntry* ScTableConditionalFormat::GetObjectByIndex_Impl(USHORT nIndex) const @@ -348,7 +343,6 @@ void SAL_CALL ScTableConditionalFormat::addNew( } AddEntry_Impl(aEntry); - DataChanged(); } void SAL_CALL ScTableConditionalFormat::removeByIndex( sal_Int32 nIndex ) @@ -360,7 +354,6 @@ void SAL_CALL ScTableConditionalFormat::removeByIndex( sal_Int32 nIndex ) { aEntries.Remove(pEntry); pEntry->release(); - DataChanged(); } } @@ -371,8 +364,6 @@ void SAL_CALL ScTableConditionalFormat::clear() throw(uno::RuntimeException) aEntries.First(); while ( ( pEntry = (ScTableConditionalEntry*)aEntries.Remove() ) != NULL ) pEntry->release(); - - DataChanged(); } // XEnumerationAccess @@ -525,19 +516,14 @@ ScTableConditionalFormat* ScTableConditionalFormat::getImplementation( //UNUSED2008-05 { //UNUSED2008-05 } -ScTableConditionalEntry::ScTableConditionalEntry(ScTableConditionalFormat* pPar, - const ScCondFormatEntryItem& aItem) : - pParent( pPar ), +ScTableConditionalEntry::ScTableConditionalEntry(const ScCondFormatEntryItem& aItem) : aData( aItem ) { - if (pParent) - pParent->acquire(); + // #i113668# only store the settings, keep no reference to parent object } ScTableConditionalEntry::~ScTableConditionalEntry() { - if (pParent) - pParent->release(); } void ScTableConditionalEntry::GetData(ScCondFormatEntryItem& rData) const @@ -559,8 +545,6 @@ void SAL_CALL ScTableConditionalEntry::setOperator( sheet::ConditionOperator nOp { ScUnoGuard aGuard; aData.meMode = lcl_ConditionOperatorToMode( nOperator ); - if (pParent) - pParent->DataChanged(); } rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula1() throw(uno::RuntimeException) @@ -574,8 +558,6 @@ void SAL_CALL ScTableConditionalEntry::setFormula1( const rtl::OUString& aFormul { ScUnoGuard aGuard; aData.maExpr1 = String( aFormula1 ); - if (pParent) - pParent->DataChanged(); } rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula2() throw(uno::RuntimeException) @@ -589,8 +571,6 @@ void SAL_CALL ScTableConditionalEntry::setFormula2( const rtl::OUString& aFormul { ScUnoGuard aGuard; aData.maExpr2 = String( aFormula2 ); - if (pParent) - pParent->DataChanged(); } table::CellAddress SAL_CALL ScTableConditionalEntry::getSourcePosition() throw(uno::RuntimeException) @@ -608,8 +588,6 @@ void SAL_CALL ScTableConditionalEntry::setSourcePosition( const table::CellAddre { ScUnoGuard aGuard; aData.maPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet ); - if (pParent) - pParent->DataChanged(); } // XSheetConditionalEntry @@ -625,8 +603,6 @@ void SAL_CALL ScTableConditionalEntry::setStyleName( const rtl::OUString& aStyle { ScUnoGuard aGuard; aData.maStyle = ScStyleNameConversion::ProgrammaticToDisplayName( aStyleName, SFX_STYLE_FAMILY_PARA ); - if (pParent) - pParent->DataChanged(); } //------------------------------------------------------------------------ @@ -739,11 +715,6 @@ ScTableValidationObj::~ScTableValidationObj() { } -void ScTableValidationObj::DataChanged() -{ - // wenn's mal das "lebende Objekt" ist, muss hier was passieren... -} - // XSheetCondition sheet::ConditionOperator SAL_CALL ScTableValidationObj::getOperator() @@ -758,7 +729,6 @@ void SAL_CALL ScTableValidationObj::setOperator( sheet::ConditionOperator nOpera { ScUnoGuard aGuard; nMode = sal::static_int_cast<USHORT>( lcl_ConditionOperatorToMode( nOperator ) ); - DataChanged(); } rtl::OUString SAL_CALL ScTableValidationObj::getFormula1() throw(uno::RuntimeException) @@ -772,7 +742,6 @@ void SAL_CALL ScTableValidationObj::setFormula1( const rtl::OUString& aFormula1 { ScUnoGuard aGuard; aExpr1 = String( aFormula1 ); - DataChanged(); } rtl::OUString SAL_CALL ScTableValidationObj::getFormula2() throw(uno::RuntimeException) @@ -786,7 +755,6 @@ void SAL_CALL ScTableValidationObj::setFormula2( const rtl::OUString& aFormula2 { ScUnoGuard aGuard; aExpr2 = String( aFormula2 ); - DataChanged(); } table::CellAddress SAL_CALL ScTableValidationObj::getSourcePosition() throw(uno::RuntimeException) @@ -804,7 +772,6 @@ void SAL_CALL ScTableValidationObj::setSourcePosition( const table::CellAddress& { ScUnoGuard aGuard; aSrcPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet ); - DataChanged(); } uno::Sequence<sheet::FormulaToken> SAL_CALL ScTableValidationObj::getTokens( sal_Int32 nIndex ) @@ -963,8 +930,6 @@ void SAL_CALL ScTableValidationObj::setPropertyValue( if ( aValue >>= nVal ) meGrammar2 = static_cast< FormulaGrammar::Grammar >(nVal); } - - DataChanged(); } uno::Any SAL_CALL ScTableValidationObj::getPropertyValue( const rtl::OUString& aPropertyName ) diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index e8c51122f..a38b6b719 100755..100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -400,20 +400,16 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter ) if ( !bRepairPackage ) { // ask the user whether he wants to try to repair - RequestPackageReparation* pRequest = new RequestPackageReparation( aDocumentTitle ); - uno::Reference< task::XInteractionRequest > xRequest ( pRequest ); - - xInteraction->handle( xRequest ); - - bRepairAllowed = pRequest->isApproved(); + RequestPackageReparation aRequest( aDocumentTitle ); + xInteraction->handle( aRequest.GetRequest() ); + bRepairAllowed = aRequest.isApproved(); } if ( !bRepairAllowed ) { // repair either not allowed or not successful - NotifyBrokenPackage* pNotifyRequest = new NotifyBrokenPackage( aDocumentTitle ); - uno::Reference< task::XInteractionRequest > xRequest ( pNotifyRequest ); - xInteraction->handle( xRequest ); + NotifyBrokenPackage aNotifyRequest( aDocumentTitle ); + xInteraction->handle( aNotifyRequest.GetRequest() ); } } diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index a9a83b7ee..3fd9db7a0 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -28,8 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - #include <tools/debug.hxx> #include <svtools/unoimap.hxx> #include <svx/unofill.hxx> @@ -61,6 +59,7 @@ #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> #include <com/sun/star/script/ScriptEventDescriptor.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/document/XCodeNameQuery.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> @@ -573,6 +572,11 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); if ( pAppMgr ) pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); + + // create the VBA document event processor + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( + ::ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBASpreadsheetEventProcessor", aArgs ), uno::UNO_QUERY ); + pDocShell->GetDocument()->SetVbaEventProcessor( xVbaEvents ); } } break; diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 0a3fe3f9e..5643dce45 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -572,7 +572,7 @@ void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent ) } } -void ScTabViewObj::SheetChanged() +void ScTabViewObj::SheetChanged( bool bSameTabButMoved ) { if ( !GetViewShell() ) return; @@ -600,9 +600,10 @@ void ScTabViewObj::SheetChanged() } } - // handle sheet events + /* Handle sheet events, but do not trigger event handlers, if the old + active sheet gets re-activated after inserting/deleting/moving a sheet. */ SCTAB nNewTab = pViewData->GetTabNo(); - if ( nNewTab != nPreviousTab ) + if ( !bSameTabButMoved && (nNewTab != nPreviousTab) ) { lcl_CallActivate( pDocSh, nPreviousTab, SC_SHEETEVENT_UNFOCUS ); lcl_CallActivate( pDocSh, nNewTab, SC_SHEETEVENT_FOCUS ); diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 5fc1b3c40..77f80b889 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -24,24 +24,25 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <docuno.hxx> + #include "excelvbahelper.hxx" + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/sheet/XSheetCellRange.hpp> +#include "docuno.hxx" #include "tabvwsh.hxx" #include "transobj.hxx" #include "scmod.hxx" #include "cellsuno.hxx" -#include <comphelper/processfactory.hxx> -#include <com/sun/star/sheet/XSheetCellRange.hpp> + +namespace ooo { +namespace vba { +namespace excel { using namespace ::com::sun::star; using namespace ::ooo::vba; -namespace ooo -{ -namespace vba -{ -namespace excel -{ +// ============================================================================ ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) { @@ -150,7 +151,14 @@ implnCopy( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) + { pViewShell->CopyToClip(NULL,false,false,true); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } void @@ -158,7 +166,14 @@ implnCut( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) + { pViewShell->CutToClip( NULL, TRUE ); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) @@ -181,7 +196,10 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFl ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); ScDocument* pDoc = NULL; if ( pOwnClip ) + { pDoc = pOwnClip->GetDocument(); + pOwnClip->SetUseInApi( false ); // don't use in Insert after it was pasted once + } pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, eMoveMode, IDF_NONE, TRUE ); @@ -229,40 +247,63 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) return NULL; } -uno::Reference< XHelperInterface > -getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +uno::Reference< vba::XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet ) throw ( uno::RuntimeException ) { - uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xSheet, 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 + // 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 ); - + uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xSheet ) ), uno::UNO_QUERY ); return xParent; } +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< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + 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 ); } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCell >& xCell ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xCell, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< frame::XModel >& xModel, SCTAB nTab ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSpreadsheetDocument > xDoc( xModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheets->getByIndex( nTab ), uno::UNO_QUERY_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } +// ============================================================================ -} //excel -} //vba -} //ooo +} // namespace excel +} // namespace vba +} // namespace ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 528457a0f..3a32af6fc 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -27,41 +27,54 @@ #ifndef SC_EXCEL_VBA_HELPER_HXX #define SC_EXCEL_VBA_HELPER_HXX -#include<vbahelper/vbahelper.hxx> -#include <docsh.hxx> +#include <vbahelper/vbahelper.hxx> +#include "docsh.hxx" #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> #include <ooo/vba/XHelperInterface.hpp> class ScCellRangesBase; -namespace ooo +namespace ooo { +namespace vba { +namespace excel { + +// ============================================================================ + +// nTabs empty means apply zoom to all sheets +void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); +void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); +ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; +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::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException ); +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 ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) 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 { - namespace vba - { - namespace excel - { - // nTabs empty means apply zoom to all sheets - void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); - void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); - ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - 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: - static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); - }; -} -} -} +public: + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); +}; + +// ============================================================================ + +} // namespace excel +} // namespace vba +} // namespace ooo + #endif diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 92bb3fd39..5842b9023 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -110,15 +110,3 @@ SLOFILES= \ .INCLUDE : target.mk -.IF "$(L10N_framework)"=="" - -ALLTAR : \ - $(MISC)$/$(TARGET).don \ - -$(SLOFILES) : $(MISC)$/$(TARGET).don - -$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb - +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ - echo $@ - -.ENDIF diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 624fb610d..a0683a815 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -60,6 +60,7 @@ #include "sc.hrc" #include <osl/file.hxx> +#include <rtl/instance.hxx> #include <sfx2/request.hxx> #include <sfx2/objsh.hxx> @@ -108,11 +109,32 @@ public: ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){} }; +// ============================================================================ + +/** Global application settings shared by all open workbooks. */ +struct ScVbaAppSettings +{ + sal_Int32 mnCalculation; + sal_Bool mbDisplayAlerts; + sal_Bool mbEnableEvents; + + explicit ScVbaAppSettings(); +}; + +ScVbaAppSettings::ScVbaAppSettings() : + mnCalculation( excel::XlCalculation::xlCalculationAutomatic ), + mbDisplayAlerts( sal_True ), + mbEnableEvents( sal_True ) +{ +} + +struct ScVbaStaticAppSettings : public ::rtl::Static< ScVbaAppSettings, ScVbaStaticAppSettings > {}; + +// ============================================================================ + ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ) : ScVbaApplication_BASE( xContext ), - m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ), - m_bDisplayAlerts( sal_True ), - m_bEnableEvents( sal_True ) + mrAppSettings( ScVbaStaticAppSettings::get() ) { } @@ -120,6 +142,11 @@ ScVbaApplication::~ScVbaApplication() { } +/*static*/ bool ScVbaApplication::getDocumentEventsEnabled() +{ + return ScVbaStaticAppSettings::get().mbEnableEvents; +} + SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) ); @@ -396,8 +423,10 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::Runtime if( _statusbar >>= sText ) { setDisplayStatusBar( sal_True ); - xStatusIndicator->start( sText, 100 ); - //xStatusIndicator->setText( sText ); + if ( sText.getLength() ) + xStatusIndicator->start( sText, 100 ); + else + xStatusIndicator->end(); // restore normal state for empty text } else if( _statusbar >>= bDefault ) { @@ -415,6 +444,7 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::Runtime ::sal_Int32 SAL_CALL ScVbaApplication::getCalculation() throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); if(xCalc->isAutomaticCalculationEnabled()) return excel::XlCalculation::xlCalculationAutomatic; @@ -425,6 +455,7 @@ ScVbaApplication::getCalculation() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); switch(_calculation) { @@ -704,25 +735,25 @@ ScVbaApplication::getName() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException) { - m_bDisplayAlerts = displayAlerts; + mrAppSettings.mbDisplayAlerts = displayAlerts; } sal_Bool SAL_CALL ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) { - return m_bDisplayAlerts; + return mrAppSettings.mbDisplayAlerts; } void SAL_CALL ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) { - m_bEnableEvents = bEnable; + mrAppSettings.mbEnableEvents = bEnable; } sal_Bool SAL_CALL ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) { - return m_bEnableEvents; + return mrAppSettings.mbEnableEvents; } void SAL_CALL diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index e6ebe28a8..3060f76f6 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -39,12 +39,13 @@ //typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE; typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE; +struct ScVbaAppSettings; + class ScVbaApplication : public ScVbaApplication_BASE { private: - sal_Int32 m_xCalculation; - sal_Bool m_bDisplayAlerts; - sal_Bool m_bEnableEvents; + // note: member variables moved to struct "ScVbaAppSettings", see cxx file, to be shared by all application instances + ScVbaAppSettings& mrAppSettings; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); @@ -55,6 +56,9 @@ public: ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext ); virtual ~ScVbaApplication(); + /** Returns true, if VBA document events are enabled. */ + static bool getDocumentEventsEnabled(); + virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); // XExactName diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index bd71c9eb3..41f5a7123 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -48,6 +48,7 @@ #include "cellsuno.hxx" #include "convuno.hxx" +#include "vbaapplication.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::script::vba::VBAEventId; @@ -55,6 +56,51 @@ using namespace ::ooo::vba; // ============================================================================ +namespace { + +/** Extracts a sheet index from the specified element of the passed sequence. + The element may be an integer, a Calc range or ranges object, or a VBA Range object. */ +SCTAB lclGetTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) +{ + VbaEventsHelperBase::checkArgument( rArgs, nIndex ); + + // first try to extract a sheet index + SCTAB nTab = -1; + if( rArgs[ nIndex ] >>= nTab ) + return nTab; + + // try VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( xVbaRange.is() ) + { + uno::Reference< XHelperInterface > xVbaHelper( xVbaRange, uno::UNO_QUERY_THROW ); + // TODO: in the future, the parent may be an excel::XChart (chart sheet) -> will there be a common base interface? + uno::Reference< excel::XWorksheet > xVbaSheet( xVbaHelper->getParent(), uno::UNO_QUERY_THROW ); + // VBA sheet index is 1-based + return static_cast< SCTAB >( xVbaSheet->getIndex() - 1 ); + } + + // try single UNO range object + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); + if( xCellRangeAddressable.is() ) + return xCellRangeAddressable->getRangeAddress().Sheet; + + // at last, try UNO 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(); +} + +} // namespace + +// ============================================================================ + typedef ::cppu::WeakImplHelper4< awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener, util::XChangesListener > ScVbaEventsListener_BASE; @@ -90,7 +136,6 @@ private: uno::Reference< awt::XWindow > getContainerWindow(); bool isMouseReleased(); DECL_LINK( fireResizeMacro, void* ); - void processWindowResizeMacro(); private: ::osl::Mutex maMutex; @@ -287,7 +332,7 @@ void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aE aChange.ReplacedElement >>= xRangeObj; if( xRangeObj.is() ) { - uno::Sequence< uno::Any > aArgs(1); + uno::Sequence< uno::Any > aArgs( 1 ); aArgs[0] <<= xRangeObj; mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs ); } @@ -362,19 +407,18 @@ bool ScVbaEventsListener::isMouseReleased() IMPL_LINK( ScVbaEventsListener, fireResizeMacro, void*, EMPTYARG ) { - if( !mbDisposed && isMouseReleased() ) - processWindowResizeMacro(); + if( !mbDisposed && isMouseReleased() ) try + { + mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); + } + catch( uno::Exception& ) + { + // #163419# do not throw exceptions into application core + } 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 ) : @@ -383,7 +427,7 @@ ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, co { mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0; - + if( !mxModel.is() || !mpDocShell || !mpDoc ) return; @@ -441,43 +485,19 @@ void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) t // protected ------------------------------------------------------------------ -bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) 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() ) + if( !mpShell || !mpDoc ) 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; + // framework and Calc fire a few events before 'opened', ignore them + bool bExecuteEvent = mbOpened; + + // special handling for some events 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 ) @@ -490,15 +510,25 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, break; case WORKSHEET_SELECTIONCHANGE: // if selection is not changed, then do not fire the event - bExecuteEvent = mbOpened && isSelectionChanged( rArgs, 0 ); + bExecuteEvent = bExecuteEvent && 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 ) ); + if( bExecuteEvent ) + { + // add workbook event associated to a sheet event + bool bSheetEvent = false; + if( (rInfo.maUserData >>= bSheetEvent) && bSheetEvent ) + rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + + /* For document events: check if events are enabled via the + Application.EnableEvents symbol (this is an Excel-only attribute). + Check this again for every event, as the event handler may change + the state of the EnableEvents symbol. Global events such as + AUTO_OPEN and AUTO_CLOSE are always enabled. */ + if( rInfo.meType == EVENTHANDLER_DOCUMENT ) + bExecuteEvent = ScVbaApplication::getDocumentEventsEnabled(); + } return bExecuteEvent; } @@ -622,7 +652,7 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, { bool bSheetEvent = false; rInfo.maUserData >>= bSheetEvent; - SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1; + SCTAB nTab = bSheetEvent ? lclGetTabFromArgs( rArgs, 0 ) : -1; if( bSheetEvent && (nTab < 0) ) throw lang::IllegalArgumentException(); @@ -636,95 +666,82 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, // private -------------------------------------------------------------------- -SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) -{ - checkArgument( rArgs, nIndex ); +namespace { - // first try to extract a sheet index - SCTAB nTab = -1; - if( rArgs[ nIndex ] >>= nTab ) - return nTab; +/** Compares the passed range lists representing sheet selections. Ignores + selections that refer to different sheets (returns false in this case). */ +bool lclSelectionChanged( const ScRangeList& rLeft, const ScRangeList& rRight ) +{ + // one of the range lists empty? -> return false, if both lists empty + bool bLeftEmpty = rLeft.Count() == 0; + bool bRightEmpty = rRight.Count() == 0; + if( bLeftEmpty || bRightEmpty ) + return !(bLeftEmpty && bRightEmpty); - // next, try single range object - uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); - if( xCellRangeAddressable.is() ) - return xCellRangeAddressable->getRangeAddress().Sheet; + // check sheet indexes of the range lists (assuming that all ranges in a list are on the same sheet) + if( rLeft.GetObject( 0 )->aStart.Tab() != rRight.GetObject( 0 )->aStart.Tab() ) + return false; - // 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(); + // compare all ranges + return rLeft != rRight; } +} // namespace + bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) { + uno::Reference< uno::XInterface > xOldSelection( maOldSelection, uno::UNO_QUERY ); 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; + ScCellRangesBase* pOldCellRanges = ScCellRangesBase::getImplementation( xOldSelection ); + ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ); + bool bChanged = !pOldCellRanges || !pNewCellRanges || lclSelectionChanged( pOldCellRanges->GetRangeList(), pNewCellRanges->GetRangeList() ); + maOldSelection <<= xNewSelection; + return bChanged; } 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 ); + SCTAB nTab = lclGetTabFromArgs( rArgs, nIndex ); + return uno::Any( excel::getUnoSheetModuleObj( mxModel, nTab ) ); } 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(); + // it is possible to pass an existing VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( !xVbaRange.is() ) + { + 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 ); + uno::Sequence< uno::Any > aArgs( 2 ); + if ( xRanges.is() ) + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRanges ); + aArgs[ 1 ] <<= xRanges; + } + else + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRange ); + aArgs[ 1 ] <<= xRange; + } + xVbaRange.set( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_QUERY_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::Reference< table::XCell > xCell = getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent - aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xCell ); + aArgs[ 1 ] <<= xCell; uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW ); return uno::Any( xHyperlink ); } diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index dd704a141..6024387c3 100755 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -33,8 +33,6 @@ #include "excelvbahelper.hxx" #include "rangelst.hxx" -namespace ooo { namespace vba { namespace excel { class XApplication; } } } - class ScVbaEventsListener; // ============================================================================ @@ -51,16 +49,12 @@ public: 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); @@ -75,11 +69,10 @@ private: css::uno::Any createWindow() const throw (css::uno::RuntimeException); private: - mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication; ::rtl::Reference< ScVbaEventsListener > mxListener; + css::uno::Any maOldSelection; ScDocShell* mpDocShell; ScDocument* mpDoc; - ScRangeList maOldSelection; bool mbOpened; }; diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index 6a3291492..2ba10765a 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -100,7 +100,6 @@ ScVbaNames::Add( const css::uno::Any& Name , const css::uno::Any& RefersToR1C1, const css::uno::Any& RefersToR1C1Local ) throw (css::uno::RuntimeException) { - rtl::OUString sName; uno::Reference< excel::XRange > xRange; if ( Name.hasValue() ) @@ -153,11 +152,13 @@ ScVbaNames::Add( const css::uno::Any& Name , sTmp += sRangeAdd; if ( mxNames.is() ) { - RangeType nType = RT_NAME; + RangeType nType = RT_NAME; table::CellAddress aCellAddr( aAddr.Sheet , aAddr.StartColumn , aAddr.StartRow ); if ( mxNames->hasByName( sName ) ) mxNames->removeByName(sName); mxNames->addNewByName( sName , rtl::OUString(sTmp) , aCellAddr , (sal_Int32)nType); + uno::Reference< sheet::XNamedRange > xName( mxNames->getByName( sName ), uno::UNO_QUERY_THROW ); + return uno::Any( uno::Reference< excel::XName >( new ScVbaName( getParent(), mxContext, xName, mxNames, mxModel ) ) ); } } return css::uno::Any(); @@ -174,7 +175,7 @@ uno::Reference< container::XEnumeration > ScVbaNames::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW ); - return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); + return new NamesEnumeration( getParent(), mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); } uno::Any diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 82f6f44f3..843f61cbe 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -24,6 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + +#include "vbarange.hxx" + #include <vbahelper/helperdecl.hxx> #include <comphelper/unwrapargs.hxx> @@ -31,6 +34,8 @@ #include <sfx2/objsh.hxx> #include <com/sun/star/script/ArrayWrapper.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/sheet/XDatabaseRange.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> #include <com/sun/star/sheet/XGoalSeek.hpp> @@ -123,6 +128,7 @@ #include <cellsuno.hxx> #include <dbcolect.hxx> #include "docfunc.hxx" +#include "transobj.hxx" #include <sfx2/dispatch.hxx> #include <sfx2/app.hxx> @@ -134,7 +140,7 @@ #include <globstr.hrc> #include <unonames.hxx> -#include "vbarange.hxx" +#include "vbaapplication.hxx" #include "vbafont.hxx" #include "vbacomment.hxx" #include "vbainterior.hxx" @@ -172,6 +178,9 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; using ::std::vector; +// difference between VBA and file format width, in character units +const double fExtraWidth = 182.0 / 256.0; + // * 1 point = 1/72 inch = 20 twips // * 1 inch = 72 points = 1440 twips // * 1 cm = 567 twips @@ -264,6 +273,26 @@ SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) return pDataSet; } +void ScVbaRange::fireChangeEvent() +{ + if( ScVbaApplication::getDocumentEventsEnabled() ) + { + if( ScDocument* pDoc = getScDocument() ) + { + uno::Reference< script::vba::XVBAEventProcessor > xVBAEvents = pDoc->GetVbaEventProcessor(); + if( xVBAEvents.is() ) try + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< excel::XRange >( this ); + xVBAEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_CHANGE, aArgs ); + } + catch( uno::Exception& ) + { + } + } + } +} + class SingleRangeEnumeration : public EnumerationHelper_BASE { uno::Reference< XHelperInterface > m_xParent; @@ -539,19 +568,22 @@ public: { uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps(); sal_Int16 nType = ::comphelper::getINT16( - xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) ); + xNumberProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) ); return nType; } - bool setNumberFormat( const rtl::OUString& rFormat ) + bool setNumberFormat( const rtl::OUString& rFormat ) { - lang::Locale aLocale; - uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); - xNumProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale; - sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false ); - if ( nNewIndex == -1 ) // format not defined + // #163288# treat "General" as "Standard" format + sal_Int32 nNewIndex = 0; + if( !rFormat.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "General" ) ) ) { - nNewIndex = mxFormats->addNew( rFormat, aLocale ); + lang::Locale aLocale; + uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); + xNumProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) ) ) >>= aLocale; + nNewIndex = mxFormats->queryKey( rFormat, aLocale, false ); + if ( nNewIndex == -1 ) // format not defined + nNewIndex = mxFormats->addNew( rFormat, aLocale ); } mxRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat") ), uno::makeAny( nNewIndex ) ); return true; @@ -561,7 +593,7 @@ public: { uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps(); lang::Locale aLocale; - xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale; + xNumberProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) ) ) >>= aLocale; uno::Reference<util::XNumberFormatTypes> xTypes( mxFormats, uno::UNO_QUERY ); if ( xTypes.is() ) { @@ -733,8 +765,26 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab rtl::OUString aString; if ( aValue >>= aString ) { - uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); - xTextRange->setString( aString ); + // The required behavior for a string value is: + // 1. If the first character is a single quote, use the rest as a string cell, regardless of the cell's number format. + // 2. Otherwise, if the cell's number format is "text", use the string value as a string cell. + // 3. Otherwise, parse the string value in English locale, and apply a corresponding number format with the cell's locale + // if the cell's number format was "General". + // Case 1 is handled here, the rest in ScCellObj::InputEnglishString + + if ( aString.toChar() == '\'' ) // case 1 - handle with XTextRange + { + rtl::OUString aRemainder( aString.copy(1) ); // strip the quote + uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); + xTextRange->setString( aRemainder ); + } + else + { + // call implementation method InputEnglishString + ScCellObj* pCellObj = dynamic_cast< ScCellObj* >( xCell.get() ); + if ( pCellObj ) + pCellObj->InputEnglishString( aString ); + } } else isExtracted = false; @@ -1473,7 +1523,7 @@ ScVbaRange::getValue() throw (uno::RuntimeException) void -ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) throw (uno::RuntimeException) +ScVbaRange::setValue( const uno::Any& aValue, ValueSetter& valueSetter, bool bFireEvent ) throw (uno::RuntimeException) { uno::TypeClass aClass = aValue.getValueTypeClass(); if ( aClass == uno::TypeClass_SEQUENCE ) @@ -1508,6 +1558,7 @@ ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) thro { visitArray( valueSetter ); } + if( bFireEvent ) fireChangeEvent(); } void SAL_CALL @@ -1522,20 +1573,20 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) return; } CellValueSetter valueSetter( aValue ); - setValue( aValue, valueSetter ); + setValue( aValue, valueSetter, true ); } -void +void SAL_CALL ScVbaRange::Clear() throw (uno::RuntimeException) { using namespace ::com::sun::star::sheet::CellFlags; sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; - ClearContents( nFlags ); + ClearContents( nFlags, true ); } //helper ClearContent void -ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) +ScVbaRange::ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (uno::RuntimeException) { // #TODO code within the test below "if ( m_Areas.... " can be removed // Test is performed only because m_xRange is NOT set to be @@ -1549,40 +1600,44 @@ ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW ); ScVbaRange* pRange = getImplementation( xRange ); if ( pRange ) - pRange->ClearContents( nFlags ); + pRange->ClearContents( nFlags, false ); // do not fire for single ranges } + // fire change event for the entire range list + if( bFireEvent ) fireChangeEvent(); return; } uno::Reference< sheet::XSheetOperation > xSheetOperation(mxRange, uno::UNO_QUERY_THROW); xSheetOperation->clearContents( nFlags ); + if( bFireEvent ) fireChangeEvent(); } -void + +void SAL_CALL ScVbaRange::ClearComments() throw (uno::RuntimeException) { - ClearContents( sheet::CellFlags::ANNOTATION ); + ClearContents( sheet::CellFlags::ANNOTATION, false ); } -void +void SAL_CALL ScVbaRange::ClearContents() throw (uno::RuntimeException) { - sal_Int32 nClearFlags = ( sheet::CellFlags::VALUE | - sheet::CellFlags::STRING | sheet::CellFlags::DATETIME | - sheet::CellFlags::FORMULA ); - ClearContents( nClearFlags ); + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | STRING | DATETIME | FORMULA; + ClearContents( nFlags, true ); } -void +void SAL_CALL ScVbaRange::ClearFormats() throw (uno::RuntimeException) { - //FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED - sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR; - ClearContents( nClearFlags ); + //FIXME: need to check if we need to combine FORMATTED + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = HARDATTR | FORMATTED | EDITATTR; + ClearContents( nFlags, false ); } void -ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException) +ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram, bool bFireEvent ) throw (uno::RuntimeException) { // If this is a multiple selection apply setFormula over all areas if ( m_Areas->getCount() > 1 ) @@ -1593,7 +1648,7 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar:: return; } CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram ); - setValue( rFormula, formulaValueSetter ); + setValue( rFormula, formulaValueSetter, bFireEvent ); } uno::Any @@ -1617,7 +1672,7 @@ void ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException) { // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true ); } uno::Any @@ -1629,7 +1684,7 @@ ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) void ScVbaRange::setFormulaR1C1(const uno::Any& rFormula ) throw (uno::RuntimeException) { - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 ); + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1, true ); } uno::Any @@ -2040,7 +2095,7 @@ ScVbaRange::Font() throw ( script::BasicErrorException, uno::RuntimeException) } return new ScVbaFont( this, mxContext, aPalette, xProps, pRangeObj ); } - + uno::Reference< excel::XRange > ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException) { @@ -2054,6 +2109,18 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr return xRange->Cells( nRowIndex, nColumnIndex ); } + // Performance: Use a common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells, + // instead of creating a new ScVbaRange object in often-called ScVbaWorksheet::Cells + return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex ); +} + +// static +uno::Reference< excel::XRange > +ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< css::table::XCellRange >& xRange, + const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException) +{ sal_Int32 nRow = 0, nColumn = 0; sal_Bool bIsIndex = nRowIndex.hasValue(); @@ -2065,7 +2132,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr // convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) ) if ( nRowIndex.hasValue() && !( nRowIndex >>= nRow ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2076,7 +2143,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr } if ( bIsColumnIndex && !( nColumnIndex >>= nColumn ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2086,17 +2153,17 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr catch( uno::Exception& ) {} // silence any errors } - RangeHelper thisRange( mxRange ); + RangeHelper thisRange( xRange ); table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells // #FIXE needs proper parent ( Worksheet ) - return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) ); + return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange ) ); sal_Int32 nIndex = --nRow; if( bIsIndex && !bIsColumnIndex ) // .Cells(n) { - uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW); + uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, ::uno::UNO_QUERY_THROW); sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount(); if ( !nIndex || nIndex < 0 ) @@ -2109,7 +2176,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( xParent, xContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void @@ -3236,7 +3303,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() ); sal_Int16 nDataOption1 = excel::XlSortDataOption::xlSortNormal; - sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal;; + sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal; sal_Int16 nDataOption3 = excel::XlSortDataOption::xlSortNormal; ScDocument* pDoc = getScDocument(); @@ -3611,15 +3678,6 @@ ScVbaRange::getDefaultMethodName( ) throw (uno::RuntimeException) } -uno::Reference< awt::XDevice > -getDeviceFromDoc( const uno::Reference< frame::XModel >& xModel ) throw( uno::RuntimeException ) -{ - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame> xFrame( xController->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< awt::XDevice > xDevice( xFrame->getComponentWindow(), uno::UNO_QUERY_THROW ); - return xDevice; -} - // returns calc internal col. width ( in points ) double ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno::RuntimeException) @@ -3642,29 +3700,16 @@ ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (u } // return Char Width in points -double getDefaultCharWidth( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) -{ - const static rtl::OUString sDflt( RTL_CONSTASCII_USTRINGPARAM("Default")); - const static rtl::OUString sCharFontName( RTL_CONSTASCII_USTRINGPARAM("CharFontName")); - const static rtl::OUString sPageStyles( RTL_CONSTASCII_USTRINGPARAM("PageStyles")); - // get the font from the default style - uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xNameAccess( xStyleSupplier->getStyleFamilies(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xNameAccess2( xNameAccess->getByName( sPageStyles ), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xNameAccess2->getByName( sDflt ), uno::UNO_QUERY_THROW ); - rtl::OUString sFontName; - xProps->getPropertyValue( sCharFontName ) >>= sFontName; - - uno::Reference< awt::XDevice > xDevice = getDeviceFromDoc( xModel ); - awt::FontDescriptor aDesc; - aDesc.Name = sFontName; - uno::Reference< awt::XFont > xFont( xDevice->getFont( aDesc ), uno::UNO_QUERY_THROW ); - double nCharPixelWidth = xFont->getCharWidth( (sal_Int8)'0' ); - - double nPixelsPerMeter = xDevice->getInfo().PixelPerMeterX; - double nCharWidth = nCharPixelWidth / nPixelsPerMeter; - nCharWidth = nCharWidth * (double)56700;// in twips - return lcl_TwipsToPoints( (USHORT)nCharWidth ); +double getDefaultCharWidth( ScDocShell* pDocShell ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + OutputDevice* pRefDevice = pDoc->GetRefDevice(); + ScPatternAttr* pAttr = pDoc->GetDefPattern(); + ::Font aDefFont; + pAttr->GetFont( aDefFont, SC_AUTOCOL_BLACK, pRefDevice ); + pRefDevice->SetFont( aDefFont ); + long nCharWidth = pRefDevice->GetTextWidth( String( '0' ) ); // 1/100th mm + return lcl_hmmToPoints( nCharWidth ); } uno::Any SAL_CALL @@ -3682,7 +3727,7 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) if ( pShell ) { uno::Reference< frame::XModel > xModel = pShell->GetModel(); - double defaultCharWidth = getDefaultCharWidth( xModel ); + double defaultCharWidth = getDefaultCharWidth( pShell ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int32 nStartCol = thisAddress.StartColumn; @@ -3697,9 +3742,9 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) if ( nColTwips != nCurTwips ) return aNULL(); } - nColWidth = lcl_Round2DecPlaces( lcl_TwipsToPoints( nColTwips ) ); - if ( xModel.is() ) - nColWidth = nColWidth / defaultCharWidth; + nColWidth = lcl_TwipsToPoints( nColTwips ); + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth / defaultCharWidth ) - fExtraWidth; } nColWidth = lcl_Round2DecPlaces( nColWidth ); return uno::makeAny( nColWidth ); @@ -3724,11 +3769,8 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx ScDocShell* pDocShell = getScDocShell(); if ( pDocShell ) { - uno::Reference< frame::XModel > xModel = pDocShell->GetModel(); - if ( xModel.is() ) - { - - nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) ); + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth + fExtraWidth ) * getDefaultCharWidth( pDocShell ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); USHORT nTwips = lcl_pointsToTwips( nColWidth ); @@ -3737,11 +3779,11 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx SCCOLROW nColArr[2]; nColArr[0] = thisAddress.StartColumn; nColArr[1] = thisAddress.EndColumn; - aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, + // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values + aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_DIRECT, nTwips, TRUE, TRUE ); } - } } uno::Any SAL_CALL @@ -3901,7 +3943,8 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti SCCOLROW nRowArr[2]; nRowArr[0] = thisAddress.StartRow; nRowArr[1] = thisAddress.EndRow; - aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, + // #163561# use mode SC_SIZE_DIRECT: hide for height 0, show for other values + aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_DIRECT, nTwips, TRUE, TRUE ); } @@ -4350,6 +4393,20 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const { RangeHelper multiCellRange( mxRange ); autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress(); + // #163530# Filter box shows only entry of first row + ScDocument* pDocument = ( pShell ? pShell->GetDocument() : NULL ); + if ( pDocument ) + { + SCCOL nStartCol = autoFiltAddress.StartColumn; + SCROW nStartRow = autoFiltAddress.StartRow; + SCCOL nEndCol = autoFiltAddress.EndColumn; + SCROW nEndRow = autoFiltAddress.EndRow; + pDocument->GetDataArea( autoFiltAddress.Sheet, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, true ); + autoFiltAddress.StartColumn = nStartCol; + autoFiltAddress.StartRow = nStartRow; + autoFiltAddress.EndColumn = nEndCol; + autoFiltAddress.EndRow = nEndRow; + } } uno::Reference< sheet::XDatabaseRanges > xDBRanges = lcl_GetDataBaseRanges( pShell ); @@ -4369,13 +4426,9 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const uno::Reference< beans::XPropertySet > xDBRangeProps( xDataBaseRange, uno::UNO_QUERY_THROW ); // set autofilt xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(sal_True) ); - // set header + // set header (autofilter always need column headers) uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW ); - sal_Bool bHasColHeader = sal_False; - ScDocument* pDoc = pShell ? pShell->GetDocument() : NULL; - - bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ) ? sal_True : sal_False; - xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( bHasColHeader ) ); + xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( sal_True ) ); } @@ -4405,7 +4458,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const // Use the normal uno api, sometimes e.g. when you want to use ALL as the filter // we can't use refresh as the uno interface doesn't have a concept of ALL // in this case we just call the core calc functionality - - bool bAll = false;; + bool bAll = false; if ( ( Field >>= nField ) ) { uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc( @@ -4543,10 +4596,8 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const } void SAL_CALL -ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException) +ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /* CopyOrigin */ ) throw (uno::RuntimeException) { - sal_Bool bCopyOrigin = sal_True; - CopyOrigin >>= bCopyOrigin; // It appears ( from the web ) that the undocumented CopyOrigin // param should contain member of enum XlInsertFormatOrigin // which can have values xlFormatFromLeftOrAbove or xlFormatFromRightOrBelow @@ -4581,7 +4632,11 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW ); xCellRangeMove->insertCells( thisAddress, mode ); - if ( bCopyOrigin ) + + // Paste from clipboard only if the clipboard content was copied via VBA, and not already pasted via VBA again. + // "Insert" behavior should not depend on random clipboard content previously copied by the user. + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if ( pClipObj && pClipObj->GetUseInApi() ) { // 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 ) ); diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 14f0bde9e..551ed1240 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -99,6 +99,7 @@ class ScVbaRange : public ScVbaRange_BASE sal_Bool mbIsRows; sal_Bool mbIsColumns; css::uno::Reference< ov::excel::XValidation > m_xValidation; + double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); void visitArray( ArrayVisitor& vistor ); @@ -107,11 +108,14 @@ class ScVbaRange : public ScVbaRange_BASE void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException ); - void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException); - virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException); - virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); - virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); - virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException); + void ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (css::uno::RuntimeException); + + css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); + void setValue( const css::uno::Any& aValue, ValueSetter& setter, bool bFireEvent ) throw ( css::uno::RuntimeException); + + css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); + void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar, bool bFireEvent ) throw ( css::uno::RuntimeException); + css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException ); ScCellRangesObj* getCellRangesObj() throw ( css::uno::RuntimeException ); @@ -120,6 +124,10 @@ class ScVbaRange : public ScVbaRange_BASE css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious ); css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); css::awt::Point getPosition() throw ( css::uno::RuntimeException ); + + /** Fires a Worksheet_Change event for this range or range list. */ + void fireChangeEvent(); + protected: virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); @@ -149,6 +157,12 @@ public: const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); + static css::uno::Reference< ov::excel::XRange > CellsHelper( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::table::XCellRange >& xRange, + const css::uno::Any &nRowIndex, const css::uno::Any &nColumnIndex ) throw(css::uno::RuntimeException); + // Attributes virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx index 215a62cec..1d3d1dda0 100755..100644 --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -38,7 +38,9 @@ #include <rtl/ustrbuf.hxx> #include <filter/msfilter/msvbahelper.hxx> #include <oox/helper/helper.hxx> +#include <svx/unoshape.hxx> #include "vbafont.hxx" +#include "drwlayer.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -237,13 +239,38 @@ void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno: sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException) { - // TODO - return excel::XlPlacement::xlMoveAndSize; + sal_Int32 nRet = excel::XlPlacement::xlMoveAndSize; + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = ScDrawLayer::GetAnchor(pObj); + if (eType == SCA_PAGE) + nRet = excel::XlPlacement::xlFreeFloating; + } + } + return nRet; } -void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException) +void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 nPlacement ) throw (uno::RuntimeException) { - // TODO + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = SCA_CELL; + if ( nPlacement == excel::XlPlacement::xlFreeFloating ) + eType = SCA_PAGE; + + // xlMove is not supported, treated as SCA_CELL (xlMoveAndSize) + + ScDrawLayer::SetAnchor(pObj, eType); + } + } } sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException) @@ -350,14 +377,14 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) // if a macro name has been passed, try to attach it to the event if( rMacroName.getLength() > 0 ) { - VBAMacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); - if( !aResolvedMacro.IsResolved() ) + MacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); + if( !aResolvedMacro.mbFound ) throw uno::RuntimeException(); script::ScriptEventDescriptor aDescriptor; aDescriptor.ListenerType = maListenerType; aDescriptor.EventMethod = maEventMethod; aDescriptor.ScriptType = CREATE_OUSTRING( "Script" ); - aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.ResolvedMacro() ); + aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro ); xEventMgr->registerScriptEvent( nIndex, aDescriptor ); } } diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 60fe76580..07cc6cc2e 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -300,7 +300,7 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime } css::uno::Any SAL_CALL -ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) +ScVbaWorkbook::Styles( const uno::Any& Item ) throw (uno::RuntimeException) { // quick look and Styles object doesn't seem to have a valid parent // or a least the object browser just shows an object that has no @@ -313,18 +313,16 @@ ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) // Amelia Wang uno::Any SAL_CALL -ScVbaWorkbook::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) +ScVbaWorkbook::Names( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel( getModel() ); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xModel, uno::UNO_QUERY_THROW ); uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xNames( new ScVbaNames( this , mxContext , xNamedRanges , xModel )); - if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - { + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, xModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); return uno::Any( xNames ); } - return uno::Any( xNames->Item( aIndex, uno::Any() ) ); -} rtl::OUString& ScVbaWorkbook::getServiceImplName() diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 5316c58c0..498f79383 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -46,7 +46,9 @@ #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/VBAEventId.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> @@ -73,15 +75,19 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& ScDocShell* pShell = excel::getDocShell( xModel ); if ( pShell ) { + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + /* Set library container to VBA compatibility mode. This will create + the VBA Globals object and store it in the Basic manager of the + document. */ 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 ) ) + if( !xLibContainer->hasByName( aPrjName ) ) xLibContainer->createLibrary( aPrjName ); uno::Any aLibAny = xLibContainer->getByName( aPrjName ); uno::Reference< container::XNameContainer > xLib; @@ -90,8 +96,6 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& { 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 @@ -129,7 +133,19 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) ); } } - } + } + + /* Trigger the Workbook_Open event, event processor will register + itself as listener for specific events. */ + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); + } + catch( uno::Exception& ) + { + } } } @@ -200,9 +216,41 @@ ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) uno::Any SAL_CALL -ScVbaWorkbooks::Add() throw (uno::RuntimeException) +ScVbaWorkbooks::Add( const uno::Any& Template ) throw (uno::RuntimeException) { - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheetDocument > xSpreadDoc; + sal_Int32 nWorkbookType = 0; + ::rtl::OUString aTemplateFileName; + if( Template >>= nWorkbookType ) + { + // nWorkbookType is a constant from XlWBATemplate (added in Excel 2007) + // TODO: create chart-sheet if supported by Calc + + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + // create a document with one sheet only + uno::Reference< sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_SET_THROW ); + uno::Reference< container::XIndexAccess > xSheetsIA( xSheets, uno::UNO_QUERY_THROW ); + while( xSheetsIA->getCount() > 1 ) + { + uno::Reference< container::XNamed > xSheetName( xSheetsIA->getByIndex( xSheetsIA->getCount() - 1 ), uno::UNO_QUERY_THROW ); + xSheets->removeByName( xSheetName->getName() ); + } + } + else if( Template >>= aTemplateFileName ) + { + // TODO: create document from template + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else if( !Template.hasValue() ) + { + // regular spreadsheet document with configured number of sheets + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else + { + // illegal argument + throw uno::RuntimeException(); + } // need to set up the document modules ( and vba mode ) here setUpDocumentModules( xSpreadDoc ); @@ -211,13 +259,13 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException) return uno::Any(); } -void +void SAL_CALL ScVbaWorkbooks::Close() throw (uno::RuntimeException) { - VbaDocumentsBase::Close(); + closeDocuments(); } -bool +bool ScVbaWorkbooks::isTextFile( const rtl::OUString& sType ) { // will return true if the file is @@ -254,7 +302,7 @@ ScVbaWorkbooks::getFileFilterType( const rtl::OUString& rFileName ) } // #TODO# #FIXME# can any of the unused params below be used? -uno::Any +uno::Any SAL_CALL ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLinks*/, const uno::Any& ReadOnly, const uno::Any& Format, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*IgnoreReadOnlyRecommended*/, const uno::Any& /*Origin*/, const uno::Any& Delimiter, const uno::Any& /*Editable*/, const uno::Any& /*Notify*/, const uno::Any& /*Converter*/, const uno::Any& /*AddToMru*/ ) throw (uno::RuntimeException) { // we need to detect if this is a URL, if not then assume its a file path @@ -333,7 +381,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi else if ( !isSpreadSheetFile( sType ) ) 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::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( openDocument( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) @@ -341,13 +389,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi return aRet; } -uno::Any -ScVbaWorkbooks::Open( const rtl::OUString& Filename, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException) -{ - return VbaDocumentsBase::Open( Filename, ReadOnly, rProps ); -} - -rtl::OUString& +rtl::OUString& ScVbaWorkbooks::getServiceImplName() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbooks") ); diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx index 1ec89217c..cf19ecddd 100644 --- a/sc/source/ui/vba/vbaworkbooks.hxx +++ b/sc/source/ui/vba/vbaworkbooks.hxx @@ -60,12 +60,9 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XWorkbooks - virtual css::uno::Any SAL_CALL Add() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Template ) throw (css::uno::RuntimeException); virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& UpdateLinks, const css::uno::Any& ReadOnly, const css::uno::Any& Format, const css::uno::Any& Password, const css::uno::Any& WriteResPassword, const css::uno::Any& IgnoreReadOnlyRecommended, const css::uno::Any& Origin, const css::uno::Any& Delimiter, const css::uno::Any& Editable, const css::uno::Any& Notify, const css::uno::Any& Converter, const css::uno::Any& AddToMru ) throw (css::uno::RuntimeException); - - // VbaDocumentsBase / XDocumentsBase (to avoid warning C4266 for hiding function on wntmsci) - virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException); }; #endif /* SC_VBA_WORKBOOKS_HXX */ diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 71e4faebb..a4da72f94 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XSheetPageBreak.hpp> #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -61,6 +62,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/XlSheetVisibility.hpp> #include <ooo/vba/excel/XWorkbook.hpp> #include <ooo/vba/XControlProvider.hpp> @@ -94,6 +96,7 @@ #include "vbaworksheets.hxx" #include "vbahyperlinks.hxx" #include "vbasheetobjects.hxx" +#include "vbanames.hxx" #define STANDARDWIDTH 2267 #define STANDARDHEIGHT 427 @@ -179,20 +182,20 @@ openNewDoc(rtl::OUString aSheetName ) return xModel; } -ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ) +ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ), mbVeryHidden( false ) { } ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheet >& xSheet, - const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel) + const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel), mbVeryHidden( false ) { } ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args, - uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) + uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ), mbVeryHidden( false ) { - if ( args.getLength() < 2 ) + if ( args.getLength() < 3 ) throw lang::IllegalArgumentException(); rtl::OUString sSheetName; @@ -221,24 +224,40 @@ ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeExcept xNamed->setName( rName ); } -sal_Bool +sal_Int32 ScVbaWorksheet::getVisible() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - uno::Any aValue = xProps->getPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) ); - sal_Bool bRet = false; - aValue >>= bRet; - return bRet; + bool bVisible = false; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) ) >>= bVisible; + using namespace ::ooo::vba::excel::XlSheetVisibility; + return bVisible ? xlSheetVisible : (mbVeryHidden ? xlSheetVeryHidden : xlSheetHidden); } void -ScVbaWorksheet::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +ScVbaWorksheet::setVisible( sal_Int32 nVisible ) throw (uno::RuntimeException) { + using namespace ::ooo::vba::excel::XlSheetVisibility; + bool bVisible = true; + switch( nVisible ) + { + case xlSheetVisible: case 1: // Excel accepts -1 and 1 for visible sheets + bVisible = true; + mbVeryHidden = false; + break; + case xlSheetHidden: + bVisible = false; + mbVeryHidden = false; + break; + case xlSheetVeryHidden: + bVisible = false; + mbVeryHidden = true; + break; + default: + throw uno::RuntimeException(); + } uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - uno::Any aValue( bVisible ); - xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue); + xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), uno::Any( bVisible ) ); } sal_Int16 @@ -639,7 +658,10 @@ uno::Reference< excel::XRange > ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol ) throw (uno::RuntimeException) { - return getSheetRange()->Cells( nRow, nCol ); + // Performance optimization for often-called Cells method: + // Use a common helper method instead of creating a new ScVbaRange object + uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW ); + return ScVbaRange::CellsHelper( this, mxContext, xRange, nRow, nCol ); } uno::Reference< excel::XRange > @@ -716,8 +738,15 @@ 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 ); + // fake sheet-local names by returning all global names + // #163498# initialize Names object with correct parent (this worksheet) + // TODO: real sheet-local names... + uno::Reference< beans::XPropertySet > xProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, mxModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); + return uno::Any( xNames ); } uno::Any SAL_CALL @@ -888,7 +917,8 @@ ScVbaWorksheet::getFormControls() // get the www-standard container ( maybe we should access the // 'www-standard' by name rather than index, this seems an // implementation detail - xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); + if( xIndexAccess->hasElements() ) + xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY ); } catch( uno::Exception& ) diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index eaa9fdf0f..2ff76ec54 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -62,6 +62,7 @@ class ScVbaWorksheet : public WorksheetImpl_BASE css::uno::Reference< ov::excel::XChartObjects > mxCharts; css::uno::Reference< ov::excel::XHyperlinks > mxHlinks; ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons; + bool mbVeryHidden; css::uno::Reference< ov::excel::XWorksheet > getSheetAtOffset(SCTAB offset) throw (css::uno::RuntimeException); css::uno::Reference< ov::excel::XRange > getSheetRange() throw (css::uno::RuntimeException); @@ -91,8 +92,8 @@ public: // Attributes virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); virtual void SAL_CALL setName( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); - virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Int32 nVisible ) throw (css::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getStandardWidth() throw (css::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getStandardHeight() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 25643609c..51f293c56 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -530,19 +530,15 @@ void ScDrawView::MarkListHasChanged() SfxViewFrame* pViewFrame = pViewSh->GetViewFrame(); BOOL bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace(); + uno::Sequence< embed::VerbDescriptor > aVerbs; if ( pOle2Obj && !bOle ) { uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef(); + DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" ); if (xObj.is()) - pViewSh->SetVerbs( xObj->getSupportedVerbs() ); - else - { - DBG_ERROR("SdrOle2Obj ohne ObjRef"); - pViewSh->SetVerbs( 0 ); - } + aVerbs = xObj->getSupportedVerbs(); } - else - pViewSh->SetVerbs( 0 ); + pViewSh->SetVerbs( aVerbs ); // Image-Map Editor diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index ccf501a36..d7d401aef 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -453,7 +453,7 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) { if ( pStyleSheet ) { - pTabViewShell->RemoveStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->RemoveStyleSheetInUse( pStyleSheet ); pStylePool->Remove( pStyleSheet ); pTabViewShell->InvalidateAttribs(); nRetMask = TRUE; @@ -556,7 +556,7 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) // Attribute uebernehmen und Style anwenden pStyleSheet->GetItemSet().Put( aAttrSet ); - pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); // call SetStyleSheetToMarked after adding the ScUndoModifyStyle // (pStyleSheet pointer is used!) @@ -578,7 +578,7 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) } pStyleSheet->GetItemSet().Put( aAttrSet ); - pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); // call SetStyleSheetToMarked after adding the ScUndoModifyStyle // (pStyleSheet pointer is used!) @@ -868,7 +868,7 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) (const SvxNumberInfoItem&) *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) ); - pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); pTabViewShell->InvalidateAttribs(); } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index e26056ba8..aff5a5abe 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -529,9 +529,18 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) // must be a value or formula cell. return; - if (eType == CELLTYPE_FORMULA && !static_cast<ScFormulaCell*>(pCell)->IsValue()) + if (eType == CELLTYPE_FORMULA) + { + ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); + if (pFCell->GetErrCode() != 0) + { + SetHashText(); // If the error string doesn't fit, always use "###" + return; + } // If it's formula, the result must be a value. - return; + if (!pFCell->IsValue()) + return; + } ULONG nFormat = GetValueFormat(); if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index c8775fdcd..a04456601 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -44,7 +44,6 @@ #include <sfx2/dispatch.hxx> #include <sfx2/objface.hxx> #include <sfx2/request.hxx> -#include <svtools/printdlg.hxx> #include <svl/stritem.hxx> #include <svl/whiter.hxx> #include <vcl/msgbox.hxx> @@ -140,7 +139,6 @@ void ScPreviewShell::Construct( Window* pParent ) if (pDrawBC) StartListening(*pDrawBC); -// pPreview->Show(); // wird vom Sfx angezeigt pHorScroll->Show(); pVerScroll->Show(); pCorner->Show(); @@ -485,40 +483,6 @@ USHORT __EXPORT ScPreviewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDif return pDocShell->SetPrinter( pNewPrinter, nDiffFlags ); } -PrintDialog* __EXPORT ScPreviewShell::CreatePrintDialog( Window* pParent ) -{ - pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen - (void)GetPrinter(); - - const long nCurPage = pPreview->GetPageNo()+1; - const long nDocPageMax = pPreview->GetTotalPages(); - PrintDialog* pDlg = new PrintDialog( pParent, true ); -// wenn zu langsam wieder einbauen -// if ( pPreview->AllTested() ) -// nPageMax = pPreview->GetTotalPages(); - - pDlg->EnableSheetRange( true, PRINTSHEETS_ALL ); - pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_SHEETS ); - pDlg->EnableSheetRange( false, PRINTSHEETS_SELECTED_CELLS ); - bool bAllTabs = SC_MOD()->GetPrintOptions().GetAllSheets(); - pDlg->CheckSheetRange( bAllTabs ? PRINTSHEETS_ALL : PRINTSHEETS_SELECTED_SHEETS ); - - if ( nDocPageMax > 0 ) - pDlg->SetRangeText( String::CreateFromInt32( nCurPage ) ); - - pDlg->EnableRange ( PRINTDIALOG_ALL ); - pDlg->EnableRange ( PRINTDIALOG_RANGE ); - pDlg->SetFirstPage ( 1 ); - pDlg->SetMinPage ( 1 ); - pDlg->SetLastPage ( (USHORT)nDocPageMax ); - pDlg->SetMaxPage ( (USHORT)nDocPageMax ); - pDlg->EnableCollate (); - - // Selektion hier nicht - - return pDlg; -} - SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ) { ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); @@ -530,66 +494,6 @@ SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( Window *pParent, const SfxIt return 0; } -void __EXPORT ScPreviewShell::PreparePrint( PrintDialog* pPrintDialog ) -{ - SfxViewShell::PreparePrint( pPrintDialog ); - - ScMarkData aMarkData; - aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE ); - pDocShell->PreparePrint( pPrintDialog, &aMarkData ); -} - -ErrCode ScPreviewShell::DoPrint( SfxPrinter *pPrinter, - PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ) -{ - ErrCode nRet = ERRCODE_IO_ABORT; - - ScMarkData aMarkData; - aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE ); - - if ( pDocShell->CheckPrint( pPrintDialog, &aMarkData, false, bIsAPI ) ) - { - // SfxViewShell::DoPrint calls Print (after StartJob etc.) - nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent, bIsAPI ); - } - - return nRet; -} - -USHORT __EXPORT ScPreviewShell::Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog ) -{ - pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen - - // get the list of affected sheets before SfxViewShell::Print - bool bAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() ); - - ScMarkData aMarkData; - aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE ); - - uno::Sequence< sal_Int32 > aSheets; - SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); - sal_Int32 nPrinted = 0; - for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab ) - { - if ( bAllTabs || aMarkData.GetTableSelect( nTab ) ) - { - aSheets.realloc( nPrinted + 1 ); - aSheets[nPrinted] = nTab; - ++nPrinted; - } - } - - uno::Sequence < beans::PropertyValue > aProps(1); - aProps[0].Name = ::rtl::OUString::createFromAscii( "PrintSheets" ); - aProps[0].Value <<= aSheets; - SetAdditionalPrintOptions( aProps ); - - SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog ); - pDocShell->Print( rProgress, pPrintDialog, &aMarkData, pPreview, FALSE, bIsAPI ); - - return 0; -} - //------------------------------------------------------------------------ void __EXPORT ScPreviewShell::Activate(BOOL bMDI) diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 78e032a67..8d21d8ac2 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -767,11 +767,13 @@ void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode, if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ) { nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX(); + if (nNewDeltaX < 0) nNewDeltaX = 0; nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); } if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY ) { nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY(); + if (nNewDeltaY < 0) nNewDeltaY = 0; nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); } @@ -780,7 +782,7 @@ void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode, if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX ) { nNewDeltaX = nCurX - (nSizeX / 2); - if (nNewDeltaX < 0) nNewDeltaY = 0; + if (nNewDeltaX < 0) nNewDeltaX = 0; nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); } if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY ) @@ -1549,7 +1551,7 @@ void ScTabView::SelectNextTab( short nDir, BOOL bExtendSelection ) // SetTabNo - angezeigte Tabelle -void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection ) +void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection, bool bSameTabButMoved ) { if ( !ValidTab(nTab) ) { @@ -1681,7 +1683,7 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection ) pGridWin[i]->UpdateEditViewPos(); } - TabChanged(); // DrawView + TabChanged( bSameTabButMoved ); // DrawView aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist if ( !bUnoRefDialog ) diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index a42ff860f..8c31f82b3 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -267,7 +267,7 @@ void ScTabView::DoAddWin( ScGridWindow* pWin ) //================================================================== -void ScTabView::TabChanged() +void ScTabView::TabChanged( bool bSameTabButMoved ) { if (pDrawView) { @@ -339,7 +339,7 @@ void ScTabView::TabChanged() { ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController ); if (pImp) - pImp->SheetChanged(); + pImp->SheetChanged( bSameTabButMoved ); } } } diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx index 8a407e03a..b6cd897da 100644 --- a/sc/source/ui/view/tabvwsh.cxx +++ b/sc/source/ui/view/tabvwsh.cxx @@ -96,10 +96,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL)) SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION(ScSpellDialogChildWindow::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION( ::avmedia::MediaPlayer::GetChildWindowId() ); - - //<!--Added by PengYunQuan for Validity Cell Range Picker SFX_CHILDWINDOW_REGISTRATION(ScValidityRefChildWin::GetChildWindowId()); - //-->Added by PengYunQuan for Validity Cell Range Picker } SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" ) diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 1e494c1ee..367ea1449 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -46,7 +46,6 @@ #include <sfx2/request.hxx> #include <sfx2/printer.hxx> #include <sfx2/dispatch.hxx> -#include <svtools/printdlg.hxx> #include <svl/whiter.hxx> #include <unotools/moduleoptions.hxx> #include <rtl/logfile.hxx> @@ -1159,57 +1158,6 @@ USHORT __EXPORT ScTabViewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDif return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter, nDiffFlags ); } -PrintDialog* __EXPORT ScTabViewShell::CreatePrintDialog( Window *pParent ) -{ - ScDocShell* pDocShell = GetViewData()->GetDocShell(); - ScDocument* pDoc = pDocShell->GetDocument(); - - pDoc->SetPrintOptions(); // Optionen aus OFA am Printer setzen - SfxPrinter* pPrinter = GetPrinter(); - - String aStrRange; - PrintDialog* pDlg = new PrintDialog( pParent, true ); - SCTAB nTabCount = pDoc->GetTableCount(); - long nDocPageMax = 0; - - pDlg->EnableSheetRange( true, PRINTSHEETS_ALL ); - pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_SHEETS ); - pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_CELLS ); - bool bAllTabs = SC_MOD()->GetPrintOptions().GetAllSheets(); - pDlg->CheckSheetRange( bAllTabs ? PRINTSHEETS_ALL : PRINTSHEETS_SELECTED_SHEETS ); - - // update all pending row heights with a single progress bar, - // instead of a separate progress for each sheet from ScPrintFunc - pDocShell->UpdatePendingRowHeights( MAXTAB, true ); - - for ( SCTAB i=0; i<nTabCount; i++ ) - { - ScPrintFunc aPrintFunc( pDocShell, pPrinter, i ); - nDocPageMax += aPrintFunc.GetTotalPages(); - } - - if ( nDocPageMax > 0 ) - { - aStrRange = '1'; - if ( nDocPageMax > 1 ) - { - aStrRange += '-'; - aStrRange += String::CreateFromInt32( nDocPageMax ); - } - } - - pDlg->SetRangeText ( aStrRange ); - pDlg->EnableRange ( PRINTDIALOG_ALL ); - pDlg->EnableRange ( PRINTDIALOG_RANGE ); - pDlg->SetFirstPage ( 1 ); - pDlg->SetMinPage ( 1 ); - pDlg->SetLastPage ( (USHORT)nDocPageMax ); - pDlg->SetMaxPage ( (USHORT)nDocPageMax ); - pDlg->EnableCollate (); - - return pDlg; -} - SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ) { ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); @@ -1221,78 +1169,6 @@ SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( Window *pParent, const SfxIt return 0; } -void __EXPORT ScTabViewShell::PreparePrint( PrintDialog* pPrintDialog ) -{ - ScDocShell* pDocShell = GetViewData()->GetDocShell(); - - SfxViewShell::PreparePrint( pPrintDialog ); - pDocShell->PreparePrint( pPrintDialog, &GetViewData()->GetMarkData() ); -} - -ErrCode ScTabViewShell::DoPrint( SfxPrinter *pPrinter, - PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ) -{ - // #72527# if SID_PRINTDOCDIRECT is executed and there's a selection, - // ask if only the selection should be printed - - const ScMarkData& rMarkData = GetViewData()->GetMarkData(); - if ( !pPrintDialog && !bSilent && !bIsAPI && ( rMarkData.IsMarked() || rMarkData.IsMultiMarked() ) ) - { - SvxPrtQryBox aQuery( GetDialogParent() ); - short nBtn = aQuery.Execute(); - - if ( nBtn == RET_CANCEL ) - return ERRCODE_IO_ABORT; - - if ( nBtn == RET_OK ) - bPrintSelected = TRUE; - } - - ErrCode nRet = ERRCODE_IO_ABORT; - - ScDocShell* pDocShell = GetViewData()->GetDocShell(); - if ( pDocShell->CheckPrint( pPrintDialog, &GetViewData()->GetMarkData(), bPrintSelected, bIsAPI ) ) - { - // get the list of affected sheets before SfxViewShell::Print - bool bAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() ); - - uno::Sequence<sal_Int32> aSheets; - SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); - USHORT nPrinted = 0; - for ( SCTAB nTab=0; nTab<nTabCount; nTab++ ) - if ( bAllTabs || rMarkData.GetTableSelect(nTab) ) - { - aSheets.realloc( nPrinted + 1 ); - aSheets[nPrinted] = nTab; - ++nPrinted; - } - - uno::Sequence < beans::PropertyValue > aProps(1); - aProps[0].Name=::rtl::OUString::createFromAscii("PrintSheets"); - aProps[0].Value <<= aSheets; - SetAdditionalPrintOptions( aProps ); - - // SfxViewShell::DoPrint calls Print (after StartJob etc.) - nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent, bIsAPI ); - } - - bPrintSelected = FALSE; - - return nRet; -} - -USHORT __EXPORT ScTabViewShell::Print( SfxProgress& rProgress, BOOL bIsAPI, - PrintDialog* pPrintDialog ) -{ - ScDocShell* pDocShell = GetViewData()->GetDocShell(); - pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen - - SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog ); - pDocShell->Print( rProgress, pPrintDialog, &GetViewData()->GetMarkData(), - GetDialogParent(), bPrintSelected, bIsAPI ); - return 0; -} - void ScTabViewShell::StopEditShell() { if ( pEditShell != NULL && !bDontSwitch ) diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 472b35717..3c679d5f7 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -249,7 +249,7 @@ void __EXPORT ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint // kann und dann auch die aktive View umgeschaltet werden muss. SCTAB nNewTab = nActiveTab; - BOOL bForce = FALSE; + bool bStayOnActiveTab = true; switch (nId) { case SC_TAB_INSERTED: @@ -260,7 +260,7 @@ void __EXPORT ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint if ( nTab1 < nNewTab ) // vorher geloescht --nNewTab; else if ( nTab1 == nNewTab ) // aktuelle geloescht - bForce = TRUE; + bStayOnActiveTab = false; break; case SC_TAB_MOVED: if ( nNewTab == nTab1 ) // verschobene Tabelle @@ -282,7 +282,7 @@ void __EXPORT ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint break; case SC_TAB_HIDDEN: if ( nTab1 == nNewTab ) // aktuelle ausgeblendet - bForce = TRUE; + bStayOnActiveTab = false; break; } @@ -290,7 +290,8 @@ void __EXPORT ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint if ( nNewTab >= pDoc->GetTableCount() ) nNewTab = pDoc->GetTableCount() - 1; - SetTabNo( nNewTab, bForce ); + BOOL bForce = !bStayOnActiveTab; + SetTabNo( nNewTab, bForce, FALSE, bStayOnActiveTab ); } else if (rHint.ISA(ScIndexHint)) { diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 5b997d2e9..ad0770af5 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -392,9 +392,11 @@ void ScViewFunc::DoThesaurus( BOOL bRecord ) if (pCell) { ((ScEditCell*) pCell)->GetData(pTObject); - pOldTObj = pTObject->Clone(); if (pTObject) + { + pOldTObj = pTObject->Clone(); pThesaurusEngine->SetText(*pTObject); + } } } else diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index c594e3b32..463377614 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1545,7 +1545,7 @@ void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, BOOL bRecord } -void ScViewFunc::RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet ) +void ScViewFunc::RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ) { if ( !pStyleSheet) return; // ------------------------------------------------------------------- @@ -1572,7 +1572,7 @@ void ScViewFunc::RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet ) pHdl->ForgetLastPattern(); } -void ScViewFunc::UpdateStyleSheetInUse( SfxStyleSheet* pStyleSheet ) +void ScViewFunc::UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ) { if ( !pStyleSheet) return; // ------------------------------------------------------------------- diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index 09578f6ef..ff4696409 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -51,7 +51,7 @@ RESLIB1LIST=\ $(SRS)$/pagedlg.srs \ $(SRS)$/navipi.srs \ $(SRS)$/cctrl.srs \ - $(SOLARCOMMONRESDIR)$/sfx.srs + RESLIB1NAME=sc RESLIB1IMAGES=\ diff --git a/sc/workben/test.cxx b/sc/workben/test.cxx index d91e76af3..0e9a42f04 100644 --- a/sc/workben/test.cxx +++ b/sc/workben/test.cxx @@ -29,7 +29,7 @@ #include <svtools/libcall.hxx> #include <vcl/msgbox.hxx> #include <vcl/window.hxx> -#include <vcl/imagebtn.hxx> +#include <vcl/button.hxx> #include <vcl/field.hxx> #include <vcl/fixed.hxx> #include <vcl/help.hxx> diff --git a/scaddins/prj/build.lst b/scaddins/prj/build.lst index c2ade63c0..6f5116123 100644 --- a/scaddins/prj/build.lst +++ b/scaddins/prj/build.lst @@ -1,4 +1,4 @@ -ca scaddins : l10n vcl NULL +ca scaddins : LIBXSLT:libxslt l10n vcl NULL ca scaddins usr1 - all sc_mkout NULL ca scaddins\source\datefunc nmake - all sc_dfunc NULL ca scaddins\source\analysis nmake - all sc_analysis NULL diff --git a/sccomp/prj/build.lst b/sccomp/prj/build.lst index 8e1e0d018..6884378f7 100644 --- a/sccomp/prj/build.lst +++ b/sccomp/prj/build.lst @@ -1,4 +1,4 @@ -scc sccomp : l10n offuh comphelper LPSOLVE:lpsolve tools rsc NULL +scc sccomp : l10n offuh comphelper LPSOLVE:lpsolve tools rsc LIBXSLT:libxslt NULL scc sccomp usr1 - all scc_mkout NULL scc sccomp\prj get - all scc_prj NULL scc sccomp\source\solver nmake - all scc_solver NULL |