From 939a03584ed61839c3a5d9796b51f6aad0db6c7a Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Wed, 6 Oct 2010 17:57:13 +0200 Subject: chartextensibility: #i113619# Pasting a chart into a spreadsheet is not notified --- chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 062dcc1a129d..7a0907b05a28 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -237,7 +237,7 @@ struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator virtual bool setsCategories( bool bDataInColumns ) { - return !bDataInColumns; + return bDataInColumns; } virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) -- cgit From 569acb98dd402b230ef905101e6021c9dcfb17bc Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Wed, 20 Oct 2010 20:04:03 +0200 Subject: chartextensibility: #i82971# layout fixes for hierarchical axes --- chart2/source/view/axes/VCartesianAxis.cxx | 54 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8ec895fbd452..14d728151992 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -110,7 +110,7 @@ Reference< drawing::XShape > createSingleLabel( //correctPositionForRotation LabelPositionHelper::correctPositionForRotation( xShape2DText - , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, false ); + , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories ); return xShape2DText; } @@ -259,7 +259,7 @@ TickInfo* EquidistantLabelIterator::nextInfo() return pTickInfo; } -B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText ) +B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText, double fRotationAngleDegree ) { //calculates the height or width of a line of labels //thus a following line of labels can be shifted for that distance @@ -282,7 +282,7 @@ B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTick xShape2DText = pTickInfo->xTextShape; if( xShape2DText.is() ) { - awt::Size aSize = xShape2DText->getSize(); + awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) nDistance = ::std::max(nDistance,aSize.Width); else @@ -717,7 +717,7 @@ bool VCartesianAxis::createTextShapes( //if NO OVERLAP -> remove overlapping shapes if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) { - if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, m_aAxisLabelProperties.fRotationAngleDegree ) ) + if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ) ) { bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true; if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) @@ -1286,10 +1286,15 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); if(apTickIter.get()) { + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; if( nTextLevel>0 ) + { lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance ); + fRotationAngleDegree = 0.0; + } aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ); + , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) + , fRotationAngleDegree ); } } } @@ -1302,7 +1307,7 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel lcl_shiftLables( aOuterIter , lcl_getLabelsDistance( aInnerIter - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ), 0.0 ) ); } } @@ -1344,10 +1349,24 @@ void SAL_CALL VCartesianAxis::createLabels() nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half } - AxisLabelProperties aCopy(m_aAxisLabelProperties); - aCopy.bRhythmIsFix = true; - aCopy.nRhythm = 1; - AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy; + AxisLabelProperties aComplexProps(m_aAxisLabelProperties); + if( m_aAxisProperties.m_bComplexCategories ) + { + if( nTextLevel==0 ) + { + aComplexProps.bLineBreakAllowed = true; + aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 ); + } + else + { + aComplexProps.bLineBreakAllowed = false; + aComplexProps.bOverlapAllowed = true; + aComplexProps.bRhythmIsFix = true; + aComplexProps.nRhythm = 1; + aComplexProps.fRotationAngleDegree = 0.0; + } + } + AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties; while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickmarkHelper2D, nScreenDistanceBetweenTicks ) ) { }; @@ -1417,7 +1436,7 @@ void SAL_CALL VCartesianAxis::updatePositions() ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); - for( ; aDepthIter != aDepthEnd; aDepthIter++ ) + for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd; aDepthIter++, nDepth++ ) { ::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin(); const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end(); @@ -1434,8 +1453,12 @@ void SAL_CALL VCartesianAxis::updatePositions() static_cast(aTickScreenPos2D.getX()) ,static_cast(aTickScreenPos2D.getY())); + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; + if( nDepth>0 ) + fRotationAngleDegree = 0.0; + // #i78696# use mathematically correct rotation now - const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0)); + const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0)); uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); //set new position @@ -1454,7 +1477,7 @@ void SAL_CALL VCartesianAxis::updatePositions() //correctPositionForRotation LabelPositionHelper::correctPositionForRotation( xShape2DText - , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false ); + , m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories ); } } } @@ -1526,7 +1549,10 @@ void SAL_CALL VCartesianAxis::createShapes() ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); if( apTickIter.get() ) { - B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; + if( nTextLevel>0 ) + fRotationAngleDegree = 0.0; + B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ), fRotationAngleDegree ) ); sal_Int32 nCurrentLength = static_cast(aLabelsDistance.getLength()); aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); nOffset += nCurrentLength; -- cgit From a82a5b6191de8e8dad9f55f0f7da57732a0bef14 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Wed, 27 Oct 2010 16:02:26 +0200 Subject: chartextensibility: #i115276# improve layout of hierarchical axis labels in chart --- chart2/source/view/axes/VCartesianAxis.cxx | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'chart2') diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 14d728151992..991c87e3a2ef 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include @@ -319,6 +321,47 @@ void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance ) } } +bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape ) +{ + if ( rxShape.is() ) + { + SvxShape* pShape = SvxShape::getImplementation( rxShape ); + SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( pShape ); + if ( pShapeText ) + { + SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() ); + if ( pTextEditSource ) + { + pTextEditSource->UpdateOutliner(); + SvxTextForwarder* pTextForwarder = pTextEditSource->GetTextForwarder(); + if ( pTextForwarder ) + { + USHORT nParaCount = pTextForwarder->GetParagraphCount(); + for ( USHORT nPara = 0; nPara < nParaCount; ++nPara ) + { + USHORT nLineCount = pTextForwarder->GetLineCount( nPara ); + for ( USHORT nLine = 0; nLine < nLineCount; ++nLine ) + { + USHORT nLineStart = 0; + USHORT nLineEnd = 0; + pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine ); + USHORT nWordStart = 0; + USHORT nWordEnd = 0; + if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) && + ( nWordStart != nLineStart ) ) + { + return true; + } + } + } + } + } + } + } + + return false; +} + class MaxLabelEquidistantTickIter : public EquidistantTickIter { //iterate over first two and last two labels and the longest label -- cgit From db36cee77def18c36b2316fee9eac05ff7c9b2d2 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Wed, 27 Oct 2010 19:06:03 +0200 Subject: chartextensibility: #i115276# improve layout of hierarchical axis labels --- chart2/source/view/axes/VCartesianAxis.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'chart2') diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 991c87e3a2ef..7594018826b5 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -757,6 +757,20 @@ bool VCartesianAxis::createTextShapes( recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); + //better rotate if single words are broken apart + if( nLimitedSpaceForText>0 && !rAxisLabelProperties.bOverlapAllowed + && ::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) + && m_aAxisProperties.m_bComplexCategories + && lcl_hasWordBreak( pTickInfo->xTextShape ) ) + { + rAxisLabelProperties.fRotationAngleDegree = 90; + rAxisLabelProperties.bLineBreakAllowed = false; + m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree; + m_aAxisLabelProperties.bLineBreakAllowed = false; + removeTextShapesFromTicks(); + return false; + } + //if NO OVERLAP -> remove overlapping shapes if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) { -- cgit From b9fd0c3f3135bbae779ea0061bd719c4e06cde01 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 5 Nov 2010 13:25:12 +0100 Subject: chartextensibility: #i115276# improve layout of hierarchical axis labels in chart --- chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 14 ++++++++++++++ chart2/source/controller/dialogs/tp_AxisLabel.cxx | 10 ++++++++-- chart2/source/controller/dialogs/tp_AxisLabel.hxx | 2 ++ chart2/source/controller/inc/dlg_ObjectProperties.hxx | 4 ++++ chart2/source/view/axes/VCartesianAxis.cxx | 2 -- 5 files changed, 28 insertions(+), 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2a41d35313e8..448adbf3e89c 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -59,6 +59,7 @@ #include "chartview/NumberFormatterWrapper.hxx" #include "AxisIndexDefines.hxx" #include "AxisHelper.hxx" +#include "ExplicitCategoriesProvider.hxx" #include #include @@ -116,6 +117,7 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const rtl::OUS , m_bIsCrossingAxisIsCategoryAxis(false) , m_aCategories() , m_xChartDocument( 0 ) + , m_bComplexCategoriesAxis( false ) { rtl::OUString aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); m_bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS")); @@ -206,6 +208,13 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel if( m_bIsCrossingAxisIsCategoryAxis ) m_aCategories = DiagramHelper::getExplicitSimpleCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) ); } + + m_bComplexCategoriesAxis = false; + if ( nDimensionIndex == 0 && aData.AxisType == chart2::AxisType::CATEGORY ) + { + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel ); + m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories(); + } } } @@ -322,6 +331,10 @@ uno::Reference< chart2::XChartDocument > ObjectPropertiesDialogParameter::getDoc { return m_xChartDocument; } +bool ObjectPropertiesDialogParameter::IsComplexCategoriesAxis() const +{ + return m_bComplexCategoriesAxis; +} //const USHORT nNoArrowDlg = 1100; const USHORT nNoArrowNoShadowDlg = 1101; @@ -566,6 +579,7 @@ void SchAttribTabDlg::PageCreated(USHORT nId, SfxTabPage &rPage) { bool bShowStaggeringControls = m_pParameter->CanAxisLabelsBeStaggered(); ((SchAxisLabelTabPage&)rPage).ShowStaggeringControls( bShowStaggeringControls ); + ( dynamic_cast< SchAxisLabelTabPage& >( rPage ) ).SetComplexCategories( m_pParameter->IsComplexCategoriesAxis() ); break; } diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 3dcaa3092e57..87cc48ec6a55 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -78,7 +78,8 @@ SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rIn m_nInitialDegrees( 0 ), m_bHasInitialDegrees( true ), m_bInitialStacking( false ), - m_bHasInitialStacking( true ) + m_bHasInitialStacking( true ), + m_bComplexCategories( false ) { FreeResource(); @@ -295,6 +296,11 @@ void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls ) } } +void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories ) +{ + m_bComplexCategories = bComplexCategories; +} + // event handling routines // ----------------------- @@ -310,7 +316,7 @@ IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG ) aRbAuto.Enable( bEnable ); aFlTextFlow.Enable( bEnable ); - aCbTextOverlap.Enable( bEnable ); + aCbTextOverlap.Enable( bEnable && !m_bComplexCategories ); aCbTextBreak.Enable( bEnable ); m_aFtTextDirection.Enable( bEnable ); diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx index 6043b16001ac..a1b8c7530743 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.hxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -76,6 +76,7 @@ private: bool m_bHasInitialDegrees; /// false = DialControl in tristate bool m_bInitialStacking; bool m_bHasInitialStacking; /// false = checkbox in tristate + bool m_bComplexCategories; DECL_LINK ( ToggleShowLabel, void* ); @@ -90,6 +91,7 @@ public: virtual void Reset( const SfxItemSet& rInAttrs ); void ShowStaggeringControls( BOOL bShowStaggeringControls ); + void SetComplexCategories( bool bComplexCategories ); }; //............................................................................. } //namespace chart diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx index 8ceabdbe33b7..140c33389fe3 100644 --- a/chart2/source/controller/inc/dlg_ObjectProperties.hxx +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -69,6 +69,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > getDocument() const; + bool IsComplexCategoriesAxis() const; + private: rtl::OUString m_aObjectCID; ObjectType m_eObjectType; @@ -96,6 +98,8 @@ private: ::com::sun::star::uno::Sequence< rtl::OUString > m_aCategories; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + + bool m_bComplexCategoriesAxis; }; /************************************************************************* diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 7594018826b5..c17e56ce6bc5 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -766,7 +766,6 @@ bool VCartesianAxis::createTextShapes( rAxisLabelProperties.fRotationAngleDegree = 90; rAxisLabelProperties.bLineBreakAllowed = false; m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree; - m_aAxisLabelProperties.bLineBreakAllowed = false; removeTextShapesFromTicks(); return false; } @@ -1416,7 +1415,6 @@ void SAL_CALL VCartesianAxis::createLabels() } else { - aComplexProps.bLineBreakAllowed = false; aComplexProps.bOverlapAllowed = true; aComplexProps.bRhythmIsFix = true; aComplexProps.nRhythm = 1; -- cgit From a2882eb71c5153d87074d47da3ecfc954184c2b5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Nov 2010 21:36:50 +0100 Subject: undoapi: step 0.0 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: remove the unused XUndoHelper --- chart2/source/controller/main/UndoManager.cxx | 16 ---------------- chart2/source/inc/UndoManager.hxx | 15 ++------------- 2 files changed, 2 insertions(+), 29 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx index 21e27922b1c8..9f9c7a7d57ec 100644 --- a/chart2/source/controller/main/UndoManager.cxx +++ b/chart2/source/controller/main/UndoManager.cxx @@ -381,22 +381,6 @@ Sequence< OUString > SAL_CALL UndoManager::getAllRedoStrings() return m_apRedoStack->getUndoStrings(); } -// ____ XUndoHelper ____ -Reference< frame::XModel > SAL_CALL UndoManager::getModelCloneForUndo( - const Reference< frame::XModel >& xModelBeforeChange ) - throw (uno::RuntimeException) -{ - return impl::UndoElement::cloneModel( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::applyModelContent( - Reference< frame::XModel >& xModelToChange, - const Reference< frame::XModel >& xModelToCopyFrom ) - throw (uno::RuntimeException) -{ - impl::UndoElement::applyModelContentToModel( xModelToChange, xModelToCopyFrom ); -} - // ____ XUnoTunnel ____ sal_Int64 UndoManager::getSomething( const Sequence< sal_Int8 >& rId ) throw (uno::RuntimeException) diff --git a/chart2/source/inc/UndoManager.hxx b/chart2/source/inc/UndoManager.hxx index a28a0d78c470..99ade9d2b98a 100644 --- a/chart2/source/inc/UndoManager.hxx +++ b/chart2/source/inc/UndoManager.hxx @@ -35,10 +35,9 @@ #include #include #include -#include #include -#include +#include #include // for pair @@ -65,10 +64,9 @@ class UndoElement; class UndoStack; class ModifyBroadcaster; -typedef ::cppu::WeakComponentImplHelper4< +typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::util::XModifyBroadcaster, ::com::sun::star::chart2::XUndoManager, - ::com::sun::star::chart2::XUndoHelper, ::com::sun::star::lang::XUnoTunnel > UndoManager_Base; @@ -142,15 +140,6 @@ protected: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings() throw (::com::sun::star::uno::RuntimeException); - // ____ XUndoHelper ____ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModelCloneForUndo( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL applyModelContent( - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToChange, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToCopyFrom ) - throw (::com::sun::star::uno::RuntimeException); - private: void retrieveConfigUndoSteps(); void fireModifyEvent(); -- cgit From 78fed9b8623faca46c3e1ef4dc633d80682d0414 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Nov 2010 21:36:54 +0100 Subject: undoapi: step 0.1 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: remove the XModel paramter from the XUndoManager methods, they're an implicit attribute of the instance --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 4 +- chart2/source/controller/dialogs/res_ErrorBar.cxx | 4 +- .../source/controller/dialogs/tp_RangeChooser.cxx | 2 +- chart2/source/controller/main/ChartController.cxx | 8 +- .../controller/main/ChartController_EditData.cxx | 4 +- .../controller/main/ChartController_Insert.cxx | 128 ++++++++++----------- .../controller/main/ChartController_Position.cxx | 2 +- .../controller/main/ChartController_Properties.cxx | 6 +- .../controller/main/ChartController_TextEdit.cxx | 2 +- .../controller/main/ChartController_Tools.cxx | 44 +++---- .../controller/main/ChartController_Window.cxx | 6 +- chart2/source/controller/main/ElementSelector.cxx | 2 +- chart2/source/controller/main/ImplUndoManager.cxx | 32 +++--- chart2/source/controller/main/ImplUndoManager.hxx | 14 +-- .../source/controller/main/UndoCommandDispatch.cxx | 4 +- chart2/source/controller/main/UndoGuard.cxx | 38 +++--- chart2/source/controller/main/UndoManager.cxx | 45 +++++--- chart2/source/inc/UndoGuard.hxx | 23 +--- chart2/source/inc/UndoManager.hxx | 50 +++----- chart2/source/model/main/ChartModel.cxx | 104 ++++++++--------- chart2/source/model/main/ChartModel.hxx | 1 - chart2/source/tools/ResId.cxx | 2 +- 22 files changed, 245 insertions(+), 280 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index d6487d425657..64dbac8db86e 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -83,6 +83,7 @@ using namespace ::com::sun::star::chart; using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; @@ -1413,7 +1414,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( } else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) ) { - Reference< chart2::XUndoManager > xUndoManager( new UndoManager() ); + Reference< XModel > xModel( queryInterface( XModel::static_type() ), UNO_QUERY_THROW ); + Reference< chart2::XUndoManager > xUndoManager( new UndoManager( xModel ) ); xResult.set( xUndoManager ); bServiceFound = true; } diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 8b649072538e..c71e9de73a31 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -474,12 +474,12 @@ IMPL_LINK( ErrorBarResources, ChooseRange, RangeSelectionButton *, pButton ) if( pButton == &m_aIbRangePositive ) { m_pCurrentRangeChoosingField = &m_aEdRangePositive; - aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS ))); + aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS )); } else { m_pCurrentRangeChoosingField = &m_aEdRangeNegative; - aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS ))); + aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS )); } OSL_ASSERT( m_pParentDialog ); diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 3ba6ca0f74b2..82a1d19ffdb3 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -366,7 +366,7 @@ IMPL_LINK( RangeChooserTabPage, ChooseRangeHdl, void *, EMPTYARG ) { rtl::OUString aRange = m_aED_Range.GetText(); // using assignment for broken gcc 3.3 - rtl::OUString aTitle = ::rtl::OUString( String( SchResId( STR_PAGE_DATA_RANGE ) )); + rtl::OUString aTitle = String( SchResId( STR_PAGE_DATA_RANGE ) ); lcl_enableRangeChoosing( true, m_pParentDialog ); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this ); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index bf8afc65e78f..55acbf6a7389 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1327,7 +1327,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager ); // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); @@ -1352,7 +1352,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager ); if( xChartDoc.is()) { // /-- @@ -1379,8 +1379,8 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) UndoGuardWithSelection aUndoGuard( ActionDescriptionProvider::createDescription( (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), - ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))), - m_xUndoManager, getModel()); + String( SchResId( STR_OBJECT_DATASERIES ))), + m_xUndoManager ); bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); if( bChanged ) diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index 0248732a63a7..06cb8882c2c0 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -66,8 +66,8 @@ void ChartController::executeDispatch_EditData() ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); // using assignment for broken gcc 3.3 UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))), - m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_CHART_DATA )), + m_xUndoManager ); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); // the dialog has no OK/Cancel aDataEditorDialog.Execute(); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 0a7a4057ef9a..6581e092d7d4 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -121,8 +121,8 @@ void ChartController::executeDispatch_InsertAxes() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))), + m_xUndoManager ); try { @@ -159,8 +159,8 @@ void ChartController::executeDispatch_InsertGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))), + m_xUndoManager ); try { @@ -196,8 +196,8 @@ void ChartController::executeDispatch_InsertTitles() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))), + m_xUndoManager ); try { @@ -227,8 +227,8 @@ void ChartController::executeDispatch_DeleteLegend() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); LegendHelper::hideLegend( getModel() ); aUndoGuard.commitAction(); @@ -238,8 +238,8 @@ void ChartController::executeDispatch_InsertLegend() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC ); aUndoGuard.commitAction(); @@ -249,8 +249,8 @@ void ChartController::executeDispatch_OpenLegendDialog() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); try { @@ -280,8 +280,8 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); //if a series is selected insert labels for that series only: uno::Reference< chart2::XDataSeries > xSeries( @@ -354,7 +354,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), - m_xUndoManager, getModel() ); + m_xUndoManager ); try { @@ -393,8 +393,8 @@ void ChartController::executeDispatch_InsertMeanValue() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); lcl_InsertMeanValueLine( m_xCC ).operator()( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); aUndoGuard.commitAction(); @@ -404,8 +404,8 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); @@ -437,7 +437,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), - m_xUndoManager, getModel() ); + m_xUndoManager ); try { @@ -477,8 +477,8 @@ void ChartController::executeDispatch_InsertTrendline() { UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); // add a linear curve RegressionCurveHelper::addRegressionCurve( @@ -531,8 +531,8 @@ void ChartController::executeDispatch_InsertYErrorBars() { UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))), + m_xUndoManager ); // add error bars with standard deviation uno::Reference< beans::XPropertySet > xErrorBarProp( @@ -591,8 +591,8 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); aUndoGuard.commitAction(); @@ -608,8 +608,8 @@ void ChartController::executeDispatch_InsertR2Value() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); aUndoGuard.commitAction(); } @@ -623,8 +623,8 @@ void ChartController::executeDispatch_DeleteR2Value() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); aUndoGuard.commitAction(); } @@ -638,8 +638,8 @@ void ChartController::executeDispatch_DeleteMeanValue() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -653,8 +653,8 @@ void ChartController::executeDispatch_DeleteTrendline() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -668,8 +668,8 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); RegressionCurveHelper::removeEquations( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -683,8 +683,8 @@ void ChartController::executeDispatch_DeleteYErrorBars() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); StatisticsHelper::removeErrorBars( xDataSeries ); aUndoGuard.commitAction(); } @@ -697,8 +697,8 @@ void ChartController::executeDispatch_InsertDataLabels() if( xSeries.is() ) { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); aUndoGuard.commitAction(); } @@ -707,8 +707,8 @@ void ChartController::executeDispatch_InsertDataLabels() void ChartController::executeDispatch_InsertDataLabel() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, - ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_LABEL ))), + m_xUndoManager ); DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); aUndoGuard.commitAction(); } @@ -720,8 +720,8 @@ void ChartController::executeDispatch_DeleteDataLabels() if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); aUndoGuard.commitAction(); } @@ -730,8 +730,8 @@ void ChartController::executeDispatch_DeleteDataLabels() void ChartController::executeDispatch_DeleteDataLabel() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, - ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_LABEL ))), + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); aUndoGuard.commitAction(); } @@ -739,8 +739,8 @@ void ChartController::executeDispatch_DeleteDataLabel() void ChartController::executeDispatch_ResetAllDataPoints() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATAPOINTS ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) xSeries->resetAllDataPoints(); @@ -749,8 +749,8 @@ void ChartController::executeDispatch_ResetAllDataPoints() void ChartController::executeDispatch_ResetDataPoint() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATAPOINT ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) { @@ -768,8 +768,8 @@ void ChartController::executeDispatch_InsertAxisTitle() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))), + m_xUndoManager ); Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); sal_Int32 nDimensionIndex = -1; @@ -809,8 +809,8 @@ void ChartController::executeDispatch_InsertAxis() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))), + m_xUndoManager ); try { @@ -831,8 +831,8 @@ void ChartController::executeDispatch_DeleteAxis() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))), + m_xUndoManager ); try { @@ -853,8 +853,8 @@ void ChartController::executeDispatch_InsertMajorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -875,8 +875,8 @@ void ChartController::executeDispatch_DeleteMajorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -897,8 +897,8 @@ void ChartController::executeDispatch_InsertMinorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -921,8 +921,8 @@ void ChartController::executeDispatch_DeleteMinorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 619d308ffad2..8acc8bf10e17 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -139,7 +139,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); SfxAbstractTabDialog * pDlg = NULL; try diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 649b9cb62f9d..7bd99e8fa74c 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -720,7 +720,7 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); if( bSuccess ) @@ -838,8 +838,8 @@ void SAL_CALL ChartController::executeDispatch_View3D() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_3D_VIEW ))), - m_xUndoManager, getModel()); + String( SchResId( STR_ACTION_EDIT_3D_VIEW )), + m_xUndoManager ); // /-- //open dialog diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index a6e82430d8f6..50037f0846e8 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -80,7 +80,7 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) if(!pTextObj) return; - m_xUndoManager->preAction( getModel()); + m_xUndoManager->preAction(); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 779e3c32f1e7..c142ad33bcb9 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -115,8 +115,8 @@ bool lcl_deleteDataSeries( { ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))), - xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))), + xUndoManager ); Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); @@ -145,8 +145,8 @@ bool lcl_deleteDataCurve( { ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_CURVE )))), - xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))), + xUndoManager ); ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); bResult = true; aUndoGuard.commitAction(); @@ -235,8 +235,8 @@ void ChartController::executeDispatch_NewArrangement() { // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_REARRANGE_CHART ))), - m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_REARRANGE_CHART )), + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( xModel ); // diagram @@ -285,8 +285,8 @@ void ChartController::executeDispatch_ScaleText() ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_SCALE_TEXT ))), - m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_SCALE_TEXT )), + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( getModel() ); ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider()); OSL_ASSERT( apRefSizeProv.get()); @@ -655,8 +655,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), - m_xUndoManager, getModel()); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))), + m_xUndoManager ); TitleHelper::removeTitle( ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); bReturn = true; @@ -674,8 +674,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false )); bReturn = true; aUndoGuard.commitAction(); @@ -709,8 +709,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); bReturn = true; aUndoGuard.commitAction(); @@ -732,8 +732,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); @@ -755,8 +755,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), - m_xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))), + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xErrorBarProp->setPropertyValue( @@ -780,7 +780,7 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + m_xUndoManager ); chart2::DataPointLabel aLabel; xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel; aLabel.ShowNumber = false; @@ -844,7 +844,7 @@ void ChartController::executeDispatch_ToggleLegend() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_LEGEND ))), m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager ); Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY ); bool bChanged = false; if( xLegendProp.is()) @@ -878,7 +878,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ))), m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); if( xDiagram.is()) { @@ -911,7 +911,7 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), - m_xUndoManager, m_aModel->getModel() ); + m_xUndoManager ); if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) aUndoGuard.commitAction(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 56908ac4ef79..1b060431df5e 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -839,7 +839,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( pChartDragMethod ) { UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(), - m_xUndoManager, getModel() ); + m_xUndoManager ); if( pDrawViewWrapper->EndDragObj(false) ) { @@ -872,7 +872,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) @@ -1808,7 +1808,7 @@ bool ChartController::impl_moveOrResizeObject( ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager, xChartModel ); + eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); { ControllerLockGuard aCLGuard( xChartModel ); if( bNeedShift ) diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx index 3b41fd1b6b66..38d05635477a 100644 --- a/chart2/source/controller/main/ElementSelector.cxx +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -156,7 +156,7 @@ void SelectorListBox::UpdateChartElementsListAndSelection() ListBoxEntryData aEntry; SdrObject* pSelectedObj = DrawViewWrapper::getSdrObject( aSelectedOID.getAdditionalShape() ); ::rtl::OUString aName( pSelectedObj ? pSelectedObj->GetName() : String() ); - aEntry.UIName = ( aName.getLength() > 0 ? aName : ::rtl::OUString( String( SchResId( STR_OBJECT_SHAPE ) ) ) ); + aEntry.UIName = ( aName.getLength() > 0 ? aName : String( SchResId( STR_OBJECT_SHAPE ) ) ); aEntry.OID = aSelectedOID; m_aEntries.push_back( aEntry ); } diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx index 57e8e7315334..4426433791c4 100644 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ b/chart2/source/controller/main/ImplUndoManager.cxx @@ -60,10 +60,10 @@ namespace impl { void ImplApplyDataToModel( - Reference< frame::XModel > & xInOutModelToChange, + const Reference< frame::XModel > & xModel, const Reference< chart2::XInternalDataProvider > & xData ) { - Reference< chart2::XChartDocument > xDoc( xInOutModelToChange, uno::UNO_QUERY ); + Reference< chart2::XChartDocument > xDoc( xModel, uno::UNO_QUERY ); OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); // copy data from stored internal data provider @@ -122,9 +122,9 @@ void UndoElement::dispose() } void UndoElement::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) + const Reference< frame::XModel > & xModel ) { - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); + UndoElement::applyModelContentToModel( xModel, m_xModel ); } UndoElement * UndoElement::createFromModel( @@ -157,22 +157,22 @@ Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XMod // static void UndoElement::applyModelContentToModel( - Reference< frame::XModel > & xInOutModelToChange, + const Reference< frame::XModel > & xModel, const Reference< frame::XModel > & xModelToCopyFrom, const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) { - if( xModelToCopyFrom.is() && xInOutModelToChange.is()) + if( xModelToCopyFrom.is() && xModel.is()) { try { // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( xInOutModelToChange ); + ControllerLockGuard aLockedControllers( xModel ); Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); - Reference< chart2::XChartDocument > xDestination( xInOutModelToChange, uno::UNO_QUERY_THROW ); + Reference< chart2::XChartDocument > xDestination( xModel, uno::UNO_QUERY_THROW ); // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xInOutModelToChange ); + ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xModel ); // diagram xDestination->setFirstDiagram( xSource->getFirstDiagram()); @@ -189,14 +189,14 @@ void UndoElement::applyModelContentToModel( // apply data (not applied in standard Undo) if( xData.is()) - ImplApplyDataToModel( xInOutModelToChange, xData ); + ImplApplyDataToModel( xModel, xData ); // register all sequences at the internal data provider to get adapted // indexes when columns are added/removed if( xDestination->hasInternalDataProvider()) { Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xInOutModelToChange )); + Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xModel )); if( xUsedData.is() && xNewDataProvider.is()) { Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); @@ -278,9 +278,9 @@ void UndoElementWithData::dispose() } void UndoElementWithData::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) + const Reference< frame::XModel > & xModel ) { - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel, m_xData ); + UndoElement::applyModelContentToModel( xModel, m_xModel, m_xData ); } UndoElement * UndoElementWithData::createFromModel( @@ -340,10 +340,10 @@ void UndoElementWithSelection::dispose() } void UndoElementWithSelection::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) + const Reference< frame::XModel > & xModel ) { - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); - Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xInOutModelToChange->getCurrentController(), uno::UNO_QUERY ); + UndoElement::applyModelContentToModel( xModel, m_xModel ); + Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xModel->getCurrentController(), uno::UNO_QUERY ); OSL_ASSERT( xCurrentSelectionSuppl.is() ); if( xCurrentSelectionSuppl.is()) diff --git a/chart2/source/controller/main/ImplUndoManager.hxx b/chart2/source/controller/main/ImplUndoManager.hxx index 4dde0bc65719..aaf8f18c1231 100644 --- a/chart2/source/controller/main/ImplUndoManager.hxx +++ b/chart2/source/controller/main/ImplUndoManager.hxx @@ -70,8 +70,8 @@ public: ::com::sun::star::frame::XModel > & xModel ); virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); void setActionString( const ::rtl::OUString & rActionString ); ::rtl::OUString getActionString() const; @@ -80,7 +80,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); static void applyModelContentToModel( - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xInOutModelToChange, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); @@ -112,8 +112,8 @@ public: ::com::sun::star::frame::XModel > & xModel ); virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); private: void initializeData(); @@ -139,8 +139,8 @@ public: ::com::sun::star::frame::XModel > & xModel ); virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); private: void initialize( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index eb3d00a2723a..97201efa2e04 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -115,9 +115,9 @@ void SAL_CALL UndoCommandDispatch::dispatch( // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xUndoManager->undo( m_xModel ); + m_xUndoManager->undo(); else - m_xUndoManager->redo( m_xModel ); + m_xUndoManager->redo(); // \-- } } diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index 8513b6ba9093..d55d52f8d41e 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -40,10 +40,8 @@ namespace chart { UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : m_xModel( xModel ) - , m_xUndoManager( xUndoManager ) + , const uno::Reference< chart2::XUndoManager > & xUndoManager ) + : m_xUndoManager( xUndoManager ) , m_aUndoString( rUndoString ) , m_bActionPosted( false ) { @@ -63,12 +61,11 @@ void UndoGuard_Base::commitAction() //----------------------------------------------------------------------------- UndoGuard::UndoGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) + , const uno::Reference< chart2::XUndoManager > & xUndoManager ) + : UndoGuard_Base( rUndoString, xUndoManager ) { if( m_xUndoManager.is() ) - m_xUndoManager->preAction( m_xModel ); + m_xUndoManager->preAction(); } UndoGuard::~UndoGuard() @@ -80,26 +77,24 @@ UndoGuard::~UndoGuard() //----------------------------------------------------------------------------- UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) + , const uno::Reference< chart2::XUndoManager > & xUndoManager ) + : UndoGuard_Base( rUndoString, xUndoManager ) { if( m_xUndoManager.is() ) - m_xUndoManager->preAction( m_xModel ); + m_xUndoManager->preAction(); } UndoLiveUpdateGuard::~UndoLiveUpdateGuard() { if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); + m_xUndoManager->cancelActionWithUndo(); } //----------------------------------------------------------------------------- UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) + , const uno::Reference< chart2::XUndoManager > & xUndoManager ) + : UndoGuard_Base( rUndoString, xUndoManager ) { if( m_xUndoManager.is() ) { @@ -107,22 +102,21 @@ UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoS aArgs[0] = beans::PropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(), beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); + m_xUndoManager->preActionWithArguments( aArgs ); } } UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() { if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); + m_xUndoManager->cancelActionWithUndo(); } //----------------------------------------------------------------------------- UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) + , const uno::Reference< chart2::XUndoManager > & xUndoManager ) + : UndoGuard_Base( rUndoString, xUndoManager ) { if( m_xUndoManager.is() ) { @@ -130,7 +124,7 @@ UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString aArgs[0] = beans::PropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(), beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); + m_xUndoManager->preActionWithArguments( aArgs ); } } diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx index 9f9c7a7d57ec..a76a8c356852 100644 --- a/chart2/source/controller/main/UndoManager.cxx +++ b/chart2/source/controller/main/UndoManager.cxx @@ -36,7 +36,6 @@ #include "ChartViewHelper.hxx" #include -#include #include #include @@ -50,6 +49,7 @@ using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; +using ::com::sun::star::frame::XModel; using ::rtl::OUString; @@ -118,13 +118,14 @@ void ModifyBroadcaster::fireEvent() } // namespace impl -UndoManager::UndoManager() : +UndoManager::UndoManager( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) : impl::UndoManager_Base( m_aMutex ), m_apUndoStack( new impl::UndoStack()), m_apRedoStack( new impl::UndoStack()), m_pLastRemeberedUndoElement( 0 ), m_nMaxNumberOfUndos( 100 ), - m_pModifyBroadcaster( 0 ) + m_pModifyBroadcaster( 0 ), + m_aModel( rModel ) {} UndoManager::~UndoManager() @@ -157,8 +158,13 @@ void UndoManager::addShapeUndoAction( SdrUndoAction* pAction ) } } +Reference< XModel > UndoManager::impl_getModel() const +{ + Reference< XModel > xModel( m_aModel ); + return xModel; +} + void UndoManager::impl_undoRedo( - Reference< frame::XModel > & xCurrentModel, impl::UndoStack * pStackToRemoveFrom, impl::UndoStack * pStackToAddTo, bool bUndo ) @@ -169,6 +175,7 @@ void UndoManager::impl_undoRedo( impl::UndoElement * pTop( pStackToRemoveFrom->top()); if( pTop ) { + Reference< XModel > xModel( impl_getModel() ); impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop ); if ( pShapeUndoElement ) { @@ -191,13 +198,13 @@ void UndoManager::impl_undoRedo( { // put a clone of current model into redo/undo stack with the same // action string as the undo/redo - pStackToAddTo->push( pTop->createFromModel( xCurrentModel )); + pStackToAddTo->push( pTop->createFromModel( xModel )); // change current model by properties of the model from undo - pTop->applyToModel( xCurrentModel ); + pTop->applyToModel( xModel ); } // remove the top undo element pStackToRemoveFrom->pop(), pTop = 0; - ChartViewHelper::setViewToDirtyState( xCurrentModel ); + ChartViewHelper::setViewToDirtyState( xModel ); fireModifyEvent(); } } @@ -259,18 +266,18 @@ void SAL_CALL UndoManager::removeModifyListener( const Reference< util::XModifyL } // ____ chart2::XUndoManager ____ -void SAL_CALL UndoManager::preAction( const Reference< frame::XModel >& xModelBeforeChange ) +void SAL_CALL UndoManager::preAction( ) throw (uno::RuntimeException) { OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - m_pLastRemeberedUndoElement = new impl::UndoElement( xModelBeforeChange ); + m_pLastRemeberedUndoElement = new impl::UndoElement( impl_getModel() ); } void SAL_CALL UndoManager::preActionWithArguments( - const Reference< frame::XModel >& xModelBeforeChange, const Sequence< beans::PropertyValue >& aArguments ) throw (uno::RuntimeException) { + Reference< XModel > xModel( impl_getModel() ); bool bActionHandled( false ); OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); if( aArguments.getLength() > 0 ) @@ -278,18 +285,18 @@ void SAL_CALL UndoManager::preActionWithArguments( OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) { - m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModelBeforeChange ); + m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModel ); bActionHandled = true; } else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) { - m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModelBeforeChange ); + m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModel ); bActionHandled = true; } } if( !bActionHandled ) - preAction( xModelBeforeChange ); + preAction(); } void SAL_CALL UndoManager::postAction( const OUString& aUndoText ) @@ -321,28 +328,28 @@ void SAL_CALL UndoManager::cancelAction() m_pLastRemeberedUndoElement = 0; } -void SAL_CALL UndoManager::cancelActionWithUndo( Reference< frame::XModel >& xModelToRestore ) +void SAL_CALL UndoManager::cancelActionWithUndo( ) throw (uno::RuntimeException) { if( m_pLastRemeberedUndoElement ) { - m_pLastRemeberedUndoElement->applyToModel( xModelToRestore ); + m_pLastRemeberedUndoElement->applyToModel( impl_getModel() ); cancelAction(); } } -void SAL_CALL UndoManager::undo( Reference< frame::XModel >& xCurrentModel ) +void SAL_CALL UndoManager::undo( ) throw (uno::RuntimeException) { OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get(), true ); + impl_undoRedo( m_apUndoStack.get(), m_apRedoStack.get(), true ); } -void SAL_CALL UndoManager::redo( Reference< frame::XModel >& xCurrentModel ) +void SAL_CALL UndoManager::redo( ) throw (uno::RuntimeException) { OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get(), false ); + impl_undoRedo( m_apRedoStack.get(), m_apUndoStack.get(), false ); } ::sal_Bool SAL_CALL UndoManager::undoPossible() diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx index 864d5ccff994..cf59337eaf53 100644 --- a/chart2/source/inc/UndoGuard.hxx +++ b/chart2/source/inc/UndoGuard.hxx @@ -27,7 +27,6 @@ #ifndef CHART2_UNDOGUARD_HXX #define CHART2_UNDOGUARD_HXX -#include #include // header for class OUString @@ -42,16 +41,12 @@ class UndoGuard_Base public: explicit UndoGuard_Base( const rtl::OUString & rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager - , const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ::com::sun::star::chart2::XUndoManager > & xUndoManager ); virtual ~UndoGuard_Base(); void commitAction(); protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; @@ -68,9 +63,7 @@ class UndoGuard : public UndoGuard_Base public: explicit UndoGuard( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager - , const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ::com::sun::star::chart2::XUndoManager > & xUndoManager ); virtual ~UndoGuard(); }; @@ -83,9 +76,7 @@ class UndoLiveUpdateGuard : public UndoGuard_Base public: explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager - , const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ::com::sun::star::chart2::XUndoManager > & xUndoManager ); virtual ~UndoLiveUpdateGuard(); }; @@ -98,9 +89,7 @@ class UndoLiveUpdateGuardWithData : public: explicit UndoLiveUpdateGuardWithData( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager - , const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ::com::sun::star::chart2::XUndoManager > & xUndoManager ); virtual ~UndoLiveUpdateGuardWithData(); }; @@ -109,9 +98,7 @@ class UndoGuardWithSelection : public UndoGuard_Base public: explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager - , const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ::com::sun::star::chart2::XUndoManager > & xUndoManager ); virtual ~UndoGuardWithSelection(); }; diff --git a/chart2/source/inc/UndoManager.hxx b/chart2/source/inc/UndoManager.hxx index 99ade9d2b98a..a73bbc69a9d0 100644 --- a/chart2/source/inc/UndoManager.hxx +++ b/chart2/source/inc/UndoManager.hxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -86,7 +87,7 @@ class UndoManager : public impl::UndoManager_Base { public: - explicit UndoManager(); + explicit UndoManager( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ); virtual ~UndoManager(); void addShapeUndoAction( SdrUndoAction* pAction ); @@ -111,45 +112,31 @@ protected: throw (::com::sun::star::uno::RuntimeException); // ____ chart2::XUndoManager ____ - virtual void SAL_CALL preAction( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL preActionWithArguments( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelAction() - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelActionWithUndo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToRestore ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xCurrentModel ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xCurrentModel ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL undoPossible() - throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL redoPossible() - throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentUndoString() - throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentRedoString() - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings() - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings() - throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL preAction( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL preActionWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelAction( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelActionWithUndo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL undoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL redoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); private: void retrieveConfigUndoSteps(); void fireModifyEvent(); void impl_undoRedo( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xCurrentModel, impl::UndoStack * pStackToRemoveFrom, impl::UndoStack * pStackToAddTo, bool bUndo = true ); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + impl_getModel() const; + ::std::auto_ptr< impl::UndoStack > m_apUndoStack; ::std::auto_ptr< impl::UndoStack > m_apRedoStack; @@ -161,6 +148,7 @@ private: ::com::sun::star::util::XModifyBroadcaster > m_xModifyBroadcaster; // pointer is valid as long as m_xModifyBroadcaster.is() impl::ModifyBroadcaster * m_pModifyBroadcaster; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; }; } // namespace chart diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 5a30d97118c5..9b77f4aa2b94 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -114,14 +114,21 @@ ChartModel::ChartModel(uno::Reference const & xContext) C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY) { OSL_TRACE( "ChartModel: CTOR called" ); - osl_incrementInterlockedCount(&m_refCount); - ModifyListenerHelper::addListener( m_xPageBackground, this ); - m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext( - C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY ); - m_xUndoManager = Reference< chart2::XUndoManager >( - this->createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY ); + osl_incrementInterlockedCount(&m_refCount); + { + m_xOldModelAgg.set( + m_xContext->getServiceManager()->createInstanceWithContext( + CHART_CHARTAPIWRAPPER_SERVICE_NAME, + m_xContext ), uno::UNO_QUERY_THROW ); + m_xOldModelAgg->setDelegator( *this ); + } + { + ModifyListenerHelper::addListener( m_xPageBackground, this ); + m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY ); + } osl_decrementInterlockedCount(&m_refCount); } @@ -145,33 +152,40 @@ ChartModel::ChartModel( const ChartModel & rOther ) , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector ) , m_xDataProvider( rOther.m_xDataProvider ) , m_xInternalDataProvider( rOther.m_xInternalDataProvider ) - , m_xUndoManager( rOther.m_xUndoManager ) + , m_xUndoManager( NULL ) { OSL_TRACE( "ChartModel: Copy-CTOR called" ); - osl_incrementInterlockedCount(&m_refCount); - - Reference< util::XModifyListener > xListener; - Reference< chart2::XTitle > xNewTitle = CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ); - Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< Reference< chart2::XDiagram > >()( rOther.m_xDiagram ); - Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ); - Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ); - Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ); + osl_incrementInterlockedCount(&m_refCount); { - MutexGuard aGuard( m_aModelMutex ); - xListener = this; - m_xTitle = xNewTitle; - m_xDiagram = xNewDiagram; - m_xPageBackground = xNewPageBackground; - m_xChartTypeManager = xChartTypeManager; - m_xXMLNamespaceMap = xXMLNamespaceMap; - } + m_xOldModelAgg.set( + m_xContext->getServiceManager()->createInstanceWithContext( + CHART_CHARTAPIWRAPPER_SERVICE_NAME, + m_xContext ), uno::UNO_QUERY_THROW ); + m_xOldModelAgg->setDelegator( *this ); - ModifyListenerHelper::addListener( xNewTitle, xListener ); - ModifyListenerHelper::addListener( xNewDiagram, xListener ); - ModifyListenerHelper::addListener( xNewPageBackground, xListener ); - xListener.clear(); + Reference< util::XModifyListener > xListener; + Reference< chart2::XTitle > xNewTitle = CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ); + Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< Reference< chart2::XDiagram > >()( rOther.m_xDiagram ); + Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ); + Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ); + Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ); + { + MutexGuard aGuard( m_aModelMutex ); + xListener = this; + m_xTitle = xNewTitle; + m_xDiagram = xNewDiagram; + m_xPageBackground = xNewPageBackground; + m_xChartTypeManager = xChartTypeManager; + m_xXMLNamespaceMap = xXMLNamespaceMap; + } + + ModifyListenerHelper::addListener( xNewTitle, xListener ); + ModifyListenerHelper::addListener( xNewDiagram, xListener ); + ModifyListenerHelper::addListener( xNewPageBackground, xListener ); + xListener.clear(); + } osl_decrementInterlockedCount(&m_refCount); } @@ -179,7 +193,7 @@ ChartModel::~ChartModel() { OSL_TRACE( "ChartModel: DTOR called" ); if( m_xOldModelAgg.is()) - m_xOldModelAgg->setDelegator( 0 ); + m_xOldModelAgg->setDelegator( NULL ); } @@ -530,26 +544,12 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) DisposeHelper::DisposeAndClear( m_xPageBackground ); DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap ); - // not owner of storage -// if( m_xStorage.is()) -// { -// Reference< lang::XComponent > xComp( m_xStorage, uno::UNO_QUERY ); -// if( xComp.is()) -// xComp->dispose(); -// } m_xStorage.clear(); - - if( m_xOldModelAgg.is()) - { - m_xOldModelAgg->setDelegator( 0 ); - m_xOldModelAgg.clear(); - } + // just clear, don't dispose - we're not the owner m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this ))); m_xCurrentController.clear(); - m_xStorage.clear(); - m_xParent.clear(); DisposeHelper::DisposeAndClear( m_xRangeHighlighter ); OSL_TRACE( "ChartModel: dispose() called" ); } @@ -991,18 +991,6 @@ void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle > setModified( sal_True ); } -void ChartModel::impl_createOldModelAgg() -{ - if( ! m_xOldModelAgg.is()) - { - m_xOldModelAgg.set( - m_xContext->getServiceManager()->createInstanceWithContext( - CHART_CHARTAPIWRAPPER_SERVICE_NAME, - m_xContext ), uno::UNO_QUERY_THROW ); - m_xOldModelAgg->setDelegator( static_cast< ::cppu::OWeakObject* >( this )); - } -} - // ____ XInterface (for old API wrapper) ____ uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType ) throw (uno::RuntimeException) @@ -1014,7 +1002,6 @@ uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType ) // try old API wrapper try { - impl_createOldModelAgg(); if( m_xOldModelAgg.is()) aResult = m_xOldModelAgg->queryAggregation( aType ); } @@ -1253,7 +1240,6 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString } else { - impl_createOldModelAgg(); if( m_xOldModelAgg.is() ) { Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) ); @@ -1281,7 +1267,6 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames() { uno::Sequence< ::rtl::OUString > aResult; - impl_createOldModelAgg(); if( m_xOldModelAgg.is()) { Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) ); @@ -1361,6 +1346,9 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent Reference< chart2::XUndoManager > SAL_CALL ChartModel::getUndoManager() throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( !m_xUndoManager.is() ) + m_xUndoManager.set( createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY ); return m_xUndoManager; } diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 23da02f3f83a..962324c29cef 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -203,7 +203,6 @@ private: void impl_killInternalData() throw( com::sun::star::util::CloseVetoException ); - void impl_createOldModelAgg(); void impl_store( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescriptor, diff --git a/chart2/source/tools/ResId.cxx b/chart2/source/tools/ResId.cxx index 0d6e35974aaa..b7d4c725d367 100644 --- a/chart2/source/tools/ResId.cxx +++ b/chart2/source/tools/ResId.cxx @@ -41,7 +41,7 @@ SchResId::SchResId( sal_Int16 nId ) ::rtl::OUString SchResId::getResString( sal_Int16 nId ) { - return ::rtl::OUString( String( SchResId( nId ))); + return String( SchResId( nId )); } } // namespace chart -- cgit From 587dfc9e8a00e8b97d5460e4e1d7c48de91b7425 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Nov 2010 21:37:01 +0100 Subject: undoapi: step 2.0 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: rename css.chart2.XUndoManager to XDocumentActions. Not sure this class will still exist (in either form) after the refactoring is finished. --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 8 +- chart2/source/controller/main/ChartController.cxx | 26 +- chart2/source/controller/main/ChartController.hxx | 4 +- .../controller/main/ChartController_EditData.cxx | 2 +- .../controller/main/ChartController_Insert.cxx | 66 +-- .../controller/main/ChartController_Position.cxx | 2 +- .../controller/main/ChartController_Properties.cxx | 4 +- .../controller/main/ChartController_TextEdit.cxx | 6 +- .../controller/main/ChartController_Tools.cxx | 38 +- .../controller/main/ChartController_Window.cxx | 6 +- .../controller/main/CommandDispatchContainer.cxx | 6 - .../controller/main/CommandDispatchContainer.hxx | 11 +- chart2/source/controller/main/DocumentActions.cxx | 431 ++++++++++++++++++ .../source/controller/main/ImplDocumentActions.cxx | 505 +++++++++++++++++++++ .../source/controller/main/ImplDocumentActions.hxx | 227 +++++++++ chart2/source/controller/main/ImplUndoManager.cxx | 505 --------------------- chart2/source/controller/main/ImplUndoManager.hxx | 227 --------- .../source/controller/main/UndoCommandDispatch.cxx | 34 +- .../source/controller/main/UndoCommandDispatch.hxx | 6 +- chart2/source/controller/main/UndoGuard.cxx | 56 +-- chart2/source/controller/main/UndoManager.cxx | 431 ------------------ chart2/source/controller/main/makefile.mk | 4 +- chart2/source/inc/ChartModelHelper.hxx | 2 +- chart2/source/inc/DocumentActions.hxx | 157 +++++++ chart2/source/inc/UndoGuard.hxx | 14 +- chart2/source/inc/UndoManager.hxx | 157 ------- chart2/source/inc/servicenames.hxx | 2 +- chart2/source/model/main/ChartModel.cxx | 111 ++++- chart2/source/model/main/ChartModel.hxx | 40 +- 29 files changed, 1598 insertions(+), 1490 deletions(-) create mode 100644 chart2/source/controller/main/DocumentActions.cxx create mode 100644 chart2/source/controller/main/ImplDocumentActions.cxx create mode 100644 chart2/source/controller/main/ImplDocumentActions.hxx delete mode 100644 chart2/source/controller/main/ImplUndoManager.cxx delete mode 100644 chart2/source/controller/main/ImplUndoManager.hxx delete mode 100644 chart2/source/controller/main/UndoManager.cxx create mode 100644 chart2/source/inc/DocumentActions.hxx delete mode 100644 chart2/source/inc/UndoManager.hxx (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 64dbac8db86e..2ba38e9582e1 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -56,7 +56,7 @@ #include "WrappedAddInProperty.hxx" #include "WrappedIgnoreProperty.hxx" #include "ChartRenderer.hxx" -#include "UndoManager.hxx" +#include "DocumentActions.hxx" #include #include #include @@ -1412,11 +1412,11 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( xResult.set( m_xChartView ); bServiceFound = true; } - else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) ) + else if ( aServiceSpecifier.equals( CHART_DOCUMENT_ACTIONS_SERVICE_NAME ) ) { Reference< XModel > xModel( queryInterface( XModel::static_type() ), UNO_QUERY_THROW ); - Reference< chart2::XUndoManager > xUndoManager( new UndoManager( xModel ) ); - xResult.set( xUndoManager ); + Reference< chart2::XDocumentActions > xDocumentActions( new DocumentActions( xModel ) ); + xResult.set( xDocumentActions ); bServiceFound = true; } else diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 55acbf6a7389..4e29cc45907b 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -53,13 +53,12 @@ #include "AccessibleChartView.hxx" #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" -#include "UndoManager.hxx" +#include "DocumentActions.hxx" #include #include #include -#include #include #include #include @@ -128,12 +127,11 @@ ChartController::ChartController(uno::Reference const & , m_bWaitingForDoubleClick(false) , m_bWaitingForMouseUp(false) , m_bConnectingToView(false) - , m_xUndoManager( 0 ) + , m_xDocumentActions( 0 ) , m_aDispatchContainer( m_xCC, this ) , m_eDrawMode( CHARTDRAW_SELECT ) { DBG_CTOR(ChartController,NULL); -// m_aDispatchContainer.setUndoManager( m_xUndoManager ); m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) ); } @@ -615,9 +613,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( m_pChartWindow ) m_pChartWindow->Invalidate(); - uno::Reference< chart2::XUndoSupplier > xUndoSupplier( getModel(), uno::UNO_QUERY ); - if( xUndoSupplier.is()) - m_xUndoManager.set( xUndoSupplier->getUndoManager()); + m_xDocumentActions.set( getModel(), uno::UNO_QUERY ); return sal_True; } @@ -818,7 +814,7 @@ void ChartController::impl_deleteDrawViewController() } m_xFrame.clear(); - m_xUndoManager.clear(); + m_xDocumentActions.clear(); TheModelRef aModelRef( m_aModel, m_aModelMutex); m_aModel = NULL; @@ -955,7 +951,7 @@ bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterfa if( m_aModel.is() && m_aModel->getModel() == xModel ) { m_aModel = NULL; - m_xUndoManager.clear(); + m_xDocumentActions.clear(); bReleaseModel = true; } } @@ -1327,7 +1323,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager ); + String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xDocumentActions ); // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); @@ -1352,7 +1348,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager ); + String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xDocumentActions ); if( xChartDoc.is()) { // /-- @@ -1380,7 +1376,7 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) ActionDescriptionProvider::createDescription( (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), String( SchResId( STR_OBJECT_DATASERIES ))), - m_xUndoManager ); + m_xDocumentActions ); bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); if( bChanged ) @@ -1449,10 +1445,10 @@ IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction ) ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID(); if ( aObjectCID.getLength() == 0 ) { - UndoManager* pUndoManager = UndoManager::getImplementation( m_xUndoManager ); - if ( pUndoManager ) + DocumentActions* pDocumentActions = DocumentActions::getImplementation( m_xDocumentActions ); + if ( pDocumentActions ) { - pUndoManager->addShapeUndoAction( pUndoAction ); + pDocumentActions->addShapeUndoAction( pUndoAction ); } } return 0L; diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index f2b64eb7a9c5..aa9ade1f17b5 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include @@ -578,7 +578,7 @@ private: bool volatile m_bConnectingToView; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; /// needed for dispatching URLs in FeatureStateEvents mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index 06cb8882c2c0..cbc66a2368b3 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -67,7 +67,7 @@ void ChartController::executeDispatch_EditData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( String( SchResId( STR_ACTION_EDIT_CHART_DATA )), - m_xUndoManager ); + m_xDocumentActions ); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); // the dialog has no OK/Cancel aDataEditorDialog.Execute(); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 6581e092d7d4..adb6cf91a62e 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -122,7 +122,7 @@ void ChartController::executeDispatch_InsertAxes() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -160,7 +160,7 @@ void ChartController::executeDispatch_InsertGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -197,7 +197,7 @@ void ChartController::executeDispatch_InsertTitles() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -228,7 +228,7 @@ void ChartController::executeDispatch_DeleteLegend() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), - m_xUndoManager ); + m_xDocumentActions ); LegendHelper::hideLegend( getModel() ); aUndoGuard.commitAction(); @@ -239,7 +239,7 @@ void ChartController::executeDispatch_InsertLegend() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), - m_xUndoManager ); + m_xDocumentActions ); Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC ); aUndoGuard.commitAction(); @@ -250,7 +250,7 @@ void ChartController::executeDispatch_OpenLegendDialog() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -281,7 +281,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xUndoManager ); + m_xDocumentActions ); //if a series is selected insert labels for that series only: uno::Reference< chart2::XDataSeries > xSeries( @@ -354,7 +354,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -394,7 +394,7 @@ void ChartController::executeDispatch_InsertMeanValue() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xUndoManager ); + m_xDocumentActions ); lcl_InsertMeanValueLine( m_xCC ).operator()( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); aUndoGuard.commitAction(); @@ -405,7 +405,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xUndoManager ); + m_xDocumentActions ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); @@ -437,7 +437,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -478,7 +478,7 @@ void ChartController::executeDispatch_InsertTrendline() UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))), - m_xUndoManager ); + m_xDocumentActions ); // add a linear curve RegressionCurveHelper::addRegressionCurve( @@ -532,7 +532,7 @@ void ChartController::executeDispatch_InsertYErrorBars() UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))), - m_xUndoManager ); + m_xDocumentActions ); // add error bars with standard deviation uno::Reference< beans::XPropertySet > xErrorBarProp( @@ -592,7 +592,7 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xUndoManager ); + m_xDocumentActions ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); aUndoGuard.commitAction(); @@ -609,7 +609,7 @@ void ChartController::executeDispatch_InsertR2Value() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xUndoManager ); + m_xDocumentActions ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); aUndoGuard.commitAction(); } @@ -624,7 +624,7 @@ void ChartController::executeDispatch_DeleteR2Value() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xUndoManager ); + m_xDocumentActions ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); aUndoGuard.commitAction(); } @@ -639,7 +639,7 @@ void ChartController::executeDispatch_DeleteMeanValue() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xUndoManager ); + m_xDocumentActions ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -654,7 +654,7 @@ void ChartController::executeDispatch_DeleteTrendline() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), - m_xUndoManager ); + m_xDocumentActions ); RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -669,7 +669,7 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xUndoManager ); + m_xDocumentActions ); RegressionCurveHelper::removeEquations( xRegCurveCnt ); aUndoGuard.commitAction(); } @@ -684,7 +684,7 @@ void ChartController::executeDispatch_DeleteYErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), - m_xUndoManager ); + m_xDocumentActions ); StatisticsHelper::removeErrorBars( xDataSeries ); aUndoGuard.commitAction(); } @@ -698,7 +698,7 @@ void ChartController::executeDispatch_InsertDataLabels() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xUndoManager ); + m_xDocumentActions ); DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); aUndoGuard.commitAction(); } @@ -708,7 +708,7 @@ void ChartController::executeDispatch_InsertDataLabel() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LABEL ))), - m_xUndoManager ); + m_xDocumentActions ); DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); aUndoGuard.commitAction(); } @@ -721,7 +721,7 @@ void ChartController::executeDispatch_DeleteDataLabels() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xUndoManager ); + m_xDocumentActions ); DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); aUndoGuard.commitAction(); } @@ -731,7 +731,7 @@ void ChartController::executeDispatch_DeleteDataLabel() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LABEL ))), - m_xUndoManager ); + m_xDocumentActions ); DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); aUndoGuard.commitAction(); } @@ -740,7 +740,7 @@ void ChartController::executeDispatch_ResetAllDataPoints() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, String( SchResId( STR_OBJECT_DATAPOINTS ))), - m_xUndoManager ); + m_xDocumentActions ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) xSeries->resetAllDataPoints(); @@ -750,7 +750,7 @@ void ChartController::executeDispatch_ResetDataPoint() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, String( SchResId( STR_OBJECT_DATAPOINT ))), - m_xUndoManager ); + m_xDocumentActions ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) { @@ -769,7 +769,7 @@ void ChartController::executeDispatch_InsertAxisTitle() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))), - m_xUndoManager ); + m_xDocumentActions ); Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); sal_Int32 nDimensionIndex = -1; @@ -810,7 +810,7 @@ void ChartController::executeDispatch_InsertAxis() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -832,7 +832,7 @@ void ChartController::executeDispatch_DeleteAxis() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -854,7 +854,7 @@ void ChartController::executeDispatch_InsertMajorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -876,7 +876,7 @@ void ChartController::executeDispatch_DeleteMajorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -898,7 +898,7 @@ void ChartController::executeDispatch_InsertMinorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), - m_xUndoManager ); + m_xDocumentActions ); try { @@ -922,7 +922,7 @@ void ChartController::executeDispatch_DeleteMinorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), - m_xUndoManager ); + m_xDocumentActions ); try { diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 8acc8bf10e17..78f607773ca9 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -139,7 +139,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), - m_xUndoManager ); + m_xDocumentActions ); SfxAbstractTabDialog * pDlg = NULL; try diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 7bd99e8fa74c..f6508c74f462 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -720,7 +720,7 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager ); + m_xDocumentActions ); bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); if( bSuccess ) @@ -839,7 +839,7 @@ void SAL_CALL ChartController::executeDispatch_View3D() // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( String( SchResId( STR_ACTION_EDIT_3D_VIEW )), - m_xUndoManager ); + m_xDocumentActions ); // /-- //open dialog diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 50037f0846e8..96175fb119ca 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -80,7 +80,7 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) if(!pTextObj) return; - m_xUndoManager->preAction(); + m_xDocumentActions->preAction(); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); @@ -166,7 +166,7 @@ bool ChartController::EndTextEdit() try { - m_xUndoManager->postAction( C2U("Edit Text") ); + m_xDocumentActions->postAction( C2U("Edit Text") ); } catch( uno::RuntimeException& e) { @@ -177,7 +177,7 @@ bool ChartController::EndTextEdit() { try { - m_xUndoManager->cancelAction(); + m_xDocumentActions->cancelAction(); } catch ( uno::RuntimeException& e ) { diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index c142ad33bcb9..9b2115fff83b 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -102,7 +102,7 @@ namespace bool lcl_deleteDataSeries( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XUndoManager > & xUndoManager ) + const Reference< chart2::XDocumentActions > & xDocumentActions ) { bool bResult = false; uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); @@ -116,7 +116,7 @@ bool lcl_deleteDataSeries( ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))), - xUndoManager ); + xDocumentActions ); Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); @@ -135,7 +135,7 @@ bool lcl_deleteDataSeries( bool lcl_deleteDataCurve( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XUndoManager > & xUndoManager ) + const Reference< chart2::XDocumentActions > & xDocumentActions ) { bool bResult = false; uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( @@ -146,7 +146,7 @@ bool lcl_deleteDataCurve( ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))), - xUndoManager ); + xDocumentActions ); ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); bResult = true; aUndoGuard.commitAction(); @@ -236,7 +236,7 @@ void ChartController::executeDispatch_NewArrangement() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( String( SchResId( STR_ACTION_REARRANGE_CHART )), - m_xUndoManager ); + m_xDocumentActions ); ControllerLockGuard aCtlLockGuard( xModel ); // diagram @@ -286,7 +286,7 @@ void ChartController::executeDispatch_ScaleText() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( String( SchResId( STR_ACTION_SCALE_TEXT )), - m_xUndoManager ); + m_xDocumentActions ); ControllerLockGuard aCtlLockGuard( getModel() ); ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider()); OSL_ASSERT( apRefSizeProv.get()); @@ -656,7 +656,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))), - m_xUndoManager ); + m_xDocumentActions ); TitleHelper::removeTitle( ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); bReturn = true; @@ -675,7 +675,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), - m_xUndoManager ); + m_xDocumentActions ); xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false )); bReturn = true; aUndoGuard.commitAction(); @@ -685,7 +685,7 @@ bool ChartController::executeDispatch_Delete() } case OBJECTTYPE_DATA_SERIES: - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions ); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -693,9 +693,9 @@ bool ChartController::executeDispatch_Delete() ObjectType eParentObjectType = ObjectIdentifier::getObjectType( ObjectIdentifier::getFullParentParticle( aCID )); if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions ); else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions ); break; } @@ -710,7 +710,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xUndoManager ); + m_xDocumentActions ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); bReturn = true; aUndoGuard.commitAction(); @@ -719,7 +719,7 @@ bool ChartController::executeDispatch_Delete() } case OBJECTTYPE_DATA_CURVE: - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions ); break; case OBJECTTYPE_DATA_CURVE_EQUATION: @@ -733,7 +733,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xUndoManager ); + m_xDocumentActions ); { ControllerLockGuard aCtlLockGuard( xModel ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); @@ -756,7 +756,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))), - m_xUndoManager ); + m_xDocumentActions ); { ControllerLockGuard aCtlLockGuard( xModel ); xErrorBarProp->setPropertyValue( @@ -780,7 +780,7 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))), - m_xUndoManager ); + m_xDocumentActions ); chart2::DataPointLabel aLabel; xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel; aLabel.ShowNumber = false; @@ -844,7 +844,7 @@ void ChartController::executeDispatch_ToggleLegend() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager ); + String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xDocumentActions ); Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY ); bool bChanged = false; if( xLegendProp.is()) @@ -878,7 +878,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager ); + String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xDocumentActions ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); if( xDiagram.is()) { @@ -911,7 +911,7 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), - m_xUndoManager ); + m_xDocumentActions ); if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) aUndoGuard.commitAction(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 1b060431df5e..c12ce38fa7cd 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -839,7 +839,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( pChartDragMethod ) { UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(), - m_xUndoManager ); + m_xDocumentActions ); if( pDrawViewWrapper->EndDragObj(false) ) { @@ -872,7 +872,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), - m_xUndoManager ); + m_xDocumentActions ); bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) @@ -1808,7 +1808,7 @@ bool ChartController::impl_moveOrResizeObject( ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); + eActionType, ObjectNameProvider::getName( eObjectType )), m_xDocumentActions ); { ControllerLockGuard aCLGuard( xChartModel ); if( bNeedShift ) diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index e0d689340760..c0847a490ea1 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -75,12 +75,6 @@ void CommandDispatchContainer::setModel( m_xModel = xModel; } -// void CommandDispatchContainer::setUndoManager( -// const Reference< chart2::XUndoManager > & xUndoManager ) -// { -// m_xUndoManager = xUndoManager; -// } - void CommandDispatchContainer::setChartDispatch( const Reference< frame::XDispatch > xChartDispatch, const ::std::set< OUString > & rChartCommands ) diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx index 1c8769e0a6d9..38f0c2ce8771 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.hxx +++ b/chart2/source/controller/main/CommandDispatchContainer.hxx @@ -28,7 +28,7 @@ #define CHART2_COMMANDDISPATCHCONTAINER_HXX #include -#include +#include #include #include #include @@ -86,9 +86,6 @@ public: void setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); -// void setUndoManager( -// const ::com::sun::star::uno::Reference< -// ::com::sun::star::chart2::XUndoManager > & xUndoManager ); /** Set a chart dispatcher that is used for all commands contained in rChartCommands @@ -140,9 +137,9 @@ private: mutable tDispatchMap m_aCachedDispatches; mutable tDisposeVector m_aToBeDisposedDispatches; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher; ::std::set< ::rtl::OUString > m_aChartCommands; diff --git a/chart2/source/controller/main/DocumentActions.cxx b/chart2/source/controller/main/DocumentActions.cxx new file mode 100644 index 000000000000..e4fe1ab0fc3f --- /dev/null +++ b/chart2/source/controller/main/DocumentActions.cxx @@ -0,0 +1,431 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "DocumentActions.hxx" +#include "ImplDocumentActions.hxx" +#include "DisposeHelper.hxx" +#include "MutexContainer.hxx" +#include "macros.hxx" +#include "ChartViewHelper.hxx" + +#include +#include + +#include +#include +#include +#include + +#include + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::frame::XModel; +using ::rtl::OUString; + + +// -------------------------------------------------------------------------------- + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper1< + util::XModifyBroadcaster > + ModifyBroadcaster_Base; + +class ModifyBroadcaster : + public ::chart::MutexContainer, + public ModifyBroadcaster_Base +{ +public: + ModifyBroadcaster(); + + void fireEvent(); + +protected: + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) + throw (uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener ) + throw (uno::RuntimeException); +}; + +ModifyBroadcaster::ModifyBroadcaster() : + ModifyBroadcaster_Base( m_aMutex ) +{} + +void SAL_CALL ModifyBroadcaster::addModifyListener( + const Reference< util::XModifyListener >& xListener ) + throw (uno::RuntimeException) +{ + rBHelper.addListener( ::getCppuType( & xListener ), xListener); +} + +void SAL_CALL ModifyBroadcaster::removeModifyListener( + const Reference< util::XModifyListener >& xListener ) + throw (uno::RuntimeException) +{ + rBHelper.removeListener( ::getCppuType( & xListener ), xListener ); +} + +void ModifyBroadcaster::fireEvent() +{ + ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer( + ::getCppuType((const uno::Reference< util::XModifyListener >*)0) ); + if( pIC ) + { + lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); + ::cppu::OInterfaceIteratorHelper aIt( *pIC ); + while( aIt.hasMoreElements() ) + { + uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY ); + if( xListener.is() ) + xListener->modified( aEvent ); + } + } +} + +} // namespace impl + +DocumentActions::DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) : + impl::DocumentActions_Base( m_aMutex ), + m_apUndoStack( new impl::UndoStack()), + m_apRedoStack( new impl::UndoStack()), + m_pLastRemeberedUndoElement( 0 ), + m_nMaxNumberOfUndos( 100 ), + m_pModifyBroadcaster( 0 ), + m_aModel( rModel ) +{} + +DocumentActions::~DocumentActions() +{ + DisposeHelper::Dispose( m_xModifyBroadcaster ); + m_apUndoStack->disposeAndClear(); + m_apRedoStack->disposeAndClear(); + + delete m_pLastRemeberedUndoElement; + m_pLastRemeberedUndoElement = 0; +} + +void DocumentActions::addShapeUndoAction( SdrUndoAction* pAction ) +{ + if ( !pAction ) + { + return; + } + + impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction ); + if ( pShapeUndoElement ) + { + m_apUndoStack->push( pShapeUndoElement ); + m_apRedoStack->disposeAndClear(); + if ( !m_apUndoStepsConfigItem.get() ) + { + retrieveConfigUndoSteps(); + } + fireModifyEvent(); + } +} + +Reference< XModel > DocumentActions::impl_getModel() const +{ + Reference< XModel > xModel( m_aModel ); + return xModel; +} + +void DocumentActions::impl_undoRedo( + impl::UndoStack * pStackToRemoveFrom, + impl::UndoStack * pStackToAddTo, + bool bUndo ) +{ + if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() ) + { + // get model from undo/redo + impl::UndoElement * pTop( pStackToRemoveFrom->top()); + if( pTop ) + { + Reference< XModel > xModel( impl_getModel() ); + impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop ); + if ( pShapeUndoElement ) + { + impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement ); + pStackToAddTo->push( pNewShapeUndoElement ); + SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction(); + if ( pAction ) + { + if ( bUndo ) + { + pAction->Undo(); + } + else + { + pAction->Redo(); + } + } + } + else + { + // put a clone of current model into redo/undo stack with the same + // action string as the undo/redo + pStackToAddTo->push( pTop->createFromModel( xModel )); + // change current model by properties of the model from undo + pTop->applyToModel( xModel ); + } + // remove the top undo element + pStackToRemoveFrom->pop(), pTop = 0; + ChartViewHelper::setViewToDirtyState( xModel ); + fireModifyEvent(); + } + } + else + { + OSL_ENSURE( false, "Can't Undo/Redo" ); + } +} + +void DocumentActions::fireModifyEvent() +{ + if( m_xModifyBroadcaster.is()) + m_pModifyBroadcaster->fireEvent(); +} + + +// ____ ConfigItemListener ____ +void DocumentActions::notify( const ::rtl::OUString & rPropertyName ) +{ + OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )), + "Unwanted config property change Notified" ); + if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" ))) + retrieveConfigUndoSteps(); +} + +void DocumentActions::retrieveConfigUndoSteps() +{ + if( ! m_apUndoStepsConfigItem.get()) + m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this )); + m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps(); + m_apUndoStack->limitSize( m_nMaxNumberOfUndos ); + m_apRedoStack->limitSize( m_nMaxNumberOfUndos ); + + // a list of available undo steps could shrink here + fireModifyEvent(); +} + +// ____ XModifyBroadcaster ____ +void SAL_CALL DocumentActions::addModifyListener( const Reference< util::XModifyListener >& aListener ) + throw (uno::RuntimeException) +{ + if( ! m_xModifyBroadcaster.is()) + { + m_pModifyBroadcaster = new impl::ModifyBroadcaster(); + m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); + } + m_xModifyBroadcaster->addModifyListener( aListener ); +} + +void SAL_CALL DocumentActions::removeModifyListener( const Reference< util::XModifyListener >& aListener ) + throw (uno::RuntimeException) +{ + if( ! m_xModifyBroadcaster.is()) + { + m_pModifyBroadcaster = new impl::ModifyBroadcaster(); + m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); + } + m_xModifyBroadcaster->removeModifyListener( aListener ); +} + +// ____ chart2::XDocumentActions ____ +void SAL_CALL DocumentActions::preAction( ) + throw (uno::RuntimeException) +{ + OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); + m_pLastRemeberedUndoElement = new impl::UndoElement( impl_getModel() ); +} + +void SAL_CALL DocumentActions::preActionWithArguments( + const Sequence< beans::PropertyValue >& aArguments ) + throw (uno::RuntimeException) +{ + Reference< XModel > xModel( impl_getModel() ); + bool bActionHandled( false ); + OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); + if( aArguments.getLength() > 0 ) + { + OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); + if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) + { + m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModel ); + bActionHandled = true; + } + else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) + { + m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModel ); + bActionHandled = true; + } + } + + if( !bActionHandled ) + preAction(); +} + +void SAL_CALL DocumentActions::postAction( const OUString& aUndoText ) + throw (uno::RuntimeException) +{ + OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" ); + if( m_pLastRemeberedUndoElement ) + { + m_pLastRemeberedUndoElement->setActionString( aUndoText ); + m_apUndoStack->push( m_pLastRemeberedUndoElement ); + m_pLastRemeberedUndoElement = 0; + + // redo no longer possible + m_apRedoStack->disposeAndClear(); + + // it suffices to get the number of undo steps from config after the + // first time postAction has been called + if( ! m_apUndoStepsConfigItem.get()) + retrieveConfigUndoSteps(); + + fireModifyEvent(); + } +} + +void SAL_CALL DocumentActions::cancelAction() + throw (uno::RuntimeException) +{ + delete m_pLastRemeberedUndoElement; + m_pLastRemeberedUndoElement = 0; +} + +void SAL_CALL DocumentActions::cancelActionWithUndo( ) + throw (uno::RuntimeException) +{ + if( m_pLastRemeberedUndoElement ) + { + m_pLastRemeberedUndoElement->applyToModel( impl_getModel() ); + cancelAction(); + } +} + +void SAL_CALL DocumentActions::undo( ) + throw (uno::RuntimeException) +{ + OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); + impl_undoRedo( m_apUndoStack.get(), m_apRedoStack.get(), true ); +} + +void SAL_CALL DocumentActions::redo( ) + throw (uno::RuntimeException) +{ + OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); + impl_undoRedo( m_apRedoStack.get(), m_apUndoStack.get(), false ); +} + +::sal_Bool SAL_CALL DocumentActions::undoPossible() + throw (uno::RuntimeException) +{ + return ! m_apUndoStack->empty(); +} + +::sal_Bool SAL_CALL DocumentActions::redoPossible() + throw (uno::RuntimeException) +{ + return ! m_apRedoStack->empty(); +} + +OUString SAL_CALL DocumentActions::getCurrentUndoString() + throw (uno::RuntimeException) +{ + return m_apUndoStack->topUndoString(); +} + +OUString SAL_CALL DocumentActions::getCurrentRedoString() + throw (uno::RuntimeException) +{ + return m_apRedoStack->topUndoString(); +} + +Sequence< OUString > SAL_CALL DocumentActions::getAllUndoStrings() + throw (uno::RuntimeException) +{ + return m_apUndoStack->getUndoStrings(); +} + +Sequence< OUString > SAL_CALL DocumentActions::getAllRedoStrings() + throw (uno::RuntimeException) +{ + return m_apRedoStack->getUndoStrings(); +} + +// ____ XUnoTunnel ____ +sal_Int64 DocumentActions::getSomething( const Sequence< sal_Int8 >& rId ) + throw (uno::RuntimeException) +{ + if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); + } + return 0; +} + +// static +const Sequence< sal_Int8 >& DocumentActions::getUnoTunnelId() +{ + static Sequence< sal_Int8 >* pSeq = 0; + if( !pSeq ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if( !pSeq ) + { + static Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} + +// static +DocumentActions* DocumentActions::getImplementation( const Reference< uno::XInterface > xObj ) +{ + DocumentActions* pRet = NULL; + Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY ); + if ( xUT.is() ) + { + pRet = reinterpret_cast< DocumentActions* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) ); + } + return pRet; +} + +} // namespace chart diff --git a/chart2/source/controller/main/ImplDocumentActions.cxx b/chart2/source/controller/main/ImplDocumentActions.cxx new file mode 100644 index 000000000000..8103bec54114 --- /dev/null +++ b/chart2/source/controller/main/ImplDocumentActions.cxx @@ -0,0 +1,505 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ImplDocumentActions.hxx" +#include "DisposeHelper.hxx" +#include "CommonFunctors.hxx" +#include "ControllerLockGuard.hxx" +#include "PropertyHelper.hxx" +#include "DataSourceHelper.hxx" +#include "ChartModelHelper.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; +using ::com::sun::star::chart::XComplexDescriptionAccess; + +namespace chart +{ +namespace impl +{ + +void ImplApplyDataToModel( + const Reference< frame::XModel > & xModel, + const Reference< chart2::XInternalDataProvider > & xData ) +{ + Reference< chart2::XChartDocument > xDoc( xModel, uno::UNO_QUERY ); + OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); + + // copy data from stored internal data provider + if( xDoc.is() && xDoc->hasInternalDataProvider()) + { + Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); + Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); + if( xCurrentData.is() && xSavedData.is()) + { + xCurrentData->setData( xSavedData->getData()); + xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); + xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); + } + } +} + +// ---------------------------------------- + +UndoElement::UndoElement( + const OUString & rActionString, + const Reference< frame::XModel > & xModel ) : + m_aActionString( rActionString ) +{ + initialize( xModel ); +} + +UndoElement::UndoElement( + const Reference< frame::XModel > & xModel ) +{ + initialize( xModel ); +} + +UndoElement::UndoElement( const UndoElement & rOther ) : + m_aActionString( rOther.m_aActionString ) +{ + initialize( rOther.m_xModel ); +} + +UndoElement::~UndoElement() +{} + +void UndoElement::initialize( const Reference< frame::XModel > & xModel ) +{ + if ( xModel.is() ) + { + m_xModel.set( UndoElement::cloneModel( xModel ) ); + } +} + +void UndoElement::dispose() +{ + Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); + m_xModel.set( 0 ); +} + +void UndoElement::applyToModel( + const Reference< frame::XModel > & xModel ) +{ + UndoElement::applyModelContentToModel( xModel, m_xModel ); +} + +UndoElement * UndoElement::createFromModel( + const Reference< frame::XModel > & xModel ) +{ + return new UndoElement( getActionString(), xModel ); +} + +void UndoElement::setActionString( const ::rtl::OUString & rActionString ) +{ + m_aActionString = rActionString; +} + +OUString UndoElement::getActionString() const +{ + return m_aActionString; +} + +// static +Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) +{ + Reference< frame::XModel > xResult; + uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY ); + OSL_ENSURE( xCloneable.is(), "Cannot clone model" ); + if( xCloneable.is()) + xResult.set( xCloneable->createClone(), uno::UNO_QUERY ); + + return xResult; +} + +// static +void UndoElement::applyModelContentToModel( + const Reference< frame::XModel > & xModel, + const Reference< frame::XModel > & xModelToCopyFrom, + const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) +{ + + if( xModelToCopyFrom.is() && xModel.is()) + { + try + { + // /-- loccked controllers of destination + ControllerLockGuard aLockedControllers( xModel ); + Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); + Reference< chart2::XChartDocument > xDestination( xModel, uno::UNO_QUERY_THROW ); + + // propagate the correct flag for plotting of hidden values to the data provider and all used sequences + ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xModel ); + + // diagram + xDestination->setFirstDiagram( xSource->getFirstDiagram()); + + // main title + Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW ); + Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW ); + xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject()); + + // page background + comphelper::copyProperties( + xSource->getPageBackground(), + xDestination->getPageBackground() ); + + // apply data (not applied in standard Undo) + if( xData.is()) + ImplApplyDataToModel( xModel, xData ); + + // register all sequences at the internal data provider to get adapted + // indexes when columns are added/removed + if( xDestination->hasInternalDataProvider()) + { + Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); + Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xModel )); + if( xUsedData.is() && xNewDataProvider.is()) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); + for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues()); + xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel()); + } + } + } + + // restore modify status + Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY ); + Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY ); + if( xSourceMod.is() && xDestMod.is() && + ! xSourceMod->isModified() ) + { + xDestMod->setModified( sal_False ); + } + // \-- loccked controllers of destination + } + catch( uno::Exception & ) + { + } + } +} + +// ---------------------------------------- + +UndoElementWithData::UndoElementWithData( + const OUString & rActionString, + const Reference< frame::XModel > & xModel ) : + UndoElement( rActionString, xModel ) +{ + initializeData(); +} + +UndoElementWithData::UndoElementWithData( + const Reference< frame::XModel > & xModel ) : + UndoElement( xModel ) +{ + initializeData(); +} + + +UndoElementWithData::UndoElementWithData( + const UndoElementWithData & rOther ) : + UndoElement( rOther ) +{ + initializeData(); +} + +UndoElementWithData::~UndoElementWithData() +{} + +void UndoElementWithData::initializeData() +{ + try + { + Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW ); + OSL_ASSERT( xChartDoc->hasInternalDataProvider()); + if( xChartDoc->hasInternalDataProvider()) + { + Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + OSL_ENSURE( xCloneable.is(), "Cannot clone data" ); + if( xCloneable.is()) + m_xData.set( xCloneable->createClone(), uno::UNO_QUERY ); + } + } + catch( uno::Exception & ) + { + } +} + +void UndoElementWithData::dispose() +{ + UndoElement::dispose(); + m_xData.set( 0 ); +} + +void UndoElementWithData::applyToModel( + const Reference< frame::XModel > & xModel ) +{ + UndoElement::applyModelContentToModel( xModel, m_xModel, m_xData ); +} + +UndoElement * UndoElementWithData::createFromModel( + const Reference< frame::XModel > & xModel ) +{ + return new UndoElementWithData( getActionString(), xModel ); +} + +// ======================================== + +// ---------------------------------------- + +UndoElementWithSelection::UndoElementWithSelection( + const OUString & rActionString, + const Reference< frame::XModel > & xModel ) : + UndoElement( rActionString, xModel ) +{ + initialize( xModel ); +} + +UndoElementWithSelection::UndoElementWithSelection( + const Reference< frame::XModel > & xModel ) : + UndoElement( xModel ) +{ + initialize( xModel ); +} + +UndoElementWithSelection::UndoElementWithSelection( + const UndoElementWithSelection & rOther ) : + UndoElement( rOther ) +{ + initialize( rOther.m_xModel ); +} + +UndoElementWithSelection::~UndoElementWithSelection() +{} + +void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel ) +{ + try + { + uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); + OSL_ASSERT( xSelSupp.is() ); + + if( xSelSupp.is() ) + m_aSelection = xSelSupp->getSelection(); + } + catch( const uno::Exception & ) + { + } +} + +void UndoElementWithSelection::dispose() +{ + UndoElement::dispose(); + m_aSelection.clear(); +} + +void UndoElementWithSelection::applyToModel( + const Reference< frame::XModel > & xModel ) +{ + UndoElement::applyModelContentToModel( xModel, m_xModel ); + Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xModel->getCurrentController(), uno::UNO_QUERY ); + OSL_ASSERT( xCurrentSelectionSuppl.is() ); + + if( xCurrentSelectionSuppl.is()) + xCurrentSelectionSuppl->select( m_aSelection ); +} + +UndoElement * UndoElementWithSelection::createFromModel( + const Reference< frame::XModel > & xModel ) +{ + return new UndoElementWithSelection( getActionString(), xModel ); +} + +// ---------------------------------------- + +ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction ) + :UndoElement( rActionString, Reference< frame::XModel >() ) + ,m_pAction( pAction ) +{ +} + +ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther ) + :UndoElement( rOther ) + ,m_pAction( rOther.m_pAction ) +{ +} + +ShapeUndoElement::~ShapeUndoElement() +{ +} + +SdrUndoAction* ShapeUndoElement::getSdrUndoAction() +{ + return m_pAction; +} + +// ======================================== + +UndoStack::UndoStack() : + m_nSizeLimit( 1000 ) +{ +} + +UndoStack::~UndoStack() +{ + disposeAndClear(); +} + +void UndoStack::pop() +{ + if( ! empty()) + { + top()->dispose(); + delete top(); + m_aStack.pop_back(); + } +} + +void UndoStack::push( UndoElement * pElement ) +{ + m_aStack.push_back( pElement ); + applyLimitation(); +} + +UndoElement * UndoStack::top() const +{ + return m_aStack.back(); +} + +OUString UndoStack::topUndoString() const +{ + if( ! empty()) + return top()->getActionString(); + return OUString(); +} + +Sequence< OUString > UndoStack::getUndoStrings() const +{ + sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size())); + Sequence< OUString > aResult( nSize ); + for( sal_Int32 i=0; igetActionString(); + return aResult; +} + +bool UndoStack::empty() const +{ + return m_aStack.empty(); +} + +void UndoStack::disposeAndClear() +{ + ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose )); + ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() ); + m_aStack.clear(); +} + +void UndoStack::limitSize( sal_Int32 nMaxSize ) +{ + m_nSizeLimit = nMaxSize; + applyLimitation(); +} + +void UndoStack::applyLimitation() +{ + if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit )) + { + tUndoStackType::iterator aBegin( m_aStack.begin()); + tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit)); + // dispose and remove all undo elements that are over the limit + ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose )); + ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() ); + m_aStack.erase( aBegin, aEnd ); + } +} + +// ================================================================================ + +namespace +{ +static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps")); +} // anonymous namespace + +UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) : + ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))), + m_rListener( rListener ) +{ + EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 )); +} + +UndoStepsConfigItem::~UndoStepsConfigItem() +{ +} + +void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) +{ + for( sal_Int32 nIdx=0; nIdx aValues( + GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 ))); + if( aValues.getLength()) + aValues[0] >>= nSteps; + return nSteps; +} + +} // namespace impl +} // namespace chart diff --git a/chart2/source/controller/main/ImplDocumentActions.hxx b/chart2/source/controller/main/ImplDocumentActions.hxx new file mode 100644 index 000000000000..aaf8f18c1231 --- /dev/null +++ b/chart2/source/controller/main/ImplDocumentActions.hxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_IMPLUNDOMANAGER_HXX +#define CHART2_IMPLUNDOMANAGER_HXX + +#include "ConfigItemListener.hxx" + +#include +#include + +#include +#include + +#include +#include + + +class SdrUndoAction; + +namespace com { namespace sun { namespace star { +namespace chart2 { + class XInternalDataProvider; +} +}}} + + +namespace chart +{ +namespace impl +{ + +class UndoElement +{ +public: + UndoElement( const ::rtl::OUString & rActionString, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElement( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElement( const UndoElement & rOther ); + virtual ~UndoElement(); + + virtual void dispose(); + virtual UndoElement * createFromModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + virtual void applyToModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + void setActionString( const ::rtl::OUString & rActionString ); + ::rtl::OUString getActionString() const; + + static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); + + static void applyModelContentToModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); + +protected: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xModel; + +private: + void initialize( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + ::rtl::OUString m_aActionString; +}; + +class UndoElementWithData : public UndoElement +{ +public: + UndoElementWithData( const ::rtl::OUString & rActionString, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElementWithData( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElementWithData( const UndoElementWithData & rOther ); + virtual ~UndoElementWithData(); + + virtual void dispose(); + virtual UndoElement * createFromModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + virtual void applyToModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + +private: + void initializeData(); + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XInternalDataProvider > m_xData; +}; + +class UndoElementWithSelection : public UndoElement +{ +public: + UndoElementWithSelection( const ::rtl::OUString & rActionString, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElementWithSelection( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + UndoElementWithSelection( const UndoElementWithSelection & rOther ); + virtual ~UndoElementWithSelection(); + + virtual void dispose(); + virtual UndoElement * createFromModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + virtual void applyToModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + +private: + void initialize( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + ::com::sun::star::uno::Any m_aSelection; +}; + +class ShapeUndoElement : public UndoElement +{ +public: + ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction ); + ShapeUndoElement( const ShapeUndoElement& rOther ); + virtual ~ShapeUndoElement(); + + SdrUndoAction* getSdrUndoAction(); + +private: + SdrUndoAction* m_pAction; +}; + +/** Note that all models that are put into this container are at some point + disposed of inside this class. (At least in the destructor). That means + the models retrieved here should never be used, but instead their content + should be copied to a living model. + */ +class UndoStack +{ +public: + UndoStack(); + // disposes of all models left in the stack + ~UndoStack(); + + // removes he last undo action and disposes of the model + void pop(); + void push( UndoElement * rElement ); + + // precondition: !empty() + UndoElement * top() const; + ::rtl::OUString topUndoString() const; + + ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const; + + bool empty() const; + void disposeAndClear(); + + // removes all actions that have been inserted more than nMaxSize steps ago. + // The models of those actions are disposed of + void limitSize( sal_Int32 nMaxSize ); + +private: + void applyLimitation(); + + typedef ::std::deque< UndoElement * > tUndoStackType; + + tUndoStackType m_aStack; + sal_Int32 m_nSizeLimit; +}; + +// ---------------------------------------- + +class UndoStepsConfigItem : public ::utl::ConfigItem +{ +public: + explicit UndoStepsConfigItem( ConfigItemListener & rListener ); + virtual ~UndoStepsConfigItem(); + + sal_Int32 getUndoSteps(); + +protected: + // ____ ::utl::ConfigItem ____ + virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames ); + virtual void Commit(); + +private: + ConfigItemListener & m_rListener; +}; + + +} // namespace impl +} // namespace chart + +// CHART2_IMPLUNDOMANAGER_HXX +#endif diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx deleted file mode 100644 index 4426433791c4..000000000000 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ /dev/null @@ -1,505 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "CommonFunctors.hxx" -#include "ControllerLockGuard.hxx" -#include "PropertyHelper.hxx" -#include "DataSourceHelper.hxx" -#include "ChartModelHelper.hxx" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; -using ::com::sun::star::chart::XComplexDescriptionAccess; - -namespace chart -{ -namespace impl -{ - -void ImplApplyDataToModel( - const Reference< frame::XModel > & xModel, - const Reference< chart2::XInternalDataProvider > & xData ) -{ - Reference< chart2::XChartDocument > xDoc( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); - - // copy data from stored internal data provider - if( xDoc.is() && xDoc->hasInternalDataProvider()) - { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); - if( xCurrentData.is() && xSavedData.is()) - { - xCurrentData->setData( xSavedData->getData()); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); - } - } -} - -// ---------------------------------------- - -UndoElement::UndoElement( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - m_aActionString( rActionString ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( - const Reference< frame::XModel > & xModel ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( const UndoElement & rOther ) : - m_aActionString( rOther.m_aActionString ) -{ - initialize( rOther.m_xModel ); -} - -UndoElement::~UndoElement() -{} - -void UndoElement::initialize( const Reference< frame::XModel > & xModel ) -{ - if ( xModel.is() ) - { - m_xModel.set( UndoElement::cloneModel( xModel ) ); - } -} - -void UndoElement::dispose() -{ - Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); - m_xModel.set( 0 ); -} - -void UndoElement::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel ); -} - -UndoElement * UndoElement::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElement( getActionString(), xModel ); -} - -void UndoElement::setActionString( const ::rtl::OUString & rActionString ) -{ - m_aActionString = rActionString; -} - -OUString UndoElement::getActionString() const -{ - return m_aActionString; -} - -// static -Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) -{ - Reference< frame::XModel > xResult; - uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone model" ); - if( xCloneable.is()) - xResult.set( xCloneable->createClone(), uno::UNO_QUERY ); - - return xResult; -} - -// static -void UndoElement::applyModelContentToModel( - const Reference< frame::XModel > & xModel, - const Reference< frame::XModel > & xModelToCopyFrom, - const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) -{ - - if( xModelToCopyFrom.is() && xModel.is()) - { - try - { - // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( xModel ); - Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); - Reference< chart2::XChartDocument > xDestination( xModel, uno::UNO_QUERY_THROW ); - - // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xModel ); - - // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram()); - - // main title - Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW ); - Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject()); - - // page background - comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); - - // apply data (not applied in standard Undo) - if( xData.is()) - ImplApplyDataToModel( xModel, xData ); - - // register all sequences at the internal data provider to get adapted - // indexes when columns are added/removed - if( xDestination->hasInternalDataProvider()) - { - Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xModel )); - if( xUsedData.is() && xNewDataProvider.is()) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); - for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues()); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel()); - } - } - } - - // restore modify status - Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY ); - Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY ); - if( xSourceMod.is() && xDestMod.is() && - ! xSourceMod->isModified() ) - { - xDestMod->setModified( sal_False ); - } - // \-- loccked controllers of destination - } - catch( uno::Exception & ) - { - } - } -} - -// ---------------------------------------- - -UndoElementWithData::UndoElementWithData( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initializeData(); -} - -UndoElementWithData::UndoElementWithData( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initializeData(); -} - - -UndoElementWithData::UndoElementWithData( - const UndoElementWithData & rOther ) : - UndoElement( rOther ) -{ - initializeData(); -} - -UndoElementWithData::~UndoElementWithData() -{} - -void UndoElementWithData::initializeData() -{ - try - { - Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW ); - OSL_ASSERT( xChartDoc->hasInternalDataProvider()); - if( xChartDoc->hasInternalDataProvider()) - { - Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone data" ); - if( xCloneable.is()) - m_xData.set( xCloneable->createClone(), uno::UNO_QUERY ); - } - } - catch( uno::Exception & ) - { - } -} - -void UndoElementWithData::dispose() -{ - UndoElement::dispose(); - m_xData.set( 0 ); -} - -void UndoElementWithData::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel, m_xData ); -} - -UndoElement * UndoElementWithData::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithData( getActionString(), xModel ); -} - -// ======================================== - -// ---------------------------------------- - -UndoElementWithSelection::UndoElementWithSelection( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const UndoElementWithSelection & rOther ) : - UndoElement( rOther ) -{ - initialize( rOther.m_xModel ); -} - -UndoElementWithSelection::~UndoElementWithSelection() -{} - -void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel ) -{ - try - { - uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xSelSupp.is() ); - - if( xSelSupp.is() ) - m_aSelection = xSelSupp->getSelection(); - } - catch( const uno::Exception & ) - { - } -} - -void UndoElementWithSelection::dispose() -{ - UndoElement::dispose(); - m_aSelection.clear(); -} - -void UndoElementWithSelection::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel ); - Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xCurrentSelectionSuppl.is() ); - - if( xCurrentSelectionSuppl.is()) - xCurrentSelectionSuppl->select( m_aSelection ); -} - -UndoElement * UndoElementWithSelection::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithSelection( getActionString(), xModel ); -} - -// ---------------------------------------- - -ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction ) - :UndoElement( rActionString, Reference< frame::XModel >() ) - ,m_pAction( pAction ) -{ -} - -ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther ) - :UndoElement( rOther ) - ,m_pAction( rOther.m_pAction ) -{ -} - -ShapeUndoElement::~ShapeUndoElement() -{ -} - -SdrUndoAction* ShapeUndoElement::getSdrUndoAction() -{ - return m_pAction; -} - -// ======================================== - -UndoStack::UndoStack() : - m_nSizeLimit( 1000 ) -{ -} - -UndoStack::~UndoStack() -{ - disposeAndClear(); -} - -void UndoStack::pop() -{ - if( ! empty()) - { - top()->dispose(); - delete top(); - m_aStack.pop_back(); - } -} - -void UndoStack::push( UndoElement * pElement ) -{ - m_aStack.push_back( pElement ); - applyLimitation(); -} - -UndoElement * UndoStack::top() const -{ - return m_aStack.back(); -} - -OUString UndoStack::topUndoString() const -{ - if( ! empty()) - return top()->getActionString(); - return OUString(); -} - -Sequence< OUString > UndoStack::getUndoStrings() const -{ - sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size())); - Sequence< OUString > aResult( nSize ); - for( sal_Int32 i=0; igetActionString(); - return aResult; -} - -bool UndoStack::empty() const -{ - return m_aStack.empty(); -} - -void UndoStack::disposeAndClear() -{ - ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.clear(); -} - -void UndoStack::limitSize( sal_Int32 nMaxSize ) -{ - m_nSizeLimit = nMaxSize; - applyLimitation(); -} - -void UndoStack::applyLimitation() -{ - if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit )) - { - tUndoStackType::iterator aBegin( m_aStack.begin()); - tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit)); - // dispose and remove all undo elements that are over the limit - ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.erase( aBegin, aEnd ); - } -} - -// ================================================================================ - -namespace -{ -static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps")); -} // anonymous namespace - -UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) : - ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))), - m_rListener( rListener ) -{ - EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 )); -} - -UndoStepsConfigItem::~UndoStepsConfigItem() -{ -} - -void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) -{ - for( sal_Int32 nIdx=0; nIdx aValues( - GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 ))); - if( aValues.getLength()) - aValues[0] >>= nSteps; - return nSteps; -} - -} // namespace impl -} // namespace chart diff --git a/chart2/source/controller/main/ImplUndoManager.hxx b/chart2/source/controller/main/ImplUndoManager.hxx deleted file mode 100644 index aaf8f18c1231..000000000000 --- a/chart2/source/controller/main/ImplUndoManager.hxx +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_IMPLUNDOMANAGER_HXX -#define CHART2_IMPLUNDOMANAGER_HXX - -#include "ConfigItemListener.hxx" - -#include -#include - -#include -#include - -#include -#include - - -class SdrUndoAction; - -namespace com { namespace sun { namespace star { -namespace chart2 { - class XInternalDataProvider; -} -}}} - - -namespace chart -{ -namespace impl -{ - -class UndoElement -{ -public: - UndoElement( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const UndoElement & rOther ); - virtual ~UndoElement(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - void setActionString( const ::rtl::OUString & rActionString ); - ::rtl::OUString getActionString() const; - - static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); - - static void applyModelContentToModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); - -protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > m_xModel; - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::rtl::OUString m_aActionString; -}; - -class UndoElementWithData : public UndoElement -{ -public: - UndoElementWithData( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const UndoElementWithData & rOther ); - virtual ~UndoElementWithData(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - -private: - void initializeData(); - - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XInternalDataProvider > m_xData; -}; - -class UndoElementWithSelection : public UndoElement -{ -public: - UndoElementWithSelection( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const UndoElementWithSelection & rOther ); - virtual ~UndoElementWithSelection(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::com::sun::star::uno::Any m_aSelection; -}; - -class ShapeUndoElement : public UndoElement -{ -public: - ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction ); - ShapeUndoElement( const ShapeUndoElement& rOther ); - virtual ~ShapeUndoElement(); - - SdrUndoAction* getSdrUndoAction(); - -private: - SdrUndoAction* m_pAction; -}; - -/** Note that all models that are put into this container are at some point - disposed of inside this class. (At least in the destructor). That means - the models retrieved here should never be used, but instead their content - should be copied to a living model. - */ -class UndoStack -{ -public: - UndoStack(); - // disposes of all models left in the stack - ~UndoStack(); - - // removes he last undo action and disposes of the model - void pop(); - void push( UndoElement * rElement ); - - // precondition: !empty() - UndoElement * top() const; - ::rtl::OUString topUndoString() const; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const; - - bool empty() const; - void disposeAndClear(); - - // removes all actions that have been inserted more than nMaxSize steps ago. - // The models of those actions are disposed of - void limitSize( sal_Int32 nMaxSize ); - -private: - void applyLimitation(); - - typedef ::std::deque< UndoElement * > tUndoStackType; - - tUndoStackType m_aStack; - sal_Int32 m_nSizeLimit; -}; - -// ---------------------------------------- - -class UndoStepsConfigItem : public ::utl::ConfigItem -{ -public: - explicit UndoStepsConfigItem( ConfigItemListener & rListener ); - virtual ~UndoStepsConfigItem(); - - sal_Int32 getUndoSteps(); - -protected: - // ____ ::utl::ConfigItem ____ - virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames ); - virtual void Commit(); - -private: - ConfigItemListener & m_rListener; -}; - - -} // namespace impl -} // namespace chart - -// CHART2_IMPLUNDOMANAGER_HXX -#endif diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 97201efa2e04..0d1a26d6fc65 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -31,7 +31,6 @@ #include "UndoCommandDispatch.hxx" #include "macros.hxx" -#include #include #include @@ -57,10 +56,7 @@ UndoCommandDispatch::UndoCommandDispatch( CommandDispatch( xContext ), m_xModel( xModel ) { - Reference< chart2::XUndoSupplier > xUndoSupplier( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xUndoSupplier.is()); - if( xUndoSupplier.is()) - m_xUndoManager.set( xUndoSupplier->getUndoManager()); + m_xDocumentActions.set( xModel, uno::UNO_QUERY ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -68,7 +64,7 @@ UndoCommandDispatch::~UndoCommandDispatch() void UndoCommandDispatch::initialize() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); if( xBroadcaster.is() ) { xBroadcaster->addModifyListener( this ); @@ -79,27 +75,27 @@ void UndoCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { bool bFireAll = (rURL.getLength() == 0); uno::Any aUndoState, aRedoState; - if( m_xUndoManager->undoPossible()) + if( m_xDocumentActions->undoPossible()) { // using assignment for broken gcc 3.3 OUString aUndo = OUString( String( SchResId( STR_UNDO ))); - aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString()); + aUndoState <<= ( aUndo + m_xDocumentActions->getCurrentUndoString()); } - if( m_xUndoManager->redoPossible()) + if( m_xDocumentActions->redoPossible()) { // using assignment for broken gcc 3.3 OUString aRedo = OUString( String( SchResId( STR_REDO ))); - aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString()); + aRedoState <<= ( aRedo + m_xDocumentActions->getCurrentRedoString()); } if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) - fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->undoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xDocumentActions->undoPossible(), xSingleListener ); if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Redo"))) - fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->redoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xDocumentActions->redoPossible(), xSingleListener ); } } @@ -109,15 +105,15 @@ void SAL_CALL UndoCommandDispatch::dispatch( const Sequence< beans::PropertyValue >& /* Arguments */ ) throw (uno::RuntimeException) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { // why is it necessary to lock the solar mutex here? // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xUndoManager->undo(); + m_xDocumentActions->undo(); else - m_xUndoManager->redo(); + m_xDocumentActions->redo(); // \-- } } @@ -126,13 +122,13 @@ void SAL_CALL UndoCommandDispatch::dispatch( /// is called when this is disposed void SAL_CALL UndoCommandDispatch::disposing() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); if( xBroadcaster.is() ) { xBroadcaster->removeModifyListener( this ); } - m_xUndoManager.clear(); + m_xDocumentActions.clear(); m_xModel.clear(); } @@ -140,7 +136,7 @@ void SAL_CALL UndoCommandDispatch::disposing() void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ ) throw (uno::RuntimeException) { - m_xUndoManager.clear(); + m_xDocumentActions.clear(); m_xModel.clear(); } diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx index 28fb813f63de..3130863dec61 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.hxx +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -30,14 +30,14 @@ #include "CommandDispatch.hxx" #include -#include +#include namespace chart { /** This is a CommandDispatch implementation for Undo and Redo. - You need to pass an UndoManager to this class that is then used for Undo and + You need to pass an DocumentActions to this class that is then used for Undo and Redo. The changes are applied to the given XModel. */ class UndoCommandDispatch : public CommandDispatch @@ -77,7 +77,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; }; } // namespace chart diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index d55d52f8d41e..e38bb89d9249 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -40,8 +40,8 @@ namespace chart { UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager ) - : m_xUndoManager( xUndoManager ) + , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) + : m_xDocumentActions( xDocumentActions ) , m_aUndoString( rUndoString ) , m_bActionPosted( false ) { @@ -53,85 +53,85 @@ UndoGuard_Base::~UndoGuard_Base() void UndoGuard_Base::commitAction() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->postAction( m_aUndoString ); + if( !m_bActionPosted && m_xDocumentActions.is() ) + m_xDocumentActions->postAction( m_aUndoString ); m_bActionPosted = true; } //----------------------------------------------------------------------------- UndoGuard::UndoGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager ) - : UndoGuard_Base( rUndoString, xUndoManager ) + , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) + : UndoGuard_Base( rUndoString, xDocumentActions ) { - if( m_xUndoManager.is() ) - m_xUndoManager->preAction(); + if( m_xDocumentActions.is() ) + m_xDocumentActions->preAction(); } UndoGuard::~UndoGuard() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelAction(); + if( !m_bActionPosted && m_xDocumentActions.is() ) + m_xDocumentActions->cancelAction(); } //----------------------------------------------------------------------------- UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager ) - : UndoGuard_Base( rUndoString, xUndoManager ) + , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) + : UndoGuard_Base( rUndoString, xDocumentActions ) { - if( m_xUndoManager.is() ) - m_xUndoManager->preAction(); + if( m_xDocumentActions.is() ) + m_xDocumentActions->preAction(); } UndoLiveUpdateGuard::~UndoLiveUpdateGuard() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo(); + if( !m_bActionPosted && m_xDocumentActions.is() ) + m_xDocumentActions->cancelActionWithUndo(); } //----------------------------------------------------------------------------- UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager ) - : UndoGuard_Base( rUndoString, xUndoManager ) + , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) + : UndoGuard_Base( rUndoString, xDocumentActions ) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { Sequence< beans::PropertyValue > aArgs(1); aArgs[0] = beans::PropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(), beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( aArgs ); + m_xDocumentActions->preActionWithArguments( aArgs ); } } UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo(); + if( !m_bActionPosted && m_xDocumentActions.is() ) + m_xDocumentActions->cancelActionWithUndo(); } //----------------------------------------------------------------------------- UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager ) - : UndoGuard_Base( rUndoString, xUndoManager ) + , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) + : UndoGuard_Base( rUndoString, xDocumentActions ) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { Sequence< beans::PropertyValue > aArgs(1); aArgs[0] = beans::PropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(), beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( aArgs ); + m_xDocumentActions->preActionWithArguments( aArgs ); } } UndoGuardWithSelection::~UndoGuardWithSelection() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelAction(); + if( !m_bActionPosted && m_xDocumentActions.is() ) + m_xDocumentActions->cancelAction(); } } // namespace chart diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx deleted file mode 100644 index a76a8c356852..000000000000 --- a/chart2/source/controller/main/UndoManager.cxx +++ /dev/null @@ -1,431 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "UndoManager.hxx" -#include "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "MutexContainer.hxx" -#include "macros.hxx" -#include "ChartViewHelper.hxx" - -#include -#include - -#include -#include -#include -#include - -#include - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::frame::XModel; -using ::rtl::OUString; - - -// -------------------------------------------------------------------------------- - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakComponentImplHelper1< - util::XModifyBroadcaster > - ModifyBroadcaster_Base; - -class ModifyBroadcaster : - public ::chart::MutexContainer, - public ModifyBroadcaster_Base -{ -public: - ModifyBroadcaster(); - - void fireEvent(); - -protected: - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); -}; - -ModifyBroadcaster::ModifyBroadcaster() : - ModifyBroadcaster_Base( m_aMutex ) -{} - -void SAL_CALL ModifyBroadcaster::addModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.addListener( ::getCppuType( & xListener ), xListener); -} - -void SAL_CALL ModifyBroadcaster::removeModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.removeListener( ::getCppuType( & xListener ), xListener ); -} - -void ModifyBroadcaster::fireEvent() -{ - ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer( - ::getCppuType((const uno::Reference< util::XModifyListener >*)0) ); - if( pIC ) - { - lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY ); - if( xListener.is() ) - xListener->modified( aEvent ); - } - } -} - -} // namespace impl - -UndoManager::UndoManager( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) : - impl::UndoManager_Base( m_aMutex ), - m_apUndoStack( new impl::UndoStack()), - m_apRedoStack( new impl::UndoStack()), - m_pLastRemeberedUndoElement( 0 ), - m_nMaxNumberOfUndos( 100 ), - m_pModifyBroadcaster( 0 ), - m_aModel( rModel ) -{} - -UndoManager::~UndoManager() -{ - DisposeHelper::Dispose( m_xModifyBroadcaster ); - m_apUndoStack->disposeAndClear(); - m_apRedoStack->disposeAndClear(); - - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void UndoManager::addShapeUndoAction( SdrUndoAction* pAction ) -{ - if ( !pAction ) - { - return; - } - - impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction ); - if ( pShapeUndoElement ) - { - m_apUndoStack->push( pShapeUndoElement ); - m_apRedoStack->disposeAndClear(); - if ( !m_apUndoStepsConfigItem.get() ) - { - retrieveConfigUndoSteps(); - } - fireModifyEvent(); - } -} - -Reference< XModel > UndoManager::impl_getModel() const -{ - Reference< XModel > xModel( m_aModel ); - return xModel; -} - -void UndoManager::impl_undoRedo( - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo, - bool bUndo ) -{ - if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() ) - { - // get model from undo/redo - impl::UndoElement * pTop( pStackToRemoveFrom->top()); - if( pTop ) - { - Reference< XModel > xModel( impl_getModel() ); - impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop ); - if ( pShapeUndoElement ) - { - impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement ); - pStackToAddTo->push( pNewShapeUndoElement ); - SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction(); - if ( pAction ) - { - if ( bUndo ) - { - pAction->Undo(); - } - else - { - pAction->Redo(); - } - } - } - else - { - // put a clone of current model into redo/undo stack with the same - // action string as the undo/redo - pStackToAddTo->push( pTop->createFromModel( xModel )); - // change current model by properties of the model from undo - pTop->applyToModel( xModel ); - } - // remove the top undo element - pStackToRemoveFrom->pop(), pTop = 0; - ChartViewHelper::setViewToDirtyState( xModel ); - fireModifyEvent(); - } - } - else - { - OSL_ENSURE( false, "Can't Undo/Redo" ); - } -} - -void UndoManager::fireModifyEvent() -{ - if( m_xModifyBroadcaster.is()) - m_pModifyBroadcaster->fireEvent(); -} - - -// ____ ConfigItemListener ____ -void UndoManager::notify( const ::rtl::OUString & rPropertyName ) -{ - OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )), - "Unwanted config property change Notified" ); - if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" ))) - retrieveConfigUndoSteps(); -} - -void UndoManager::retrieveConfigUndoSteps() -{ - if( ! m_apUndoStepsConfigItem.get()) - m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this )); - m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps(); - m_apUndoStack->limitSize( m_nMaxNumberOfUndos ); - m_apRedoStack->limitSize( m_nMaxNumberOfUndos ); - - // a list of available undo steps could shrink here - fireModifyEvent(); -} - -// ____ XModifyBroadcaster ____ -void SAL_CALL UndoManager::addModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->addModifyListener( aListener ); -} - -void SAL_CALL UndoManager::removeModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->removeModifyListener( aListener ); -} - -// ____ chart2::XUndoManager ____ -void SAL_CALL UndoManager::preAction( ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - m_pLastRemeberedUndoElement = new impl::UndoElement( impl_getModel() ); -} - -void SAL_CALL UndoManager::preActionWithArguments( - const Sequence< beans::PropertyValue >& aArguments ) - throw (uno::RuntimeException) -{ - Reference< XModel > xModel( impl_getModel() ); - bool bActionHandled( false ); - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - if( aArguments.getLength() > 0 ) - { - OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); - if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModel ); - bActionHandled = true; - } - else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModel ); - bActionHandled = true; - } - } - - if( !bActionHandled ) - preAction(); -} - -void SAL_CALL UndoManager::postAction( const OUString& aUndoText ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" ); - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->setActionString( aUndoText ); - m_apUndoStack->push( m_pLastRemeberedUndoElement ); - m_pLastRemeberedUndoElement = 0; - - // redo no longer possible - m_apRedoStack->disposeAndClear(); - - // it suffices to get the number of undo steps from config after the - // first time postAction has been called - if( ! m_apUndoStepsConfigItem.get()) - retrieveConfigUndoSteps(); - - fireModifyEvent(); - } -} - -void SAL_CALL UndoManager::cancelAction() - throw (uno::RuntimeException) -{ - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void SAL_CALL UndoManager::cancelActionWithUndo( ) - throw (uno::RuntimeException) -{ - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->applyToModel( impl_getModel() ); - cancelAction(); - } -} - -void SAL_CALL UndoManager::undo( ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( m_apUndoStack.get(), m_apRedoStack.get(), true ); -} - -void SAL_CALL UndoManager::redo( ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( m_apRedoStack.get(), m_apUndoStack.get(), false ); -} - -::sal_Bool SAL_CALL UndoManager::undoPossible() - throw (uno::RuntimeException) -{ - return ! m_apUndoStack->empty(); -} - -::sal_Bool SAL_CALL UndoManager::redoPossible() - throw (uno::RuntimeException) -{ - return ! m_apRedoStack->empty(); -} - -OUString SAL_CALL UndoManager::getCurrentUndoString() - throw (uno::RuntimeException) -{ - return m_apUndoStack->topUndoString(); -} - -OUString SAL_CALL UndoManager::getCurrentRedoString() - throw (uno::RuntimeException) -{ - return m_apRedoStack->topUndoString(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllUndoStrings() - throw (uno::RuntimeException) -{ - return m_apUndoStack->getUndoStrings(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllRedoStrings() - throw (uno::RuntimeException) -{ - return m_apRedoStack->getUndoStrings(); -} - -// ____ XUnoTunnel ____ -sal_Int64 UndoManager::getSomething( const Sequence< sal_Int8 >& rId ) - throw (uno::RuntimeException) -{ - if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); - } - return 0; -} - -// static -const Sequence< sal_Int8 >& UndoManager::getUnoTunnelId() -{ - static Sequence< sal_Int8 >* pSeq = 0; - if( !pSeq ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; -} - -// static -UndoManager* UndoManager::getImplementation( const Reference< uno::XInterface > xObj ) -{ - UndoManager* pRet = NULL; - Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY ); - if ( xUT.is() ) - { - pRet = reinterpret_cast< UndoManager* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) ); - } - return pRet; -} - -} // namespace chart diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index 729276d5bd0e..a90d1537b89b 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -72,8 +72,8 @@ SLOFILES = \ $(SLO)$/DrawCommandDispatch.obj \ $(SLO)$/ShapeController.obj \ $(SLO)$/ShapeToolbarController.obj \ - $(SLO)$/ImplUndoManager.obj \ - $(SLO)$/UndoManager.obj \ + $(SLO)$/ImplDocumentActions.obj \ + $(SLO)$/DocumentActions.obj \ $(SLO)$/UndoGuard.obj # $(SLO)$/CommonConverters.obj \ diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index fb087abf15fd..9518d3362e84 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/chart2/source/inc/DocumentActions.hxx b/chart2/source/inc/DocumentActions.hxx new file mode 100644 index 000000000000..52c3282002a9 --- /dev/null +++ b/chart2/source/inc/DocumentActions.hxx @@ -0,0 +1,157 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_UNDOMANAGER_HXX +#define CHART2_UNDOMANAGER_HXX + +#include "ConfigItemListener.hxx" +#include "MutexContainer.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +// for pair +#include +// for auto_ptr +#include + +class SdrUndoAction; + +namespace com { namespace sun { namespace star { +namespace frame { + class XModel; +} +}}} + +namespace chart +{ +// ---------------------------------------- +namespace impl +{ + +class UndoStepsConfigItem; +class UndoElement; +class UndoStack; +class ModifyBroadcaster; + +typedef ::cppu::WeakComponentImplHelper3< + ::com::sun::star::util::XModifyBroadcaster, + ::com::sun::star::chart2::XDocumentActions, + ::com::sun::star::lang::XUnoTunnel > + DocumentActions_Base; + +} // namespace impl +// ---------------------------------------- + +/** Manages undo by storing the entire XModel in the undo- and redo-buffers. + Note, that therefore this should not be used for "big" XModels. + + A prerequisite for this to work is that the XModels added to the undo- + redo-stacks support the css::util::XCloneable interface, which is + implemented such that the entire model is cloned. + */ +class DocumentActions : + public MutexContainer, + public ConfigItemListener, + public impl::DocumentActions_Base +{ +public: + explicit DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ); + virtual ~DocumentActions(); + + void addShapeUndoAction( SdrUndoAction* pAction ); + + // ____ XUnoTunnel ____ + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + static DocumentActions* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj ); + +protected: + // ____ ConfigItemListener ____ + virtual void notify( const ::rtl::OUString & rPropertyName ); + + // ____ util::XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ chart2::XDocumentActions ____ + virtual void SAL_CALL preAction( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL preActionWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelAction( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelActionWithUndo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL undoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL redoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); + +private: + void retrieveConfigUndoSteps(); + void fireModifyEvent(); + void impl_undoRedo( + impl::UndoStack * pStackToRemoveFrom, + impl::UndoStack * pStackToAddTo, + bool bUndo = true ); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + impl_getModel() const; + + ::std::auto_ptr< impl::UndoStack > m_apUndoStack; + ::std::auto_ptr< impl::UndoStack > m_apRedoStack; + + impl::UndoElement * m_pLastRemeberedUndoElement; + + ::std::auto_ptr< impl::UndoStepsConfigItem > m_apUndoStepsConfigItem; + sal_Int32 m_nMaxNumberOfUndos; + ::com::sun::star::uno::Reference< + ::com::sun::star::util::XModifyBroadcaster > m_xModifyBroadcaster; + // pointer is valid as long as m_xModifyBroadcaster.is() + impl::ModifyBroadcaster * m_pModifyBroadcaster; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; +}; + +} // namespace chart + +// CHART2_UNDOMANAGER_HXX +#endif diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx index cf59337eaf53..e36949bcdb18 100644 --- a/chart2/source/inc/UndoGuard.hxx +++ b/chart2/source/inc/UndoGuard.hxx @@ -27,7 +27,7 @@ #ifndef CHART2_UNDOGUARD_HXX #define CHART2_UNDOGUARD_HXX -#include +#include // header for class OUString #include @@ -41,14 +41,14 @@ class UndoGuard_Base public: explicit UndoGuard_Base( const rtl::OUString & rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); virtual ~UndoGuard_Base(); void commitAction(); protected: ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; rtl::OUString m_aUndoString; bool m_bActionPosted; @@ -63,7 +63,7 @@ class UndoGuard : public UndoGuard_Base public: explicit UndoGuard( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); virtual ~UndoGuard(); }; @@ -76,7 +76,7 @@ class UndoLiveUpdateGuard : public UndoGuard_Base public: explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); virtual ~UndoLiveUpdateGuard(); }; @@ -89,7 +89,7 @@ class UndoLiveUpdateGuardWithData : public: explicit UndoLiveUpdateGuardWithData( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); virtual ~UndoLiveUpdateGuardWithData(); }; @@ -98,7 +98,7 @@ class UndoGuardWithSelection : public UndoGuard_Base public: explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); virtual ~UndoGuardWithSelection(); }; diff --git a/chart2/source/inc/UndoManager.hxx b/chart2/source/inc/UndoManager.hxx deleted file mode 100644 index a73bbc69a9d0..000000000000 --- a/chart2/source/inc/UndoManager.hxx +++ /dev/null @@ -1,157 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_UNDOMANAGER_HXX -#define CHART2_UNDOMANAGER_HXX - -#include "ConfigItemListener.hxx" -#include "MutexContainer.hxx" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// for pair -#include -// for auto_ptr -#include - -class SdrUndoAction; - -namespace com { namespace sun { namespace star { -namespace frame { - class XModel; -} -}}} - -namespace chart -{ -// ---------------------------------------- -namespace impl -{ - -class UndoStepsConfigItem; -class UndoElement; -class UndoStack; -class ModifyBroadcaster; - -typedef ::cppu::WeakComponentImplHelper3< - ::com::sun::star::util::XModifyBroadcaster, - ::com::sun::star::chart2::XUndoManager, - ::com::sun::star::lang::XUnoTunnel > - UndoManager_Base; - -} // namespace impl -// ---------------------------------------- - -/** Manages undo by storing the entire XModel in the undo- and redo-buffers. - Note, that therefore this should not be used for "big" XModels. - - A prerequisite for this to work is that the XModels added to the undo- - redo-stacks support the css::util::XCloneable interface, which is - implemented such that the entire model is cloned. - */ -class UndoManager : - public MutexContainer, - public ConfigItemListener, - public impl::UndoManager_Base -{ -public: - explicit UndoManager( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ); - virtual ~UndoManager(); - - void addShapeUndoAction( SdrUndoAction* pAction ); - - // ____ XUnoTunnel ____ - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) - throw (::com::sun::star::uno::RuntimeException); - - static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - static UndoManager* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj ); - -protected: - // ____ ConfigItemListener ____ - virtual void notify( const ::rtl::OUString & rPropertyName ); - - // ____ util::XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - - // ____ chart2::XUndoManager ____ - virtual void SAL_CALL preAction( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL preActionWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelAction( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelActionWithUndo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL undoPossible( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL redoPossible( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); - -private: - void retrieveConfigUndoSteps(); - void fireModifyEvent(); - void impl_undoRedo( - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo, - bool bUndo = true ); - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - impl_getModel() const; - - ::std::auto_ptr< impl::UndoStack > m_apUndoStack; - ::std::auto_ptr< impl::UndoStack > m_apRedoStack; - - impl::UndoElement * m_pLastRemeberedUndoElement; - - ::std::auto_ptr< impl::UndoStepsConfigItem > m_apUndoStepsConfigItem; - sal_Int32 m_nMaxNumberOfUndos; - ::com::sun::star::uno::Reference< - ::com::sun::star::util::XModifyBroadcaster > m_xModifyBroadcaster; - // pointer is valid as long as m_xModifyBroadcaster.is() - impl::ModifyBroadcaster * m_pModifyBroadcaster; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; -}; - -} // namespace chart - -// CHART2_UNDOMANAGER_HXX -#endif diff --git a/chart2/source/inc/servicenames.hxx b/chart2/source/inc/servicenames.hxx index d1af0edb3335..98fd7cdf2db0 100644 --- a/chart2/source/inc/servicenames.hxx +++ b/chart2/source/inc/servicenames.hxx @@ -62,7 +62,7 @@ namespace chart #define CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.ChartRenderer") -#define CHART_UNDOMANAGER_SERVICE_NAME ::rtl::OUString::createFromAscii( "com.sun.star.chart2.UndoManager" ) +#define CHART_DOCUMENT_ACTIONS_SERVICE_NAME ::rtl::OUString::createFromAscii( "com.sun.star.chart2.DocumentActions" ) //............................................................................. } //namespace chart diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 9b77f4aa2b94..fea1ef1544f0 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -73,6 +73,7 @@ using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Any; using ::rtl::OUString; using ::osl::MutexGuard; @@ -152,7 +153,7 @@ ChartModel::ChartModel( const ChartModel & rOther ) , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector ) , m_xDataProvider( rOther.m_xDataProvider ) , m_xInternalDataProvider( rOther.m_xInternalDataProvider ) - , m_xUndoManager( NULL ) + , m_xDocumentActions( NULL ) { OSL_TRACE( "ChartModel: Copy-CTOR called" ); @@ -1342,14 +1343,110 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent m_xParent.set( Parent, uno::UNO_QUERY ); } -// ____ XUndoManager ____ -Reference< chart2::XUndoManager > SAL_CALL ChartModel::getUndoManager() - throw (uno::RuntimeException) +bool ChartModel::impl_getDocumentActions_lck() +{ + if ( !m_xDocumentActions.is() ) + m_xDocumentActions.set( createInstance( CHART_DOCUMENT_ACTIONS_SERVICE_NAME ), uno::UNO_QUERY ); + OSL_POSTCOND( m_xDocumentActions.is(), "ChartModel::impl_getDocumentActions_lck: could not create the legacy DocumentActions service!" ); + return m_xDocumentActions.is(); +} + +// ____ XDocumentActions ____ +void SAL_CALL ChartModel::preAction( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->preAction(); +} + +void SAL_CALL ChartModel::preActionWithArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->preActionWithArguments( aArguments ); +} + +void SAL_CALL ChartModel::postAction( const ::rtl::OUString& aUndoText ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->postAction( aUndoText ); +} + +void SAL_CALL ChartModel::cancelAction( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->cancelAction(); +} + +void SAL_CALL ChartModel::cancelActionWithUndo( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->cancelActionWithUndo(); +} + +void SAL_CALL ChartModel::undo( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->undo(); +} + +void SAL_CALL ChartModel::redo( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + m_xDocumentActions->redo(); +} + +::sal_Bool SAL_CALL ChartModel::undoPossible( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->undoPossible(); + return sal_False; +} + +::sal_Bool SAL_CALL ChartModel::redoPossible( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->redoPossible(); + return sal_False; +} + +::rtl::OUString SAL_CALL ChartModel::getCurrentUndoString( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->getCurrentUndoString(); + return ::rtl::OUString(); +} + +::rtl::OUString SAL_CALL ChartModel::getCurrentRedoString( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->getCurrentRedoString(); + return ::rtl::OUString(); +} + +Sequence< ::rtl::OUString > SAL_CALL ChartModel::getAllUndoStrings( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->getAllUndoStrings(); + return Sequence< ::rtl::OUString >(); +} + +Sequence< ::rtl::OUString > SAL_CALL ChartModel::getAllRedoStrings( ) throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( !m_xUndoManager.is() ) - m_xUndoManager.set( createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY ); - return m_xUndoManager; + if ( impl_getDocumentActions_lck() ) + return m_xDocumentActions->getAllRedoStrings(); + return Sequence< ::rtl::OUString >(); } // ____ XDataSource ____ diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 962324c29cef..7b6610836466 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -108,7 +108,7 @@ typedef ::comphelper::WeakImplHelper20< ,::com::sun::star::container::XChild ,::com::sun::star::util::XModifyListener ,::com::sun::star::datatransfer::XTransferable - ,::com::sun::star::chart2::XUndoSupplier + ,::com::sun::star::chart2::XDocumentActions ,::com::sun::star::document::XDocumentPropertiesSupplier ,::com::sun::star::chart2::data::XDataSource > @@ -171,8 +171,8 @@ private: bool m_bIsDisposed; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xPageBackground; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > - m_xUndoManager; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > + m_xDocumentActions; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap; @@ -594,13 +594,41 @@ public: throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); - // ____ XUndoSupplier ____ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > SAL_CALL getUndoManager() + // ____ XDocumentActions ____ + virtual void SAL_CALL preAction( ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL preActionWithArguments( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelAction( ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelActionWithUndo( ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL undoPossible( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL redoPossible( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); // ____ XDataSource ____ allows access to the curently used data and data ranges virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() throw (::com::sun::star::uno::RuntimeException); + +private: + bool impl_getDocumentActions_lck(); }; } // namespace chart -- cgit From 5aa51f86396a4e8709d42c64b11946a9987a7876 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 15 Nov 2010 22:12:20 +0100 Subject: undoapi: step 2.1 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: implement an XUndoManager/Supplier for chart documents --- chart2/source/model/main/ChartModel.cxx | 21 ++ chart2/source/model/main/ChartModel.hxx | 20 +- chart2/source/model/main/UndoManager.cxx | 387 +++++++++++++++++++++++++++++++ chart2/source/model/main/UndoManager.hxx | 98 ++++++++ chart2/source/model/main/makefile.mk | 1 + chart2/source/model/makefile.mk | 3 +- 6 files changed, 523 insertions(+), 7 deletions(-) create mode 100755 chart2/source/model/main/UndoManager.cxx create mode 100755 chart2/source/model/main/UndoManager.hxx (limited to 'chart2') diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index fea1ef1544f0..10ff9095fc54 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -42,6 +42,7 @@ #include "PageBackground.hxx" #include "CloneHelper.hxx" #include "NameContainer.hxx" +#include "UndoManager.hxx" #include @@ -104,6 +105,7 @@ ChartModel::ChartModel(uno::Reference const & xContext) , m_bModified( sal_False ) , m_nInLoad(0) , m_bUpdateNotificationsPending(false) + , m_pUndoManager( NULL ) , m_aControllers( m_aModelMutex ) , m_nControllerLockCount(0) , m_xContext( xContext ) @@ -523,6 +525,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection() thr //----------------------------------------------------------------- void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) { + Reference< XInterface > xKeepAlive( *this ); + //This object should release all resources and references in the //easiest possible manner //This object must notify all registered listeners using the method @@ -548,6 +552,11 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) m_xStorage.clear(); // just clear, don't dispose - we're not the owner + if ( m_pUndoManager.is() ) + m_pUndoManager->disposing(); + m_pUndoManager.clear(); + // that's important, since the UndoManager implementation delegates its ref counting to ourself. + m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this ))); m_xCurrentController.clear(); @@ -680,6 +689,7 @@ uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes() uno::Reference< document::XDocumentProperties > SAL_CALL ChartModel::getDocumentProperties() throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aModelMutex ); if ( !m_xDocumentProperties.is() ) { uno::Reference< document::XDocumentProperties > xDocProps( @@ -690,6 +700,17 @@ uno::Reference< document::XDocumentProperties > SAL_CALL return m_xDocumentProperties; } +//----------------------------------------------------------------- +// document::XDocumentPropertiesSupplier +//----------------------------------------------------------------- +Reference< document::XUndoManager > SAL_CALL ChartModel::getUndoManager( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aModelMutex ); + if ( !m_pUndoManager.is() ) + m_pUndoManager.set( new UndoManager( *this, m_aModelMutex ) ); + return m_pUndoManager.get(); +} + //----------------------------------------------------------------- // chart2::XChartDocument //----------------------------------------------------------------- diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 7b6610836466..772640510400 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -62,12 +63,13 @@ #include #include -#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 +#include #include #include @@ -75,8 +77,6 @@ #include //============================================================================= -/** this is an example implementation for the service ::com::sun::star::document::OfficeDocument -*/ namespace chart { @@ -85,7 +85,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) @@ -111,10 +111,13 @@ typedef ::comphelper::WeakImplHelper20< ,::com::sun::star::chart2::XDocumentActions ,::com::sun::star::document::XDocumentPropertiesSupplier ,::com::sun::star::chart2::data::XDataSource + ,::com::sun::star::document::XUndoManagerSupplier > ChartModel_Base; } +class UndoManager; + class ChartModel : public impl::ChartModel_Base { @@ -130,6 +133,7 @@ private: ::rtl::OUString m_aResource; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aMediaDescriptor; ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > m_xDocumentProperties; + ::rtl::Reference< UndoManager > m_pUndoManager; ::cppu::OInterfaceContainerHelper m_aControllers; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController; @@ -427,6 +431,10 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > SAL_CALL getDocumentProperties( ) throw (::com::sun::star::uno::RuntimeException); + // ____ document::XUndoManagerSupplier ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL + getUndoManager( ) throw (::com::sun::star::uno::RuntimeException); + //----------------------------------------------------------------- // ::com::sun::star::chart2::XChartDocument //----------------------------------------------------------------- diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx new file mode 100755 index 000000000000..5ae57808b3c2 --- /dev/null +++ b/chart2/source/model/main/UndoManager.cxx @@ -0,0 +1,387 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" + +#include "UndoManager.hxx" + +/** === begin UNO includes === **/ +#include +/** === end UNO includes === **/ + +#include +#include + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::document::XUndoManager; + using ::com::sun::star::document::EmptyUndoStackException; + using ::com::sun::star::document::UndoContextNotClosedException; + using ::com::sun::star::document::UndoFailedException; + using ::com::sun::star::util::InvalidStateException; + using ::com::sun::star::document::XUndoAction; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::document::XUndoManagerListener; + using ::com::sun::star::util::NotLockedException; + /** === end UNO using === **/ + + namespace impl + { + //============================================================================================================== + //= UndoManager_Impl + //============================================================================================================== + class UndoManager_Impl : public ::framework::IUndoManagerImplementation + { + public: + UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex ) + :m_rAntiImpl( i_antiImpl ) + ,m_rParent( i_parent ) + ,m_rMutex( i_mutex ) + ,m_bDisposed( false ) + ,m_aUndoManager() + ,m_aUndoHelper( *this ) + { + } + + virtual ~UndoManager_Impl() + { + } + + // ......................................................................................................... + // IUndoManagerImplementation + virtual ::osl::Mutex& getMutex(); + virtual ::svl::IUndoManager& getImplUndoManager(); + virtual Reference< XUndoManager > getThis(); + + // ......................................................................................................... + // attribute access + ::cppu::OWeakObject& getParent() { return m_rParent; } + ::framework::UndoManagerHelper& getUndoHelper() { return m_aUndoHelper; } + + // ......................................................................................................... + // public interface + + /// is called when the owner of the UndoManager is being disposed + void disposing(); + + /// checks whether we're already disposed, throws a DisposedException if so + void checkDisposed_lck(); + + private: + UndoManager& m_rAntiImpl; + ::cppu::OWeakObject& m_rParent; + ::osl::Mutex& m_rMutex; + bool m_bDisposed; + + SfxUndoManager m_aUndoManager; + ::framework::UndoManagerHelper m_aUndoHelper; + }; + + //-------------------------------------------------------------------------------------------------------------- + ::osl::Mutex& UndoManager_Impl::getMutex() + { + return m_rMutex; + } + + //-------------------------------------------------------------------------------------------------------------- + ::svl::IUndoManager& UndoManager_Impl::getImplUndoManager() + { + return m_aUndoManager; + } + + //-------------------------------------------------------------------------------------------------------------- + Reference< XUndoManager > UndoManager_Impl::getThis() + { + return &m_rAntiImpl; + } + + //-------------------------------------------------------------------------------------------------------------- + void UndoManager_Impl::disposing() + { + ::osl::MutexGuard aGuard( m_rMutex ); + m_bDisposed = true; + m_aUndoHelper.disposing(); + } + + //-------------------------------------------------------------------------------------------------------------- + void UndoManager_Impl::checkDisposed_lck() + { + if ( m_bDisposed ) + throw DisposedException( ::rtl::OUString(), getThis() ); + } + + //============================================================================================================== + //= UndoManagerMethodGuard + //============================================================================================================== + /** guard for public UNO methods of the UndoManager + + The only purpose of this guard is to check for the instance being disposed already. Everything else, + in particular the IMutexGuard functionality required by the UndoManagerHelper class, is a dummy only, + as all involved classes (means we ourselves, the UndoManagerHelper, the SfxUndoManager, and the Undo actions + we create) are inherently thread-safe, thus need no external lock (in particular no SolarMutex!). + */ + class UndoManagerMethodGuard : public ::framework::IMutexGuard + { + public: + UndoManagerMethodGuard( UndoManager_Impl& i_impl ) + { + ::osl::MutexGuard aGuard( i_impl.getMutex() ); + // throw if the instance is already disposed + i_impl.checkDisposed_lck(); + } + virtual ~UndoManagerMethodGuard() + { + } + + // IMutexGuard + virtual ::framework::IMutex& getGuardedMutex(); + + // IGuard + virtual void clear(); + virtual void reset(); + }; + + class DummyMutex : public ::framework::IMutex + { + public: + virtual void acquire() { } + virtual void release() { } + }; + + //-------------------------------------------------------------------------------------------------------------- + ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex() + { + static DummyMutex s_aDummyMutex; + return s_aDummyMutex; + } + + //-------------------------------------------------------------------------------------------------------------- + void UndoManagerMethodGuard::clear() + { + // nothing to do. This interface implementation is a dummy. + } + + //-------------------------------------------------------------------------------------------------------------- + void UndoManagerMethodGuard::reset() + { + // nothing to do. This interface implementation is a dummy. + } + } + + //================================================================================================================== + //= UndoManager + //================================================================================================================== + using impl::UndoManagerMethodGuard; + + //------------------------------------------------------------------------------------------------------------------ + UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex ) + :m_pImpl( new impl::UndoManager_Impl( *this, i_parent, i_mutex ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + UndoManager::~UndoManager() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::acquire() throw () + { + m_pImpl->getParent().acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::release() throw () + { + m_pImpl->getParent().release(); + } + + //------------------------------------------------------------------------------------------------------------------ + void UndoManager::disposing() + { + m_pImpl->disposing(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().enterUndoContext( i_title, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().enterHiddenUndoContext( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().leaveUndoContext( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (IllegalArgumentException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().addUndoAction( i_action, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().undo( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().redo( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL UndoManager::isUndoPossible( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().isUndoPossible(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL UndoManager::isRedoPossible( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().isRedoPossible(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL UndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().getCurrentUndoActionTitle(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL UndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().getCurrentRedoActionTitle(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllUndoActionTitles( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().getAllUndoActionTitles(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllRedoActionTitles( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().getAllRedoActionTitles(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().clear( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().clearRedo( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::reset( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().reset( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().addUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().removeUndoManagerListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::lock( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().lock(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::unlock( ) throw (NotLockedException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().unlock(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL UndoManager::isLocked( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return m_pImpl->getUndoHelper().isLocked(); + } + + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx new file mode 100755 index 000000000000..4e6c2b0417cf --- /dev/null +++ b/chart2/source/model/main/UndoManager.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART2_UNDOMANAGER_HXX +#define CHART2_UNDOMANAGER_HXX + +/** === begin UNO includes === **/ +#include +/** === end UNO includes === **/ + +#include + +#include + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + namespace impl + { + class UndoManager_Impl; + typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager + > UndoManager_Base; + } + + //================================================================================================================== + //= UndoManager + //================================================================================================================== + class UndoManager : public impl::UndoManager_Base + { + public: + UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex ); + virtual ~UndoManager(); + + // XInterface + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + + // XComponent equivalents + void disposing(); + + // XUndoManager + virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL enterHiddenUndoContext( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL leaveUndoContext( ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isUndoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isRedoPossible( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clear( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearRedo( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + + // XLockable (base of XUndoManager) + virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); + + private: + ::boost::scoped_ptr< impl::UndoManager_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... + +#endif // CHART2_UNDOMANAGER_HXX diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk index 8e963dfa0f5c..5ca78bbdea25 100644 --- a/chart2/source/model/main/makefile.mk +++ b/chart2/source/model/main/makefile.mk @@ -60,6 +60,7 @@ SLOFILES= \ $(SLO)$/StockBar.obj \ $(SLO)$/Title.obj \ $(SLO)$/Wall.obj \ + $(SLO)$/UndoManager.obj \ $(SLO)$/_serviceregistration_model.obj # --- Targets ----------------------------------------------------------------- diff --git a/chart2/source/model/makefile.mk b/chart2/source/model/makefile.mk index 52cc85c10904..25d4b1b2949a 100644 --- a/chart2/source/model/makefile.mk +++ b/chart2/source/model/makefile.mk @@ -79,7 +79,8 @@ SHL1STDLIBS= $(CHARTTOOLS) \ $(SVLLIB) \ $(SVTOOLLIB) \ $(SALLIB) \ - $(UCBHELPERLIB) + $(UCBHELPERLIB) \ + $(FWELIB) \ #--------exports -- cgit From 3909360c32b8e018bab468db7aece015c6d1a2b4 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 15 Nov 2010 22:12:48 +0100 Subject: undoapi: step 2.2 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: base the implementation of XDocumentActions on the document's UndoManager --- chart2/source/controller/main/DocumentActions.cxx | 303 +++++------ .../source/controller/main/ImplDocumentActions.cxx | 584 ++++++++------------- .../source/controller/main/ImplDocumentActions.hxx | 208 +++----- chart2/source/inc/DocumentActions.hxx | 45 +- chart2/source/model/main/ChartModel.cxx | 2 + 5 files changed, 457 insertions(+), 685 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/DocumentActions.cxx b/chart2/source/controller/main/DocumentActions.cxx index e4fe1ab0fc3f..a4864541fc70 100644 --- a/chart2/source/controller/main/DocumentActions.cxx +++ b/chart2/source/controller/main/DocumentActions.cxx @@ -37,11 +37,13 @@ #include #include +#include #include +#include #include +#include #include -#include #include @@ -49,7 +51,14 @@ using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::frame::XModel; +using ::com::sun::star::document::XUndoManagerSupplier; +using ::com::sun::star::document::XUndoAction; using ::rtl::OUString; @@ -73,7 +82,7 @@ public: void fireEvent(); -protected: +public: // ____ XModifyBroadcaster ____ virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) throw (uno::RuntimeException); @@ -118,44 +127,33 @@ void ModifyBroadcaster::fireEvent() } // namespace impl -DocumentActions::DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) : - impl::DocumentActions_Base( m_aMutex ), - m_apUndoStack( new impl::UndoStack()), - m_apRedoStack( new impl::UndoStack()), - m_pLastRemeberedUndoElement( 0 ), - m_nMaxNumberOfUndos( 100 ), - m_pModifyBroadcaster( 0 ), - m_aModel( rModel ) -{} +DocumentActions::DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) + :impl::DocumentActions_Base( m_aMutex ) + ,m_pDocumentSnapshot() + ,m_pModifyBroadcaster( NULL ) + ,m_aModel( rModel ) + ,m_xUndoManager() +{ + Reference< XUndoManagerSupplier > xSuppUndo( rModel, UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), UNO_SET_THROW ); +} DocumentActions::~DocumentActions() { - DisposeHelper::Dispose( m_xModifyBroadcaster ); - m_apUndoStack->disposeAndClear(); - m_apRedoStack->disposeAndClear(); - - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; + if ( m_pModifyBroadcaster.is() ) + { + m_pModifyBroadcaster->dispose(); + m_pModifyBroadcaster.clear(); + } } void DocumentActions::addShapeUndoAction( SdrUndoAction* pAction ) { if ( !pAction ) - { return; - } - - impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction ); - if ( pShapeUndoElement ) - { - m_apUndoStack->push( pShapeUndoElement ); - m_apRedoStack->disposeAndClear(); - if ( !m_apUndoStepsConfigItem.get() ) - { - retrieveConfigUndoSteps(); - } - fireModifyEvent(); - } + const Reference< XUndoAction > xAction( new impl::ShapeUndoElement( *pAction ) ); + m_xUndoManager->addUndoAction( xAction ); + impl_fireModifyEvent(); } Reference< XModel > DocumentActions::impl_getModel() const @@ -164,228 +162,191 @@ Reference< XModel > DocumentActions::impl_getModel() const return xModel; } -void DocumentActions::impl_undoRedo( - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo, - bool bUndo ) +void DocumentActions::impl_fireModifyEvent() { - if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() ) - { - // get model from undo/redo - impl::UndoElement * pTop( pStackToRemoveFrom->top()); - if( pTop ) - { - Reference< XModel > xModel( impl_getModel() ); - impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop ); - if ( pShapeUndoElement ) - { - impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement ); - pStackToAddTo->push( pNewShapeUndoElement ); - SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction(); - if ( pAction ) - { - if ( bUndo ) - { - pAction->Undo(); - } - else - { - pAction->Redo(); - } - } - } - else - { - // put a clone of current model into redo/undo stack with the same - // action string as the undo/redo - pStackToAddTo->push( pTop->createFromModel( xModel )); - // change current model by properties of the model from undo - pTop->applyToModel( xModel ); - } - // remove the top undo element - pStackToRemoveFrom->pop(), pTop = 0; - ChartViewHelper::setViewToDirtyState( xModel ); - fireModifyEvent(); - } - } - else - { - OSL_ENSURE( false, "Can't Undo/Redo" ); - } -} - -void DocumentActions::fireModifyEvent() -{ - if( m_xModifyBroadcaster.is()) + if ( m_pModifyBroadcaster.is() ) m_pModifyBroadcaster->fireEvent(); } -// ____ ConfigItemListener ____ -void DocumentActions::notify( const ::rtl::OUString & rPropertyName ) -{ - OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )), - "Unwanted config property change Notified" ); - if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" ))) - retrieveConfigUndoSteps(); -} - -void DocumentActions::retrieveConfigUndoSteps() -{ - if( ! m_apUndoStepsConfigItem.get()) - m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this )); - m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps(); - m_apUndoStack->limitSize( m_nMaxNumberOfUndos ); - m_apRedoStack->limitSize( m_nMaxNumberOfUndos ); - - // a list of available undo steps could shrink here - fireModifyEvent(); -} - // ____ XModifyBroadcaster ____ void SAL_CALL DocumentActions::addModifyListener( const Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) { - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->addModifyListener( aListener ); + if ( !m_pModifyBroadcaster.is() ) + m_pModifyBroadcaster.set( new impl::ModifyBroadcaster() ); + + m_pModifyBroadcaster->addModifyListener( aListener ); } void SAL_CALL DocumentActions::removeModifyListener( const Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) { - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->removeModifyListener( aListener ); + if ( m_pModifyBroadcaster.is() ) + m_pModifyBroadcaster->removeModifyListener( aListener ); } // ____ chart2::XDocumentActions ____ void SAL_CALL DocumentActions::preAction( ) throw (uno::RuntimeException) { - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - m_pLastRemeberedUndoElement = new impl::UndoElement( impl_getModel() ); + ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" ); + m_pDocumentSnapshot.reset( new impl::ChartModelClone( impl_getModel(), impl::E_MODEL ) ); } -void SAL_CALL DocumentActions::preActionWithArguments( - const Sequence< beans::PropertyValue >& aArguments ) - throw (uno::RuntimeException) +void SAL_CALL DocumentActions::preActionWithArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (uno::RuntimeException, lang::IllegalArgumentException) { - Reference< XModel > xModel( impl_getModel() ); - bool bActionHandled( false ); - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - if( aArguments.getLength() > 0 ) - { - OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); - if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModel ); - bActionHandled = true; - } - else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModel ); - bActionHandled = true; - } - } + ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" ); + + impl::ModelFacet eModelFacet( impl::E_MODEL ); + ::comphelper::NamedValueCollection aArgs( aArguments ); - if( !bActionHandled ) - preAction(); + const sal_Bool bWithData = aArgs.getOrDefault( "WithData", sal_False ); + if ( bWithData ) + eModelFacet = impl::E_MODEL_WITH_DATA; + + const sal_Bool bWithSelection = aArgs.getOrDefault( "WithSelection", sal_False ); + if ( bWithSelection ) + eModelFacet = impl::E_MODEL_WITH_SELECTION; + + const Reference< XModel > xModel( impl_getModel() ); + m_pDocumentSnapshot.reset( new impl::ChartModelClone( xModel, eModelFacet ) ); } void SAL_CALL DocumentActions::postAction( const OUString& aUndoText ) throw (uno::RuntimeException) { - OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" ); - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->setActionString( aUndoText ); - m_apUndoStack->push( m_pLastRemeberedUndoElement ); - m_pLastRemeberedUndoElement = 0; + ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); - // redo no longer possible - m_apRedoStack->disposeAndClear(); + const Reference< XUndoAction > xAction( new impl::UndoElement( aUndoText, impl_getModel(), m_pDocumentSnapshot ) ); + m_pDocumentSnapshot.reset(); - // it suffices to get the number of undo steps from config after the - // first time postAction has been called - if( ! m_apUndoStepsConfigItem.get()) - retrieveConfigUndoSteps(); + m_xUndoManager->addUndoAction( xAction ); - fireModifyEvent(); - } + impl_fireModifyEvent(); } void SAL_CALL DocumentActions::cancelAction() throw (uno::RuntimeException) { - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; + ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); + + m_pDocumentSnapshot->dispose(); + m_pDocumentSnapshot.reset(); } void SAL_CALL DocumentActions::cancelActionWithUndo( ) throw (uno::RuntimeException) { - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->applyToModel( impl_getModel() ); - cancelAction(); - } + ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); + + m_pDocumentSnapshot->applyToModel( impl_getModel() ); + m_pDocumentSnapshot->dispose(); + m_pDocumentSnapshot.reset(); } void SAL_CALL DocumentActions::undo( ) throw (uno::RuntimeException) { - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( m_apUndoStack.get(), m_apRedoStack.get(), true ); + try + { + m_xUndoManager->undo(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } void SAL_CALL DocumentActions::redo( ) throw (uno::RuntimeException) { - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( m_apRedoStack.get(), m_apUndoStack.get(), false ); + try + { + m_xUndoManager->redo(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } ::sal_Bool SAL_CALL DocumentActions::undoPossible() throw (uno::RuntimeException) { - return ! m_apUndoStack->empty(); + return m_xUndoManager->isUndoPossible(); } ::sal_Bool SAL_CALL DocumentActions::redoPossible() throw (uno::RuntimeException) { - return ! m_apRedoStack->empty(); + return m_xUndoManager->isRedoPossible(); } OUString SAL_CALL DocumentActions::getCurrentUndoString() throw (uno::RuntimeException) { - return m_apUndoStack->topUndoString(); + OUString sTitle; + try + { + sTitle = m_xUndoManager->getCurrentUndoActionTitle(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sTitle; } OUString SAL_CALL DocumentActions::getCurrentRedoString() throw (uno::RuntimeException) { - return m_apRedoStack->topUndoString(); + OUString sTitle; + try + { + sTitle = m_xUndoManager->getCurrentRedoActionTitle(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sTitle; } Sequence< OUString > SAL_CALL DocumentActions::getAllUndoStrings() throw (uno::RuntimeException) { - return m_apUndoStack->getUndoStrings(); + Sequence< OUString > aStrings; + try + { + aStrings = m_xUndoManager->getAllUndoActionTitles(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aStrings; } Sequence< OUString > SAL_CALL DocumentActions::getAllRedoStrings() throw (uno::RuntimeException) { - return m_apRedoStack->getUndoStrings(); + Sequence< ::rtl::OUString > aStrings; + try + { + aStrings = m_xUndoManager->getAllRedoActionTitles(); + } + catch ( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aStrings; } // ____ XUnoTunnel ____ diff --git a/chart2/source/controller/main/ImplDocumentActions.cxx b/chart2/source/controller/main/ImplDocumentActions.cxx index 8103bec54114..f477052908ff 100644 --- a/chart2/source/controller/main/ImplDocumentActions.cxx +++ b/chart2/source/controller/main/ImplDocumentActions.cxx @@ -43,462 +43,344 @@ #include #include #include +#include + +#include +#include #include #include using namespace ::com::sun::star; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; using ::rtl::OUString; -using ::com::sun::star::chart::XComplexDescriptionAccess; namespace chart { namespace impl { -void ImplApplyDataToModel( - const Reference< frame::XModel > & xModel, - const Reference< chart2::XInternalDataProvider > & xData ) + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::view::XSelectionSupplier; + using ::com::sun::star::chart2::XChartDocument; + using ::com::sun::star::chart::XComplexDescriptionAccess; + using ::com::sun::star::chart2::XTitled; + using ::com::sun::star::chart2::XInternalDataProvider; + using ::com::sun::star::util::XModifiable; + using ::com::sun::star::document::UndoFailedException; + /** === end UNO using === **/ + +// ===================================================================================================================== +// = helper +// ===================================================================================================================== +namespace { - Reference< chart2::XChartDocument > xDoc( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); - - // copy data from stored internal data provider - if( xDoc.is() && xDoc->hasInternalDataProvider()) + Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); - if( xCurrentData.is() && xSavedData.is()) + Reference< XModel > xResult; + try { - xCurrentData->setData( xSavedData->getData()); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); + const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); + xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xResult; } -} -// ---------------------------------------- - -UndoElement::UndoElement( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - m_aActionString( rActionString ) -{ - initialize( xModel ); } -UndoElement::UndoElement( - const Reference< frame::XModel > & xModel ) -{ - initialize( xModel ); -} +// ===================================================================================================================== +// = ChartModelClone +// ===================================================================================================================== -UndoElement::UndoElement( const UndoElement & rOther ) : - m_aActionString( rOther.m_aActionString ) +// --------------------------------------------------------------------------------------------------------------------- +ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) { - initialize( rOther.m_xModel ); -} + m_xModelClone.set( lcl_cloneModel( i_model ) ); -UndoElement::~UndoElement() -{} + try + { + if ( i_facet == E_MODEL_WITH_DATA ) + { + const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); + ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); -void UndoElement::initialize( const Reference< frame::XModel > & xModel ) -{ - if ( xModel.is() ) + const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + + if ( i_facet == E_MODEL_WITH_SELECTION ) + { + const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW ); + m_aSelection = xSelSupp->getSelection(); + } + } + catch( const Exception& ) { - m_xModel.set( UndoElement::cloneModel( xModel ) ); + DBG_UNHANDLED_EXCEPTION(); } } -void UndoElement::dispose() -{ - Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); - m_xModel.set( 0 ); -} - -void UndoElement::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel ); -} -UndoElement * UndoElement::createFromModel( - const Reference< frame::XModel > & xModel ) +// --------------------------------------------------------------------------------------------------------------------- +ChartModelClone::~ChartModelClone() { - return new UndoElement( getActionString(), xModel ); + if ( !impl_isDisposed() ) + dispose(); } -void UndoElement::setActionString( const ::rtl::OUString & rActionString ) +// --------------------------------------------------------------------------------------------------------------------- +void ChartModelClone::dispose() { - m_aActionString = rActionString; -} + if ( impl_isDisposed() ) + return; -OUString UndoElement::getActionString() const -{ - return m_aActionString; + try + { + Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); + xComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_xModelClone.clear(); + m_xDataClone.clear(); + m_aSelection.clear(); } -// static -Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) +// --------------------------------------------------------------------------------------------------------------------- +ModelFacet ChartModelClone::getFacet() const { - Reference< frame::XModel > xResult; - uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone model" ); - if( xCloneable.is()) - xResult.set( xCloneable->createClone(), uno::UNO_QUERY ); - - return xResult; + if ( m_aSelection.hasValue() ) + return E_MODEL_WITH_SELECTION; + if ( m_xDataClone.is() ) + return E_MODEL_WITH_DATA; + return E_MODEL; } -// static -void UndoElement::applyModelContentToModel( - const Reference< frame::XModel > & xModel, - const Reference< frame::XModel > & xModelToCopyFrom, - const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) +// --------------------------------------------------------------------------------------------------------------------- +void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const { + applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); - if( xModelToCopyFrom.is() && xModel.is()) + if ( m_aSelection.hasValue() ) { try { - // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( xModel ); - Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); - Reference< chart2::XChartDocument > xDestination( xModel, uno::UNO_QUERY_THROW ); - - // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xModel ); - - // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram()); - - // main title - Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW ); - Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject()); - - // page background - comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); - - // apply data (not applied in standard Undo) - if( xData.is()) - ImplApplyDataToModel( xModel, xData ); - - // register all sequences at the internal data provider to get adapted - // indexes when columns are added/removed - if( xDestination->hasInternalDataProvider()) - { - Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xModel )); - if( xUsedData.is() && xNewDataProvider.is()) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); - for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues()); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel()); - } - } - } - - // restore modify status - Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY ); - Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY ); - if( xSourceMod.is() && xDestMod.is() && - ! xSourceMod->isModified() ) - { - xDestMod->setModified( sal_False ); - } - // \-- loccked controllers of destination + Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW ); + xCurrentSelectionSuppl->select( m_aSelection ); } - catch( uno::Exception & ) + catch( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } } -// ---------------------------------------- - -UndoElementWithData::UndoElementWithData( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initializeData(); -} - -UndoElementWithData::UndoElementWithData( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initializeData(); -} - - -UndoElementWithData::UndoElementWithData( - const UndoElementWithData & rOther ) : - UndoElement( rOther ) -{ - initializeData(); -} - -UndoElementWithData::~UndoElementWithData() -{} - -void UndoElementWithData::initializeData() +// --------------------------------------------------------------------------------------------------------------------- +namespace { - try + void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data ) { - Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW ); - OSL_ASSERT( xChartDoc->hasInternalDataProvider()); - if( xChartDoc->hasInternalDataProvider()) + Reference< XChartDocument > xDoc( i_model, UNO_QUERY ); + OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() ); + + // copy data from stored internal data provider + if( xDoc.is() && xDoc->hasInternalDataProvider()) { - Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone data" ); - if( xCloneable.is()) - m_xData.set( xCloneable->createClone(), uno::UNO_QUERY ); + Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY ); + Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY ); + if ( xCurrentData.is() && xSavedData.is() ) + { + xCurrentData->setData( xSavedData->getData() ); + xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() ); + xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() ); + } } } - catch( uno::Exception & ) - { - } -} - -void UndoElementWithData::dispose() -{ - UndoElement::dispose(); - m_xData.set( 0 ); -} - -void UndoElementWithData::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel, m_xData ); } -UndoElement * UndoElementWithData::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithData( getActionString(), xModel ); -} - -// ======================================== - -// ---------------------------------------- - -UndoElementWithSelection::UndoElementWithSelection( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const UndoElementWithSelection & rOther ) : - UndoElement( rOther ) -{ - initialize( rOther.m_xModel ); -} - -UndoElementWithSelection::~UndoElementWithSelection() -{} - -void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel ) +// --------------------------------------------------------------------------------------------------------------------- +void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, + const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) { + ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); + ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); try { - uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xSelSupp.is() ); + // /-- loccked controllers of destination + ControllerLockGuard aLockedControllers( i_model ); + Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); + Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); + + // propagate the correct flag for plotting of hidden values to the data provider and all used sequences + ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model ); + + // diagram + xDestination->setFirstDiagram( xSource->getFirstDiagram() ); + + // main title + Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); + Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); + xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); + + // page background + ::comphelper::copyProperties( + xSource->getPageBackground(), + xDestination->getPageBackground() ); + + // apply data (not applied in standard Undo) + if ( i_data.is() ) + ImplApplyDataToModel( i_model, i_data ); + + // register all sequences at the internal data provider to get adapted + // indexes when columns are added/removed + if ( xDestination->hasInternalDataProvider() ) + { + Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); + Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); + if ( xUsedData.is() && xNewDataProvider.is() ) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); + for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues() ); + xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() ); + } + } + } - if( xSelSupp.is() ) - m_aSelection = xSelSupp->getSelection(); + // restore modify status + Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); + Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); + if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) + { + xDestMod->setModified( sal_False ); + } + // \-- loccked controllers of destination } - catch( const uno::Exception & ) + catch( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } -void UndoElementWithSelection::dispose() -{ - UndoElement::dispose(); - m_aSelection.clear(); -} - -void UndoElementWithSelection::applyToModel( - const Reference< frame::XModel > & xModel ) -{ - UndoElement::applyModelContentToModel( xModel, m_xModel ); - Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xCurrentSelectionSuppl.is() ); - - if( xCurrentSelectionSuppl.is()) - xCurrentSelectionSuppl->select( m_aSelection ); -} - -UndoElement * UndoElementWithSelection::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithSelection( getActionString(), xModel ); -} - -// ---------------------------------------- - -ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction ) - :UndoElement( rActionString, Reference< frame::XModel >() ) - ,m_pAction( pAction ) -{ -} - -ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther ) - :UndoElement( rOther ) - ,m_pAction( rOther.m_pAction ) -{ -} - -ShapeUndoElement::~ShapeUndoElement() -{ -} - -SdrUndoAction* ShapeUndoElement::getSdrUndoAction() -{ - return m_pAction; -} - -// ======================================== - -UndoStack::UndoStack() : - m_nSizeLimit( 1000 ) -{ -} - -UndoStack::~UndoStack() +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) + :UndoElement_MBase() + ,UndoElement_TBase( m_aMutex ) + ,m_sActionString( i_actionString ) + ,m_xDocumentModel( i_documentModel ) + ,m_pModelClone( i_modelClone ) { - disposeAndClear(); } -void UndoStack::pop() +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::~UndoElement() { - if( ! empty()) - { - top()->dispose(); - delete top(); - m_aStack.pop_back(); - } } -void UndoStack::push( UndoElement * pElement ) +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::disposing() { - m_aStack.push_back( pElement ); - applyLimitation(); + if ( !!m_pModelClone ) + m_pModelClone->dispose(); + m_pModelClone.reset(); + m_xDocumentModel.clear(); } -UndoElement * UndoStack::top() const +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException) { - return m_aStack.back(); + return m_sActionString; } -OUString UndoStack::topUndoString() const +// --------------------------------------------------------------------------------------------------------------------- +void UndoElement::impl_toggleModelState() { - if( ! empty()) - return top()->getActionString(); - return OUString(); + // get a snapshot of the current state of our model + ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) ); + // apply the previous snapshot to our model + m_pModelClone->applyToModel( m_xDocumentModel ); + // remember the new snapshot, for the next toggle + m_pModelClone = pNewClone; } -Sequence< OUString > UndoStack::getUndoStrings() const +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException) { - sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size())); - Sequence< OUString > aResult( nSize ); - for( sal_Int32 i=0; igetActionString(); - return aResult; + impl_toggleModelState(); } -bool UndoStack::empty() const +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException) { - return m_aStack.empty(); + impl_toggleModelState(); } -void UndoStack::disposeAndClear() -{ - ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.clear(); -} +// ===================================================================================================================== +// = ShapeUndoElement +// ===================================================================================================================== -void UndoStack::limitSize( sal_Int32 nMaxSize ) +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ) + :ShapeUndoElement_MBase() + ,ShapeUndoElement_TBase( m_aMutex ) + ,m_pAction( &i_sdrUndoAction ) { - m_nSizeLimit = nMaxSize; - applyLimitation(); } -void UndoStack::applyLimitation() -{ - if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit )) - { - tUndoStackType::iterator aBegin( m_aStack.begin()); - tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit)); - // dispose and remove all undo elements that are over the limit - ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.erase( aBegin, aEnd ); - } -} - -// ================================================================================ - -namespace -{ -static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps")); -} // anonymous namespace - -UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) : - ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))), - m_rListener( rListener ) +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::~ShapeUndoElement() { - EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 )); } -UndoStepsConfigItem::~UndoStepsConfigItem() +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException) { + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_pAction->GetComment(); } -void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException) { - for( sal_Int32 nIdx=0; nIdxUndo(); } -void UndoStepsConfigItem::Commit() +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException) { + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + m_pAction->Redo(); } -// mtehod is not const, because GetProperties is not const -sal_Int32 UndoStepsConfigItem::getUndoSteps() +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::disposing() { - sal_Int32 nSteps = -1; - Sequence< uno::Any > aValues( - GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 ))); - if( aValues.getLength()) - aValues[0] >>= nSteps; - return nSteps; } } // namespace impl diff --git a/chart2/source/controller/main/ImplDocumentActions.hxx b/chart2/source/controller/main/ImplDocumentActions.hxx index aaf8f18c1231..889968dfe4c7 100644 --- a/chart2/source/controller/main/ImplDocumentActions.hxx +++ b/chart2/source/controller/main/ImplDocumentActions.hxx @@ -30,14 +30,19 @@ #include "ConfigItemListener.hxx" #include +#include #include #include #include +#include +#include #include #include +#include +#include class SdrUndoAction; @@ -53,173 +58,110 @@ namespace chart namespace impl { -class UndoElement +enum ModelFacet { -public: - UndoElement( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const UndoElement & rOther ); - virtual ~UndoElement(); + E_MODEL, + E_MODEL_WITH_DATA, + E_MODEL_WITH_SELECTION +}; - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); +class ChartModelClone : public ::boost::noncopyable +{ +public: + ChartModelClone( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model, + const ModelFacet i_facet + ); - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + ~ChartModelClone(); - void setActionString( const ::rtl::OUString & rActionString ); - ::rtl::OUString getActionString() const; + ModelFacet getFacet() const; - static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); + void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const; static void applyModelContentToModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data ); -protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > m_xModel; + void dispose(); private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::rtl::OUString m_aActionString; -}; - -class UndoElementWithData : public UndoElement -{ -public: - UndoElementWithData( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const UndoElementWithData & rOther ); - virtual ~UndoElementWithData(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); + bool impl_isDisposed() const { return !m_xModelClone.is(); } private: - void initializeData(); - - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XInternalDataProvider > m_xData; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone; + ::com::sun::star::uno::Any m_aSelection; }; -class UndoElementWithSelection : public UndoElement -{ -public: - UndoElementWithSelection( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const UndoElementWithSelection & rOther ); - virtual ~UndoElementWithSelection(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::com::sun::star::uno::Any m_aSelection; -}; +typedef ::cppu::BaseMutex UndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; -class ShapeUndoElement : public UndoElement +class UndoElement :public UndoElement_MBase + ,public UndoElement_TBase + ,public ::boost::noncopyable { public: - ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction ); - ShapeUndoElement( const ShapeUndoElement& rOther ); - virtual ~ShapeUndoElement(); + /** creates a new undo action + + @param i_actionString + is the title of the Undo action + @param i_documentModel + is the actual document model which the undo actions operates on + @param i_modelClone + is the cloned model from before the changes, which the Undo action represents, have been applied. + Upon invoking, the clone model is applied to the document model. + */ + UndoElement( const ::rtl::OUString & i_actionString, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel, + const ::boost::shared_ptr< ChartModelClone >& i_modelClone + ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); - SdrUndoAction* getSdrUndoAction(); +protected: + virtual ~UndoElement(); private: - SdrUndoAction* m_pAction; -}; - -/** Note that all models that are put into this container are at some point - disposed of inside this class. (At least in the destructor). That means - the models retrieved here should never be used, but instead their content - should be copied to a living model. - */ -class UndoStack -{ -public: - UndoStack(); - // disposes of all models left in the stack - ~UndoStack(); - - // removes he last undo action and disposes of the model - void pop(); - void push( UndoElement * rElement ); - - // precondition: !empty() - UndoElement * top() const; - ::rtl::OUString topUndoString() const; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const; - - bool empty() const; - void disposeAndClear(); - - // removes all actions that have been inserted more than nMaxSize steps ago. - // The models of those actions are disposed of - void limitSize( sal_Int32 nMaxSize ); + void impl_toggleModelState(); private: - void applyLimitation(); - - typedef ::std::deque< UndoElement * > tUndoStackType; - - tUndoStackType m_aStack; - sal_Int32 m_nSizeLimit; + ::rtl::OUString m_sActionString; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel; + ::boost::shared_ptr< ChartModelClone > m_pModelClone; }; -// ---------------------------------------- -class UndoStepsConfigItem : public ::utl::ConfigItem +typedef ::cppu::BaseMutex ShapeUndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase; +class ShapeUndoElement :public ShapeUndoElement_MBase + ,public ShapeUndoElement_TBase { public: - explicit UndoStepsConfigItem( ConfigItemListener & rListener ); - virtual ~UndoStepsConfigItem(); + ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); - sal_Int32 getUndoSteps(); + // OComponentHelper + virtual void SAL_CALL disposing(); protected: - // ____ ::utl::ConfigItem ____ - virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames ); - virtual void Commit(); + virtual ~ShapeUndoElement(); private: - ConfigItemListener & m_rListener; + SdrUndoAction* m_pAction; }; - } // namespace impl } // namespace chart diff --git a/chart2/source/inc/DocumentActions.hxx b/chart2/source/inc/DocumentActions.hxx index 52c3282002a9..4cb6dc5d0f02 100644 --- a/chart2/source/inc/DocumentActions.hxx +++ b/chart2/source/inc/DocumentActions.hxx @@ -27,7 +27,6 @@ #ifndef CHART2_UNDOMANAGER_HXX #define CHART2_UNDOMANAGER_HXX -#include "ConfigItemListener.hxx" #include "MutexContainer.hxx" #include @@ -37,15 +36,19 @@ #include #include #include +#include #include #include +#include // for pair #include // for auto_ptr #include +#include + class SdrUndoAction; namespace com { namespace sun { namespace star { @@ -60,10 +63,11 @@ namespace chart namespace impl { -class UndoStepsConfigItem; +class UndoStepsConfigItem; class UndoElement; -class UndoStack; -class ModifyBroadcaster; +class UndoStack; +class ChartModelClone; +class ModifyBroadcaster; typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::util::XModifyBroadcaster, @@ -83,7 +87,6 @@ typedef ::cppu::WeakComponentImplHelper3< */ class DocumentActions : public MutexContainer, - public ConfigItemListener, public impl::DocumentActions_Base { public: @@ -100,9 +103,6 @@ public: static DocumentActions* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj ); protected: - // ____ ConfigItemListener ____ - virtual void notify( const ::rtl::OUString & rPropertyName ); - // ____ util::XModifyBroadcaster ____ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) @@ -127,28 +127,13 @@ protected: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); private: - void retrieveConfigUndoSteps(); - void fireModifyEvent(); - void impl_undoRedo( - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo, - bool bUndo = true ); - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - impl_getModel() const; - - ::std::auto_ptr< impl::UndoStack > m_apUndoStack; - ::std::auto_ptr< impl::UndoStack > m_apRedoStack; - - impl::UndoElement * m_pLastRemeberedUndoElement; - - ::std::auto_ptr< impl::UndoStepsConfigItem > m_apUndoStepsConfigItem; - sal_Int32 m_nMaxNumberOfUndos; - ::com::sun::star::uno::Reference< - ::com::sun::star::util::XModifyBroadcaster > m_xModifyBroadcaster; - // pointer is valid as long as m_xModifyBroadcaster.is() - impl::ModifyBroadcaster * m_pModifyBroadcaster; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; + void impl_fireModifyEvent(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > impl_getModel() const; + + ::boost::shared_ptr< impl::ChartModelClone > m_pDocumentSnapshot; + ::rtl::Reference< impl::ModifyBroadcaster > m_pModifyBroadcaster; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; + ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; }; } // namespace chart diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 10ff9095fc54..6ba450d76f5f 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -557,6 +557,8 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) m_pUndoManager.clear(); // that's important, since the UndoManager implementation delegates its ref counting to ourself. + m_xDocumentActions.clear(); + m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this ))); m_xCurrentController.clear(); -- cgit From 4d0ae2eac2ac03475b7496f81e803b9b71b7481f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 08:49:38 +0100 Subject: undoapi: step 2.3 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: migrate the clients of XDocumentActions to using the new XUndoManager, and completely remove the (X)DocumentActions still some more cleanup needed --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 8 - chart2/source/controller/main/ChartController.cxx | 40 ++- chart2/source/controller/main/ChartController.hxx | 7 +- .../controller/main/ChartController_EditData.cxx | 4 +- .../controller/main/ChartController_Insert.cxx | 134 +++---- .../controller/main/ChartController_Position.cxx | 4 +- .../controller/main/ChartController_Properties.cxx | 8 +- .../controller/main/ChartController_TextEdit.cxx | 27 +- .../controller/main/ChartController_Tools.cxx | 64 ++-- .../controller/main/ChartController_Window.cxx | 12 +- .../controller/main/CommandDispatchContainer.hxx | 2 - chart2/source/controller/main/DocumentActions.cxx | 392 --------------------- .../source/controller/main/UndoCommandDispatch.cxx | 51 +-- .../source/controller/main/UndoCommandDispatch.hxx | 7 +- chart2/source/controller/main/UndoGuard.cxx | 133 ++++--- chart2/source/controller/main/makefile.mk | 1 - chart2/source/inc/ChartModelHelper.hxx | 1 - chart2/source/inc/DocumentActions.hxx | 142 -------- chart2/source/inc/UndoGuard.hxx | 84 +++-- chart2/source/inc/servicenames.hxx | 2 - chart2/source/model/main/ChartModel.cxx | 109 ------ chart2/source/model/main/ChartModel.hxx | 44 +-- chart2/source/model/main/UndoManager.cxx | 15 + chart2/source/model/main/UndoManager.hxx | 10 +- 24 files changed, 347 insertions(+), 954 deletions(-) delete mode 100644 chart2/source/controller/main/DocumentActions.cxx delete mode 100644 chart2/source/inc/DocumentActions.hxx (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 2ba38e9582e1..29d7735e02a8 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -56,7 +56,6 @@ #include "WrappedAddInProperty.hxx" #include "WrappedIgnoreProperty.hxx" #include "ChartRenderer.hxx" -#include "DocumentActions.hxx" #include #include #include @@ -1412,13 +1411,6 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( xResult.set( m_xChartView ); bServiceFound = true; } - else if ( aServiceSpecifier.equals( CHART_DOCUMENT_ACTIONS_SERVICE_NAME ) ) - { - Reference< XModel > xModel( queryInterface( XModel::static_type() ), UNO_QUERY_THROW ); - Reference< chart2::XDocumentActions > xDocumentActions( new DocumentActions( xModel ) ); - xResult.set( xDocumentActions ); - bServiceFound = true; - } else { // try to create a shape diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 4e29cc45907b..cebb2a574838 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -49,11 +49,10 @@ #include "macros.hxx" #include "dlg_CreationWizard.hxx" #include "dlg_ChartType.hxx" -//#include "svx/ActionDescriptionProvider.hxx" #include "AccessibleChartView.hxx" #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" -#include "DocumentActions.hxx" +#include "ImplDocumentActions.hxx" #include @@ -66,6 +65,8 @@ #include #include #include +#include +#include //------- // header for define RET_OK @@ -85,6 +86,7 @@ // object in the DTOR #include #include +#include // enable the following define to let the controller listen to model changes and // react on this by rebuilding the view @@ -127,7 +129,7 @@ ChartController::ChartController(uno::Reference const & , m_bWaitingForDoubleClick(false) , m_bWaitingForMouseUp(false) , m_bConnectingToView(false) - , m_xDocumentActions( 0 ) + , m_xUndoManager( 0 ) , m_aDispatchContainer( m_xCC, this ) , m_eDrawMode( CHARTDRAW_SELECT ) { @@ -613,7 +615,8 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( m_pChartWindow ) m_pChartWindow->Invalidate(); - m_xDocumentActions.set( getModel(), uno::UNO_QUERY ); + uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); return sal_True; } @@ -814,7 +817,7 @@ void ChartController::impl_deleteDrawViewController() } m_xFrame.clear(); - m_xDocumentActions.clear(); + m_xUndoManager.clear(); TheModelRef aModelRef( m_aModel, m_aModelMutex); m_aModel = NULL; @@ -951,7 +954,7 @@ bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterfa if( m_aModel.is() && m_aModel->getModel() == xModel ) { m_aModel = NULL; - m_xDocumentActions.clear(); + m_xUndoManager.clear(); bReleaseModel = true; } } @@ -1323,7 +1326,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xDocumentActions ); + String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager ); // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); @@ -1332,7 +1335,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() if( aDlg.Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } // \-- } @@ -1348,7 +1351,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xDocumentActions ); + String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager ); if( xChartDoc.is()) { // /-- @@ -1357,7 +1360,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() if( aDlg.Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } // \-- } @@ -1376,13 +1379,13 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) ActionDescriptionProvider::createDescription( (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), String( SchResId( STR_OBJECT_DATASERIES ))), - m_xDocumentActions ); + m_xUndoManager ); bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); if( bChanged ) { m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -1442,13 +1445,20 @@ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ ) IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction ) { + ENSURE_OR_RETURN( pUndoAction, "invalid Undo action", 1L ); + ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID(); if ( aObjectCID.getLength() == 0 ) { - DocumentActions* pDocumentActions = DocumentActions::getImplementation( m_xDocumentActions ); - if ( pDocumentActions ) + try + { + const Reference< document::XUndoManager > xUndoManager( getModel(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) ); + xUndoManager->addUndoAction( xAction ); + } + catch( const uno::Exception& ) { - pDocumentActions->addShapeUndoAction( pUndoAction ); + DBG_UNHANDLED_EXCEPTION(); } } return 0L; diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index aa9ade1f17b5..7c06a4ad4ca2 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include @@ -89,6 +89,8 @@ namespace chart { //............................................................................. +class UndoGuard; + enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT }; class WindowController @@ -578,7 +580,8 @@ private: bool volatile m_bConnectingToView; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; + ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; + ::std::auto_ptr< UndoGuard > m_pTextActionUndoGuard; /// needed for dispatching URLs in FeatureStateEvents mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index cbc66a2368b3..7c9bfe0c3986 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -67,11 +67,11 @@ void ChartController::executeDispatch_EditData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( String( SchResId( STR_ACTION_EDIT_CHART_DATA )), - m_xDocumentActions ); + m_xUndoManager ); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); // the dialog has no OK/Cancel aDataEditorDialog.Execute(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); // \-- } } diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index adb6cf91a62e..b2bdaa02dd3c 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -122,7 +122,7 @@ void ChartController::executeDispatch_InsertAxes() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -146,7 +146,7 @@ void ChartController::executeDispatch_InsertAxes() , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC , mpRefSizeProvider.get() ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -160,7 +160,7 @@ void ChartController::executeDispatch_InsertGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -180,7 +180,7 @@ void ChartController::executeDispatch_InsertGrid() bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -197,7 +197,7 @@ void ChartController::executeDispatch_InsertTitles() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -214,7 +214,7 @@ void ChartController::executeDispatch_InsertTitles() aDlg.getResult( aDialogOutput ); bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -228,10 +228,10 @@ void ChartController::executeDispatch_DeleteLegend() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), - m_xDocumentActions ); + m_xUndoManager ); LegendHelper::hideLegend( getModel() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertLegend() @@ -239,10 +239,10 @@ void ChartController::executeDispatch_InsertLegend() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), - m_xDocumentActions ); + m_xUndoManager ); Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_OpenLegendDialog() @@ -250,7 +250,7 @@ void ChartController::executeDispatch_OpenLegendDialog() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -264,7 +264,7 @@ void ChartController::executeDispatch_OpenLegendDialog() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aDlg.writeToModel( getModel() ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -281,7 +281,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xDocumentActions ); + m_xUndoManager ); //if a series is selected insert labels for that series only: uno::Reference< chart2::XDataSeries > xSeries( @@ -298,7 +298,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true ); if( bSuccess ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); return; } @@ -330,7 +330,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -354,7 +354,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -380,7 +380,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -394,10 +394,10 @@ void ChartController::executeDispatch_InsertMeanValue() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xDocumentActions ); + m_xUndoManager ); lcl_InsertMeanValueLine( m_xCC ).operator()( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertMenu_MeanValues() @@ -405,7 +405,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xDocumentActions ); + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); @@ -420,7 +420,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() ))); ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC )); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertMenu_Trendlines() @@ -437,7 +437,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -460,7 +460,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -478,7 +478,7 @@ void ChartController::executeDispatch_InsertTrendline() UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))), - m_xDocumentActions ); + m_xUndoManager ); // add a linear curve RegressionCurveHelper::addRegressionCurve( @@ -518,7 +518,7 @@ void ChartController::executeDispatch_InsertTrendline() ControllerLockGuard aCLGuard( getModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -532,7 +532,7 @@ void ChartController::executeDispatch_InsertYErrorBars() UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))), - m_xDocumentActions ); + m_xUndoManager ); // add error bars with standard deviation uno::Reference< beans::XPropertySet > xErrorBarProp( @@ -568,7 +568,7 @@ void ChartController::executeDispatch_InsertYErrorBars() ControllerLockGuard aCLGuard( getModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -592,10 +592,10 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xDocumentActions ); + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -609,9 +609,9 @@ void ChartController::executeDispatch_InsertR2Value() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xDocumentActions ); + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -624,9 +624,9 @@ void ChartController::executeDispatch_DeleteR2Value() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xDocumentActions ); + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -639,9 +639,9 @@ void ChartController::executeDispatch_DeleteMeanValue() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xDocumentActions ); + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -654,9 +654,9 @@ void ChartController::executeDispatch_DeleteTrendline() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), - m_xDocumentActions ); + m_xUndoManager ); RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -669,9 +669,9 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xDocumentActions ); + m_xUndoManager ); RegressionCurveHelper::removeEquations( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -684,9 +684,9 @@ void ChartController::executeDispatch_DeleteYErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), - m_xDocumentActions ); + m_xUndoManager ); StatisticsHelper::removeErrorBars( xDataSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -698,9 +698,9 @@ void ChartController::executeDispatch_InsertDataLabels() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xDocumentActions ); + m_xUndoManager ); DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -708,9 +708,9 @@ void ChartController::executeDispatch_InsertDataLabel() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LABEL ))), - m_xDocumentActions ); + m_xUndoManager ); DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_DeleteDataLabels() @@ -721,9 +721,9 @@ void ChartController::executeDispatch_DeleteDataLabels() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_DATALABELS ))), - m_xDocumentActions ); + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -731,33 +731,33 @@ void ChartController::executeDispatch_DeleteDataLabel() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LABEL ))), - m_xDocumentActions ); + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ResetAllDataPoints() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, String( SchResId( STR_OBJECT_DATAPOINTS ))), - m_xDocumentActions ); + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) xSeries->resetAllDataPoints(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ResetDataPoint() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, String( SchResId( STR_OBJECT_DATAPOINT ))), - m_xDocumentActions ); + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) { sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); xSeries->resetDataPoint( nPointIndex ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertAxisTitle() @@ -769,7 +769,7 @@ void ChartController::executeDispatch_InsertAxisTitle() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))), - m_xDocumentActions ); + m_xUndoManager ); Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); sal_Int32 nDimensionIndex = -1; @@ -787,7 +787,7 @@ void ChartController::executeDispatch_InsertAxisTitle() ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getModel(), m_xCC, apRefSizeProvider.get() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } /* @@ -810,7 +810,7 @@ void ChartController::executeDispatch_InsertAxis() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -818,7 +818,7 @@ void ChartController::executeDispatch_InsertAxis() if( xAxis.is() ) { AxisHelper::makeAxisVisible( xAxis ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -832,7 +832,7 @@ void ChartController::executeDispatch_DeleteAxis() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -840,7 +840,7 @@ void ChartController::executeDispatch_DeleteAxis() if( xAxis.is() ) { AxisHelper::makeAxisInvisible( xAxis ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -854,7 +854,7 @@ void ChartController::executeDispatch_InsertMajorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -862,7 +862,7 @@ void ChartController::executeDispatch_InsertMajorGrid() if( xAxis.is() ) { AxisHelper::makeGridVisible( xAxis->getGridProperties() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -876,7 +876,7 @@ void ChartController::executeDispatch_DeleteMajorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -884,7 +884,7 @@ void ChartController::executeDispatch_DeleteMajorGrid() if( xAxis.is() ) { AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -898,7 +898,7 @@ void ChartController::executeDispatch_InsertMinorGrid() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), - m_xDocumentActions ); + m_xUndoManager ); try { @@ -908,7 +908,7 @@ void ChartController::executeDispatch_InsertMinorGrid() Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); for( sal_Int32 nN=0; nN > aSubGrids( xAxis->getSubGridProperties() ); for( sal_Int32 nN=0; nNGetColorTable() ); if( aDlg.Execute() == RET_OK ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); // \-- } catch( uno::RuntimeException& e) diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 96175fb119ca..8069fd43f8cf 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -29,6 +29,7 @@ #include "precompiled_chart2.hxx" #include "ChartController.hxx" +#include "UndoGuard.hxx" #include "DrawViewWrapper.hxx" #include "ChartWindow.hxx" #include "TitleHelper.hxx" @@ -80,7 +81,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) if(!pTextObj) return; - m_xDocumentActions->preAction(); + OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" ); + m_pTextActionUndoGuard.reset( new UndoGuard( C2U( "Text Edit" ), m_xUndoManager ) ); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); @@ -164,26 +166,11 @@ bool ChartController::EndTextEdit() TitleHelper::setCompleteString( aString, uno::Reference< ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC ); - try - { - m_xDocumentActions->postAction( C2U("Edit Text") ); - } - catch( uno::RuntimeException& e) - { - ASSERT_EXCEPTION( e ); - } - } - else - { - try - { - m_xDocumentActions->cancelAction(); - } - catch ( uno::RuntimeException& e ) - { - ASSERT_EXCEPTION( e ); - } + OSL_ENSURE( m_pTextActionUndoGuard.get(), "ChartController::EndTextEdit: no TextUndoGuard!" ); + if ( m_pTextActionUndoGuard.get() ) + m_pTextActionUndoGuard->commit(); } + m_pTextActionUndoGuard.reset(); } return true; } diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 9b2115fff83b..3723c1b5bfb7 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -102,7 +102,7 @@ namespace bool lcl_deleteDataSeries( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XDocumentActions > & xDocumentActions ) + const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); @@ -116,7 +116,7 @@ bool lcl_deleteDataSeries( ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))), - xDocumentActions ); + xUndoManager ); Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); @@ -126,7 +126,7 @@ bool lcl_deleteDataSeries( ::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram ); bResult = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } return bResult; @@ -135,7 +135,7 @@ bool lcl_deleteDataSeries( bool lcl_deleteDataCurve( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XDocumentActions > & xDocumentActions ) + const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( @@ -146,10 +146,10 @@ bool lcl_deleteDataCurve( ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))), - xDocumentActions ); + xUndoManager ); ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); bResult = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } return bResult; } @@ -236,7 +236,7 @@ void ChartController::executeDispatch_NewArrangement() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( String( SchResId( STR_ACTION_REARRANGE_CHART )), - m_xDocumentActions ); + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( xModel ); // diagram @@ -271,7 +271,7 @@ void ChartController::executeDispatch_NewArrangement() ::std::for_each( aRegressionCurves.begin(), aRegressionCurves.end(), RegressionCurveHelper::resetEquationPosition ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException & ex ) @@ -286,13 +286,13 @@ void ChartController::executeDispatch_ScaleText() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( String( SchResId( STR_ACTION_SCALE_TEXT )), - m_xDocumentActions ); + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( getModel() ); ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider()); OSL_ASSERT( apRefSizeProv.get()); if( apRefSizeProv.get()) apRefSizeProv->toggleAutoResizeState(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_Paste() @@ -656,11 +656,11 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))), - m_xDocumentActions ); + m_xUndoManager ); TitleHelper::removeTitle( ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); break; } case OBJECTTYPE_LEGEND: @@ -675,17 +675,17 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), - m_xDocumentActions ); + m_xUndoManager ); xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false )); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } break; } case OBJECTTYPE_DATA_SERIES: - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions ); + bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -693,9 +693,9 @@ bool ChartController::executeDispatch_Delete() ObjectType eParentObjectType = ObjectIdentifier::getObjectType( ObjectIdentifier::getFullParentParticle( aCID )); if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions ); + bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions ); + bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); break; } @@ -710,16 +710,16 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), - m_xDocumentActions ); + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } case OBJECTTYPE_DATA_CURVE: - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions ); + bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); break; case OBJECTTYPE_DATA_CURVE_EQUATION: @@ -733,14 +733,14 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), - m_xDocumentActions ); + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); } bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -756,7 +756,7 @@ bool ChartController::executeDispatch_Delete() UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))), - m_xDocumentActions ); + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xErrorBarProp->setPropertyValue( @@ -764,7 +764,7 @@ bool ChartController::executeDispatch_Delete() uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE )); } bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -780,7 +780,7 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))), - m_xDocumentActions ); + m_xUndoManager ); chart2::DataPointLabel aLabel; xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel; aLabel.ShowNumber = false; @@ -795,7 +795,7 @@ bool ChartController::executeDispatch_Delete() else xObjectProperties->setPropertyValue( C2U( "Label" ), uno::makeAny(aLabel) ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -844,7 +844,7 @@ void ChartController::executeDispatch_ToggleLegend() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xDocumentActions ); + String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager ); Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY ); bool bChanged = false; if( xLegendProp.is()) @@ -871,14 +871,14 @@ void ChartController::executeDispatch_ToggleLegend() } if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ToggleGridHorizontal() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xDocumentActions ); + String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); if( xDiagram.is()) { @@ -893,7 +893,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() else AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram, m_xCC ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -911,9 +911,9 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), - m_xDocumentActions ); + m_xUndoManager ); if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } // namespace chart diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index c12ce38fa7cd..311bf38ea38c 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -839,12 +839,12 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( pChartDragMethod ) { UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(), - m_xDocumentActions ); + m_xUndoManager ); if( pDrawViewWrapper->EndDragObj(false) ) { bDraggingDone = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -872,7 +872,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), - m_xDocumentActions ); + m_xUndoManager ); bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) @@ -880,7 +880,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( bChanged ) { bDraggingDone = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -1808,7 +1808,7 @@ bool ChartController::impl_moveOrResizeObject( ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - eActionType, ObjectNameProvider::getName( eObjectType )), m_xDocumentActions ); + eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); { ControllerLockGuard aCLGuard( xChartModel ); if( bNeedShift ) @@ -1816,7 +1816,7 @@ bool ChartController::impl_moveOrResizeObject( if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set xObjProp->setPropertyValue( C2U("RelativeSize"), uno::makeAny( aRelSize )); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } return bResult; diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx index 38f0c2ce8771..a5995253e059 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.hxx +++ b/chart2/source/controller/main/CommandDispatchContainer.hxx @@ -28,7 +28,6 @@ #define CHART2_COMMANDDISPATCHCONTAINER_HXX #include -#include #include #include #include @@ -139,7 +138,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher; ::std::set< ::rtl::OUString > m_aChartCommands; diff --git a/chart2/source/controller/main/DocumentActions.cxx b/chart2/source/controller/main/DocumentActions.cxx deleted file mode 100644 index a4864541fc70..000000000000 --- a/chart2/source/controller/main/DocumentActions.cxx +++ /dev/null @@ -1,392 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "DocumentActions.hxx" -#include "ImplDocumentActions.hxx" -#include "DisposeHelper.hxx" -#include "MutexContainer.hxx" -#include "macros.hxx" -#include "ChartViewHelper.hxx" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::RuntimeException; -using ::com::sun::star::frame::XModel; -using ::com::sun::star::document::XUndoManagerSupplier; -using ::com::sun::star::document::XUndoAction; -using ::rtl::OUString; - - -// -------------------------------------------------------------------------------- - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakComponentImplHelper1< - util::XModifyBroadcaster > - ModifyBroadcaster_Base; - -class ModifyBroadcaster : - public ::chart::MutexContainer, - public ModifyBroadcaster_Base -{ -public: - ModifyBroadcaster(); - - void fireEvent(); - -public: - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); -}; - -ModifyBroadcaster::ModifyBroadcaster() : - ModifyBroadcaster_Base( m_aMutex ) -{} - -void SAL_CALL ModifyBroadcaster::addModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.addListener( ::getCppuType( & xListener ), xListener); -} - -void SAL_CALL ModifyBroadcaster::removeModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.removeListener( ::getCppuType( & xListener ), xListener ); -} - -void ModifyBroadcaster::fireEvent() -{ - ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer( - ::getCppuType((const uno::Reference< util::XModifyListener >*)0) ); - if( pIC ) - { - lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY ); - if( xListener.is() ) - xListener->modified( aEvent ); - } - } -} - -} // namespace impl - -DocumentActions::DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ) - :impl::DocumentActions_Base( m_aMutex ) - ,m_pDocumentSnapshot() - ,m_pModifyBroadcaster( NULL ) - ,m_aModel( rModel ) - ,m_xUndoManager() -{ - Reference< XUndoManagerSupplier > xSuppUndo( rModel, UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), UNO_SET_THROW ); -} - -DocumentActions::~DocumentActions() -{ - if ( m_pModifyBroadcaster.is() ) - { - m_pModifyBroadcaster->dispose(); - m_pModifyBroadcaster.clear(); - } -} - -void DocumentActions::addShapeUndoAction( SdrUndoAction* pAction ) -{ - if ( !pAction ) - return; - const Reference< XUndoAction > xAction( new impl::ShapeUndoElement( *pAction ) ); - m_xUndoManager->addUndoAction( xAction ); - impl_fireModifyEvent(); -} - -Reference< XModel > DocumentActions::impl_getModel() const -{ - Reference< XModel > xModel( m_aModel ); - return xModel; -} - -void DocumentActions::impl_fireModifyEvent() -{ - if ( m_pModifyBroadcaster.is() ) - m_pModifyBroadcaster->fireEvent(); -} - - -// ____ XModifyBroadcaster ____ -void SAL_CALL DocumentActions::addModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if ( !m_pModifyBroadcaster.is() ) - m_pModifyBroadcaster.set( new impl::ModifyBroadcaster() ); - - m_pModifyBroadcaster->addModifyListener( aListener ); -} - -void SAL_CALL DocumentActions::removeModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if ( m_pModifyBroadcaster.is() ) - m_pModifyBroadcaster->removeModifyListener( aListener ); -} - -// ____ chart2::XDocumentActions ____ -void SAL_CALL DocumentActions::preAction( ) - throw (uno::RuntimeException) -{ - ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" ); - m_pDocumentSnapshot.reset( new impl::ChartModelClone( impl_getModel(), impl::E_MODEL ) ); -} - -void SAL_CALL DocumentActions::preActionWithArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (uno::RuntimeException, lang::IllegalArgumentException) -{ - ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" ); - - impl::ModelFacet eModelFacet( impl::E_MODEL ); - ::comphelper::NamedValueCollection aArgs( aArguments ); - - const sal_Bool bWithData = aArgs.getOrDefault( "WithData", sal_False ); - if ( bWithData ) - eModelFacet = impl::E_MODEL_WITH_DATA; - - const sal_Bool bWithSelection = aArgs.getOrDefault( "WithSelection", sal_False ); - if ( bWithSelection ) - eModelFacet = impl::E_MODEL_WITH_SELECTION; - - const Reference< XModel > xModel( impl_getModel() ); - m_pDocumentSnapshot.reset( new impl::ChartModelClone( xModel, eModelFacet ) ); -} - -void SAL_CALL DocumentActions::postAction( const OUString& aUndoText ) - throw (uno::RuntimeException) -{ - ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); - - const Reference< XUndoAction > xAction( new impl::UndoElement( aUndoText, impl_getModel(), m_pDocumentSnapshot ) ); - m_pDocumentSnapshot.reset(); - - m_xUndoManager->addUndoAction( xAction ); - - impl_fireModifyEvent(); -} - -void SAL_CALL DocumentActions::cancelAction() - throw (uno::RuntimeException) -{ - ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); - - m_pDocumentSnapshot->dispose(); - m_pDocumentSnapshot.reset(); -} - -void SAL_CALL DocumentActions::cancelActionWithUndo( ) - throw (uno::RuntimeException) -{ - ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" ); - - m_pDocumentSnapshot->applyToModel( impl_getModel() ); - m_pDocumentSnapshot->dispose(); - m_pDocumentSnapshot.reset(); -} - -void SAL_CALL DocumentActions::undo( ) - throw (uno::RuntimeException) -{ - try - { - m_xUndoManager->undo(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -void SAL_CALL DocumentActions::redo( ) - throw (uno::RuntimeException) -{ - try - { - m_xUndoManager->redo(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -::sal_Bool SAL_CALL DocumentActions::undoPossible() - throw (uno::RuntimeException) -{ - return m_xUndoManager->isUndoPossible(); -} - -::sal_Bool SAL_CALL DocumentActions::redoPossible() - throw (uno::RuntimeException) -{ - return m_xUndoManager->isRedoPossible(); -} - -OUString SAL_CALL DocumentActions::getCurrentUndoString() - throw (uno::RuntimeException) -{ - OUString sTitle; - try - { - sTitle = m_xUndoManager->getCurrentUndoActionTitle(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return sTitle; -} - -OUString SAL_CALL DocumentActions::getCurrentRedoString() - throw (uno::RuntimeException) -{ - OUString sTitle; - try - { - sTitle = m_xUndoManager->getCurrentRedoActionTitle(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return sTitle; -} - -Sequence< OUString > SAL_CALL DocumentActions::getAllUndoStrings() - throw (uno::RuntimeException) -{ - Sequence< OUString > aStrings; - try - { - aStrings = m_xUndoManager->getAllUndoActionTitles(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return aStrings; -} - -Sequence< OUString > SAL_CALL DocumentActions::getAllRedoStrings() - throw (uno::RuntimeException) -{ - Sequence< ::rtl::OUString > aStrings; - try - { - aStrings = m_xUndoManager->getAllRedoActionTitles(); - } - catch ( const RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return aStrings; -} - -// ____ XUnoTunnel ____ -sal_Int64 DocumentActions::getSomething( const Sequence< sal_Int8 >& rId ) - throw (uno::RuntimeException) -{ - if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); - } - return 0; -} - -// static -const Sequence< sal_Int8 >& DocumentActions::getUnoTunnelId() -{ - static Sequence< sal_Int8 >* pSeq = 0; - if( !pSeq ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; -} - -// static -DocumentActions* DocumentActions::getImplementation( const Reference< uno::XInterface > xObj ) -{ - DocumentActions* pRet = NULL; - Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY ); - if ( xUT.is() ) - { - pRet = reinterpret_cast< DocumentActions* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) ); - } - return pRet; -} - -} // namespace chart diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 0d1a26d6fc65..92a4a469ff1b 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -32,9 +32,11 @@ #include "macros.hxx" #include +#include #include #include +#include // for ressource strings STR_UNDO and STR_REDO #include @@ -56,7 +58,8 @@ UndoCommandDispatch::UndoCommandDispatch( CommandDispatch( xContext ), m_xModel( xModel ) { - m_xDocumentActions.set( xModel, uno::UNO_QUERY ); + uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -64,38 +67,36 @@ UndoCommandDispatch::~UndoCommandDispatch() void UndoCommandDispatch::initialize() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); - if( xBroadcaster.is() ) - { - xBroadcaster->addModifyListener( this ); - } + Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); + xBroadcaster->addModifyListener( this ); } void UndoCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { - if( m_xDocumentActions.is() ) + if( m_xUndoManager.is() ) { bool bFireAll = (rURL.getLength() == 0); uno::Any aUndoState, aRedoState; - if( m_xDocumentActions->undoPossible()) + if( m_xUndoManager->isUndoPossible()) { // using assignment for broken gcc 3.3 OUString aUndo = OUString( String( SchResId( STR_UNDO ))); - aUndoState <<= ( aUndo + m_xDocumentActions->getCurrentUndoString()); + aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle()); } - if( m_xDocumentActions->redoPossible()) + if( m_xUndoManager->isRedoPossible()) { // using assignment for broken gcc 3.3 OUString aRedo = OUString( String( SchResId( STR_REDO ))); - aRedoState <<= ( aRedo + m_xDocumentActions->getCurrentRedoString()); + aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle()); } if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) - fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xDocumentActions->undoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Redo"))) - fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xDocumentActions->redoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); } } @@ -105,15 +106,22 @@ void SAL_CALL UndoCommandDispatch::dispatch( const Sequence< beans::PropertyValue >& /* Arguments */ ) throw (uno::RuntimeException) { - if( m_xDocumentActions.is() ) + if( m_xUndoManager.is() ) { // why is it necessary to lock the solar mutex here? // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); - if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xDocumentActions->undo(); - else - m_xDocumentActions->redo(); + try + { + if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) + m_xUndoManager->undo(); + else + m_xUndoManager->redo(); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // \-- } } @@ -122,13 +130,14 @@ void SAL_CALL UndoCommandDispatch::dispatch( /// is called when this is disposed void SAL_CALL UndoCommandDispatch::disposing() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); + Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + OSL_ENSURE( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); if( xBroadcaster.is() ) { xBroadcaster->removeModifyListener( this ); } - m_xDocumentActions.clear(); + m_xUndoManager.clear(); m_xModel.clear(); } @@ -136,7 +145,7 @@ void SAL_CALL UndoCommandDispatch::disposing() void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ ) throw (uno::RuntimeException) { - m_xDocumentActions.clear(); + m_xUndoManager.clear(); m_xModel.clear(); } diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx index 3130863dec61..891ab8b019e5 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.hxx +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -30,15 +30,12 @@ #include "CommandDispatch.hxx" #include -#include +#include namespace chart { /** This is a CommandDispatch implementation for Undo and Redo. - - You need to pass an DocumentActions to this class that is then used for Undo and - Redo. The changes are applied to the given XModel. */ class UndoCommandDispatch : public CommandDispatch { @@ -77,7 +74,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; + ::com::sun::star::document::XUndoManager > m_xUndoManager; }; } // namespace chart diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index e38bb89d9249..b89b463cc0eb 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -29,6 +29,11 @@ #include "precompiled_chart2.hxx" #include "UndoGuard.hxx" +#include "ImplDocumentActions.hxx" + +#include + +#include using namespace ::com::sun::star; @@ -39,99 +44,131 @@ using ::rtl::OUString; namespace chart { -UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString - , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) - : m_xDocumentActions( xDocumentActions ) - , m_aUndoString( rUndoString ) - , m_bActionPosted( false ) +//----------------------------------------------------------------------------- +namespace { + uno::Reference< uno::XInterface > lcl_getParent( const uno::Reference< uno::XInterface >& i_component ) + { + const uno::Reference< container::XChild > xAsChild( i_component, uno::UNO_QUERY_THROW ); + return xAsChild->getParent(); + } } +//----------------------------------------------------------------------------- + +UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager ) + :m_xChartModel( lcl_getParent( i_undoManager ), uno::UNO_QUERY_THROW ) + ,m_xUndoManager( i_undoManager ) + ,m_aUndoString( i_undoString ) + ,m_bActionPosted( false ) +{ +} + +//----------------------------------------------------------------------------- + UndoGuard_Base::~UndoGuard_Base() { + if ( !!m_pDocumentSnapshot ) + discardSnapshot(); } -void UndoGuard_Base::commitAction() +//----------------------------------------------------------------------------- + +void UndoGuard_Base::commit() { - if( !m_bActionPosted && m_xDocumentActions.is() ) - m_xDocumentActions->postAction( m_aUndoString ); + if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() ) + { + const Reference< document::XUndoAction > xAction( new impl::UndoElement( m_aUndoString, m_xChartModel, m_pDocumentSnapshot ) ); + m_pDocumentSnapshot.reset(); // don't dispose, it's data went over to the UndoElement + m_xUndoManager->addUndoAction( xAction ); + } m_bActionPosted = true; } //----------------------------------------------------------------------------- -UndoGuard::UndoGuard( const OUString& rUndoString - , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) - : UndoGuard_Base( rUndoString, xDocumentActions ) +void UndoGuard_Base::rollback() +{ + ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); + m_pDocumentSnapshot->applyToModel( m_xChartModel ); + discardSnapshot(); +} + +//----------------------------------------------------------------------------- + +void UndoGuard_Base::takeSnapshot( bool i_withData, bool i_withSelection ) { - if( m_xDocumentActions.is() ) - m_xDocumentActions->preAction(); + impl::ModelFacet eModelFacet( impl::E_MODEL ); + if ( i_withData ) + eModelFacet = impl::E_MODEL_WITH_DATA; + else if ( i_withSelection ) + eModelFacet = impl::E_MODEL_WITH_SELECTION; + m_pDocumentSnapshot.reset( new impl::ChartModelClone( m_xChartModel, eModelFacet ) ); +} + +//----------------------------------------------------------------------------- +void UndoGuard_Base::discardSnapshot() +{ + ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); + m_pDocumentSnapshot->dispose(); + m_pDocumentSnapshot.reset(); +} + +//----------------------------------------------------------------------------- + +UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard_Base( i_undoString, i_undoManager ) +{ + takeSnapshot( false, false ); } UndoGuard::~UndoGuard() { - if( !m_bActionPosted && m_xDocumentActions.is() ) - m_xDocumentActions->cancelAction(); + // nothing to do ... TODO: can this class be removed? } //----------------------------------------------------------------------------- -UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString - , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) - : UndoGuard_Base( rUndoString, xDocumentActions ) +UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard_Base( i_undoString, i_undoManager ) { - if( m_xDocumentActions.is() ) - m_xDocumentActions->preAction(); + takeSnapshot( false, false ); } UndoLiveUpdateGuard::~UndoLiveUpdateGuard() { - if( !m_bActionPosted && m_xDocumentActions.is() ) - m_xDocumentActions->cancelActionWithUndo(); + if ( !isActionPosted() ) + rollback(); } //----------------------------------------------------------------------------- -UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString - , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) - : UndoGuard_Base( rUndoString, xDocumentActions ) +UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( + const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard_Base( i_undoString, i_undoManager ) { - if( m_xDocumentActions.is() ) - { - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xDocumentActions->preActionWithArguments( aArgs ); - } + takeSnapshot( true, false ); } UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() { - if( !m_bActionPosted && m_xDocumentActions.is() ) - m_xDocumentActions->cancelActionWithUndo(); + if ( !isActionPosted() ) + rollback(); } //----------------------------------------------------------------------------- -UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString - , const uno::Reference< chart2::XDocumentActions > & xDocumentActions ) - : UndoGuard_Base( rUndoString, xDocumentActions ) +UndoGuardWithSelection::UndoGuardWithSelection( + const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard_Base( i_undoString, i_undoManager ) { - if( m_xDocumentActions.is() ) - { - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xDocumentActions->preActionWithArguments( aArgs ); - } + takeSnapshot( false, true ); } UndoGuardWithSelection::~UndoGuardWithSelection() { - if( !m_bActionPosted && m_xDocumentActions.is() ) - m_xDocumentActions->cancelAction(); + if ( !isActionPosted() ) + rollback(); } } // namespace chart diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index a90d1537b89b..b8bbd0615a76 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -73,7 +73,6 @@ SLOFILES = \ $(SLO)$/ShapeController.obj \ $(SLO)$/ShapeToolbarController.obj \ $(SLO)$/ImplDocumentActions.obj \ - $(SLO)$/DocumentActions.obj \ $(SLO)$/UndoGuard.obj # $(SLO)$/CommonConverters.obj \ diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index 9518d3362e84..7dbf0459d870 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/chart2/source/inc/DocumentActions.hxx b/chart2/source/inc/DocumentActions.hxx deleted file mode 100644 index 4cb6dc5d0f02..000000000000 --- a/chart2/source/inc/DocumentActions.hxx +++ /dev/null @@ -1,142 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_UNDOMANAGER_HXX -#define CHART2_UNDOMANAGER_HXX - -#include "MutexContainer.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// for pair -#include -// for auto_ptr -#include - -#include - -class SdrUndoAction; - -namespace com { namespace sun { namespace star { -namespace frame { - class XModel; -} -}}} - -namespace chart -{ -// ---------------------------------------- -namespace impl -{ - -class UndoStepsConfigItem; -class UndoElement; -class UndoStack; -class ChartModelClone; -class ModifyBroadcaster; - -typedef ::cppu::WeakComponentImplHelper3< - ::com::sun::star::util::XModifyBroadcaster, - ::com::sun::star::chart2::XDocumentActions, - ::com::sun::star::lang::XUnoTunnel > - DocumentActions_Base; - -} // namespace impl -// ---------------------------------------- - -/** Manages undo by storing the entire XModel in the undo- and redo-buffers. - Note, that therefore this should not be used for "big" XModels. - - A prerequisite for this to work is that the XModels added to the undo- - redo-stacks support the css::util::XCloneable interface, which is - implemented such that the entire model is cloned. - */ -class DocumentActions : - public MutexContainer, - public impl::DocumentActions_Base -{ -public: - explicit DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel ); - virtual ~DocumentActions(); - - void addShapeUndoAction( SdrUndoAction* pAction ); - - // ____ XUnoTunnel ____ - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) - throw (::com::sun::star::uno::RuntimeException); - - static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - static DocumentActions* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj ); - -protected: - // ____ util::XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - - // ____ chart2::XDocumentActions ____ - virtual void SAL_CALL preAction( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL preActionWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelAction( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelActionWithUndo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL undoPossible( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL redoPossible( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) throw (::com::sun::star::uno::RuntimeException); - -private: - void impl_fireModifyEvent(); - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > impl_getModel() const; - - ::boost::shared_ptr< impl::ChartModelClone > m_pDocumentSnapshot; - ::rtl::Reference< impl::ModifyBroadcaster > m_pModifyBroadcaster; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_aModel; - ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; -}; - -} // namespace chart - -// CHART2_UNDOMANAGER_HXX -#endif diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx index e36949bcdb18..e995e8ed0905 100644 --- a/chart2/source/inc/UndoGuard.hxx +++ b/chart2/source/inc/UndoGuard.hxx @@ -27,57 +27,77 @@ #ifndef CHART2_UNDOGUARD_HXX #define CHART2_UNDOGUARD_HXX -#include +#include +#include // header for class OUString #include +#include + namespace chart { + +namespace impl +{ + class ChartModelClone; +} + /** Base Class for UndoGuard and UndoLiveUpdateGuard */ class UndoGuard_Base { public: - explicit UndoGuard_Base( const rtl::OUString & rUndoMessage - , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); - virtual ~UndoGuard_Base(); + explicit UndoGuard_Base( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoGuard_Base(); - void commitAction(); + void commit(); + void rollback(); protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions; + void takeSnapshot( bool i_withData, bool i_withSelection ); + + bool isActionPosted() const { return m_bActionPosted; } + +private: + void discardSnapshot(); + +private: + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; - rtl::OUString m_aUndoString; - bool m_bActionPosted; + ::boost::shared_ptr< impl::ChartModelClone > m_pDocumentSnapshot; + rtl::OUString m_aUndoString; + bool m_bActionPosted; }; -/** This guard calls preAction at the given Model in the CTOR and - cancelAction in the DTOR if no other method is called. - If commitAction is called the destructor does nothin anymore. +/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it + does neither auto-commit nor auto-rollback the model changes. */ class UndoGuard : public UndoGuard_Base { public: - explicit UndoGuard( const rtl::OUString& rUndoMessage - , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); - virtual ~UndoGuard(); + explicit UndoGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoGuard(); }; -/** This guard calls preAction at the given Model in the CTOR and - cancelActionUndo in the DTOR if no other method is called. - If commitAction is called the destructor does nothin anymore. +/** A guard which, in its destructor, restores the model state it found in the constructor. If + commitAction is called inbetween, the restouration is not performed. */ class UndoLiveUpdateGuard : public UndoGuard_Base { public: - explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage - , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); - virtual ~UndoLiveUpdateGuard(); + explicit UndoLiveUpdateGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuard(); }; /** Same as UndoLiveUpdateGuard but with additional storage of the chart's data. @@ -87,18 +107,20 @@ class UndoLiveUpdateGuardWithData : public UndoGuard_Base { public: - explicit UndoLiveUpdateGuardWithData( const rtl::OUString& rUndoMessage - , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); - virtual ~UndoLiveUpdateGuardWithData(); + explicit UndoLiveUpdateGuardWithData( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuardWithData(); }; class UndoGuardWithSelection : public UndoGuard_Base { public: - explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage - , const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDocumentActions > & xDocumentActions ); + explicit UndoGuardWithSelection( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); virtual ~UndoGuardWithSelection(); }; diff --git a/chart2/source/inc/servicenames.hxx b/chart2/source/inc/servicenames.hxx index 98fd7cdf2db0..43de8c3485d8 100644 --- a/chart2/source/inc/servicenames.hxx +++ b/chart2/source/inc/servicenames.hxx @@ -62,8 +62,6 @@ namespace chart #define CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.ChartRenderer") -#define CHART_DOCUMENT_ACTIONS_SERVICE_NAME ::rtl::OUString::createFromAscii( "com.sun.star.chart2.DocumentActions" ) - //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 6ba450d76f5f..481f968f9488 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -155,7 +155,6 @@ ChartModel::ChartModel( const ChartModel & rOther ) , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector ) , m_xDataProvider( rOther.m_xDataProvider ) , m_xInternalDataProvider( rOther.m_xInternalDataProvider ) - , m_xDocumentActions( NULL ) { OSL_TRACE( "ChartModel: Copy-CTOR called" ); @@ -557,8 +556,6 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) m_pUndoManager.clear(); // that's important, since the UndoManager implementation delegates its ref counting to ourself. - m_xDocumentActions.clear(); - m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this ))); m_xCurrentController.clear(); @@ -1366,112 +1363,6 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent m_xParent.set( Parent, uno::UNO_QUERY ); } -bool ChartModel::impl_getDocumentActions_lck() -{ - if ( !m_xDocumentActions.is() ) - m_xDocumentActions.set( createInstance( CHART_DOCUMENT_ACTIONS_SERVICE_NAME ), uno::UNO_QUERY ); - OSL_POSTCOND( m_xDocumentActions.is(), "ChartModel::impl_getDocumentActions_lck: could not create the legacy DocumentActions service!" ); - return m_xDocumentActions.is(); -} - -// ____ XDocumentActions ____ -void SAL_CALL ChartModel::preAction( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->preAction(); -} - -void SAL_CALL ChartModel::preActionWithArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->preActionWithArguments( aArguments ); -} - -void SAL_CALL ChartModel::postAction( const ::rtl::OUString& aUndoText ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->postAction( aUndoText ); -} - -void SAL_CALL ChartModel::cancelAction( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->cancelAction(); -} - -void SAL_CALL ChartModel::cancelActionWithUndo( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->cancelActionWithUndo(); -} - -void SAL_CALL ChartModel::undo( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->undo(); -} - -void SAL_CALL ChartModel::redo( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - m_xDocumentActions->redo(); -} - -::sal_Bool SAL_CALL ChartModel::undoPossible( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->undoPossible(); - return sal_False; -} - -::sal_Bool SAL_CALL ChartModel::redoPossible( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->redoPossible(); - return sal_False; -} - -::rtl::OUString SAL_CALL ChartModel::getCurrentUndoString( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->getCurrentUndoString(); - return ::rtl::OUString(); -} - -::rtl::OUString SAL_CALL ChartModel::getCurrentRedoString( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->getCurrentRedoString(); - return ::rtl::OUString(); -} - -Sequence< ::rtl::OUString > SAL_CALL ChartModel::getAllUndoStrings( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->getAllUndoStrings(); - return Sequence< ::rtl::OUString >(); -} - -Sequence< ::rtl::OUString > SAL_CALL ChartModel::getAllRedoStrings( ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aModelMutex ); - if ( impl_getDocumentActions_lck() ) - return m_xDocumentActions->getAllRedoStrings(); - return Sequence< ::rtl::OUString >(); -} - // ____ XDataSource ____ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences() throw (uno::RuntimeException) diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 772640510400..6b59eda1b0f4 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -63,9 +62,9 @@ #include #include -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_20) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_20 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 20 #include "comphelper/implbase_var.hxx" #endif #include @@ -85,7 +84,7 @@ namespace impl { // Note: needed for queryInterface (if it calls the base-class implementation) -typedef ::comphelper::WeakImplHelper21< +typedef ::comphelper::WeakImplHelper20< // ::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) @@ -108,7 +107,6 @@ typedef ::comphelper::WeakImplHelper21< ,::com::sun::star::container::XChild ,::com::sun::star::util::XModifyListener ,::com::sun::star::datatransfer::XTransferable - ,::com::sun::star::chart2::XDocumentActions ,::com::sun::star::document::XDocumentPropertiesSupplier ,::com::sun::star::chart2::data::XDataSource ,::com::sun::star::document::XUndoManagerSupplier @@ -175,8 +173,6 @@ private: bool m_bIsDisposed; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xPageBackground; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > - m_xDocumentActions; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap; @@ -602,41 +598,9 @@ public: throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); - // ____ XDocumentActions ____ - virtual void SAL_CALL preAction( ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL preActionWithArguments( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelAction( ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelActionWithUndo( ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL undoPossible( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL redoPossible( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentUndoString( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getCurrentRedoString( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings( ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings( ) - throw (::com::sun::star::uno::RuntimeException); - // ____ XDataSource ____ allows access to the curently used data and data ranges virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() throw (::com::sun::star::uno::RuntimeException); - -private: - bool impl_getDocumentActions_lck(); }; } // namespace chart diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index 5ae57808b3c2..7260ac15987f 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -62,6 +62,7 @@ namespace chart using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::document::XUndoManagerListener; using ::com::sun::star::util::NotLockedException; + using ::com::sun::star::lang::NoSupportException; /** === end UNO using === **/ namespace impl @@ -381,6 +382,20 @@ namespace chart return m_pImpl->getUndoHelper().isLocked(); } + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL UndoManager::getParent( ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + return *&m_pImpl->getParent(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + (void)i_parent; + throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() ); + } //...................................................................................................................... } // namespace chart diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx index 4e6c2b0417cf..28f41afd6241 100755 --- a/chart2/source/model/main/UndoManager.hxx +++ b/chart2/source/model/main/UndoManager.hxx @@ -29,9 +29,10 @@ /** === begin UNO includes === **/ #include +#include /** === end UNO includes === **/ -#include +#include #include @@ -43,7 +44,8 @@ namespace chart namespace impl { class UndoManager_Impl; - typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager + typedef ::cppu::ImplHelper2 < ::com::sun::star::document::XUndoManager + , ::com::sun::star::container::XChild > UndoManager_Base; } @@ -87,6 +89,10 @@ namespace chart virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + private: ::boost::scoped_ptr< impl::UndoManager_Impl > m_pImpl; }; -- cgit From fa0b1d6e1d2850cae0cd11e33d662c8d8fad20a9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 12:22:48 +0100 Subject: undoapi: derive XUndoManager from XChild, to allow convenient access to the document it belongs to --- chart2/source/controller/main/UndoGuard.cxx | 18 ++++-------------- chart2/source/model/main/UndoManager.hxx | 7 +++---- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index b89b463cc0eb..1be8af4de180 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -44,23 +44,13 @@ using ::rtl::OUString; namespace chart { -//----------------------------------------------------------------------------- -namespace -{ - uno::Reference< uno::XInterface > lcl_getParent( const uno::Reference< uno::XInterface >& i_component ) - { - const uno::Reference< container::XChild > xAsChild( i_component, uno::UNO_QUERY_THROW ); - return xAsChild->getParent(); - } -} - //----------------------------------------------------------------------------- UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager ) - :m_xChartModel( lcl_getParent( i_undoManager ), uno::UNO_QUERY_THROW ) - ,m_xUndoManager( i_undoManager ) - ,m_aUndoString( i_undoString ) - ,m_bActionPosted( false ) + :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) + ,m_xUndoManager( i_undoManager ) + ,m_aUndoString( i_undoString ) + ,m_bActionPosted( false ) { } diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx index 28f41afd6241..9071a9010b47 100755 --- a/chart2/source/model/main/UndoManager.hxx +++ b/chart2/source/model/main/UndoManager.hxx @@ -32,7 +32,7 @@ #include /** === end UNO includes === **/ -#include +#include #include @@ -44,8 +44,7 @@ namespace chart namespace impl { class UndoManager_Impl; - typedef ::cppu::ImplHelper2 < ::com::sun::star::document::XUndoManager - , ::com::sun::star::container::XChild + typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager > UndoManager_Base; } @@ -89,7 +88,7 @@ namespace chart virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); - // XChild + // XChild (base of XUndoManager) virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); -- cgit From 2f09474ea14bf08a33e0788905a2a68bf5f93b2d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 13:10:17 +0100 Subject: undoapi: some cleanups after the previos refactoring (more to come) --- chart2/source/controller/dialogs/Strings.src | 4 + chart2/source/controller/main/ChartController.cxx | 2 +- .../controller/main/ChartController_TextEdit.cxx | 5 +- chart2/source/controller/main/ChartModelClone.cxx | 280 +++++++++++++++++++++ chart2/source/controller/main/ChartModelClone.hxx | 89 +++++++ .../source/controller/main/ImplDocumentActions.cxx | 211 +--------------- .../source/controller/main/ImplDocumentActions.hxx | 39 +-- chart2/source/controller/main/UndoGuard.cxx | 48 +--- chart2/source/controller/main/makefile.mk | 6 +- chart2/source/inc/Strings.hrc | 1 + chart2/source/inc/UndoGuard.hxx | 49 ++-- 11 files changed, 412 insertions(+), 322 deletions(-) create mode 100755 chart2/source/controller/main/ChartModelClone.cxx create mode 100755 chart2/source/controller/main/ChartModelClone.hxx (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 4b4cec65426e..3b46d4441a0b 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -463,6 +463,10 @@ String STR_ACTION_NOTPOSSIBLE { Text [ en-US ] = "This function cannot be completed with the selected objects." ; }; +String STR_ACTION_EDIT_TEXT +{ + Text [ en-US ] = "Edit text"; +}; String STR_COLUMN_LABEL { diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index cebb2a574838..7df48b757174 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -616,7 +616,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent m_pChartWindow->Invalidate(); uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); return sal_True; } diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 8069fd43f8cf..6d7844c1307c 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -29,6 +29,7 @@ #include "precompiled_chart2.hxx" #include "ChartController.hxx" +#include "ResId.hxx" #include "UndoGuard.hxx" #include "DrawViewWrapper.hxx" #include "ChartWindow.hxx" @@ -37,6 +38,7 @@ #include "macros.hxx" #include "ControllerLockGuard.hxx" #include "AccessibleTextHelper.hxx" +#include "Strings.hrc" #include "chartview/DrawModelWrapper.hxx" #include @@ -82,7 +84,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) return; OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" ); - m_pTextActionUndoGuard.reset( new UndoGuard( C2U( "Text Edit" ), m_xUndoManager ) ); + m_pTextActionUndoGuard.reset( new UndoGuard( + String( SchResId( STR_ACTION_EDIT_TEXT ) ), m_xUndoManager ) ); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx new file mode 100755 index 000000000000..f04f74ec72b1 --- /dev/null +++ b/chart2/source/controller/main/ChartModelClone.cxx @@ -0,0 +1,280 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" + +#include "ChartModelClone.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "DataSourceHelper.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::chart2::XChartDocument; + using ::com::sun::star::chart2::XInternalDataProvider; + using ::com::sun::star::chart::XComplexDescriptionAccess; + using ::com::sun::star::view::XSelectionSupplier; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::chart2::XTitled; + using ::com::sun::star::util::XModifiable; + using ::com::sun::star::chart2::data::XDataSource; + using ::com::sun::star::chart2::data::XLabeledDataSequence; + /** === end UNO using === **/ + + // ================================================================================================================= + // = helper + // ================================================================================================================= + namespace + { + Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) + { + Reference< XModel > xResult; + try + { + const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); + xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xResult; + } + + } + + // ================================================================================================================= + // = ChartModelClone + // ================================================================================================================= + // ----------------------------------------------------------------------------------------------------------------- + ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) + { + m_xModelClone.set( lcl_cloneModel( i_model ) ); + + try + { + if ( i_facet == E_MODEL_WITH_DATA ) + { + const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); + ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); + + const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + + if ( i_facet == E_MODEL_WITH_SELECTION ) + { + const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW ); + m_aSelection = xSelSupp->getSelection(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + + // ----------------------------------------------------------------------------------------------------------------- + ChartModelClone::~ChartModelClone() + { + if ( !impl_isDisposed() ) + dispose(); + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::dispose() + { + if ( impl_isDisposed() ) + return; + + try + { + Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); + xComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_xModelClone.clear(); + m_xDataClone.clear(); + m_aSelection.clear(); + } + + // ----------------------------------------------------------------------------------------------------------------- + ModelFacet ChartModelClone::getFacet() const + { + if ( m_aSelection.hasValue() ) + return E_MODEL_WITH_SELECTION; + if ( m_xDataClone.is() ) + return E_MODEL_WITH_DATA; + return E_MODEL; + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const + { + applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); + + if ( m_aSelection.hasValue() ) + { + try + { + Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW ); + xCurrentSelectionSuppl->select( m_aSelection ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + namespace + { + void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data ) + { + Reference< XChartDocument > xDoc( i_model, UNO_QUERY ); + OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() ); + + // copy data from stored internal data provider + if( xDoc.is() && xDoc->hasInternalDataProvider()) + { + Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY ); + Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY ); + if ( xCurrentData.is() && xSavedData.is() ) + { + xCurrentData->setData( xSavedData->getData() ); + xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() ); + xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() ); + } + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, + const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) + { + ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); + ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); + try + { + // /-- loccked controllers of destination + ControllerLockGuard aLockedControllers( i_model ); + Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); + Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); + + // propagate the correct flag for plotting of hidden values to the data provider and all used sequences + ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model ); + + // diagram + xDestination->setFirstDiagram( xSource->getFirstDiagram() ); + + // main title + Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); + Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); + xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); + + // page background + ::comphelper::copyProperties( + xSource->getPageBackground(), + xDestination->getPageBackground() ); + + // apply data (not applied in standard Undo) + if ( i_data.is() ) + ImplApplyDataToModel( i_model, i_data ); + + // register all sequences at the internal data provider to get adapted + // indexes when columns are added/removed + if ( xDestination->hasInternalDataProvider() ) + { + Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); + Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); + if ( xUsedData.is() && xNewDataProvider.is() ) + { + Sequence< Reference< XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); + for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues() ); + xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() ); + } + } + } + + // restore modify status + Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); + Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); + if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) + { + xDestMod->setModified( sal_False ); + } + // \-- loccked controllers of destination + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... diff --git a/chart2/source/controller/main/ChartModelClone.hxx b/chart2/source/controller/main/ChartModelClone.hxx new file mode 100755 index 000000000000..d5653b8e1ccc --- /dev/null +++ b/chart2/source/controller/main/ChartModelClone.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART2_CHARTMODELCLONE_HXX +#define CHART2_CHARTMODELCLONE_HXX + +/** === begin UNO includes === **/ +#include +#include +/** === end UNO includes === **/ + +#include + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + //================================================================================================================== + //= ModelFacet + //================================================================================================================== + enum ModelFacet + { + E_MODEL, + E_MODEL_WITH_DATA, + E_MODEL_WITH_SELECTION + }; + + //================================================================================================================== + //= ChartModelClone + //================================================================================================================== + class ChartModelClone : public ::boost::noncopyable + { + public: + ChartModelClone( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model, + const ModelFacet i_facet + ); + + ~ChartModelClone(); + + ModelFacet getFacet() const; + + void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const; + + static void applyModelContentToModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data ); + + void dispose(); + + private: + bool impl_isDisposed() const { return !m_xModelClone.is(); } + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone; + ::com::sun::star::uno::Any m_aSelection; + }; + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... + +#endif // CHART2_CHARTMODELCLONE_HXX diff --git a/chart2/source/controller/main/ImplDocumentActions.cxx b/chart2/source/controller/main/ImplDocumentActions.cxx index f477052908ff..a565c81dad56 100644 --- a/chart2/source/controller/main/ImplDocumentActions.cxx +++ b/chart2/source/controller/main/ImplDocumentActions.cxx @@ -31,17 +31,11 @@ #include "ImplDocumentActions.hxx" #include "DisposeHelper.hxx" #include "CommonFunctors.hxx" -#include "ControllerLockGuard.hxx" #include "PropertyHelper.hxx" -#include "DataSourceHelper.hxx" -#include "ChartModelHelper.hxx" +#include "ChartModelClone.hxx" -#include #include -#include -#include #include -#include #include #include @@ -78,212 +72,9 @@ namespace impl using ::com::sun::star::lang::DisposedException; using ::com::sun::star::view::XSelectionSupplier; using ::com::sun::star::chart2::XChartDocument; - using ::com::sun::star::chart::XComplexDescriptionAccess; - using ::com::sun::star::chart2::XTitled; - using ::com::sun::star::chart2::XInternalDataProvider; - using ::com::sun::star::util::XModifiable; using ::com::sun::star::document::UndoFailedException; /** === end UNO using === **/ -// ===================================================================================================================== -// = helper -// ===================================================================================================================== -namespace -{ - Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) - { - Reference< XModel > xResult; - try - { - const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); - xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return xResult; - } - -} - -// ===================================================================================================================== -// = ChartModelClone -// ===================================================================================================================== - -// --------------------------------------------------------------------------------------------------------------------- -ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) -{ - m_xModelClone.set( lcl_cloneModel( i_model ) ); - - try - { - if ( i_facet == E_MODEL_WITH_DATA ) - { - const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); - ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); - - const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); - m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); - } - - if ( i_facet == E_MODEL_WITH_SELECTION ) - { - const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW ); - m_aSelection = xSelSupp->getSelection(); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - - -// --------------------------------------------------------------------------------------------------------------------- -ChartModelClone::~ChartModelClone() -{ - if ( !impl_isDisposed() ) - dispose(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void ChartModelClone::dispose() -{ - if ( impl_isDisposed() ) - return; - - try - { - Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); - xComp->dispose(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - m_xModelClone.clear(); - m_xDataClone.clear(); - m_aSelection.clear(); -} - -// --------------------------------------------------------------------------------------------------------------------- -ModelFacet ChartModelClone::getFacet() const -{ - if ( m_aSelection.hasValue() ) - return E_MODEL_WITH_SELECTION; - if ( m_xDataClone.is() ) - return E_MODEL_WITH_DATA; - return E_MODEL; -} - -// --------------------------------------------------------------------------------------------------------------------- -void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const -{ - applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); - - if ( m_aSelection.hasValue() ) - { - try - { - Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW ); - xCurrentSelectionSuppl->select( m_aSelection ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } -} - -// --------------------------------------------------------------------------------------------------------------------- -namespace -{ - void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data ) - { - Reference< XChartDocument > xDoc( i_model, UNO_QUERY ); - OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() ); - - // copy data from stored internal data provider - if( xDoc.is() && xDoc->hasInternalDataProvider()) - { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY ); - if ( xCurrentData.is() && xSavedData.is() ) - { - xCurrentData->setData( xSavedData->getData() ); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() ); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() ); - } - } - } -} - -// --------------------------------------------------------------------------------------------------------------------- -void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, - const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) -{ - ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); - ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); - try - { - // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( i_model ); - Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); - Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); - - // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model ); - - // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram() ); - - // main title - Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); - Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); - - // page background - ::comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); - - // apply data (not applied in standard Undo) - if ( i_data.is() ) - ImplApplyDataToModel( i_model, i_data ); - - // register all sequences at the internal data provider to get adapted - // indexes when columns are added/removed - if ( xDestination->hasInternalDataProvider() ) - { - Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); - if ( xUsedData.is() && xNewDataProvider.is() ) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); - for( sal_Int32 i=0; iregisterDataSequenceForChanges( aData[i]->getValues() ); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() ); - } - } - } - - // restore modify status - Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); - Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); - if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) - { - xDestMod->setModified( sal_False ); - } - // \-- loccked controllers of destination - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - // --------------------------------------------------------------------------------------------------------------------- UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) :UndoElement_MBase() diff --git a/chart2/source/controller/main/ImplDocumentActions.hxx b/chart2/source/controller/main/ImplDocumentActions.hxx index 889968dfe4c7..2c98d6af1d54 100644 --- a/chart2/source/controller/main/ImplDocumentActions.hxx +++ b/chart2/source/controller/main/ImplDocumentActions.hxx @@ -55,45 +55,10 @@ namespace chart2 { namespace chart { -namespace impl -{ - -enum ModelFacet -{ - E_MODEL, - E_MODEL_WITH_DATA, - E_MODEL_WITH_SELECTION -}; +class ChartModelClone; -class ChartModelClone : public ::boost::noncopyable +namespace impl { -public: - ChartModelClone( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model, - const ModelFacet i_facet - ); - - ~ChartModelClone(); - - ModelFacet getFacet() const; - - void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const; - - static void applyModelContentToModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom, - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data ); - - void dispose(); - -private: - bool impl_isDisposed() const { return !m_xModelClone.is(); } - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone; - ::com::sun::star::uno::Any m_aSelection; -}; typedef ::cppu::BaseMutex UndoElement_MBase; typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index 1be8af4de180..e331aee3a762 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -29,6 +29,7 @@ #include "precompiled_chart2.hxx" #include "UndoGuard.hxx" +#include "ChartModelClone.hxx" #include "ImplDocumentActions.hxx" #include @@ -46,17 +47,20 @@ namespace chart //----------------------------------------------------------------------------- -UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager ) +UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager, + const ModelFacet i_facet ) :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) ,m_xUndoManager( i_undoManager ) + ,m_pDocumentSnapshot() ,m_aUndoString( i_undoString ) ,m_bActionPosted( false ) { + m_pDocumentSnapshot.reset( new ChartModelClone( m_xChartModel, i_facet ) ); } //----------------------------------------------------------------------------- -UndoGuard_Base::~UndoGuard_Base() +UndoGuard::~UndoGuard() { if ( !!m_pDocumentSnapshot ) discardSnapshot(); @@ -64,7 +68,7 @@ UndoGuard_Base::~UndoGuard_Base() //----------------------------------------------------------------------------- -void UndoGuard_Base::commit() +void UndoGuard::commit() { if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() ) { @@ -77,7 +81,7 @@ void UndoGuard_Base::commit() //----------------------------------------------------------------------------- -void UndoGuard_Base::rollback() +void UndoGuard::rollback() { ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); m_pDocumentSnapshot->applyToModel( m_xChartModel ); @@ -85,19 +89,7 @@ void UndoGuard_Base::rollback() } //----------------------------------------------------------------------------- - -void UndoGuard_Base::takeSnapshot( bool i_withData, bool i_withSelection ) -{ - impl::ModelFacet eModelFacet( impl::E_MODEL ); - if ( i_withData ) - eModelFacet = impl::E_MODEL_WITH_DATA; - else if ( i_withSelection ) - eModelFacet = impl::E_MODEL_WITH_SELECTION; - m_pDocumentSnapshot.reset( new impl::ChartModelClone( m_xChartModel, eModelFacet ) ); -} - -//----------------------------------------------------------------------------- -void UndoGuard_Base::discardSnapshot() +void UndoGuard::discardSnapshot() { ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); m_pDocumentSnapshot->dispose(); @@ -106,23 +98,9 @@ void UndoGuard_Base::discardSnapshot() //----------------------------------------------------------------------------- -UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) - :UndoGuard_Base( i_undoString, i_undoManager ) -{ - takeSnapshot( false, false ); -} - -UndoGuard::~UndoGuard() -{ - // nothing to do ... TODO: can this class be removed? -} - -//----------------------------------------------------------------------------- - UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) - :UndoGuard_Base( i_undoString, i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL ) { - takeSnapshot( false, false ); } UndoLiveUpdateGuard::~UndoLiveUpdateGuard() @@ -135,9 +113,8 @@ UndoLiveUpdateGuard::~UndoLiveUpdateGuard() UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) - :UndoGuard_Base( i_undoString, i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_DATA ) { - takeSnapshot( true, false ); } UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() @@ -150,9 +127,8 @@ UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() UndoGuardWithSelection::UndoGuardWithSelection( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) - :UndoGuard_Base( i_undoString, i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_SELECTION ) { - takeSnapshot( false, true ); } UndoGuardWithSelection::~UndoGuardWithSelection() diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index b8bbd0615a76..af2dbcb39c8d 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -73,10 +73,8 @@ SLOFILES = \ $(SLO)$/ShapeController.obj \ $(SLO)$/ShapeToolbarController.obj \ $(SLO)$/ImplDocumentActions.obj \ - $(SLO)$/UndoGuard.obj - -# $(SLO)$/CommonConverters.obj \ -# $(SLO)$/Scaling.obj \ + $(SLO)$/UndoGuard.obj \ + $(SLO)$/ChartModelClone.obj \ # --- Targets ----------------------------------------------------------------- diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index 47ed75e80a9a..204133bd1cd5 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -310,6 +310,7 @@ #define STR_ACTION_TOGGLE_GRID_HORZ (RID_APP_START + 86) #define STR_ACTION_SCALE_TEXT (RID_APP_START + 93) #define STR_ACTION_REARRANGE_CHART (RID_APP_START + 94) +#define STR_ACTION_EDIT_TEXT (RID_APP_START + 95) #define STR_TIP_CHOOSECOLOR (RID_APP_START + 233) #define STR_TIP_LIGHTSOURCE_X (RID_APP_START + 234) diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx index e995e8ed0905..6040d7472329 100644 --- a/chart2/source/inc/UndoGuard.hxx +++ b/chart2/source/inc/UndoGuard.hxx @@ -27,10 +27,11 @@ #ifndef CHART2_UNDOGUARD_HXX #define CHART2_UNDOGUARD_HXX +#include "ChartModelClone.hxx" + #include #include -// header for class OUString #include #include @@ -38,28 +39,23 @@ namespace chart { -namespace impl -{ - class ChartModelClone; -} - -/** Base Class for UndoGuard and UndoLiveUpdateGuard -*/ -class UndoGuard_Base +/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it + does neither auto-commit nor auto-rollback the model changes. + */ +class UndoGuard { public: - explicit UndoGuard_Base( + explicit UndoGuard( const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, + const ModelFacet i_facet = E_MODEL ); - ~UndoGuard_Base(); + ~UndoGuard(); void commit(); void rollback(); protected: - void takeSnapshot( bool i_withData, bool i_withSelection ); - bool isActionPosted() const { return m_bActionPosted; } private: @@ -69,28 +65,15 @@ private: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; - ::boost::shared_ptr< impl::ChartModelClone > m_pDocumentSnapshot; - rtl::OUString m_aUndoString; - bool m_bActionPosted; -}; - -/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it - does neither auto-commit nor auto-rollback the model changes. - */ -class UndoGuard : public UndoGuard_Base -{ -public: - explicit UndoGuard( - const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager - ); - ~UndoGuard(); + ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot; + rtl::OUString m_aUndoString; + bool m_bActionPosted; }; /** A guard which, in its destructor, restores the model state it found in the constructor. If commitAction is called inbetween, the restouration is not performed. */ -class UndoLiveUpdateGuard : public UndoGuard_Base +class UndoLiveUpdateGuard : public UndoGuard { public: explicit UndoLiveUpdateGuard( @@ -104,7 +87,7 @@ public: Only use this if the data has internal data. */ class UndoLiveUpdateGuardWithData : - public UndoGuard_Base + public UndoGuard { public: explicit UndoLiveUpdateGuardWithData( @@ -114,7 +97,7 @@ public: ~UndoLiveUpdateGuardWithData(); }; -class UndoGuardWithSelection : public UndoGuard_Base +class UndoGuardWithSelection : public UndoGuard { public: explicit UndoGuardWithSelection( -- cgit From d2de048b2b685ab3376b8f85d3d51e95fca7b80b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 13:20:01 +0100 Subject: undoapi: moved UndoGuard.hxx to the only folder where it is used, renamed ImplDocumentActions.* to UndoActions.* --- chart2/source/controller/main/ChartController.cxx | 2 +- .../source/controller/main/ImplDocumentActions.cxx | 178 --------------------- .../source/controller/main/ImplDocumentActions.hxx | 134 ---------------- chart2/source/controller/main/UndoActions.cxx | 178 +++++++++++++++++++++ chart2/source/controller/main/UndoActions.hxx | 134 ++++++++++++++++ chart2/source/controller/main/UndoGuard.cxx | 2 +- chart2/source/controller/main/UndoGuard.hxx | 112 +++++++++++++ chart2/source/controller/main/makefile.mk | 2 +- chart2/source/inc/UndoGuard.hxx | 112 ------------- 9 files changed, 427 insertions(+), 427 deletions(-) delete mode 100644 chart2/source/controller/main/ImplDocumentActions.cxx delete mode 100644 chart2/source/controller/main/ImplDocumentActions.hxx create mode 100644 chart2/source/controller/main/UndoActions.cxx create mode 100644 chart2/source/controller/main/UndoActions.hxx create mode 100644 chart2/source/controller/main/UndoGuard.hxx delete mode 100644 chart2/source/inc/UndoGuard.hxx (limited to 'chart2') diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 7df48b757174..1acf71c17fff 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -52,7 +52,7 @@ #include "AccessibleChartView.hxx" #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" -#include "ImplDocumentActions.hxx" +#include "UndoActions.hxx" #include diff --git a/chart2/source/controller/main/ImplDocumentActions.cxx b/chart2/source/controller/main/ImplDocumentActions.cxx deleted file mode 100644 index a565c81dad56..000000000000 --- a/chart2/source/controller/main/ImplDocumentActions.cxx +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "ImplDocumentActions.hxx" -#include "DisposeHelper.hxx" -#include "CommonFunctors.hxx" -#include "PropertyHelper.hxx" -#include "ChartModelClone.hxx" - -#include -#include -#include -#include - -#include -#include - -#include -#include - -using namespace ::com::sun::star; - -using ::rtl::OUString; - -namespace chart -{ -namespace impl -{ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Type; - using ::com::sun::star::frame::XModel; - using ::com::sun::star::util::XCloneable; - using ::com::sun::star::lang::XComponent; - using ::com::sun::star::lang::DisposedException; - using ::com::sun::star::view::XSelectionSupplier; - using ::com::sun::star::chart2::XChartDocument; - using ::com::sun::star::document::UndoFailedException; - /** === end UNO using === **/ - -// --------------------------------------------------------------------------------------------------------------------- -UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) - :UndoElement_MBase() - ,UndoElement_TBase( m_aMutex ) - ,m_sActionString( i_actionString ) - ,m_xDocumentModel( i_documentModel ) - ,m_pModelClone( i_modelClone ) -{ -} - -// --------------------------------------------------------------------------------------------------------------------- -UndoElement::~UndoElement() -{ -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UndoElement::disposing() -{ - if ( !!m_pModelClone ) - m_pModelClone->dispose(); - m_pModelClone.reset(); - m_xDocumentModel.clear(); -} - -// --------------------------------------------------------------------------------------------------------------------- -::rtl::OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException) -{ - return m_sActionString; -} - -// --------------------------------------------------------------------------------------------------------------------- -void UndoElement::impl_toggleModelState() -{ - // get a snapshot of the current state of our model - ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) ); - // apply the previous snapshot to our model - m_pModelClone->applyToModel( m_xDocumentModel ); - // remember the new snapshot, for the next toggle - m_pModelClone = pNewClone; -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException) -{ - impl_toggleModelState(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException) -{ - impl_toggleModelState(); -} - -// ===================================================================================================================== -// = ShapeUndoElement -// ===================================================================================================================== - -// --------------------------------------------------------------------------------------------------------------------- -ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ) - :ShapeUndoElement_MBase() - ,ShapeUndoElement_TBase( m_aMutex ) - ,m_pAction( &i_sdrUndoAction ) -{ -} - -// --------------------------------------------------------------------------------------------------------------------- -ShapeUndoElement::~ShapeUndoElement() -{ -} - -// --------------------------------------------------------------------------------------------------------------------- -::rtl::OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException) -{ - if ( !m_pAction ) - throw DisposedException( ::rtl::OUString(), *this ); - return m_pAction->GetComment(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException) -{ - if ( !m_pAction ) - throw DisposedException( ::rtl::OUString(), *this ); - m_pAction->Undo(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException) -{ - if ( !m_pAction ) - throw DisposedException( ::rtl::OUString(), *this ); - m_pAction->Redo(); -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL ShapeUndoElement::disposing() -{ -} - -} // namespace impl -} // namespace chart diff --git a/chart2/source/controller/main/ImplDocumentActions.hxx b/chart2/source/controller/main/ImplDocumentActions.hxx deleted file mode 100644 index 2c98d6af1d54..000000000000 --- a/chart2/source/controller/main/ImplDocumentActions.hxx +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_IMPLUNDOMANAGER_HXX -#define CHART2_IMPLUNDOMANAGER_HXX - -#include "ConfigItemListener.hxx" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -class SdrUndoAction; - -namespace com { namespace sun { namespace star { -namespace chart2 { - class XInternalDataProvider; -} -}}} - - -namespace chart -{ -class ChartModelClone; - -namespace impl -{ - -typedef ::cppu::BaseMutex UndoElement_MBase; -typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; - -class UndoElement :public UndoElement_MBase - ,public UndoElement_TBase - ,public ::boost::noncopyable -{ -public: - /** creates a new undo action - - @param i_actionString - is the title of the Undo action - @param i_documentModel - is the actual document model which the undo actions operates on - @param i_modelClone - is the cloned model from before the changes, which the Undo action represents, have been applied. - Upon invoking, the clone model is applied to the document model. - */ - UndoElement( const ::rtl::OUString & i_actionString, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel, - const ::boost::shared_ptr< ChartModelClone >& i_modelClone - ); - - // XUndoAction - virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - -protected: - virtual ~UndoElement(); - -private: - void impl_toggleModelState(); - -private: - ::rtl::OUString m_sActionString; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel; - ::boost::shared_ptr< ChartModelClone > m_pModelClone; -}; - - -typedef ::cppu::BaseMutex ShapeUndoElement_MBase; -typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase; -class ShapeUndoElement :public ShapeUndoElement_MBase - ,public ShapeUndoElement_TBase -{ -public: - ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ); - - // XUndoAction - virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - -protected: - virtual ~ShapeUndoElement(); - -private: - SdrUndoAction* m_pAction; -}; - -} // namespace impl -} // namespace chart - -// CHART2_IMPLUNDOMANAGER_HXX -#endif diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx new file mode 100644 index 000000000000..86c0e365f590 --- /dev/null +++ b/chart2/source/controller/main/UndoActions.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "UndoActions.hxx" +#include "DisposeHelper.hxx" +#include "CommonFunctors.hxx" +#include "PropertyHelper.hxx" +#include "ChartModelClone.hxx" + +#include +#include +#include +#include + +#include +#include + +#include +#include + +using namespace ::com::sun::star; + +using ::rtl::OUString; + +namespace chart +{ +namespace impl +{ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::view::XSelectionSupplier; + using ::com::sun::star::chart2::XChartDocument; + using ::com::sun::star::document::UndoFailedException; + /** === end UNO using === **/ + +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) + :UndoElement_MBase() + ,UndoElement_TBase( m_aMutex ) + ,m_sActionString( i_actionString ) + ,m_xDocumentModel( i_documentModel ) + ,m_pModelClone( i_modelClone ) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::~UndoElement() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::disposing() +{ + if ( !!m_pModelClone ) + m_pModelClone->dispose(); + m_pModelClone.reset(); + m_xDocumentModel.clear(); +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException) +{ + return m_sActionString; +} + +// --------------------------------------------------------------------------------------------------------------------- +void UndoElement::impl_toggleModelState() +{ + // get a snapshot of the current state of our model + ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) ); + // apply the previous snapshot to our model + m_pModelClone->applyToModel( m_xDocumentModel ); + // remember the new snapshot, for the next toggle + m_pModelClone = pNewClone; +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException) +{ + impl_toggleModelState(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException) +{ + impl_toggleModelState(); +} + +// ===================================================================================================================== +// = ShapeUndoElement +// ===================================================================================================================== + +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ) + :ShapeUndoElement_MBase() + ,ShapeUndoElement_TBase( m_aMutex ) + ,m_pAction( &i_sdrUndoAction ) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::~ShapeUndoElement() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_pAction->GetComment(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + m_pAction->Undo(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + m_pAction->Redo(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::disposing() +{ +} + +} // namespace impl +} // namespace chart diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx new file mode 100644 index 000000000000..2c98d6af1d54 --- /dev/null +++ b/chart2/source/controller/main/UndoActions.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_IMPLUNDOMANAGER_HXX +#define CHART2_IMPLUNDOMANAGER_HXX + +#include "ConfigItemListener.hxx" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +class SdrUndoAction; + +namespace com { namespace sun { namespace star { +namespace chart2 { + class XInternalDataProvider; +} +}}} + + +namespace chart +{ +class ChartModelClone; + +namespace impl +{ + +typedef ::cppu::BaseMutex UndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; + +class UndoElement :public UndoElement_MBase + ,public UndoElement_TBase + ,public ::boost::noncopyable +{ +public: + /** creates a new undo action + + @param i_actionString + is the title of the Undo action + @param i_documentModel + is the actual document model which the undo actions operates on + @param i_modelClone + is the cloned model from before the changes, which the Undo action represents, have been applied. + Upon invoking, the clone model is applied to the document model. + */ + UndoElement( const ::rtl::OUString & i_actionString, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel, + const ::boost::shared_ptr< ChartModelClone >& i_modelClone + ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +protected: + virtual ~UndoElement(); + +private: + void impl_toggleModelState(); + +private: + ::rtl::OUString m_sActionString; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel; + ::boost::shared_ptr< ChartModelClone > m_pModelClone; +}; + + +typedef ::cppu::BaseMutex ShapeUndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase; +class ShapeUndoElement :public ShapeUndoElement_MBase + ,public ShapeUndoElement_TBase +{ +public: + ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +protected: + virtual ~ShapeUndoElement(); + +private: + SdrUndoAction* m_pAction; +}; + +} // namespace impl +} // namespace chart + +// CHART2_IMPLUNDOMANAGER_HXX +#endif diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index e331aee3a762..97418e725140 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -30,7 +30,7 @@ #include "UndoGuard.hxx" #include "ChartModelClone.hxx" -#include "ImplDocumentActions.hxx" +#include "UndoActions.hxx" #include diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx new file mode 100644 index 000000000000..6040d7472329 --- /dev/null +++ b/chart2/source/controller/main/UndoGuard.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_UNDOGUARD_HXX +#define CHART2_UNDOGUARD_HXX + +#include "ChartModelClone.hxx" + +#include +#include + +#include + +#include + +namespace chart +{ + +/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it + does neither auto-commit nor auto-rollback the model changes. + */ +class UndoGuard +{ +public: + explicit UndoGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, + const ModelFacet i_facet = E_MODEL + ); + ~UndoGuard(); + + void commit(); + void rollback(); + +protected: + bool isActionPosted() const { return m_bActionPosted; } + +private: + void discardSnapshot(); + +private: + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; + + ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot; + rtl::OUString m_aUndoString; + bool m_bActionPosted; +}; + +/** A guard which, in its destructor, restores the model state it found in the constructor. If + commitAction is called inbetween, the restouration is not performed. + */ +class UndoLiveUpdateGuard : public UndoGuard +{ +public: + explicit UndoLiveUpdateGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuard(); +}; + +/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data. + Only use this if the data has internal data. + */ +class UndoLiveUpdateGuardWithData : + public UndoGuard +{ +public: + explicit UndoLiveUpdateGuardWithData( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuardWithData(); +}; + +class UndoGuardWithSelection : public UndoGuard +{ +public: + explicit UndoGuardWithSelection( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + virtual ~UndoGuardWithSelection(); +}; + +} +// CHART2_UNDOGUARD_HXX +#endif diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index af2dbcb39c8d..557d6cf6216f 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -72,7 +72,7 @@ SLOFILES = \ $(SLO)$/DrawCommandDispatch.obj \ $(SLO)$/ShapeController.obj \ $(SLO)$/ShapeToolbarController.obj \ - $(SLO)$/ImplDocumentActions.obj \ + $(SLO)$/UndoActions.obj \ $(SLO)$/UndoGuard.obj \ $(SLO)$/ChartModelClone.obj \ diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx deleted file mode 100644 index 6040d7472329..000000000000 --- a/chart2/source/inc/UndoGuard.hxx +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_UNDOGUARD_HXX -#define CHART2_UNDOGUARD_HXX - -#include "ChartModelClone.hxx" - -#include -#include - -#include - -#include - -namespace chart -{ - -/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it - does neither auto-commit nor auto-rollback the model changes. - */ -class UndoGuard -{ -public: - explicit UndoGuard( - const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, - const ModelFacet i_facet = E_MODEL - ); - ~UndoGuard(); - - void commit(); - void rollback(); - -protected: - bool isActionPosted() const { return m_bActionPosted; } - -private: - void discardSnapshot(); - -private: - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; - - ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot; - rtl::OUString m_aUndoString; - bool m_bActionPosted; -}; - -/** A guard which, in its destructor, restores the model state it found in the constructor. If - commitAction is called inbetween, the restouration is not performed. - */ -class UndoLiveUpdateGuard : public UndoGuard -{ -public: - explicit UndoLiveUpdateGuard( - const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager - ); - ~UndoLiveUpdateGuard(); -}; - -/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data. - Only use this if the data has internal data. - */ -class UndoLiveUpdateGuardWithData : - public UndoGuard -{ -public: - explicit UndoLiveUpdateGuardWithData( - const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager - ); - ~UndoLiveUpdateGuardWithData(); -}; - -class UndoGuardWithSelection : public UndoGuard -{ -public: - explicit UndoGuardWithSelection( - const ::rtl::OUString& i_undoMessage, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager - ); - virtual ~UndoGuardWithSelection(); -}; - -} -// CHART2_UNDOGUARD_HXX -#endif -- cgit From fd3ece0777004f5438cf6a352fefb7270228f6d7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 13:22:05 +0100 Subject: undoapi: some exception safety --- chart2/source/controller/main/UndoGuard.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index 97418e725140..b2a02aaa3522 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -70,11 +70,18 @@ UndoGuard::~UndoGuard() void UndoGuard::commit() { - if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() ) + if ( !m_bActionPosted && !!m_pDocumentSnapshot ) { - const Reference< document::XUndoAction > xAction( new impl::UndoElement( m_aUndoString, m_xChartModel, m_pDocumentSnapshot ) ); - m_pDocumentSnapshot.reset(); // don't dispose, it's data went over to the UndoElement - m_xUndoManager->addUndoAction( xAction ); + try + { + const Reference< document::XUndoAction > xAction( new impl::UndoElement( m_aUndoString, m_xChartModel, m_pDocumentSnapshot ) ); + m_pDocumentSnapshot.reset(); // don't dispose, it's data went over to the UndoElement + m_xUndoManager->addUndoAction( xAction ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } m_bActionPosted = true; } -- cgit From 5854c96421fe2a2320b36ae570c987392c235e9a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 14:12:33 +0100 Subject: undoapi: re-implemented the XModifyBroadcaster for chart's UndoManager, for this purpose, added support to the UndoManagerHelper --- chart2/source/model/main/ChartModel.cxx | 3 +++ chart2/source/model/main/UndoManager.cxx | 27 +++++++++++++++++++++------ chart2/source/model/main/UndoManager.hxx | 10 ++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'chart2') diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 481f968f9488..95da8c778ead 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -538,6 +538,9 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) //--release all resources and references //// @todo + if ( m_xDiagram.is() ) + ModifyListenerHelper::removeListener( m_xDiagram, this ); + m_xDataProvider.clear(); m_xInternalDataProvider.clear(); m_xNumberFormatsSupplier.clear(); diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index 7260ac15987f..98b63012c737 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -63,6 +63,7 @@ namespace chart using ::com::sun::star::document::XUndoManagerListener; using ::com::sun::star::util::NotLockedException; using ::com::sun::star::lang::NoSupportException; + using ::com::sun::star::util::XModifyListener; /** === end UNO using === **/ namespace impl @@ -108,13 +109,13 @@ namespace chart void checkDisposed_lck(); private: - UndoManager& m_rAntiImpl; - ::cppu::OWeakObject& m_rParent; - ::osl::Mutex& m_rMutex; - bool m_bDisposed; + UndoManager& m_rAntiImpl; + ::cppu::OWeakObject& m_rParent; + ::osl::Mutex& m_rMutex; + bool m_bDisposed; - SfxUndoManager m_aUndoManager; - ::framework::UndoManagerHelper m_aUndoHelper; + SfxUndoManager m_aUndoManager; + ::framework::UndoManagerHelper m_aUndoHelper; }; //-------------------------------------------------------------------------------------------------------------- @@ -397,6 +398,20 @@ namespace chart throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() ); } + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::addModifyListener( const Reference< XModifyListener >& i_listener ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().addModifyListener( i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL UndoManager::removeModifyListener( const Reference< XModifyListener >& i_listener ) throw (RuntimeException) + { + UndoManagerMethodGuard aGuard( *m_pImpl ); + m_pImpl->getUndoHelper().removeModifyListener( i_listener ); + } + //...................................................................................................................... } // namespace chart //...................................................................................................................... diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx index 9071a9010b47..07091207ebd0 100755 --- a/chart2/source/model/main/UndoManager.hxx +++ b/chart2/source/model/main/UndoManager.hxx @@ -29,10 +29,11 @@ /** === begin UNO includes === **/ #include +#include #include /** === end UNO includes === **/ -#include +#include #include @@ -44,7 +45,8 @@ namespace chart namespace impl { class UndoManager_Impl; - typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager + typedef ::cppu::ImplHelper2 < ::com::sun::star::document::XUndoManager + , ::com::sun::star::util::XModifyBroadcaster > UndoManager_Base; } @@ -92,6 +94,10 @@ namespace chart virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + private: ::boost::scoped_ptr< impl::UndoManager_Impl > m_pImpl; }; -- cgit From 247ba6c56c0bf4e27744b2b895411247420bebcf Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 14:27:42 +0100 Subject: undoapi: undo/redo: call ChartViewHelper::setViewToDirtyState (was still left after the refactoring) --- chart2/source/model/main/UndoManager.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'chart2') diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index 98b63012c737..b88f40307d8a 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -27,6 +27,7 @@ #include "precompiled_chart2.hxx" #include "UndoManager.hxx" +#include "ChartViewHelper.hxx" /** === begin UNO includes === **/ #include @@ -64,6 +65,7 @@ namespace chart using ::com::sun::star::util::NotLockedException; using ::com::sun::star::lang::NoSupportException; using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::frame::XModel; /** === end UNO using === **/ namespace impl @@ -276,6 +278,8 @@ namespace chart { UndoManagerMethodGuard aGuard( *m_pImpl ); m_pImpl->getUndoHelper().undo( aGuard ); + + ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) ); } //------------------------------------------------------------------------------------------------------------------ @@ -283,6 +287,8 @@ namespace chart { UndoManagerMethodGuard aGuard( *m_pImpl ); m_pImpl->getUndoHelper().redo( aGuard ); + + ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) ); } //------------------------------------------------------------------------------------------------------------------ -- cgit From ec5f9c18235b50d564da5e23d99d4844667db5b1 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 15:38:33 +0100 Subject: undoapi: respect the config limiting the maximum number of undo actions. No life-update anymore, i.e. changes in this setting are respected by new instances only, not by existing instances. This is a degradation (a bearable, IMO) compared to the old implementation, but consistent with other apps. So, why adding unnecessary complexity? --- chart2/source/model/main/UndoManager.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'chart2') diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index b88f40307d8a..8e9ee25fa0c5 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -35,6 +35,7 @@ #include #include +#include //...................................................................................................................... namespace chart @@ -84,6 +85,7 @@ namespace chart ,m_aUndoManager() ,m_aUndoHelper( *this ) { + m_aUndoManager.SetMaxUndoActionCount( (USHORT)SvtUndoOptions().GetUndoCount() ); } virtual ~UndoManager_Impl() -- cgit From cbcedd66765bb932cb60c98f0fa60f3beecca270 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 19:31:36 +0100 Subject: undoapi: updated the Chart test backend --- chart2/source/controller/main/UndoCommandDispatch.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 92a4a469ff1b..b2252c1cae3c 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -59,7 +59,7 @@ UndoCommandDispatch::UndoCommandDispatch( m_xModel( xModel ) { uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -118,6 +118,10 @@ void SAL_CALL UndoCommandDispatch::dispatch( else m_xUndoManager->redo(); } + catch( const document::UndoFailedException& ) + { + // silently ignore + } catch( const uno::Exception& ) { DBG_UNHANDLED_EXCEPTION(); -- cgit From ab17715fd5a99d5c37d5d6ee3ca1d319a85a74f2 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 17 Nov 2010 11:32:13 +0100 Subject: undoapi: release lock on own mutex when calling into the UndoHelper --- chart2/source/model/main/UndoManager.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'chart2') diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index 8e9ee25fa0c5..702dd2e5ab54 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -143,8 +143,10 @@ namespace chart //-------------------------------------------------------------------------------------------------------------- void UndoManager_Impl::disposing() { - ::osl::MutexGuard aGuard( m_rMutex ); - m_bDisposed = true; + { + ::osl::MutexGuard aGuard( m_rMutex ); + m_bDisposed = true; + } m_aUndoHelper.disposing(); } -- cgit From 230136cff127e4170a83dcc1d909e54608f7e2ee Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 15 Nov 2010 12:22:05 +0100 Subject: undoapi: GCC WaE --- chart2/source/controller/main/ElementSelector.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx index 38d05635477a..3b41fd1b6b66 100644 --- a/chart2/source/controller/main/ElementSelector.cxx +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -156,7 +156,7 @@ void SelectorListBox::UpdateChartElementsListAndSelection() ListBoxEntryData aEntry; SdrObject* pSelectedObj = DrawViewWrapper::getSdrObject( aSelectedOID.getAdditionalShape() ); ::rtl::OUString aName( pSelectedObj ? pSelectedObj->GetName() : String() ); - aEntry.UIName = ( aName.getLength() > 0 ? aName : String( SchResId( STR_OBJECT_SHAPE ) ) ); + aEntry.UIName = ( aName.getLength() > 0 ? aName : ::rtl::OUString( String( SchResId( STR_OBJECT_SHAPE ) ) ) ); aEntry.OID = aSelectedOID; m_aEntries.push_back( aEntry ); } -- cgit From cdf76da8726c83f812c884bfba9027250a864300 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 18 Nov 2010 14:21:37 +0100 Subject: undoapi: ooops - fixed shape undo actions --- chart2/source/controller/main/ChartController.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 1acf71c17fff..b8720c0f5158 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1452,7 +1452,8 @@ IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction ) { try { - const Reference< document::XUndoManager > xUndoManager( getModel(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) ); xUndoManager->addUndoAction( xAction ); } -- cgit From 33f79158f6dd4ed6a475a826640d47ab88a0be28 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 18 Nov 2010 15:45:39 +0100 Subject: undoapi: when inserting shapes, hide the Undo action which results from the initial positioning of the object --- .../controller/main/ChartController_Window.cxx | 6 ++- chart2/source/controller/main/UndoGuard.cxx | 51 ++++++++++++++++++++++ chart2/source/controller/main/UndoGuard.hxx | 25 +++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 311bf38ea38c..fa75a9df065f 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -802,7 +802,11 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() ) { pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND ); - impl_switchDiagramPositioningToExcludingPositioning(); + { + HiddenUndoContext aUndoContext( m_xUndoManager ); + // don't want the positioning Undo action to appear in the UI + impl_switchDiagramPositioningToExcludingPositioning(); + } if ( pDrawViewWrapper->AreObjectsMarked() ) { if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index b2a02aaa3522..52ea27aa8d49 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -138,10 +138,61 @@ UndoGuardWithSelection::UndoGuardWithSelection( { } +//----------------------------------------------------------------------------- + UndoGuardWithSelection::~UndoGuardWithSelection() { if ( !isActionPosted() ) rollback(); } +//----------------------------------------------------------------------------- + +UndoContext::UndoContext( const Reference< document::XUndoManager > & i_undoManager, const ::rtl::OUString& i_undoTitle ) + :m_xUndoManager( i_undoManager ) +{ + ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" ); + m_xUndoManager->enterUndoContext( i_undoTitle ); +} + +//----------------------------------------------------------------------------- + +UndoContext::~UndoContext() +{ + m_xUndoManager->leaveUndoContext(); +} + +//----------------------------------------------------------------------------- + +HiddenUndoContext::HiddenUndoContext( const Reference< document::XUndoManager > & i_undoManager ) + :m_xUndoManager( i_undoManager ) +{ + ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" ); + try + { + m_xUndoManager->enterHiddenUndoContext(); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + m_xUndoManager.clear(); + // prevents the leaveUndoContext in the dtor + } +} + +//----------------------------------------------------------------------------- + +HiddenUndoContext::~HiddenUndoContext() +{ + try + { + if ( m_xUndoManager.is() ) + m_xUndoManager->leaveUndoContext(); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + } // namespace chart diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx index 6040d7472329..c5c00dd62d1b 100644 --- a/chart2/source/controller/main/UndoGuard.hxx +++ b/chart2/source/controller/main/UndoGuard.hxx @@ -107,6 +107,31 @@ public: virtual ~UndoGuardWithSelection(); }; +class UndoContext +{ +public: + UndoContext( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, + const ::rtl::OUString& i_undoTitle + ); + ~UndoContext(); + +private: + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; +}; + +class HiddenUndoContext +{ +public: + HiddenUndoContext( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~HiddenUndoContext(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; +}; + } // CHART2_UNDOGUARD_HXX #endif -- cgit From edaa216847e59ad93b8b99e95f293f8bb04344cc Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 30 Nov 2010 01:45:03 +0100 Subject: chart46: #i25706# implement date axis --- .../controller/chartapiwrapper/AxisWrapper.cxx | 16 + .../chartapiwrapper/Chart2ModelContact.hxx | 7 +- .../chartapiwrapper/ChartDataWrapper.cxx | 208 ++++- .../chartapiwrapper/ChartDataWrapper.hxx | 32 +- .../chartapiwrapper/ChartDocumentWrapper.cxx | 2 - .../chartapiwrapper/WrappedScaleProperty.cxx | 78 +- .../chartapiwrapper/WrappedScaleProperty.hxx | 2 + chart2/source/controller/dialogs/DataBrowser.cxx | 27 + chart2/source/controller/dialogs/DataBrowser.hxx | 5 + .../source/controller/dialogs/DataBrowserModel.cxx | 38 +- .../source/controller/dialogs/DataBrowserModel.hxx | 6 +- chart2/source/controller/dialogs/DialogModel.cxx | 10 +- chart2/source/controller/dialogs/DialogModel.hxx | 1 + chart2/source/controller/dialogs/Strings.src | 4 + chart2/source/controller/dialogs/Strings_Scale.src | 8 + chart2/source/controller/dialogs/TabPages.hrc | 25 - .../source/controller/dialogs/dlg_DataEditor.cxx | 8 +- .../source/controller/dialogs/dlg_DataEditor.hrc | 1 + .../source/controller/dialogs/dlg_DataEditor.src | 9 +- .../controller/dialogs/dlg_InsertErrorBars.cxx | 2 +- .../controller/dialogs/dlg_ObjectProperties.cxx | 2 +- chart2/source/controller/dialogs/tp_AxisLabel.cxx | 12 +- chart2/source/controller/dialogs/tp_Scale.cxx | 422 ++++++++-- chart2/source/controller/dialogs/tp_Scale.hrc | 63 ++ chart2/source/controller/dialogs/tp_Scale.hxx | 30 +- chart2/source/controller/dialogs/tp_Scale.src | 211 ++++- chart2/source/controller/inc/AxisItemConverter.hxx | 11 +- chart2/source/controller/inc/HelpIds.hrc | 1 + .../itemsetwrapper/AxisItemConverter.cxx | 366 +++++--- .../controller/itemsetwrapper/SchWhichPairs.hxx | 30 +- chart2/source/controller/main/ImplUndoManager.cxx | 12 +- chart2/source/inc/AxisHelper.hxx | 4 + chart2/source/inc/ChartTypeHelper.hxx | 3 +- chart2/source/inc/DiagramHelper.hxx | 16 + chart2/source/inc/ExplicitCategoriesProvider.hxx | 38 +- chart2/source/inc/InternalData.hxx | 24 +- chart2/source/inc/InternalDataProvider.hxx | 30 +- chart2/source/inc/Strings.hrc | 7 +- chart2/source/inc/chartview/ChartSfxItemIds.hxx | 167 ++-- .../source/inc/chartview/ExplicitScaleValues.hxx | 165 ++++ .../source/inc/chartview/ExplicitValueProvider.hxx | 8 +- .../inc/chartview/NumberFormatterWrapper.hxx | 1 + chart2/source/model/template/ChartTypeTemplate.cxx | 15 +- chart2/source/tools/AxisHelper.cxx | 41 + chart2/source/tools/ChartTypeHelper.cxx | 25 +- chart2/source/tools/DiagramHelper.cxx | 194 ++++- chart2/source/tools/ExplicitCategoriesProvider.cxx | 139 ++- chart2/source/tools/InternalData.cxx | 42 +- chart2/source/tools/InternalDataProvider.cxx | 372 +++++--- chart2/source/view/axes/DateHelper.cxx | 132 +++ chart2/source/view/axes/DateScaling.cxx | 211 +++++ chart2/source/view/axes/DateScaling.hxx | 114 +++ .../source/view/axes/MinimumAndMaximumSupplier.cxx | 21 + chart2/source/view/axes/ScaleAutomatism.cxx | 330 +++++++- chart2/source/view/axes/TickmarkHelper.cxx | 937 --------------------- chart2/source/view/axes/TickmarkHelper.hxx | 276 ------ chart2/source/view/axes/Tickmarks.cxx | 333 ++++++++ chart2/source/view/axes/Tickmarks.hxx | 166 ++++ chart2/source/view/axes/Tickmarks_Dates.cxx | 171 ++++ chart2/source/view/axes/Tickmarks_Dates.hxx | 65 ++ chart2/source/view/axes/Tickmarks_Equidistant.cxx | 671 +++++++++++++++ chart2/source/view/axes/Tickmarks_Equidistant.hxx | 166 ++++ chart2/source/view/axes/VAxisBase.cxx | 26 +- chart2/source/view/axes/VAxisBase.hxx | 21 +- chart2/source/view/axes/VAxisOrGridBase.cxx | 17 +- chart2/source/view/axes/VAxisOrGridBase.hxx | 21 +- chart2/source/view/axes/VAxisProperties.cxx | 19 +- chart2/source/view/axes/VAxisProperties.hxx | 1 - chart2/source/view/axes/VCartesianAxis.cxx | 289 ++++--- chart2/source/view/axes/VCartesianAxis.hxx | 27 +- .../view/axes/VCartesianCoordinateSystem.cxx | 17 - chart2/source/view/axes/VCartesianGrid.cxx | 13 +- chart2/source/view/axes/VCartesianGrid.hxx | 2 +- chart2/source/view/axes/VCoordinateSystem.cxx | 26 +- chart2/source/view/axes/VPolarAngleAxis.cxx | 16 +- chart2/source/view/axes/VPolarAngleAxis.hxx | 9 +- chart2/source/view/axes/VPolarAxis.cxx | 6 +- chart2/source/view/axes/VPolarAxis.hxx | 8 +- chart2/source/view/axes/VPolarCoordinateSystem.cxx | 9 - chart2/source/view/axes/VPolarGrid.cxx | 23 +- chart2/source/view/axes/VPolarGrid.hxx | 14 +- chart2/source/view/axes/VPolarRadiusAxis.cxx | 27 +- chart2/source/view/axes/VPolarRadiusAxis.hxx | 24 +- chart2/source/view/axes/makefile.mk | 6 +- chart2/source/view/charttypes/AreaChart.cxx | 29 +- chart2/source/view/charttypes/AreaChart.hxx | 13 +- chart2/source/view/charttypes/BarChart.cxx | 99 +-- chart2/source/view/charttypes/BarChart.hxx | 18 +- .../source/view/charttypes/BarPositionHelper.cxx | 79 +- .../source/view/charttypes/BarPositionHelper.hxx | 19 +- chart2/source/view/charttypes/BubbleChart.hxx | 6 +- chart2/source/view/charttypes/CandleStickChart.cxx | 103 ++- chart2/source/view/charttypes/CandleStickChart.hxx | 13 +- .../view/charttypes/CategoryPositionHelper.cxx | 17 +- .../view/charttypes/CategoryPositionHelper.hxx | 5 +- chart2/source/view/charttypes/PieChart.cxx | 6 +- chart2/source/view/charttypes/PieChart.hxx | 18 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 104 ++- chart2/source/view/diagram/VDiagram.cxx | 2 +- chart2/source/view/inc/DateHelper.hxx | 60 ++ .../source/view/inc/MinimumAndMaximumSupplier.hxx | 9 +- chart2/source/view/inc/PlotterBase.hxx | 31 +- chart2/source/view/inc/PlottingPositionHelper.hxx | 65 +- chart2/source/view/inc/ScaleAutomatism.hxx | 37 +- chart2/source/view/inc/VCoordinateSystem.hxx | 27 +- chart2/source/view/inc/VDataSeries.hxx | 4 + chart2/source/view/inc/VDiagram.hxx | 2 +- chart2/source/view/inc/VSeriesPlotter.hxx | 10 +- chart2/source/view/main/ChartItemPool.cxx | 84 +- chart2/source/view/main/ChartView.cxx | 136 ++- chart2/source/view/main/ChartView.hxx | 4 +- chart2/source/view/main/NumberFormatterWrapper.cxx | 19 + chart2/source/view/main/PlotterBase.cxx | 9 +- chart2/source/view/main/PlottingPositionHelper.cxx | 80 +- chart2/source/view/main/VDataSeries.cxx | 16 + chart2/source/view/main/VLegend.cxx | 2 +- chart2/source/view/main/VLegend.hxx | 2 +- chart2/source/view/main/VTitle.cxx | 2 +- chart2/source/view/main/VTitle.hxx | 2 +- 119 files changed, 5568 insertions(+), 2718 deletions(-) create mode 100644 chart2/source/controller/dialogs/tp_Scale.hrc mode change 100644 => 100755 chart2/source/controller/dialogs/tp_Scale.src create mode 100644 chart2/source/inc/chartview/ExplicitScaleValues.hxx create mode 100644 chart2/source/view/axes/DateHelper.cxx create mode 100644 chart2/source/view/axes/DateScaling.cxx create mode 100644 chart2/source/view/axes/DateScaling.hxx delete mode 100644 chart2/source/view/axes/TickmarkHelper.cxx delete mode 100644 chart2/source/view/axes/TickmarkHelper.hxx create mode 100644 chart2/source/view/axes/Tickmarks.cxx create mode 100644 chart2/source/view/axes/Tickmarks.hxx create mode 100644 chart2/source/view/axes/Tickmarks_Dates.cxx create mode 100644 chart2/source/view/axes/Tickmarks_Dates.hxx create mode 100644 chart2/source/view/axes/Tickmarks_Equidistant.cxx create mode 100644 chart2/source/view/axes/Tickmarks_Equidistant.hxx mode change 100755 => 100644 chart2/source/view/charttypes/BarChart.cxx create mode 100644 chart2/source/view/inc/DateHelper.hxx (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 6d53fb8b01f6..fe24a0bf4eb0 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -82,6 +82,8 @@ enum PROP_AXIS_AUTO_MIN, PROP_AXIS_AUTO_STEPMAIN, PROP_AXIS_AUTO_STEPHELP, + PROP_AXIS_TYPE, + PROP_AXIS_TIME_INCREMENT, PROP_AXIS_LOGARITHMIC, PROP_AXIS_REVERSEDIRECTION, PROP_AXIS_VISIBLE, @@ -173,6 +175,20 @@ void lcl_AddPropertiesToVector( //#i111967# no PropertyChangeEvent is fired on change so far beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "AxisType" ), + PROP_AXIS_TYPE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), //type com::sun::star::chart::ChartAxisType + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TimeIncrement" ), + PROP_AXIS_TIME_INCREMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)), + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( Property( C2U( "Logarithmic" ), PROP_AXIS_LOGARITHMIC, diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index e20167e216c2..dafef0f2aa72 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -27,8 +27,7 @@ #ifndef CHART_CHART2MODELCONTACT_HXX #define CHART_CHART2MODELCONTACT_HXX -#include -#include +#include #include #include #include @@ -79,8 +78,8 @@ public: sal_Bool getExplicitValuesForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > & xAxis, - ::com::sun::star::chart2::ExplicitScaleData & rOutExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData & rOutExplicitIncrement ); + ExplicitScaleData & rOutExplicitScale, + ExplicitIncrementData & rOutExplicitIncrement ); sal_Int32 getExplicitNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 062dcc1a129d..6ab0e6c5f483 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -64,9 +64,11 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; using ::osl::MutexGuard; +using ::com::sun::star::chart2::XAnyDescriptionAccess; using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; +using ::com::sun::star::chart::XDateCategories; namespace { @@ -132,7 +134,7 @@ struct lcl_Operator virtual ~lcl_Operator() { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) = 0; + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0; virtual bool setsCategories( bool /*bDataInColumns*/ ) { @@ -155,13 +157,20 @@ struct lcl_AllOperator : public lcl_Operator return true; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( !xDataAccess.is() ) return; + Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY ); Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY ); - if( xNewComplex.is() ) + if( xNewAny.is() ) + { + xDataAccess->setData( xNewAny->getData() ); + xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() ); + xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() ); + } + else if( xNewComplex.is() ) { xDataAccess->setData( xNewComplex->getData() ); xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() ); @@ -192,7 +201,7 @@ struct lcl_DataOperator : public lcl_Operator { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) ); @@ -205,96 +214,208 @@ struct lcl_DataOperator : public lcl_Operator struct lcl_RowDescriptionsOperator : public lcl_Operator { - lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions ) + lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rRowDescriptions( rRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setRowDescriptions( m_rRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator { - lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions ) + lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexRowDescriptions( rComplexRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { - return !bDataInColumns; + m_bDataInColumns = bDataInColumns; + return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; +//-------------------------------------------------------------------------- + +struct lcl_AnyRowDescriptionsOperator : public lcl_Operator +{ + lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions ) + : lcl_Operator() + , m_rAnyRowDescriptions( rAnyRowDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions; }; //-------------------------------------------------------------------------- struct lcl_ColumnDescriptionsOperator : public lcl_Operator { - lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions ) + lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rColumnDescriptions( rColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setColumnDescriptions( m_rColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator { - lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions ) + lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexColumnDescriptions( rComplexColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; + +//-------------------------------------------------------------------------- + +struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator +{ + lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions ) + : lcl_Operator() + , m_rAnyColumnDescriptions( rAnyColumnDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return !bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions; +}; + +//-------------------------------------------------------------------------- + +struct lcl_DateCategoriesOperator : public lcl_Operator +{ + lcl_DateCategoriesOperator( const Sequence< double >& rDates ) + : lcl_Operator() + , m_rDates( rDates ) + { + } + + virtual bool setsCategories( bool /*bDataInColumns*/ ) + { + return true; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + xDateCategories->setDateCategories( m_rDates ); + } + + const Sequence< double >& m_rDates; }; //-------------------------------------------------------------------------- @@ -353,6 +474,7 @@ Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions() return m_xDataAccess->getColumnDescriptions(); return Sequence< OUString > (); } + // ____ XComplexDescriptionAccess (read) ____ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException) { @@ -369,6 +491,32 @@ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDesc return Sequence< Sequence< OUString > >(); } +// ____ XAnyDescriptionAccess (read) ____ +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyRowDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyColumnDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} + +// ____ XDateCategories (read) ____ +Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories() throw (uno::RuntimeException) +{ + initDataAccess(); + Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + return xDateCategories->getDateCategories(); + return Sequence< double >(); +} + // ____ XChartDataArray (write)____ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData ) throw (uno::RuntimeException) @@ -379,26 +527,48 @@ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& r void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_RowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } // ____ XComplexDescriptionAccess (write) ____ void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); + applyData( aOperator ); +} + +// ____ XAnyDescriptionAccess (write) ____ +void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions ); + applyData( aOperator ); +} +void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions ); + applyData( aOperator ); +} + +// ____ XDateCategories (write) ____ +void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + lcl_DateCategoriesOperator aOperator( rDates ); applyData( aOperator ); + DiagramHelper::switchToDateCategories( xChartDoc ); } //-------------------------------------------------------------------------------------- @@ -508,11 +678,11 @@ void ChartDataWrapper::initDataAccess() if( !xChartDoc.is() ) return; if( xChartDoc->hasInternalDataProvider() ) - m_xDataAccess = Reference< XComplexDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); + m_xDataAccess = Reference< XAnyDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); else { //create a separate "internal data provider" that is not connected to the model - m_xDataAccess = Reference< XComplexDescriptionAccess >( ChartModelHelper::createInternalDataProvider( + m_xDataAccess = Reference< XAnyDescriptionAccess >( ChartModelHelper::createInternalDataProvider( xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW ); } } diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx index d56397953d79..16695914f892 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -29,9 +29,10 @@ #include "ServiceMacros.hxx" #include "MutexContainer.hxx" -#include +#include #include -#include +#include +#include #include #include #include @@ -48,8 +49,9 @@ class Chart2ModelContact; struct lcl_Operator; class ChartDataWrapper : public MutexContainer, public - ::cppu::WeakImplHelper4< - com::sun::star::chart::XComplexDescriptionAccess, + ::cppu::WeakImplHelper5< + com::sun::star::chart2::XAnyDescriptionAccess, + com::sun::star::chart::XDateCategories, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XEventListener, com::sun::star::lang::XComponent > @@ -64,7 +66,25 @@ public: APPHELPER_XSERVICEINFO_DECL() protected: - // ____ XComplexDescriptionAccess ____ + // ____ XDateCategories ____ + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XAnyDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyRowDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyColumnDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setComplexRowDescriptions( @@ -136,7 +156,7 @@ private: //methods private: //member ::com::sun::star::uno::Reference< - ::com::sun::star::chart::XComplexDescriptionAccess > m_xDataAccess; + ::com::sun::star::chart2::XAnyDescriptionAccess > m_xDataAccess; ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index d6487d425657..8dd846474170 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include // header for function SvxShapeCollection_NewInstance #include @@ -81,7 +80,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart; -using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index b0fc030d0fbf..037a5795baa5 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -33,9 +33,8 @@ #include "CommonConverters.hxx" #include "AxisHelper.hxx" #include -#include -#include -#include +#include +#include using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -43,6 +42,7 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using ::com::sun::star::chart::TimeIncrement; //............................................................................. namespace chart @@ -91,6 +91,12 @@ WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty case SCALE_PROP_AUTO_STEPHELP: m_aOuterName = C2U("AutoStepHelp"); break; + case SCALE_PROP_AXIS_TYPE: + m_aOuterName = C2U("AxisType"); + break; + case SCALE_PROP_DATE_INCREMENT: + m_aOuterName = C2U("TimeIncrement"); + break; case SCALE_PROP_LOGARITHMIC: m_aOuterName = C2U("Logarithmic"); break; @@ -122,6 +128,8 @@ void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* > rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); } @@ -266,6 +274,40 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons bSetScaleData = true; break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType; + if( (rOuterValue >>= nType) ) + { + if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType ) + { + aScaleData.AutoDateAxis = true; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::CATEGORY == nType ) + { + aScaleData.AutoDateAxis = false; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::DATE == nType ) + { + if( aScaleData.AxisType == AxisType::CATEGORY ) + aScaleData.AxisType = AxisType::DATE; + } + bSetScaleData = true; + } + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + TimeIncrement aTimeIncrement; + rOuterValue >>= aTimeIncrement; + aScaleData.TimeIncrement = aTimeIncrement; + bSetScaleData = true; + break; + } case SCALE_PROP_LOGARITHMIC: { if( rOuterValue >>= bBool ) @@ -320,8 +362,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const chart2::ScaleData aScaleData( xAxis->getScaleData() ); - chart2::ExplicitScaleData aExplicitScale; - chart2::ExplicitIncrementData aExplicitIncrement; + ExplicitScaleData aExplicitScale; + ExplicitIncrementData aExplicitIncrement; switch( eScaleProperty ) { @@ -401,7 +443,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 && + + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 ) { if( bLogarithmic ) @@ -440,7 +483,7 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const if( bNeedToCalculateExplicitValues ) { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 ) + if( !aExplicitIncrement.SubIncrements.empty() ) nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; } aRet = uno::makeAny( nIntervalCount ); @@ -486,6 +529,27 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const aRet <<= !hasDoubleValue(aScaleData.Origin); break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType = ::com::sun::star::chart::ChartAxisType::AUTOMATIC; + if( aScaleData.AxisType == AxisType::DATE ) + { + nType = ::com::sun::star::chart::ChartAxisType::DATE; + } + else if( aScaleData.AxisType == AxisType::CATEGORY ) + { + if( !aScaleData.AutoDateAxis ) + nType = ::com::sun::star::chart::ChartAxisType::CATEGORY; + } + aRet = uno::makeAny( nType ); + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + aRet = uno::makeAny( aScaleData.TimeIncrement ); + break; + } case SCALE_PROP_LOGARITHMIC: { aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 4d29bc009777..1543d7b645fb 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -55,6 +55,8 @@ public: , SCALE_PROP_AUTO_ORIGIN , SCALE_PROP_AUTO_STEPMAIN , SCALE_PROP_AUTO_STEPHELP + , SCALE_PROP_AXIS_TYPE + , SCALE_PROP_DATE_INCREMENT , SCALE_PROP_LOGARITHMIC , SCALE_PROP_REVERSEDIRECTION }; diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 513d49b6aad8..38eae1f962d1 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -517,6 +517,20 @@ DataBrowser::~DataBrowser() { } +bool DataBrowser::HasDateCategories() const +{ + if( m_apDataBrowserModel.get() ) + return m_apDataBrowserModel->hasDateCategories(); + return false; +} + +bool DataBrowser::MayToggleDateCategories() const +{ + return ! IsReadOnly() + && DiagramHelper::mayToggleDateCategories( m_xChartDoc ); + return true; +} + bool DataBrowser::MayInsertRow() const { return ! IsReadOnly() @@ -993,6 +1007,19 @@ void DataBrowser::SwapRow() } } +void DataBrowser::ToggleDateCategories() +{ + if( m_apDataBrowserModel.get() ) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->toggleDateCategories(); + RenewTable(); + } +} + void DataBrowser::SetCursorMovedHdl( const Link& rLink ) { m_aCursorMovedHdlLink = rLink; diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 3583db2770c0..7a7cd120fb5f 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -113,6 +113,9 @@ public: // predicates to determine what actions are possible at the current cursor // position. This depends on the implementation of the according mutators // below. (They are used for enabling toolbar icons) + bool HasDateCategories() const; + bool MayToggleDateCategories() const; + bool MayInsertRow() const; bool MayInsertColumn() const; bool MayDeleteRow() const; @@ -131,6 +134,8 @@ public: using BrowseBox::RemoveColumn; using BrowseBox::MouseButtonDown; + void ToggleDateCategories(); + void SwapRow(); void SwapColumn(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c0b865536686..7e93afd3b42e 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -568,6 +568,12 @@ void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) // unlockControllers } +void DataBrowserModel::toggleDateCategories() +{ + DiagramHelper::toggleDateCategories( Reference( m_apDialogModel->getChartModel(), uno::UNO_QUERY ) ); + updateFromModel(); +} + DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( const Reference< chart2::XDataSeries > & xSeries ) const { @@ -589,7 +595,7 @@ Reference< chart2::XDataSeries > return 0; } -DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) +DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) const { eCellType eResult = TEXT; tDataColumnVector::size_type nIndex( nAtColumn ); @@ -755,6 +761,12 @@ sal_Int32 DataBrowserModel::getCategoryColumnCount() } return nLastTextColumnIndex+1; } +bool DataBrowserModel::hasDateCategories() const +{ + if( NUMBER == getCellType( 0, 0 ) ) + return true; + return false; +} const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const { @@ -771,6 +783,10 @@ void DataBrowserModel::updateFromModel() Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); if( !xDiagram.is()) return; + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); + if( !xCooSysCnt.is()) + return; + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); // set template at DialogModel uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ); @@ -785,6 +801,10 @@ void DataBrowserModel::updateFromModel() { Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY ); ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); + bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); + sal_Int32 nDateCategoriesNumberFormat = 0; + if( bIsDateAxis && aCooSysSeq.getLength() ) + nDateCategoriesNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[0], 0, 0 ); const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); @@ -798,18 +818,24 @@ void DataBrowserModel::updateFromModel() aCategories.m_xLabeledDataSequence.set( xCategories ); if( lcl_ShowCategoriesAsDataLabel( xDiagram )) aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); + else if( bIsDateAxis ) + aCategories.m_aUIRoleName = DialogModel::GetRoleDates(); else aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); - aCategories.m_eCellType = TEXT; + if( bIsDateAxis ) + { + aCategories.m_eCellType = NUMBER; + aCategories.m_nNumberFormatKey = nDateCategoriesNumberFormat; + } + else + { + aCategories.m_eCellType = TEXT; + } m_aColumns.push_back( aCategories ); ++nHeaderStart; } } - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) - return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); for( sal_Int32 nCooSysIdx=0; nCooSysIdx xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index a4378972f70f..d6c82a2f15ea 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -78,13 +78,15 @@ public: void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); void removeDataPointForAllSeries( sal_Int32 nAtIndex ); + void toggleDateCategories(); + enum eCellType { NUMBER, TEXT }; - eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); @@ -103,6 +105,8 @@ public: ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; + bool hasDateCategories() const; + struct tDataHeader { ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index f32a882aa1e9..00b25fb701fb 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -160,7 +160,7 @@ void lcl_createRoleIndexMap( lcl_tRoleIndexMap & rOutMap ) struct lcl_DataSeriesContainerAppend : public ::std::iterator< ::std::output_iterator_tag, Reference< XDataSeriesContainer > > { - typedef ::std::vector< chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; + typedef ::std::vector< ::chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; explicit lcl_DataSeriesContainerAppend( tContainerType & rCnt ) : m_rDestCnt( rCnt ) @@ -180,7 +180,7 @@ struct lcl_DataSeriesContainerAppend : public for( sal_Int32 nI = 0; nI < aSeq.getLength(); ++ nI ) { m_rDestCnt.push_back( - chart::DialogModel::tSeriesWithChartTypeByName( + ::chart::DialogModel::tSeriesWithChartTypeByName( ::chart::DataSeriesHelper::getDataSeriesLabel( aSeq[nI], aRole ), ::std::make_pair( aSeq[nI], xCT ))); } @@ -736,6 +736,12 @@ OUString DialogModel::GetRoleDataLabel() return OUString( String( ::chart::SchResId( STR_OBJECT_DATALABELS ))); } +// static +OUString DialogModel::GetRoleDates() +{ + return OUString( String( ::chart::SchResId( STR_DATA_DATE_CATEGORIES ))); +} + // static sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index dcca6c716b8d..25bbc2669a9b 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -152,6 +152,7 @@ public: static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); static ::rtl::OUString GetRoleDataLabel(); + static ::rtl::OUString GetRoleDates(); // pass a role string (not translated) and get an index that serves for // relative ordering, to get e.g. x-values and y-values in the right order diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 4b4cec65426e..b25c99454cef 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -548,6 +548,10 @@ String STR_DATA_ROLE_CATEGORIES { Text [ en-US ] = "Categories"; }; +String STR_DATA_DATE_CATEGORIES +{ + Text [ en-US ] = "Dates"; +}; String STR_DATA_UNNAMED_SERIES { diff --git a/chart2/source/controller/dialogs/Strings_Scale.src b/chart2/source/controller/dialogs/Strings_Scale.src index e7a3d6c2b1cf..6f8b75d9509c 100644 --- a/chart2/source/controller/dialogs/Strings_Scale.src +++ b/chart2/source/controller/dialogs/Strings_Scale.src @@ -42,3 +42,11 @@ String STR_MIN_GREATER_MAX { Text [ en-US ] = "The minimum must be lower than the maximum. Check your input." ; }; +String STR_INVALID_INTERVALS +{ + Text [ en-US ] = "The major interval needs to be greater than the minor interval. Check your input." ; +}; +String STR_INVALID_TIME_UNIT +{ + Text [ en-US ] = "The major and minor interval need to be greater or equal to the resolution. Check your input." ; +}; diff --git a/chart2/source/controller/dialogs/TabPages.hrc b/chart2/source/controller/dialogs/TabPages.hrc index 1f445083738f..dbc166e4f2cd 100644 --- a/chart2/source/controller/dialogs/TabPages.hrc +++ b/chart2/source/controller/dialogs/TabPages.hrc @@ -111,31 +111,6 @@ #define FT_AXIS_TEXTDIR 19 #define LB_AXIS_TEXTDIR 20 -//#define TP_SCALE 903 - -#define FL_SCALE 1 - -#define TXT_MIN 1 -#define TXT_MAX 2 -#define TXT_STEP_MAIN 3 -#define TXT_STEP_HELP 4 -#define TXT_ORIGIN 5 - -#define CBX_AUTO_MIN 1 -#define CBX_AUTO_MAX 2 -#define CBX_AUTO_STEP_MAIN 3 -#define CBX_AUTO_STEP_HELP 4 -#define CBX_AUTO_ORIGIN 5 -#define CBX_LOGARITHM 6 -#define CBX_REVERSE 7 - -#define EDT_STEP_MAIN 1 -#define EDT_MAX 2 -#define EDT_MIN 3 -#define EDT_ORIGIN 4 - -#define MT_STEPHELP 10 - //#define TP_AXIS_POSITIONS 904 #define FL_AXIS_LINE 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index f1d441921a6a..ff365ae460a3 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -160,6 +160,9 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) case TBI_DATA_SWAP_ROW : m_apBrwData->SwapRow (); break; + case TBI_DATA_TOGGLE_DATE_CATEGOGRIES: + m_apBrwData->ToggleDateCategories (); + break; } return 0; @@ -175,13 +178,15 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() ); m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() && !m_apBrwData->HasDateCategories() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); + return 0; } @@ -198,6 +203,7 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, FALSE ); } m_apBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc index d2675c5bb29e..b4f1cbe1b3a7 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -41,6 +41,7 @@ #define TBI_DATA_SWAP_COL 5 #define TBI_DATA_SWAP_ROW 6 #define TBI_DATA_INSERT_TEXT_COL 7 +#define TBI_DATA_TOGGLE_DATE_CATEGOGRIES 8 // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src index 02ccc98b7a82..64919d64b0b2 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.src +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -116,6 +116,12 @@ ModalDialog DLG_DIAGRAM_DATA { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; + Identifier = TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; + Text [ en-US ] = "Categories: Date/Text" ; + }; }; }; @@ -129,8 +135,9 @@ ModalDialog DLG_DIAGRAM_DATA TBI_DATA_DELETE_COL; \ TBI_DATA_SWAP_COL; \ TBI_DATA_SWAP_ROW; \ + TBI_DATA_TOGGLE_DATE_CATEGOGRIES; \ }; \ - IdCount = { 7; } + IdCount = { 8; } ImageList IL_DIAGRAM_DATA { diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index 9c4438b6f1ca..a362c883567d 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -119,7 +119,7 @@ double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement ); fStepWidth = aExplicitIncrement.Distance; - if( aExplicitIncrement.SubIncrements.getLength() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount); else fStepWidth/=10; diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2a41d35313e8..5b3b96c705b3 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -179,7 +179,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel ScaleData aData( xAxis->getScaleData() ); if( chart2::AxisType::SERIES == aData.AxisType ) m_bHasScaleProperties = false; - if( chart2::AxisType::REALNUMBER == aData.AxisType || chart2::AxisType::PERCENT == aData.AxisType ) + if( chart2::AxisType::SERIES != aData.AxisType ) m_bHasNumberProperties = true; sal_Int32 nCooSysIndex=0; diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 3dcaa3092e57..876cb0f78c91 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -141,13 +141,13 @@ BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) bRadioButtonChecked = false; if( bRadioButtonChecked ) - rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_TEXT_ORDER )); + rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER )); } if( aCbTextOverlap.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_OVERLAP, aCbTextOverlap.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) ); if( aCbTextBreak.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXTBREAK, aCbTextBreak.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) ); if( aCbShowDescription.GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) ); @@ -211,7 +211,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); // Text overlap ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextOverlap.EnableTriState( TRUE ); @@ -230,7 +230,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) } // text break ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextBreak.EnableTriState( TRUE ); @@ -255,7 +255,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { - aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, FALSE, &pPoolItem ); if( aState == SFX_ITEM_SET ) { SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 34fc0702bafe..7544faf88bd6 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "tp_Scale.hxx" +#include "tp_Scale.hrc" #include "ResId.hxx" -#include "TabPages.hrc" #include "Strings.hrc" #include "chartview/ChartSfxItemIds.hxx" #include "NoWarningThisInCTOR.hxx" @@ -72,6 +72,20 @@ namespace chart namespace { +void lcl_placeControlAtX( Control& rControl, long nNewXPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.X() = nNewXPos; + rControl.SetPosPixel(aPos); +} + +void lcl_placeControlAtY( Control& rControl, long nNewYPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.Y() = nNewYPos; + rControl.SetPosPixel(aPos); +} + void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) { Point aPos( rEdit.GetPosPixel() ); @@ -84,50 +98,57 @@ void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) rAuto.SetPosPixel(aPos); } -void lcl_placeControlsAtY( Control& rTop, Control& rBottom, long nNewYPos ) -{ - Point aPos( rTop.GetPosPixel() ); - long nShift = nNewYPos - aPos.Y(); - aPos.Y() = nNewYPos; - rTop.SetPosPixel(aPos); - - aPos = rBottom.GetPosPixel(); - aPos.Y() += nShift; - rBottom.SetPosPixel(aPos); -} - } ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs), aFlScale(this, SchResId(FL_SCALE)), + + aCbxReverse(this, SchResId(CBX_REVERSE)), + aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), + + m_aTxt_AxisType(this, SchResId (TXT_AXIS_TYPE)), + m_aLB_AxisType(this, SchResId(LB_AXIS_TYPE)), + aTxtMin (this, SchResId (TXT_MIN)), aFmtFldMin(this, SchResId(EDT_MIN)), aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)), + aTxtMax(this, SchResId (TXT_MAX)), aFmtFldMax(this, SchResId(EDT_MAX)), aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)), + + m_aTxt_TimeResolution(this, SchResId (TXT_TIME_RESOLUTION)), + m_aLB_TimeResolution(this, SchResId(LB_TIME_RESOLUTION)), + m_aCbx_AutoTimeResolution(this, SchResId(CBX_AUTO_TIME_RESOLUTION)), + aTxtMain (this, SchResId (TXT_STEP_MAIN)), aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)), + m_aMt_MainDateStep(this, SchResId(MT_MAIN_DATE_STEP)), + m_aLB_MainTimeUnit(this, SchResId(LB_MAIN_TIME_UNIT)), aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)), + + aTxtHelpCount (this, SchResId (TXT_STEP_HELP_COUNT)), aTxtHelp (this, SchResId (TXT_STEP_HELP)), aMtStepHelp (this, SchResId (MT_STEPHELP)), + m_aLB_HelpTimeUnit(this, SchResId(LB_HELP_TIME_UNIT)), aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)), aTxtOrigin (this, SchResId (TXT_ORIGIN)), aFmtFldOrigin(this, SchResId(EDT_ORIGIN)), aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)), - aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), - aCbxReverse(this, SchResId(CBX_REVERSE)), - fMin(0.0), fMax(0.0), fStepMain(0.0), nStepHelp(0), fOrigin(0.0), - nAxisType(chart2::AxisType::REALNUMBER), + m_nTimeResolution(1), + m_nMainTimeUnit(1), + m_nHelpTimeUnit(1), + m_nAxisType(chart2::AxisType::REALNUMBER), + m_bAllowDateAxis(false), pNumFormatter(NULL), m_bShowAxisOrigin(false) { @@ -139,6 +160,14 @@ ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + m_aCbx_AutoTimeResolution.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + + m_aLB_AxisType.SetDropDownLineCount(3); + m_aLB_AxisType.SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl)); + + m_aLB_TimeResolution.SetDropDownLineCount(3); + m_aLB_MainTimeUnit.SetDropDownLineCount(3); + m_aLB_HelpTimeUnit.SetDropDownLineCount(3); } void ScaleTabPage::StateChanged( StateChangedType nType ) @@ -149,16 +178,24 @@ void ScaleTabPage::StateChanged( StateChangedType nType ) AdjustControlPositions(); } +long lcl_getLabelDistance( Control& rControl ) +{ + return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); +} + void ScaleTabPage::AdjustControlPositions() { //optimize position of the controls long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() ); nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( aTxtHelpCount.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_TimeResolution.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_AxisType.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth+=1; - long nLabelDistance = aTxtMin.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance; //ensure that the auto checkboxes are wide enough and have correct size for calculation @@ -167,9 +204,10 @@ void ScaleTabPage::AdjustControlPositions() aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() ); aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() ); aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() ); + m_aCbx_AutoTimeResolution.SetSizePixel( m_aCbx_AutoTimeResolution.CalcMinimumSize() ); //ensure new pos is ok - long nWidthOfOtherControls = aCbxAutoMin.GetPosPixel().X() + aCbxAutoMin.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); + long nWidthOfOtherControls = m_aLB_MainTimeUnit.GetPosPixel().X() + m_aLB_MainTimeUnit.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); long nDialogWidth = GetSizePixel().Width(); long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls; @@ -181,72 +219,180 @@ void ScaleTabPage::AdjustControlPositions() aTxtMax.SetSizePixel(aSize); aTxtMain.SetSizePixel(aSize); aTxtHelp.SetSizePixel(aSize); + aTxtHelpCount.SetSizePixel(aSize); aTxtOrigin.SetSizePixel(aSize); + m_aTxt_TimeResolution.SetSizePixel(aSize); + m_aTxt_AxisType.SetSizePixel(aSize); + + long nOrgAutoCheckX = aCbxAutoMin.GetPosPixel().X(); + lcl_placeControlAtX( aCbxAutoStepMain, nOrgAutoCheckX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nOrgAutoCheckX ); lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos ); lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos ); lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos ); + lcl_placeControlAtX( m_aMt_MainDateStep, aFmtFldStepMain.GetPosPixel().X() ); lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos ); lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos ); + lcl_shiftControls( m_aLB_TimeResolution, m_aCbx_AutoTimeResolution, nNewXPos ); + lcl_placeControlAtX( m_aLB_AxisType, nNewXPos ); + + nNewXPos = aCbxAutoStepMain.GetPosPixel().X() + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nNewXPos ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nNewXPos ); } + PlaceIntervalControlsAccordingToAxisType(); } -void ScaleTabPage::EnableControls() +void ScaleTabPage::PlaceIntervalControlsAccordingToAxisType() { - bool bEnableForValueOrPercentAxis = chart2::AxisType::REALNUMBER == nAxisType || chart2::AxisType::PERCENT == nAxisType; - aFlScale.Enable( bEnableForValueOrPercentAxis ); - aTxtMin.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMin.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMin.Enable( bEnableForValueOrPercentAxis ); - aTxtMax.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMax.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMax.Enable( bEnableForValueOrPercentAxis ); - aTxtMain.Enable( bEnableForValueOrPercentAxis ); - aFmtFldStepMain.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepMain.Enable( bEnableForValueOrPercentAxis ); - aTxtHelp.Enable( bEnableForValueOrPercentAxis ); - aMtStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxLogarithm.Enable( bEnableForValueOrPercentAxis ); - - aTxtOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aFmtFldOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aCbxAutoOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - - long nNewYPos = aTxtOrigin.GetPosPixel().Y(); - if( m_bShowAxisOrigin ) - nNewYPos += ( aTxtOrigin.GetPosPixel().Y() - aTxtHelp.GetPosPixel().Y() ); - lcl_placeControlsAtY( aCbxLogarithm, aCbxReverse, nNewYPos ); + long nMinX = std::min( aCbxAutoStepMain.GetPosPixel().X(), m_aLB_MainTimeUnit.GetPosPixel().X() ); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); + long nListWidth = m_aLB_MainTimeUnit.GetSizePixel().Width(); + + if( chart2::AxisType::DATE == m_nAxisType ) + { + lcl_placeControlAtX( m_aLB_MainTimeUnit, nMinX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nMinX ); + long nSecondX = nMinX + nListWidth + nLabelDistance; + lcl_placeControlAtX( aCbxAutoStepMain, nSecondX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nSecondX ); + + long nOne = m_aMt_MainDateStep.LogicToPixel( Size(0, 1), MapMode(MAP_APPFONT) ).Height(); + + long nYMajor = m_aMt_MainDateStep.GetPosPixel().Y(); + lcl_placeControlAtY( aCbxAutoStepMain , nYMajor+(3*nOne)); + lcl_placeControlAtY( aTxtMain , nYMajor+nOne+nOne); + + long nYMinor = m_aLB_HelpTimeUnit.GetPosPixel().Y(); + lcl_placeControlAtY( aMtStepHelp , nYMinor ); + lcl_placeControlAtY( aCbxAutoStepHelp , nYMinor+(3*nOne)); + } + else + { + lcl_placeControlAtX( aCbxAutoStepMain, nMinX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nMinX ); + long nSecondX = nMinX + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + long nSecondXMax = GetSizePixel().Width() - nListWidth; + if( nSecondX > nSecondXMax ) + nSecondX = nSecondXMax; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nSecondX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nSecondX ); + } } +void ScaleTabPage::EnableControls() +{ + bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType || chart2::AxisType::PERCENT == m_nAxisType || chart2::AxisType::DATE == m_nAxisType; + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + + m_aTxt_AxisType.Show(m_bAllowDateAxis); + m_aLB_AxisType.Show(m_bAllowDateAxis); + + aCbxLogarithm.Show( bValueAxis && !bDateAxis ); + aTxtMin.Show( bValueAxis ); + aFmtFldMin.Show( bValueAxis ); + aCbxAutoMin.Show( bValueAxis ); + aTxtMax.Show( bValueAxis ); + aFmtFldMax.Show( bValueAxis ); + aCbxAutoMax.Show( bValueAxis ); + aTxtMain.Show( bValueAxis ); + aFmtFldStepMain.Show( bValueAxis ); + aCbxAutoStepMain.Show( bValueAxis ); + aTxtHelp.Show( bValueAxis ); + aTxtHelpCount.Show( bValueAxis ); + aMtStepHelp.Show( bValueAxis ); + aCbxAutoStepHelp.Show( bValueAxis ); + + aTxtOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aFmtFldOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aCbxAutoOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + + aTxtHelpCount.Show( bValueAxis && !bDateAxis ); + aTxtHelp.Show( bDateAxis ); + + m_aTxt_TimeResolution.Show( bDateAxis ); + m_aLB_TimeResolution.Show( bDateAxis ); + m_aCbx_AutoTimeResolution.Show( bDateAxis ); + + bool bWasDateAxis = m_aMt_MainDateStep.IsVisible(); + if( bWasDateAxis != bDateAxis ) + { + //transport value from one to other control + if( bWasDateAxis ) + aFmtFldStepMain.SetValue( m_aMt_MainDateStep.GetValue() ); + else + m_aMt_MainDateStep.SetValue( static_cast(aFmtFldStepMain.GetValue()) ); + } + aFmtFldStepMain.Show( bValueAxis && !bDateAxis ); + m_aMt_MainDateStep.Show( bDateAxis ); + m_aLB_MainTimeUnit.Show( bDateAxis ); + m_aLB_HelpTimeUnit.Show( bDateAxis ); + + EnableValueHdl(&aCbxAutoMin); + EnableValueHdl(&aCbxAutoMax); + EnableValueHdl(&aCbxAutoStepMain); + EnableValueHdl(&aCbxAutoStepHelp); + EnableValueHdl(&aCbxAutoOrigin); + EnableValueHdl(&m_aCbx_AutoTimeResolution); +} IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx ) { + bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled(); if (pCbx == &aCbxAutoMin) { - aFmtFldMin.Enable(!aCbxAutoMin.IsChecked()); + aFmtFldMin.Enable( bEnable ); } else if (pCbx == &aCbxAutoMax) { - aFmtFldMax.Enable(!aCbxAutoMax.IsChecked()); + aFmtFldMax.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepMain) { - aFmtFldStepMain.Enable(!aCbxAutoStepMain.IsChecked()); + aFmtFldStepMain.Enable( bEnable ); + m_aMt_MainDateStep.Enable( bEnable ); + m_aLB_MainTimeUnit.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepHelp) { - aMtStepHelp.Show (); - aMtStepHelp.Enable( ! aCbxAutoStepHelp.IsChecked() ); + aMtStepHelp.Enable( bEnable ); + m_aLB_HelpTimeUnit.Enable( bEnable ); + } + else if (pCbx == &m_aCbx_AutoTimeResolution) + { + m_aLB_TimeResolution.Enable( bEnable ); } else if (pCbx == &aCbxAutoOrigin) { - aFmtFldOrigin.Enable(!aCbxAutoOrigin.IsChecked()); + aFmtFldOrigin.Enable( bEnable ); } return 0; } +enum AxisTypeListBoxEntry +{ + TYPE_AUTO=0, + TYPE_TEXT=1, + TYPE_DATE=2 +}; + +IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG ) +{ + USHORT nPos = m_aLB_AxisType.GetSelectEntryPos(); + if( nPos==TYPE_DATE ) + m_nAxisType = chart2::AxisType::DATE; + else + m_nAxisType = chart2::AxisType::CATEGORY; + if( chart2::AxisType::DATE == m_nAxisType ) + aCbxLogarithm.Check(false); + EnableControls(); + PlaceIntervalControlsAccordingToAxisType(); + SetNumFormat(); + return 0; +} + SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) { return new ScaleTabPage(pWindow, rOutAttrs); @@ -256,10 +402,18 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) { DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,aCbxAutoMin.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,aCbxAutoMax.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,aCbxAutoStepHelp.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,aCbxAutoOrigin.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType)); + if(m_bAllowDateAxis) + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_aLB_AxisType.GetSelectEntryPos())); + + bool bAutoScale = false; + if( m_nAxisType==chart2::AxisType::CATEGORY ) + bAutoScale = true;//reset scaling for category charts + + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || aCbxAutoMin.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || aCbxAutoMax.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || aCbxAutoStepHelp.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || aCbxAutoOrigin.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX)); @@ -270,6 +424,12 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution)); + + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit)); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit)); + return TRUE; } @@ -280,12 +440,34 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) return; const SfxPoolItem *pPoolItem = NULL; - nAxisType=chart2::AxisType::REALNUMBER; + if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + m_nAxisType=chart2::AxisType::REALNUMBER; if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); + if( m_bAllowDateAxis ) { - nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); - EnableControls(); + bool bAutoDateAxis = false; + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + + USHORT nPos = 0; + if( m_nAxisType==chart2::AxisType::DATE ) + nPos=TYPE_DATE; + else if( bAutoDateAxis ) + nPos=TYPE_AUTO; + else + nPos=TYPE_TEXT; + m_aLB_AxisType.SelectEntryPos( nPos ); } + PlaceIntervalControlsAccordingToAxisType(); + + aCbxAutoMin.Check( true ); + aCbxAutoMax.Check( true ); + aCbxAutoStepMain.Check( true ); + aCbxAutoStepHelp.Check( true ); + aCbxAutoOrigin.Check( true ); + m_aCbx_AutoTimeResolution.Check( true ); if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); @@ -312,6 +494,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) { fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldStepMain.SetValue( fStepMain ); + m_aMt_MainDateStep.SetValue( static_cast(fStepMain) ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); @@ -332,11 +515,27 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) aFmtFldOrigin.SetValue( fOrigin ); } - EnableValueHdl(&aCbxAutoMin); - EnableValueHdl(&aCbxAutoMax); - EnableValueHdl(&aCbxAutoStepMain); - EnableValueHdl(&aCbxAutoStepHelp); - EnableValueHdl(&aCbxAutoOrigin); + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution ); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit ); + } + if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit ); + } + + EnableControls(); + SetNumFormat(); } int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) @@ -347,6 +546,8 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) return LEAVE_PAGE; } + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); const SfxPoolItem *pPoolItem = NULL; if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) @@ -356,75 +557,105 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) OSL_ENSURE( false, "Using Standard Language" ); } - Edit* pEdit = NULL; + Control* pControl = NULL; USHORT nErrStrId = 0; double fDummy; fMax = aFmtFldMax.GetValue(); fMin = aFmtFldMin.GetValue(); fOrigin = aFmtFldOrigin.GetValue(); - fStepMain = aFmtFldStepMain.GetValue(); + fStepMain = bDateAxis ? m_aMt_MainDateStep.GetValue() : aFmtFldStepMain.GetValue(); nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue()); + m_nTimeResolution = m_aLB_TimeResolution.GetSelectEntryPos(); + m_nMainTimeUnit = m_aLB_MainTimeUnit.GetSelectEntryPos(); + m_nHelpTimeUnit = m_aLB_HelpTimeUnit.GetSelectEntryPos(); + + if( chart2::AxisType::REALNUMBER != m_nAxisType ) + aCbxLogarithm.Show( false ); + + //check wich entries need user action - //do some reasonable automatic correction of user input if necessary - if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && - fMin >= fMax) - { - pEdit = &aFmtFldMin; - nErrStrId = STR_MIN_GREATER_MAX; - } - // check for entries in invalid ranges if ( aCbxLogarithm.IsChecked() && ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 ) || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) ) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_BAD_LOGARITHM; } - if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) + else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && + fMin >= fMax) + { + pControl = &aFmtFldMin; + nErrStrId = STR_MIN_GREATER_MAX; + } + else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } - - //check wich entries need user action - // check for entries that cannot be parsed for the current number format - if ( aFmtFldMin.IsModified() + else if ( aFmtFldMin.IsModified() && !aCbxAutoMin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_INVALID_NUMBER; } else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMax; + pControl = &aFmtFldMax; nErrStrId = STR_INVALID_NUMBER; } - else if (aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && + else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldOrigin; + pControl = &aFmtFldOrigin; nErrStrId = STR_INVALID_NUMBER; } else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } + else if( bDateAxis ) + { + if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() ) + { + if( m_nHelpTimeUnit > m_nMainTimeUnit ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + } + if( !nErrStrId && !m_aCbx_AutoTimeResolution.IsChecked() ) + { + if( (!aCbxAutoStepMain.IsChecked() && m_nTimeResolution > m_nMainTimeUnit ) + || + (!aCbxAutoStepHelp.IsChecked() && m_nTimeResolution > m_nHelpTimeUnit ) + ) + { + pControl = &m_aLB_TimeResolution; + nErrStrId = STR_INVALID_TIME_UNIT; + } + } + } - if( ShowWarning( nErrStrId, pEdit ) ) + if( ShowWarning( nErrStrId, pControl ) ) return KEEP_PAGE; if( pItemSet ) @@ -486,6 +717,19 @@ void ScaleTabPage::SetNumFormat() else nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME ); } + + if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) ) + { + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE ); + + aFmtFldMax.SetFormatKey( nFmt ); + aFmtFldMin.SetFormatKey( nFmt ); + aFmtFldOrigin.SetFormatKey( nFmt ); + } } aFmtFldStepMain.SetFormatKey( nFmt ); @@ -499,7 +743,7 @@ void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) m_bShowAxisOrigin = true; } -bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ ) +bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Control* pControl /* = NULL */ ) { if( nResIdMessage == 0 ) return false; @@ -508,7 +752,9 @@ bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL if( pControl ) { pControl->GrabFocus(); - pControl->SetSelection( Selection( 0, SELECTION_MAX )); + Edit* pEdit = dynamic_cast(pControl); + if(pEdit) + pEdit->SetSelection( Selection( 0, SELECTION_MAX )); } return true; } diff --git a/chart2/source/controller/dialogs/tp_Scale.hrc b/chart2/source/controller/dialogs/tp_Scale.hrc new file mode 100644 index 000000000000..bde6c21c7924 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.hrc @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_SCALE 1 + +#define TXT_MIN 1 +#define TXT_MAX 2 +#define TXT_STEP_MAIN 3 +#define TXT_STEP_HELP_COUNT 4 +#define TXT_ORIGIN 5 +#define TXT_TIME_RESOLUTION 6 +#define TXT_AXIS_TYPE 7 +#define TXT_STEP_HELP 8 + +#define CBX_AUTO_MIN 1 +#define CBX_AUTO_MAX 2 +#define CBX_AUTO_STEP_MAIN 3 +#define CBX_AUTO_STEP_HELP 4 +#define CBX_AUTO_ORIGIN 5 +#define CBX_LOGARITHM 6 +#define CBX_REVERSE 7 +#define CBX_AUTO_TIME_RESOLUTION 8 + +#define EDT_STEP_MAIN 1 +#define EDT_MAX 2 +#define EDT_MIN 3 +#define EDT_ORIGIN 4 + +#define MT_STEPHELP 10 +#define MT_MAIN_DATE_STEP 11 + +#define LB_AXIS_TYPE 1 +#define LB_MAIN_TIME_UNIT 2 +#define LB_HELP_TIME_UNIT 3 +#define LB_TIME_RESOLUTION 4 + +#define STR_LIST_TIME_UNIT 1 diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 8d0e02186c38..953187d1d9cf 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -37,6 +37,8 @@ #include // header for MetricField #include +// header for class ListBox +#include //............................................................................. namespace chart @@ -64,6 +66,13 @@ public: private: FixedLine aFlScale; + CheckBox aCbxReverse; + + CheckBox aCbxLogarithm; + + FixedText m_aTxt_AxisType; + ListBox m_aLB_AxisType; + FixedText aTxtMin; FormattedField aFmtFldMin; CheckBox aCbxAutoMin; @@ -72,34 +81,45 @@ private: FormattedField aFmtFldMax; CheckBox aCbxAutoMax; + FixedText m_aTxt_TimeResolution; + ListBox m_aLB_TimeResolution; + CheckBox m_aCbx_AutoTimeResolution; + FixedText aTxtMain; FormattedField aFmtFldStepMain; + MetricField m_aMt_MainDateStep; + ListBox m_aLB_MainTimeUnit; CheckBox aCbxAutoStepMain; + FixedText aTxtHelpCount; FixedText aTxtHelp; MetricField aMtStepHelp; + ListBox m_aLB_HelpTimeUnit; CheckBox aCbxAutoStepHelp; FixedText aTxtOrigin; FormattedField aFmtFldOrigin; CheckBox aCbxAutoOrigin; - CheckBox aCbxLogarithm; - CheckBox aCbxReverse; - double fMin; double fMax; double fStepMain; sal_Int32 nStepHelp; double fOrigin; - int nAxisType; + sal_Int32 m_nTimeResolution; + sal_Int32 m_nMainTimeUnit; + sal_Int32 m_nHelpTimeUnit; + int m_nAxisType; + bool m_bAllowDateAxis; SvNumberFormatter* pNumFormatter; bool m_bShowAxisOrigin; void AdjustControlPositions(); void EnableControls(); + void PlaceIntervalControlsAccordingToAxisType(); + DECL_LINK( SelectAxisTypeHdl, void* ); DECL_LINK( EnableValueHdl, CheckBox* ); /** shows a warning window due to an invalid input. @@ -115,7 +135,7 @@ private: @return false, if nResIdMessage was 0, true otherwise */ - bool ShowWarning( USHORT nResIdMessage, Edit * pControl = NULL ); + bool ShowWarning( USHORT nResIdMessage, Control* pControl = NULL ); }; //............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Scale.src b/chart2/source/controller/dialogs/tp_Scale.src old mode 100644 new mode 100755 index 9e92e70f6f43..f5a9221af20d --- a/chart2/source/controller/dialogs/tp_Scale.src +++ b/chart2/source/controller/dialogs/tp_Scale.src @@ -25,7 +25,7 @@ * ************************************************************************/ #include "HelpIds.hrc" -#include "TabPages.hrc" +#include "tp_Scale.hrc" #define YLine1 3 #define Y1 (YLine1+13) @@ -33,16 +33,26 @@ #define Y3 (Y2+16) #define Y4 (Y3+16) #define Y5 (Y4+16) -#define Y6 (Y5+17) -#define Y7 (Y6+15) +#define Y6 (Y5+16) +#define Y7 (Y6+16) +#define Y8 (Y7+16) #define LABELWIDTH 88 -#define AUTOCHECKWIDTH 88 +#define AUTOCHECKWIDTH 41 #define EDITWIDTH 50 #define X1 6 #define X2 11 #define X3 (X2+LABELWIDTH+4) #define X4 (X3+EDITWIDTH+5) +#define X5 (X4+AUTOCHECKWIDTH+5) + +#define STR_LIST_TIME_UNIT \ + StringList [ en-US ] = \ + { \ + "Days" ; \ + "Months" ; \ + "Years" ; \ + }; TabPage TP_SCALE { @@ -57,86 +67,201 @@ TabPage TP_SCALE Size = MAP_APPFONT ( 248 , 8 ) ; Text [ en-US ] = "Scale" ; }; - FixedText TXT_MIN + //--------------------------- + CheckBox CBX_REVERSE { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; Pos = MAP_APPFONT ( X2 , Y1 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Reverse direction" ; + }; + //--------------------------- + CheckBox CBX_LOGARITHM + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Logarithmic scale" ; + }; + //--------------------------- + FixedText TXT_AXIS_TYPE + { + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "T~ype" ; + }; + ListBox LB_AXIS_TYPE + { + HelpID = "chart2:ListBox:TP_SCALE:LB_AXIS_TYPE"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Automatic" ; + "Text" ; + "Date" ; + }; + }; + //--------------------------- + FixedText TXT_MIN + { + Pos = MAP_APPFONT ( X2 , Y3 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "~Minimum:" ; + Text [ en-US ] = "~Minimum" ; }; SpinField EDT_MIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_MIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y1-2 ) ; + Pos = MAP_APPFONT ( X3 , Y3-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MIN"; - Pos = MAP_APPFONT ( X4 , Y1-1 ) ; + Pos = MAP_APPFONT ( X4 , Y3+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Automatic" ; }; - + //--------------------------- FixedText TXT_MAX { - Pos = MAP_APPFONT ( X2 , Y2 ) ; + Pos = MAP_APPFONT ( X2 , Y4 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~ximum:" ; + Text [ en-US ] = "Ma~ximum" ; }; SpinField EDT_MAX { HelpID = "chart2:SpinField:TP_SCALE:EDT_MAX"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Pos = MAP_APPFONT ( X3 , Y4-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MAX { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MAX"; - Pos = MAP_APPFONT ( X4 , Y2-1 ) ; + Pos = MAP_APPFONT ( X4 , Y4+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "A~utomatic" ; }; + //--------------------------- + FixedText TXT_TIME_RESOLUTION + { + Pos = MAP_APPFONT ( X2 , Y5 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "R~esolution" ; + }; + ListBox LB_TIME_RESOLUTION + { + HelpID = "chart2:ListBox:TP_SCALE:LB_TIME_RESOLUTION"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_TIME_RESOLUTION + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_TIME_RESOLUTION"; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Automat~ic" ; + }; + //--------------------------- FixedText TXT_STEP_MAIN { - Pos = MAP_APPFONT ( X2 , Y3 ) ; + Pos = MAP_APPFONT ( X2 , Y5 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~jor interval:" ; + Text [ en-US ] = "Ma~jor interval" ; }; SpinField EDT_STEP_MAIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_STEP_MAIN"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y3-2 ) ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; + MetricField MT_MAIN_DATE_STEP + { + HelpID = "chart2:MetricField:TP_SCALE:MT_MAIN_DATE_STEP"; + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100000 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100000 ; + SpinSize = 1 ; + }; + + ListBox LB_MAIN_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_MAIN_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_STEP_MAIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_MAIN"; - Pos = MAP_APPFONT ( X4 , Y3-1 ) ; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Au~tomatic" ; }; + //--------------------------- + FixedText TXT_STEP_HELP_COUNT + { + Pos = MAP_APPFONT ( X2 , Y6 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Minor inter~val count" ; + }; FixedText TXT_STEP_HELP { - Pos = MAP_APPFONT ( X2 , Y4 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Minor interval ~count:" ; + Text [ en-US ] = "Minor inter~val" ; }; MetricField MT_STEPHELP { HelpID = "chart2:MetricField:TP_SCALE:MT_STEPHELP"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y4-2 ) ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; Repeat = TRUE ; @@ -149,55 +274,51 @@ TabPage TP_SCALE Last = 100 ; SpinSize = 1 ; }; + ListBox LB_HELP_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_HELP_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y7-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; CheckBox CBX_AUTO_STEP_HELP { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_HELP"; - Pos = MAP_APPFONT ( X4 , Y4-1 ) ; + Pos = MAP_APPFONT ( X4 , Y6+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Aut~omatic" ; }; - + //--------------------------- FixedText TXT_ORIGIN { - Pos = MAP_APPFONT ( X2 , Y5 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Reference ~value:" ; + Text [ en-US ] = "Re~ference value" ; }; SpinField EDT_ORIGIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_ORIGIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Pos = MAP_APPFONT ( X3 , Y7-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_ORIGIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_ORIGIN"; - Pos = MAP_APPFONT ( X4 , Y5-1 ) ; + Pos = MAP_APPFONT ( X4 , Y7+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Automat~ic" ; }; - - CheckBox CBX_LOGARITHM - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; - Pos = MAP_APPFONT ( X2 , Y6 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Logarithmic scale" ; - }; - - CheckBox CBX_REVERSE - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; - Pos = MAP_APPFONT ( X2 , Y7 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Reverse direction" ; - }; - + //--------------------------- }; diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 7c8f83452963..647f82a9eb6a 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -27,8 +27,7 @@ #ifndef CHART_AXISITEMCONVERTER_HXX #define CHART_AXISITEMCONVERTER_HXX -#include -#include +#include #include #include #include @@ -55,8 +54,8 @@ public: SdrModel& rDrawModel, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, - ::com::sun::star::chart2::ExplicitScaleData * pScale = NULL, - ::com::sun::star::chart2::ExplicitIncrementData * pIncrement = NULL, + ExplicitScaleData * pScale = NULL, + ExplicitIncrementData * pIncrement = NULL, ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = ::std::auto_ptr< ::com::sun::star::awt::Size >() ); virtual ~AxisItemConverter(); @@ -81,8 +80,8 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; - ::com::sun::star::chart2::ExplicitScaleData * m_pExplicitScale; - ::com::sun::star::chart2::ExplicitIncrementData * m_pExplicitIncrement; + ExplicitScaleData* m_pExplicitScale; + ExplicitIncrementData* m_pExplicitIncrement; }; } // namespace wrapper diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index 5e20b7980c8b..aa9ef0332b76 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -52,6 +52,7 @@ #define HID_SCH_TBI_DATA_SWAP_COL "CHART2_HID_SCH_TBI_DATA_SWAP_COL" #define HID_SCH_TBI_DATA_SWAP_ROW "CHART2_HID_SCH_TBI_DATA_SWAP_ROW" #define HID_SCH_TBI_DATA_INSERT_TEXT_COL "CHART2_HID_SCH_TBI_DATA_INSERT_TEXT_COL" +#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES" #define HID_SCH_TBX_DATA "CHART2_HID_SCH_TBX_DATA" #define HID_SCH_ALIGNMENT_CTR_DIAL "CHART2_HID_SCH_ALIGNMENT_CTR_DIAL" diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 8cf07aabad08..b1f861461817 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -38,12 +38,14 @@ #include "ChartModelHelper.hxx" #include "AxisHelper.hxx" #include "CommonConverters.hxx" +#include "ChartTypeHelper.hxx" #include #include #include #include #include +#include // for SfxBoolItem #include @@ -58,6 +60,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; +using ::com::sun::star::chart::TimeInterval; +using ::com::sun::star::chart::TimeIncrement; namespace { @@ -65,13 +69,13 @@ namespace { static ::comphelper::ItemPropertyMapType aAxisPropertyMap( ::comphelper::MakeItemPropertyMap - IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_ORDER, "ArrangeOrder", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXTBREAK, "TextBreak", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_OVERLAP, "TextOverlap", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_ORDER, "ArrangeOrder", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_BREAK, "TextBreak", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_OVERLAP, "TextOverlap", 0 ) ); return aAxisPropertyMap; @@ -88,8 +92,8 @@ AxisItemConverter::AxisItemConverter( SfxItemPool& rItemPool, SdrModel& rDrawModel, const Reference< chart2::XChartDocument > & xChartDoc, - chart2::ExplicitScaleData * pScale /* = NULL */, - chart2::ExplicitIncrementData * pIncrement /* = NULL */, + ::chart::ExplicitScaleData * pScale /* = NULL */, + ::chart::ExplicitIncrementData * pIncrement /* = NULL */, ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) : ItemConverter( rPropertySet, rItemPool ), m_xChartDoc( xChartDoc ), @@ -99,9 +103,9 @@ AxisItemConverter::AxisItemConverter( Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY ); if( pScale ) - m_pExplicitScale = new chart2::ExplicitScaleData( *pScale ); + m_pExplicitScale = new ::chart::ExplicitScaleData( *pScale ); if( pIncrement ) - m_pExplicitIncrement = new chart2::ExplicitIncrementData( *pIncrement ); + m_pExplicitIncrement = new ::chart::ExplicitIncrementData( *pIncrement ); m_aConverters.push_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, @@ -162,30 +166,40 @@ bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWit return true; } +bool lcl_hasTimeIntervalValue( const uno::Any& rAny ) +{ + bool bRet = false; + TimeInterval aValue; + if( rAny >>= aValue ) + bRet = true; + return bRet; +} + void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { - if( ! m_xAxis.is() ) + if( !m_xAxis.is() ) return; - const chart2::ScaleData aScale( m_xAxis->getScaleData() ); - const chart2::IncrementData aInc( aScale.IncrementData ); - const uno::Sequence< chart2::SubIncrement > aSubIncs( aScale.IncrementData.SubIncrements ); + const chart2::ScaleData& rScale( m_xAxis->getScaleData() ); + const chart2::IncrementData& rIncrement( rScale.IncrementData ); + const uno::Sequence< chart2::SubIncrement >& rSubIncrements( rScale.IncrementData.SubIncrements ); + const TimeIncrement& rTimeIncrement( rScale.TimeIncrement ); + bool bDateAxis = (chart2::AxisType::DATE == rScale.AxisType); + if( m_pExplicitScale ) + bDateAxis = (chart2::AxisType::DATE == m_pExplicitScale->AxisType); switch( nWhichId ) { case SCHATTR_AXIS_AUTO_MAX: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Maximum) ) ); break; case SCHATTR_AXIS_MAX: { double fMax = 10.0; - if( aScale.Maximum >>= fMax ) - { + if( rScale.Maximum >>= fMax ) rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); - } else { if( m_pExplicitScale ) @@ -196,106 +210,141 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXIS_AUTO_MIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Minimum) ) ); break; case SCHATTR_AXIS_MIN: { double fMin = 0.0; - if( aScale.Minimum >>= fMin ) - { + if( rScale.Minimum >>= fMin ) rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) ); - } - else - { - if( m_pExplicitScale ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); - } + else if( m_pExplicitScale ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); } break; case SCHATTR_AXIS_LOGARITHM: - { - BOOL bValue = AxisHelper::isLogarithmic( aScale.Scaling ); - rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); - } - break; + { + BOOL bValue = AxisHelper::isLogarithmic( rScale.Scaling ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + break; case SCHATTR_AXIS_REVERSE: - rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == aScale.Orientation) )); + rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == rScale.Orientation) )); break; // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aInc.Distance) ) ); + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) ); + break; + + case SCHATTR_AXIS_MAIN_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) ); + } break; case SCHATTR_AXIS_STEP_MAIN: + if( bDateAxis ) + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, nWhichId )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId )); + } + else { double fDistance = 1.0; - if( aInc.Distance >>= fDistance ) - { + if( rIncrement.Distance >>= fDistance ) rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId )); - } - else - { - if( m_pExplicitIncrement ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); - } + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); } break; // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - { - // if the any has no value => auto is on - rOutItemSet.Put( - SfxBoolItem( - nWhichId, - ! ( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue() ))); - } - break; + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, + ! ( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue() ))); + break; + + case SCHATTR_AXIS_HELP_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) ); + } + break; case SCHATTR_AXIS_STEP_HELP: - { - if( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue()) + if( bDateAxis ) { - OSL_ASSERT( aSubIncs[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - *reinterpret_cast< const sal_Int32 * >( - aSubIncs[0].IntervalCount.getValue()) )); + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number )); } else { - if( m_pExplicitIncrement && - m_pExplicitIncrement->SubIncrements.getLength() > 0 ) + if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue()) + { + OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); + rOutItemSet.Put( SfxInt32Item( nWhichId, + *reinterpret_cast< const sal_Int32 * >( + rSubIncrements[0].IntervalCount.getValue()) )); + } + else { - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, + m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + } } } - } - break; + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + { + rOutItemSet.Put( SfxBoolItem( nWhichId, + !rTimeIncrement.TimeResolution.hasValue() )); + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + { + long nTimeResolution=0; + if( rTimeIncrement.TimeResolution >>= nTimeResolution ) + rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); + else if( m_pExplicitScale ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) ); + } + break; case SCHATTR_AXIS_AUTO_ORIGIN: { - // if the any has no double value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); + rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(rScale.Origin) ))); } break; case SCHATTR_AXIS_ORIGIN: { double fOrigin = 0.0; - if( !(aScale.Origin >>= fOrigin) ) + if( !(rScale.Origin >>= fOrigin) ) { if( m_pExplicitScale ) fOrigin = m_pExplicitScale->Origin; @@ -367,7 +416,6 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -391,11 +439,44 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXISTYPE: - rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); + rOutItemSet.Put( SfxInt32Item( nWhichId, rScale.AxisType )); + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + rOutItemSet.Put( SfxBoolItem( nWhichId, rScale.AutoDateAxis )); + break; + + case SCHATTR_AXIS_ALLOW_DATEAXIS: + { + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; + AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); + } break; } } +bool lcl_isDateAxis( const SfxItemSet & rItemSet ) +{ + sal_Int32 nAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_AXISTYPE )).GetValue();//::com::sun::star::chart2::AxisType + return (chart2::AxisType::DATE == nAxisType); +} + +bool lcl_isAutoMajor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue(); + return bRet; +} + +bool lcl_isAutoMinor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue(); + return bRet; +} + bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { @@ -502,23 +583,47 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() )) + if( lcl_isAutoMajor(rItemSet) ) { aScale.IncrementData.Distance.clear(); + aScale.TimeIncrement.MajorTimeInterval.clear(); bSetScale = true; } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_MAIN_TIME_UNIT: + if( !lcl_isAutoMajor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_MAIN: // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue() )) + if( !lcl_isAutoMajor(rItemSet) ) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - - if( aScale.IncrementData.Distance != aValue ) + if( lcl_isDateAxis(rItemSet) ) + { + double fValue = 1.0; + if( aValue >>= fValue ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aTimeInterval.Number = static_cast(fValue); + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + else if( aScale.IncrementData.Distance != aValue ) { aScale.IncrementData.Distance = aValue; bSetScale = true; @@ -528,35 +633,85 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 && - aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + if( lcl_isAutoMinor(rItemSet) ) { - aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + if( aScale.IncrementData.SubIncrements.getLength() > 0 && + aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + { + aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + bSetScale = true; + } + if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) + { + aScale.TimeIncrement.MinorTimeInterval.clear(); bSetScale = true; + } } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_HELP_TIME_UNIT: + if( !lcl_isAutoMinor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_HELP: - // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 ) + // only if auto is false + if( !lcl_isAutoMinor(rItemSet) ) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + if( lcl_isDateAxis(rItemSet) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.Number; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny(aTimeInterval); + bSetScale = true; + } + else if( aScale.IncrementData.SubIncrements.getLength() > 0 ) + { + if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || + aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + { + OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); + aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + bSetScale = true; + } + } + } + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + if( (static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.TimeIncrement.TimeResolution.clear(); + bSetScale = true; + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + // only if auto is false + if( ! (static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION )).GetValue() )) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || - aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + if( aScale.TimeIncrement.TimeResolution != aValue ) { - OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); - aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + aScale.TimeIncrement.TimeResolution = aValue; bSetScale = true; } } break; + case SCHATTR_AXIS_AUTO_ORIGIN: { if( (static_cast< const SfxBoolItem & >( @@ -757,7 +912,6 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -821,7 +975,23 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SCHATTR_AXISTYPE: - //don't allow to change the axis type so far + { + sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//::com::sun::star::chart2::AxisType + aScale.AxisType = nNewAxisType; + bSetScale = true; + } + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + { + bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + bool bOldValue = aScale.AutoDateAxis; + if( bOldValue != bNewValue ) + { + aScale.AutoDateAxis = bNewValue; + bSetScale = true; + } + } break; } diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index f7ddeb42c11e..139283b92e23 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -45,8 +45,7 @@ namespace const USHORT nTitleWhichPairs[] = { - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx @@ -60,24 +59,17 @@ const USHORT nAxisWhichPairs[] = CHARACTER_WHICHPAIRS, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432 svx/svxids.hrc - SCHATTR_AXISTYPE, SCHATTR_AXISTYPE, // 39 sch/schattr.hxx - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_START, SCHATTR_AXIS_END, // 70 - 95 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_START, SCHATTR_AXIS_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nAllAxisWhichPairs[] = { - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_LINE_FIRST, XATTR_LINE_LAST, CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, // 85 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; @@ -102,8 +94,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, 0 @@ -117,8 +107,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ \ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, \ SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \ SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \ @@ -165,16 +153,14 @@ const USHORT nAreaWhichPairs[] = const USHORT nTextWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nTextOrientWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx index 57e8e7315334..e45329465d45 100644 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ b/chart2/source/controller/main/ImplUndoManager.cxx @@ -36,7 +36,7 @@ #include "DataSourceHelper.hxx" #include "ChartModelHelper.hxx" -#include +#include #include #include #include @@ -52,7 +52,7 @@ using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; -using ::com::sun::star::chart::XComplexDescriptionAccess; +using ::com::sun::star::chart2::XAnyDescriptionAccess; namespace chart { @@ -69,13 +69,13 @@ void ImplApplyDataToModel( // copy data from stored internal data provider if( xDoc.is() && xDoc->hasInternalDataProvider()) { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); + Reference< XAnyDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); + Reference< XAnyDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); if( xCurrentData.is() && xSavedData.is()) { xCurrentData->setData( xSavedData->getData()); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); + xCurrentData->setAnyRowDescriptions( xSavedData->getAnyRowDescriptions()); + xCurrentData->setAnyColumnDescriptions( xSavedData->getAnyColumnDescriptions()); } } } diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index 75e69436a784..eaaee11abe10 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -29,6 +29,7 @@ #include "charttoolsdllapi.hxx" #include "ReferenceSizeProvider.hxx" +#include "ExplicitCategoriesProvider.hxx" #include #include #include @@ -58,6 +59,9 @@ public: static bool isLogarithmic( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScaling ); + static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ); + static ::com::sun::star::chart2::ScaleData getDateCheckedScale( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > createAxis( sal_Int32 nDimensionIndex, bool bMainAxis diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index 729cfc86bc52..67df6027d2d7 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -61,8 +61,9 @@ public: static bool isSupportingStartingAngle( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); //starting value for bars or baseline for areas for example static bool isSupportingBaseValue( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); - static bool shiftTicksAtXAxisPerDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); + static bool shiftCategoryPosAtXAxisPerDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); static bool isSupportingAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); + static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); //returns sequence of ::com::sun::star::chart::DataLabelPlacement static ::com::sun::star::uno::Sequence < sal_Int32 > getSupportedLabelPlacements( diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index c7cda6189680..858454497db5 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -240,6 +240,22 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCooSys ); + static bool mayToggleDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void toggleDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void switchToDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void switchToTextCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > getChartTypeByIndex( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx index 18d54eb6e2ad..dfa6379a42a1 100644 --- a/chart2/source/inc/ExplicitCategoriesProvider.hxx +++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx @@ -58,6 +58,24 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0; }; +struct DatePlusIndex +{ + DatePlusIndex() + : fValue(1.0) + , nIndex( -1 ) + { + } + + DatePlusIndex( const double& _fValue, sal_Int32 _nIndex ) + : fValue(_fValue) + , nIndex( _nIndex ) + { + } + + double fValue; + sal_Int32 nIndex; +}; + class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider { public: @@ -70,6 +88,9 @@ public: void init(); + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence > getOriginalCategories(); + ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories(); ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel ); @@ -89,17 +110,26 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList(); + bool isDateAxis(); + const std::vector< DatePlusIndex >& getDateCategories(); + private: //member - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; - ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; bool volatile m_bDirty; - ::com::sun::star::uno::WeakReference< - ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; + ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XModel > m_xChartModel; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories; + + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; + ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList; + + bool m_bIsDateAxis; + bool m_bIsAutoDate; + std::vector< DatePlusIndex > m_aDateCategories; }; } // namespace chart diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx index 6b6590cffdac..48a8ee86f6ab 100755 --- a/chart2/source/inc/InternalData.hxx +++ b/chart2/source/inc/InternalData.hxx @@ -53,11 +53,11 @@ public: void setColumnValues( sal_Int32 nColumnIndex, const ::std::vector< double > & rNewData ); void setRowValues( sal_Int32 nRowIndex, const ::std::vector< double > & rNewData ); - void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel ); - void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel ); + void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel ); + void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel ); - ::std::vector< ::rtl::OUString > getComplexColumnLabel( sal_Int32 nColumnIndex ) const; - ::std::vector< ::rtl::OUString > getComplexRowLabel( sal_Int32 nRowIndex ) const; + ::std::vector< ::com::sun::star::uno::Any > getComplexColumnLabel( sal_Int32 nColumnIndex ) const; + ::std::vector< ::com::sun::star::uno::Any > getComplexRowLabel( sal_Int32 nRowIndex ) const; void swapRowWithNext( sal_Int32 nRowIndex ); void swapColumnWithNext( sal_Int32 nColumnIndex ); @@ -76,12 +76,12 @@ public: sal_Int32 getColumnCount() const; typedef ::std::valarray< double > tDataType; - typedef ::std::vector< ::std::vector< ::rtl::OUString > > tVecVecString; //inner index is hierarchical level + typedef ::std::vector< ::std::vector< ::com::sun::star::uno::Any > > tVecVecAny; //inner index is hierarchical level - void setComplexRowLabels( const tVecVecString& rNewRowLabels ); - tVecVecString getComplexRowLabels() const; - void setComplexColumnLabels( const tVecVecString& rNewColumnLabels ); - tVecVecString getComplexColumnLabels() const; + void setComplexRowLabels( const tVecVecAny& rNewRowLabels ); + tVecVecAny getComplexRowLabels() const; + void setComplexColumnLabels( const tVecVecAny& rNewColumnLabels ); + tVecVecAny getComplexColumnLabels() const; #if OSL_DEBUG_LEVEL > 2 void traceData() const; @@ -99,9 +99,9 @@ private: sal_Int32 m_nColumnCount; sal_Int32 m_nRowCount; - tDataType m_aData; - tVecVecString m_aRowLabels;//outer index is row index, inner index is category level - tVecVecString m_aColumnLabels;//outer index is column index + tDataType m_aData; + tVecVecAny m_aRowLabels;//outer index is row index, inner index is category level + tVecVecAny m_aColumnLabels;//outer index is column index }; #endif diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx index f5e12f87f505..e467a9746df4 100644 --- a/chart2/source/inc/InternalDataProvider.hxx +++ b/chart2/source/inc/InternalDataProvider.hxx @@ -30,7 +30,8 @@ #include "InternalData.hxx" #include -#include +#include +#include #include #include #include @@ -38,7 +39,7 @@ #include #include #include -#include +#include #include "ServiceMacros.hxx" #include "CachedDataSequence.hxx" @@ -52,10 +53,11 @@ namespace chart namespace impl { -typedef ::cppu::WeakImplHelper6< +typedef ::cppu::WeakImplHelper7< ::com::sun::star::chart2::XInternalDataProvider, ::com::sun::star::chart2::data::XRangeXMLConversion, - ::com::sun::star::chart::XComplexDescriptionAccess, + ::com::sun::star::chart2::XAnyDescriptionAccess, + ::com::sun::star::chart::XDateCategories, ::com::sun::star::util::XCloneable, ::com::sun::star::lang::XInitialization, ::com::sun::star::lang::XServiceInfo > @@ -149,7 +151,25 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - // ____ XComplexDescriptionAccess ____ + // ____ XDateCategories ____ + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XAnyDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyRowDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyColumnDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setComplexRowDescriptions( diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index 47ed75e80a9a..d263881a0905 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -30,8 +30,7 @@ // this includes no link dependency #include -//next free is 291 -//single free is: 134 +//next free is 294 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -165,6 +164,8 @@ #define STR_STEP_GT_ZERO (RID_APP_START + 102) #define STR_BAD_LOGARITHM (RID_APP_START + 111) #define STR_MIN_GREATER_MAX (RID_APP_START + 101) +#define STR_INVALID_INTERVALS (RID_APP_START + 291) +#define STR_INVALID_TIME_UNIT (RID_APP_START + 292) //----------------------------------------------------------------------------- //for range didalog @@ -193,6 +194,8 @@ #define STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS (RID_APP_START + 21) #define STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS (RID_APP_START + 267) +#define STR_DATA_DATE_CATEGORIES (RID_APP_START + 293) + //----------------------------------------------------------------------------- //chart objects //e.g. used as titles for insert dialogs and object properties dialog diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index fbcce70bd1d6..b6390ab12b22 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -27,13 +27,6 @@ #ifndef CHARTSFXITEMIDS_HXX #define CHARTSFXITEMIDS_HXX -#include - -/* -// header for SID_OBJ1_START -#include -*/ - // ============================================================ // SCHATTR // ============================================================ @@ -49,68 +42,23 @@ #define SCHATTR_DATADESCR_PLACEMENT (SCHATTR_DATADESCR_START + 5) #define SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS (SCHATTR_DATADESCR_START + 6) #define SCHATTR_DATADESCR_NO_PERCENTVALUE (SCHATTR_DATADESCR_START + 7) //percentage values should not be offered -#define SCHATTR_DATADESCR_END SCHATTR_DATADESCR_NO_PERCENTVALUE +#define SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_DATADESCR_START + 8) +#define SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_DATADESCR_START + 9) +#define SCHATTR_DATADESCR_END SCHATTR_PERCENT_NUMBERFORMAT_SOURCE +//legend #define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1) #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START #define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS +//text #define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) -// #define SCHATTR_TEXT_ORIENT SCHATTR_TEXT_START -// name changed: -#define SCHATTR_TEXT_STACKED SCHATTR_TEXT_START -#define SCHATTR_TEXT_ORDER (SCHATTR_TEXT_START + 1) -#define SCHATTR_TEXT_END SCHATTR_TEXT_ORDER - -#define SCHATTR_Y_AXIS_START (SCHATTR_TEXT_END + 1) -#define SCHATTR_Y_AXIS_AUTO_MIN SCHATTR_Y_AXIS_START -#define SCHATTR_Y_AXIS_MIN (SCHATTR_Y_AXIS_START + 1) -#define SCHATTR_Y_AXIS_AUTO_MAX (SCHATTR_Y_AXIS_START + 2) -#define SCHATTR_Y_AXIS_MAX (SCHATTR_Y_AXIS_START + 3) -#define SCHATTR_Y_AXIS_AUTO_STEP_MAIN (SCHATTR_Y_AXIS_START + 4) -#define SCHATTR_Y_AXIS_STEP_MAIN (SCHATTR_Y_AXIS_START + 5) -#define SCHATTR_Y_AXIS_AUTO_STEP_HELP (SCHATTR_Y_AXIS_START + 6) -#define SCHATTR_Y_AXIS_STEP_HELP (SCHATTR_Y_AXIS_START + 7) -#define SCHATTR_Y_AXIS_LOGARITHM (SCHATTR_Y_AXIS_START + 8) -#define SCHATTR_Y_AXIS_AUTO_ORIGIN (SCHATTR_Y_AXIS_START + 9) -#define SCHATTR_Y_AXIS_ORIGIN (SCHATTR_Y_AXIS_START + 10) -#define SCHATTR_Y_AXIS_END SCHATTR_Y_AXIS_ORIGIN - -#define SCHATTR_X_AXIS_START (SCHATTR_Y_AXIS_END + 1) -#define SCHATTR_X_AXIS_AUTO_MIN SCHATTR_X_AXIS_START -#define SCHATTR_X_AXIS_MIN (SCHATTR_X_AXIS_START + 1) -#define SCHATTR_X_AXIS_AUTO_MAX (SCHATTR_X_AXIS_START + 2) -#define SCHATTR_X_AXIS_MAX (SCHATTR_X_AXIS_START + 3) -#define SCHATTR_X_AXIS_AUTO_STEP_MAIN (SCHATTR_X_AXIS_START + 4) -#define SCHATTR_X_AXIS_STEP_MAIN (SCHATTR_X_AXIS_START + 5) -#define SCHATTR_X_AXIS_AUTO_STEP_HELP (SCHATTR_X_AXIS_START + 6) -#define SCHATTR_X_AXIS_STEP_HELP (SCHATTR_X_AXIS_START + 7) -#define SCHATTR_X_AXIS_LOGARITHM (SCHATTR_X_AXIS_START + 8) -#define SCHATTR_X_AXIS_AUTO_ORIGIN (SCHATTR_X_AXIS_START + 9) -#define SCHATTR_X_AXIS_ORIGIN (SCHATTR_X_AXIS_START + 10) -#define SCHATTR_X_AXIS_END SCHATTR_X_AXIS_ORIGIN +#define SCHATTR_TEXT_DEGREES SCHATTR_TEXT_START +#define SCHATTR_TEXT_STACKED (SCHATTR_TEXT_START + 1) +#define SCHATTR_TEXT_END SCHATTR_TEXT_STACKED -#define SCHATTR_Z_AXIS_START (SCHATTR_X_AXIS_END + 1) -#define SCHATTR_Z_AXIS_AUTO_MIN SCHATTR_Z_AXIS_START -#define SCHATTR_Z_AXIS_MIN (SCHATTR_Z_AXIS_START + 1) -#define SCHATTR_Z_AXIS_AUTO_MAX (SCHATTR_Z_AXIS_START + 2) -#define SCHATTR_Z_AXIS_MAX (SCHATTR_Z_AXIS_START + 3) -#define SCHATTR_Z_AXIS_AUTO_STEP_MAIN (SCHATTR_Z_AXIS_START + 4) -#define SCHATTR_Z_AXIS_STEP_MAIN (SCHATTR_Z_AXIS_START + 5) -#define SCHATTR_Z_AXIS_AUTO_STEP_HELP (SCHATTR_Z_AXIS_START + 6) -#define SCHATTR_Z_AXIS_STEP_HELP (SCHATTR_Z_AXIS_START + 7) -#define SCHATTR_Z_AXIS_LOGARITHM (SCHATTR_Z_AXIS_START + 8) -#define SCHATTR_Z_AXIS_AUTO_ORIGIN (SCHATTR_Z_AXIS_START + 9) -#define SCHATTR_Z_AXIS_ORIGIN (SCHATTR_Z_AXIS_START + 10) -#define SCHATTR_Z_AXIS_END SCHATTR_Z_AXIS_ORIGIN - -// miscellaneous - -#define SCHATTR_AXISTYPE (SCHATTR_Z_AXIS_END + 1) -#define SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_Z_AXIS_END + 2) -#define SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_Z_AXIS_END + 3) - -#define SCHATTR_STAT_START (SCHATTR_PERCENT_NUMBERFORMAT_SOURCE + 1) +// statistic +#define SCHATTR_STAT_START (SCHATTR_TEXT_END + 1) #define SCHATTR_STAT_AVERAGE SCHATTR_STAT_START #define SCHATTR_STAT_KIND_ERROR (SCHATTR_STAT_START + 1) #define SCHATTR_STAT_PERCENT (SCHATTR_STAT_START + 2) @@ -122,16 +70,11 @@ #define SCHATTR_STAT_RANGE_NEG (SCHATTR_STAT_START + 8) #define SCHATTR_STAT_END SCHATTR_STAT_RANGE_NEG -#define SCHATTR_TEXT2_START ( SCHATTR_STAT_END + 1) -#define SCHATTR_TEXT_DEGREES ( SCHATTR_TEXT2_START ) -#define SCHATTR_TEXT_OVERLAP (SCHATTR_TEXT2_START +1) -#define SCHATTR_TEXT2_END ( SCHATTR_TEXT_OVERLAP ) - // -------------------------------------------------------- // these attributes are for replacement of enum eChartStyle // -------------------------------------------------------- -#define SCHATTR_STYLE_START ( SCHATTR_TEXT2_END +1 ) +#define SCHATTR_STYLE_START ( SCHATTR_STAT_END +1 ) // for whole chart #define SCHATTR_STYLE_DEEP ( SCHATTR_STYLE_START ) @@ -155,35 +98,44 @@ #define SCHATTR_AXIS (SCHATTR_STYLE_END + 1)// see chtmodel.hxx defines CHART_AXIS_PRIMARY_X, etc. //Ummappen: #define SCHATTR_AXIS_START (SCHATTR_AXIS + 1) -#define SCHATTR_AXIS_AUTO_MIN SCHATTR_AXIS_START -#define SCHATTR_AXIS_MIN (SCHATTR_AXIS_START + 1) -#define SCHATTR_AXIS_AUTO_MAX (SCHATTR_AXIS_START + 2) -#define SCHATTR_AXIS_MAX (SCHATTR_AXIS_START + 3) -#define SCHATTR_AXIS_AUTO_STEP_MAIN (SCHATTR_AXIS_START + 4) -#define SCHATTR_AXIS_STEP_MAIN (SCHATTR_AXIS_START + 5) -#define SCHATTR_AXIS_AUTO_STEP_HELP (SCHATTR_AXIS_START + 6) -// SCHATTR_AXIS_STEP_HELP: type changed from double to sal_Int32 ! -#define SCHATTR_AXIS_STEP_HELP (SCHATTR_AXIS_START + 7) -#define SCHATTR_AXIS_LOGARITHM (SCHATTR_AXIS_START + 8) -#define SCHATTR_AXIS_AUTO_ORIGIN (SCHATTR_AXIS_START + 9) -#define SCHATTR_AXIS_ORIGIN (SCHATTR_AXIS_START + 10) -//Neu: -#define SCHATTR_AXIS_TICKS (SCHATTR_AXIS_START + 11) -#define SCHATTR_AXIS_NUMFMT (SCHATTR_AXIS_START + 12) -#define SCHATTR_AXIS_NUMFMTPERCENT (SCHATTR_AXIS_START + 13) -#define SCHATTR_AXIS_SHOWAXIS (SCHATTR_AXIS_START + 14) -#define SCHATTR_AXIS_SHOWDESCR (SCHATTR_AXIS_START + 15) -#define SCHATTR_AXIS_SHOWMAINGRID (SCHATTR_AXIS_START + 16) -#define SCHATTR_AXIS_SHOWHELPGRID (SCHATTR_AXIS_START + 17) -#define SCHATTR_AXIS_TOPDOWN (SCHATTR_AXIS_START + 18) -#define SCHATTR_AXIS_HELPTICKS (SCHATTR_AXIS_START + 19) -#define SCHATTR_AXIS_REVERSE (SCHATTR_AXIS_START + 20) -#define SCHATTR_AXIS_POSITION (SCHATTR_AXIS_START + 21) -#define SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_START + 22) -#define SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_START + 23) -#define SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_START + 24) -#define SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_START + 25) -#define SCHATTR_AXIS_END SCHATTR_AXIS_MARK_POSITION +//axis scale +#define SCHATTR_AXISTYPE SCHATTR_AXIS_START +#define SCHATTR_AXIS_REVERSE (SCHATTR_AXIS_START + 1) +#define SCHATTR_AXIS_AUTO_MIN (SCHATTR_AXIS_START + 2) +#define SCHATTR_AXIS_MIN (SCHATTR_AXIS_START + 3) +#define SCHATTR_AXIS_AUTO_MAX (SCHATTR_AXIS_START + 4) +#define SCHATTR_AXIS_MAX (SCHATTR_AXIS_START + 5) +#define SCHATTR_AXIS_AUTO_STEP_MAIN (SCHATTR_AXIS_START + 6) +#define SCHATTR_AXIS_STEP_MAIN (SCHATTR_AXIS_START + 7) +#define SCHATTR_AXIS_MAIN_TIME_UNIT (SCHATTR_AXIS_START + 8) +#define SCHATTR_AXIS_AUTO_STEP_HELP (SCHATTR_AXIS_START + 9) +#define SCHATTR_AXIS_STEP_HELP (SCHATTR_AXIS_START + 10) +#define SCHATTR_AXIS_HELP_TIME_UNIT (SCHATTR_AXIS_START + 11) +#define SCHATTR_AXIS_AUTO_TIME_RESOLUTION (SCHATTR_AXIS_START + 12) +#define SCHATTR_AXIS_TIME_RESOLUTION (SCHATTR_AXIS_START + 13) +#define SCHATTR_AXIS_LOGARITHM (SCHATTR_AXIS_START + 14) +#define SCHATTR_AXIS_AUTO_DATEAXIS (SCHATTR_AXIS_START + 15) +#define SCHATTR_AXIS_ALLOW_DATEAXIS (SCHATTR_AXIS_START + 16) +#define SCHATTR_AXIS_AUTO_ORIGIN (SCHATTR_AXIS_START + 17) +#define SCHATTR_AXIS_ORIGIN (SCHATTR_AXIS_START + 18) +//axis position +#define SCHATTR_AXIS_POSITION_START (SCHATTR_AXIS_ORIGIN +1) +#define SCHATTR_AXIS_TICKS SCHATTR_AXIS_POSITION_START +#define SCHATTR_AXIS_HELPTICKS (SCHATTR_AXIS_POSITION_START + 1) +#define SCHATTR_AXIS_POSITION (SCHATTR_AXIS_POSITION_START + 2) +#define SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_POSITION_START + 3) +#define SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_POSITION_START + 4) +#define SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_POSITION_START + 5) +#define SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_POSITION_START + 6) +//axis label +#define SCHATTR_AXIS_LABEL_START (SCHATTR_AXIS_MARK_POSITION +1) +#define SCHATTR_AXIS_SHOWDESCR SCHATTR_AXIS_LABEL_START +#define SCHATTR_AXIS_LABEL_ORDER (SCHATTR_AXIS_LABEL_START + 1) +#define SCHATTR_AXIS_LABEL_OVERLAP (SCHATTR_AXIS_LABEL_START + 2) +#define SCHATTR_AXIS_LABEL_BREAK (SCHATTR_AXIS_LABEL_START + 3) +#define SCHATTR_AXIS_LABEL_END SCHATTR_AXIS_LABEL_BREAK + +#define SCHATTR_AXIS_END SCHATTR_AXIS_LABEL_END #define SCHATTR_SYMBOL_BRUSH (SCHATTR_AXIS_END + 1) #define SCHATTR_STOCK_VOLUME (SCHATTR_AXIS_END + 2) @@ -201,13 +153,12 @@ #define SCHATTR_SPLINE_ORDER (SCHATTR_CHARTTYPE_START + 4) #define SCHATTR_SPLINE_RESOLUTION (SCHATTR_CHARTTYPE_START + 5) #define SCHATTR_DIAGRAM_STYLE (SCHATTR_CHARTTYPE_START + 6) -#define SCHATTR_TEXTBREAK (SCHATTR_CHARTTYPE_START + 7) -#define SCHATTR_GROUP_BARS_PER_AXIS (SCHATTR_CHARTTYPE_START + 8) -#define SCHATTR_STARTING_ANGLE (SCHATTR_CHARTTYPE_START + 9) -#define SCHATTR_CLOCKWISE (SCHATTR_CHARTTYPE_START + 10) -#define SCHATTR_MISSING_VALUE_TREATMENT (SCHATTR_CHARTTYPE_START + 11) -#define SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS (SCHATTR_CHARTTYPE_START + 12) -#define SCHATTR_INCLUDE_HIDDEN_CELLS (SCHATTR_CHARTTYPE_START + 13) +#define SCHATTR_GROUP_BARS_PER_AXIS (SCHATTR_CHARTTYPE_START + 7) +#define SCHATTR_STARTING_ANGLE (SCHATTR_CHARTTYPE_START + 8) +#define SCHATTR_CLOCKWISE (SCHATTR_CHARTTYPE_START + 9) +#define SCHATTR_MISSING_VALUE_TREATMENT (SCHATTR_CHARTTYPE_START + 10) +#define SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS (SCHATTR_CHARTTYPE_START + 11) +#define SCHATTR_INCLUDE_HIDDEN_CELLS (SCHATTR_CHARTTYPE_START + 12) #define SCHATTR_CHARTTYPE_END SCHATTR_INCLUDE_HIDDEN_CELLS @@ -236,9 +187,11 @@ #define CHAXIS_MARK_NONE 0 // values for SCHATTR_AXISTYPE items -#define CHART_AXIS_X 0 -#define CHART_AXIS_Y 1 -#define CHART_AXIS_Z 2 +#define CHART_AXIS_REALNUMBER 0 +#define CHART_AXIS_PERCENT 1 +#define CHART_AXIS_CATEGORY 2 +#define CHART_AXIS_SERIES 3 +#define CHART_AXIS_DATE 4 // values for SCHATTR_STYLE_SHAPE items #define CHART_SHAPE3D_IGNORE -2 //intern! (GetChartShapeStyle()!) diff --git a/chart2/source/inc/chartview/ExplicitScaleValues.hxx b/chart2/source/inc/chartview/ExplicitScaleValues.hxx new file mode 100644 index 000000000000..a2902391b6c2 --- /dev/null +++ b/chart2/source/inc/chartview/ExplicitScaleValues.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_EXPLICITSCALEVALUES_HXX +#define _CHART2_EXPLICITSCALEVALUES_HXX + +#include "chartviewdllapi.hxx" +#include +#include +#include +#include +#include +#include +#include +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** This structure contains the explicit values for a scale like Minimum and Maximum. + See also ::com::sun::star::chart2::ScaleData. +*/ + +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitScaleData +{ + ExplicitScaleData(); + + double Minimum; + double Maximum; + double Origin; + + ::com::sun::star::chart2::AxisOrientation Orientation; + + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > Scaling; + + long AxisType;//see ::com::sun::star::chart2::AxisType + bool ShiftedCategoryPosition; + long TimeResolution; //constant of type ::com::sun::star::chart::TimeUnit + Date NullDate; +}; + +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitSubIncrement +{ + ExplicitSubIncrement(); + + /** Numbers of intervals between two superior ticks. For an axis + this usually means, that IntervalCount - 1 + sub-tick-marks are displayed between two superior ticks. + + */ + long IntervalCount; + + /** If , the distance between two sub-tick-marks on the + screen is always the same. If , the distances may + differ depending on the XScaling. + */ + bool PostEquidistant; +}; + +/** describes how tickmarks are positioned on the scale of an axis. +*/ +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitIncrementData +{ + ExplicitIncrementData(); + + /** the following two members are only for date-time axis + */ + ::com::sun::star::chart::TimeInterval MajorTimeInterval; + ::com::sun::star::chart::TimeInterval MinorTimeInterval; + + /** the other members are for *not* date-time axis + */ + + /** Distance describes the distance between two + neighboring main tickmarks on a Scale of an axis. + All neighboring main tickmarks have the same constant distance. + +

If the Scale has a XScaling the Distance + may be measured in two different ways - that is - before or after the + scaling is applied.

+ +

On a logarithmic scale for example the distance between two main + tickmarks is typically measured after the scaling is applied: + Distance = log(tick2)-log(tick1) + ( log(1000)-log(100)==log(100)-log(10)==log(10)-log(1)==1==Distance ). + The resulting tickmarks will always look equidistant on the screen. + The other possibility is to have a Distance = tick2-tick1 measured constant + before a scaling is applied, which may lead to non equidistant tickmarks + on the screen.

+ +

PostEquidistant rules wether the Distance + is meant to be a value before or after scaling.

+ */ + double Distance; + + /** + PostEquidistant rules wether the member Distance + describes a distance before or after the scaling is applied. + +

If PostEquidistant equals Distance + is given in values after XScaling is applied, thus resulting + main tickmarks will always look equidistant on the screen. + If PostEquidistant equals Distance + is given in values before XScaling is applied.

+ */ + bool PostEquidistant; + + /** The BaseValue gives a starting point on the scale + to which all further main tickmarks are relatively positioned. + +

The BaseValue is always a value on the scale before + a possible scaling is applied. If the given value is not valid in the + associated scaling the minimum of the scaling is assumed, + if there is no minimum any other obvious value will be assumed.

+ +

E.g.: assume a scale from 0 to 6 with identical scaling. + Further assume this Increment to have Distance==2 and PostEquidistant==false. + Setting BaseValue=0 would lead to main tickmarks 0; 2; 4; 6; + Setting BaseValue=1,3 would lead to main tickmarks 1,3; 3,3; 5,3; + Setting BaseValue=-0,7 would also lead to main tickmarks 1,3; 3,3; 5,3; + And setting BaseValue to 2, -2, 4, -4 etc. in this example + leads to the same result as BaseValue=0.

+ */ + double BaseValue; + + /** SubIncrements describes the positioning of further + sub tickmarks on the scale of an axis. + +

The first SubIncrement in this sequence determines how the + distance between two neighboring main tickmarks is divided for positioning + of further sub tickmarks. Every following SubIncrement determines the + positions of subsequent tickmarks in relation to their parent tickmarks + iven by the preceding SubIncrement.

+ */ + ::std::vector< ExplicitSubIncrement > SubIncrements; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index d10ee8d415fc..231b1acef6db 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -27,9 +27,9 @@ #ifndef _CHART2_EXPLICITVALUEPROVIDER_HXX #define _CHART2_EXPLICITVALUEPROVIDER_HXX +#include "ExplicitScaleValues.hxx" + #include -#include -#include #include #include #include @@ -59,8 +59,8 @@ public: */ virtual sal_Bool getExplicitValuesForAxis( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis - , ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement )=0; + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement )=0; /** for rotated objects the shape size and position differs from the visible rectangle if bSnapRect is set to true you get the resulting visible position (left-top) and size diff --git a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx index 9f5f44107997..5eb2160a8765 100644 --- a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx @@ -52,6 +52,7 @@ public: getNumberFormatsSupplier() { return m_xNumberFormatsSupplier; }; rtl::OUString getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; + Date getNullDate() const; private: //private member ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index e3943e9eb45f..498be4e2daf9 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -651,9 +651,18 @@ void ChartTypeTemplate::adaptScales( { ScaleData aData( xAxis->getScaleData() ); aData.Categories = xCategories; - aData.AxisType = bSupportsCategories ? AxisType::CATEGORY : AxisType::REALNUMBER; - if( bSupportsCategories ) - AxisHelper::removeExplicitScaling( aData ); + if(bSupportsCategories) + { + if( aData.AxisType != AxisType::CATEGORY && aData.AxisType != AxisType::DATE ) + { + aData.AxisType = AxisType::CATEGORY; + aData.AutoDateAxis = true; + AxisHelper::removeExplicitScaling( aData ); + } + } + else + aData.AxisType = AxisType::REALNUMBER; + xAxis->setScaleData( aData ); } } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 8cdd24e4dc05..506c0a96295a 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -38,7 +38,9 @@ #include "servicenames_coosystems.hxx" #include "DataSeriesHelper.hxx" #include "Scaling.hxx" +#include "ChartModelHelper.hxx" +#include #include #include @@ -81,6 +83,8 @@ ScaleData AxisHelper::createDefaultScale() { ScaleData aScaleData; aScaleData.AxisType = chart2::AxisType::REALNUMBER; + aScaleData.AutoDateAxis = true; + aScaleData.ShiftedCategoryPosition = false;//this is adapted in the view code currently Sequence< SubIncrement > aSubIncrements(1); aSubIncrements[0] = SubIncrement(); aScaleData.IncrementData.SubIncrements = aSubIncrements; @@ -93,6 +97,9 @@ void AxisHelper::removeExplicitScaling( ScaleData& rScaleData ) uno::Any aEmpty; rScaleData.Minimum = rScaleData.Maximum = rScaleData.Origin = aEmpty; rScaleData.Scaling = 0; + ScaleData aDefaultScale( createDefaultScale() ); + rScaleData.IncrementData = aDefaultScale.IncrementData; + rScaleData.TimeIncrement = aDefaultScale.TimeIncrement; } //static @@ -105,6 +112,39 @@ bool AxisHelper::isLogarithmic( const Reference< XScaling >& xScaling ) return bReturn; } +chart2::ScaleData AxisHelper::getDateCheckedScale( const Reference< chart2::XAxis >& xAxis, const Reference< frame::XModel >& xChartModel ) +{ + DBG_ASSERT(xChartModel.is(),"missing chart model"); + ScaleData aScale = xAxis->getScaleData(); + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( aScale.AutoDateAxis && aScale.AxisType == AxisType::CATEGORY ) + { + sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; + AxisHelper::getIndicesForAxis(xAxis, xCooSys, nDimensionIndex, nAxisIndex ); + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex ); + if( bChartTypeAllowsDateAxis ) + aScale.AxisType = AxisType::DATE; + } + if( aScale.AxisType == AxisType::DATE ) + { + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys,xChartModel ); + if( !aExplicitCategoriesProvider.isDateAxis() ) + aScale.AxisType = AxisType::CATEGORY; + } + return aScale; +} + +void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ) +{ + if( rScale.AutoDateAxis && rScale.AxisType == AxisType::CATEGORY && bChartTypeAllowsDateAxis ) + rScale.AxisType = AxisType::DATE; + if( rScale.AxisType == AxisType::DATE && (!pExplicitCategoriesProvider || !pExplicitCategoriesProvider->isDateAxis()) ) + { + rScale.AxisType = AxisType::CATEGORY; + removeExplicitScaling( rScale ); + } +} + //static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex @@ -137,6 +177,7 @@ Reference< XAxis > AxisHelper::createAxis( ScaleData aMainScale = xMainAxis->getScaleData(); aScale.AxisType = aMainScale.AxisType; + aScale.AutoDateAxis = aMainScale.AutoDateAxis; aScale.Categories = aMainScale.Categories; aScale.Orientation = aMainScale.Orientation; diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index b851a3864b97..cd0a62312387 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -415,13 +415,34 @@ bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2: return true; } -bool ChartTypeHelper::shiftTicksAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType ) +bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 /*nDimensionCount*/, sal_Int32 nDimensionIndex ) +{ + if( nDimensionIndex!=0 ) + return false; + if( xChartType.is() ) + { + sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex ); + if( nType != AxisType::CATEGORY ) + return false; + rtl::OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) ) + return false; + } + return true; +} + +bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType ) { if(xChartType.is()) { rtl::OUString aChartTypeName = xChartType->getChartType(); if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) - || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) return true; } return false; diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 36afef60a6d4..d19e8819f069 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -57,10 +58,15 @@ #include #include +#include +#include +#include + #include #include -#include +// header for class Application +#include using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -68,7 +74,9 @@ using namespace ::std; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; using ::rtl::OUString; +using ::com::sun::star::chart2::XAnyDescriptionAccess; namespace chart { @@ -880,7 +888,7 @@ bool DiagramHelper::isCategoryDiagram( if( xAxis.is()) { ScaleData aScaleData = xAxis->getScaleData(); - if( aScaleData.AxisType == AxisType::CATEGORY ) + if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE ) return true; } } @@ -919,7 +927,7 @@ void DiagramHelper::setCategoriesToDiagram( { if( bCategoryAxis ) aScaleData.AxisType = AxisType::CATEGORY; - else if( aScaleData.AxisType == AxisType::CATEGORY ) + else if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE ) aScaleData.AxisType = AxisType::REALNUMBER; } xCatAxis->setScaleData( aScaleData ); @@ -1037,6 +1045,186 @@ Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories( return aRet; } +bool DiagramHelper::mayToggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + if( xAxis.is() ) + { + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType == chart2::AxisType::DATE || aScale.AxisType == chart2::AxisType::CATEGORY ) + return true; + } + } + } + return false; +} + +namespace +{ +void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) +{ + if( !xAxis.is() ) + return; + if( !xChartDoc.is() ) + return; + + ScaleData aScale( xAxis->getScaleData() ); + if( xChartDoc->hasInternalDataProvider() ) + { + //remove all content the is not of type double and remove multiple level + Reference< XAnyDescriptionAccess > xDataAccess( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + if( xDataAccess.is() ) + { + Sequence< Sequence< Any > > aAnyCategories( xDataAccess->getAnyRowDescriptions() ); + double fTest = 0.0; + double fNan = 0.0; + ::rtl::math::setNan( & fNan ); + sal_Int32 nN = aAnyCategories.getLength(); + for( ; nN--; ) + { + Sequence< Any >& rCat = aAnyCategories[nN]; + if( rCat.getLength() > 1 ) + rCat.realloc(1); + if( rCat.getLength() == 1 ) + { + Any& rAny = rCat[0]; + if( !(rAny>>=fTest) ) + { + rAny = uno::makeAny(fNan); + } + } + } + xDataAccess->setAnyRowDescriptions( aAnyCategories ); + } + //check the numberformat at the axis + Reference< beans::XPropertySet > xAxisProps( xAxis, uno::UNO_QUERY ); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartDoc, uno::UNO_QUERY ); + if( xAxisProps.is() && xNumberFormatsSupplier.is() ) + { + sal_Int32 nNumberFormat = -1; + xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nNumberFormat; + + Reference< util::XNumberFormats > xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + Reference< beans::XPropertySet > xKeyProps; + try + { + xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + sal_Int32 nType = util::NumberFormat::UNDEFINED; + if( xKeyProps.is() ) + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + if( nType!=util::NumberFormat::DATE && nType!=util::NumberFormat::DATETIME ) + { + //set a date format to the axis + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + xAxisProps->setPropertyValue( C2U("NumberFormat"), uno::makeAny(aKeySeq[0]) ); + } + } + } + } + } + if( aScale.AxisType != chart2::AxisType::DATE ) + AxisHelper::removeExplicitScaling( aScale ); + aScale.AxisType = chart2::AxisType::DATE; + xAxis->setScaleData( aScale ); +} + +void lcl_switchToTextCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) +{ + if( !xAxis.is() ) + return; + if( !xChartDoc.is() ) + return; + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType != chart2::AxisType::CATEGORY ) + AxisHelper::removeExplicitScaling( aScale ); + //todo migrate dates to text? + aScale.AxisType = chart2::AxisType::CATEGORY; + aScale.AutoDateAxis = false; + xAxis->setScaleData( aScale ); +} + +} + +void DiagramHelper::switchToDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + lcl_switchToDateCategories( xChartDoc, xAxis ); + } + } +} + +void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + lcl_switchToTextCategories( xChartDoc, xAxis ); + } + } +} + +void DiagramHelper::toggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + if( xAxis.is() ) + { + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType == chart2::AxisType::DATE ) + { + lcl_switchToTextCategories( xChartDoc, xAxis ); + } + else if( aScale.AxisType == chart2::AxisType::CATEGORY ) + { + lcl_switchToDateCategories( xChartDoc, xAxis ); + } + else + { + DBG_ERROR("Cannot toggle Date Categories for this axis type"); + } + } + } + } +} + // static Sequence< Reference< XChartType > > DiagramHelper::getChartTypesFromDiagram( diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index bd1c1bb79813..5411e94ee18c 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -30,12 +30,18 @@ #include "ExplicitCategoriesProvider.hxx" #include "DiagramHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "AxisHelper.hxx" #include "CommonConverters.hxx" #include "DataSourceHelper.hxx" #include "ChartModelHelper.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" +#include +#include +#include + //............................................................................. namespace chart { @@ -53,7 +59,10 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: , const uno::Reference< frame::XModel >& xChartModel ) : m_bDirty(true) , m_xCooSysModel( xCooSysModel ) + , m_xChartModel( xChartModel ) , m_xOriginalCategories() + , m_bIsDateAxis(false) + , m_bIsAutoDate(false) { try { @@ -61,7 +70,12 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: { uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) ); if( xAxis.is() ) - m_xOriginalCategories = xAxis->getScaleData().Categories; + { + ScaleData aScale( xAxis->getScaleData() ); + m_xOriginalCategories = aScale.Categories; + m_bIsAutoDate = (aScale.AutoDateAxis && aScale.AxisType==chart2::AxisType::CATEGORY); + m_bIsDateAxis = (aScale.AxisType == chart2::AxisType::DATE || m_bIsAutoDate); + } } if( m_xOriginalCategories.is() ) @@ -134,6 +148,13 @@ ExplicitCategoriesProvider::~ExplicitCategoriesProvider() { } +Reference< chart2::data::XDataSequence > ExplicitCategoriesProvider::getOriginalCategories() +{ + if( m_xOriginalCategories.is() ) + return m_xOriginalCategories->getValues(); + return 0; +} + const Sequence< Reference< data::XLabeledDataSequence> >& ExplicitCategoriesProvider::getSplitCategoriesList() { return m_aSplitCategoriesList; @@ -363,21 +384,125 @@ Sequence< OUString > ExplicitCategoriesProvider::getExplicitSimpleCategories( return lcl_getExplicitSimpleCategories( rSplitCategoriesProvider, aComplexCats ); } +struct DatePlusIndexComparator +{ + inline bool operator() ( const DatePlusIndex& aFirst, + const DatePlusIndex& aSecond ) + { + return ( aFirst.fValue < aSecond.fValue ); + } +}; + +bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) +{ + bool bIsDate = false; + if( !xNumberFormats.is() ) + return bIsDate; + + Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + if( xKeyProps.is() ) + { + sal_Int32 nType = util::NumberFormat::DATETIME; + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + bIsDate = (nType==util::NumberFormat::DATE || nType==util::NumberFormat::DATETIME); + } + return bIsDate; +} + +bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataSequence, std::vector< DatePlusIndex >& rDateCategories, bool bIsAutoDate, Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier ) +{ + bool bOnlyDatesFound = true; + + if( xDataSequence.is() ) + { + uno::Sequence< uno::Any > aValues = xDataSequence->getData(); + sal_Int32 nCount = aValues.getLength(); + rDateCategories.reserve(nCount); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + + bool bOwnData = false; + bool bOwnDataAndDateFormat = false; + sal_Int32 nAxisNumberFormat = 0; + Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); + Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ) ); + if( xChartDoc.is() && xCooSysModel.is() ) + { + if( xChartDoc->hasInternalDataProvider() ) + { + bOwnData = true; + Reference< beans::XPropertySet > xAxisProps( xCooSysModel->getAxisByDimension(0,0), uno::UNO_QUERY ); + if( xAxisProps.is() && (xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nAxisNumberFormat) ) + bOwnDataAndDateFormat = lcl_isDateFormat( nAxisNumberFormat, xNumberFormats ); + } + } + + for(sal_Int32 nN=0;nNgetNumberFormatKeyByIndex( nN ), xNumberFormats ); + } + else + bIsDate = true; + + uno::Any aAny = aValues[nN]; + DatePlusIndex aDatePlusIndex( 1.0, nN ); + if( bIsDate && (aAny >>= aDatePlusIndex.fValue) ) + rDateCategories.push_back( aDatePlusIndex ); + else + { + if( aAny.hasValue() ) + { + OUString aTest; + if( !( (aAny>>=aTest) && !aTest.getLength() ) )//empty string does not count as non date value! + bOnlyDatesFound=false; + } + ::rtl::math::setNan( &aDatePlusIndex.fValue ); + rDateCategories.push_back( aDatePlusIndex ); + } + } + ::std::sort( rDateCategories.begin(), rDateCategories.end(), DatePlusIndexComparator() ); + } + + return bOnlyDatesFound; +} + void ExplicitCategoriesProvider::init() { if( m_bDirty ) { m_aExplicitCategories.realloc(0); m_aComplexCats.clear();//not one per index + m_aDateCategories.clear(); if( m_xOriginalCategories.is() ) { if( !hasComplexCategories() ) + { m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues()); + if(m_bIsDateAxis) + { + if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 2, 0 ) ) + m_bIsDateAxis = lcl_fillDateCategories( m_xOriginalCategories->getValues(), m_aDateCategories, m_bIsAutoDate, Reference< util::XNumberFormatsSupplier >( m_xChartModel.get(), uno::UNO_QUERY ) ); + else + m_bIsDateAxis = false; + } + } else + { m_aExplicitCategories = lcl_getExplicitSimpleCategories( SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats ); + m_bIsDateAxis = false; + } } + else + m_bIsDateAxis=false; if(!m_aExplicitCategories.getLength()) m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); m_bDirty = false; @@ -417,6 +542,18 @@ OUString ExplicitCategoriesProvider::getCategoryByIndex( return OUString(); } +bool ExplicitCategoriesProvider::isDateAxis() +{ + init(); + return m_bIsDateAxis; +} + +const std::vector< DatePlusIndex >& ExplicitCategoriesProvider::getDateCategories() +{ + init(); + return m_aDateCategories; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index 65fc97a04b38..e9b0cf689768 100755 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -38,6 +38,7 @@ using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using namespace ::com::sun::star; using namespace ::std; namespace chart @@ -55,10 +56,10 @@ struct lcl_NumberedStringGenerator m_nWildcardLength( rWildcard.getLength()) { } - vector< OUString > operator()() + vector< uno::Any > operator()() { - vector< OUString > aRet(1); - aRet[0] = m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter )); + vector< uno::Any > aRet(1); + aRet[0] = uno::makeAny( m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter )) ); return aRet; } private: @@ -113,12 +114,12 @@ void InternalData::createDefaultData() m_aRowLabels.clear(); m_aRowLabels.reserve( m_nRowCount ); generate_n( back_inserter( m_aRowLabels ), m_nRowCount, - lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") )); + lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") )); m_aColumnLabels.clear(); m_aColumnLabels.reserve( m_nColumnCount ); generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount, - lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") )); + lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") )); } void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows ) @@ -199,7 +200,7 @@ void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & r m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice; } -void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< OUString >& rComplexLabel ) +void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel ) { if( nColumnIndex < 0 ) return; @@ -208,10 +209,10 @@ void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< m_aColumnLabels.resize(nColumnIndex+1); enlargeData( nColumnIndex+1, 0 ); } - m_aColumnLabels[nColumnIndex]=rComplexLabel; } -void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUString >& rComplexLabel ) + +void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel ) { if( nRowIndex < 0 ) return; @@ -220,23 +221,22 @@ void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUStri m_aRowLabels.resize(nRowIndex+1); enlargeData( 0, nRowIndex+1 ); } - m_aRowLabels[nRowIndex] = rComplexLabel; } -vector< OUString > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const +vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const { if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) ) return m_aColumnLabels[nColumnIndex]; else - return vector< OUString >(); + return vector< uno::Any >(); } -vector< OUString > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const +vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const { if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) ) return m_aRowLabels[nRowIndex]; else - return vector< OUString >(); + return vector< uno::Any >(); } void InternalData::swapRowWithNext( sal_Int32 nRowIndex ) @@ -253,7 +253,7 @@ void InternalData::swapRowWithNext( sal_Int32 nRowIndex ) m_aData[nIndex2] = fTemp; } - vector< OUString > aTemp( m_aRowLabels[nRowIndex] ); + vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] ); m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1]; m_aRowLabels[nRowIndex + 1] = aTemp; } @@ -273,7 +273,7 @@ void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex ) m_aData[nIndex2] = fTemp; } - vector< OUString > aTemp( m_aColumnLabels[nColumnIndex] ); + vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] ); m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1]; m_aColumnLabels[nColumnIndex + 1] = aTemp; } @@ -336,7 +336,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex ) // labels if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size())) - m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< OUString >(1) ); + m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) ); #if OSL_DEBUG_LEVEL > 2 traceData(); @@ -388,7 +388,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex ) // labels if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size())) - m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< OUString> (1)); + m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1)); #if OSL_DEBUG_LEVEL > 2 traceData(); @@ -481,7 +481,7 @@ sal_Int32 InternalData::getColumnCount() const return m_nColumnCount; } -void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNewRowLabels ) +void InternalData::setComplexRowLabels( const vector< vector< uno::Any > >& rNewRowLabels ) { m_aRowLabels = rNewRowLabels; sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() ); @@ -491,12 +491,12 @@ void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNew enlargeData( 0, nNewRowCount ); } -vector< vector< OUString > > InternalData::getComplexRowLabels() const +vector< vector< uno::Any > > InternalData::getComplexRowLabels() const { return m_aRowLabels; } -void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& rNewColumnLabels ) +void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& rNewColumnLabels ) { m_aColumnLabels = rNewColumnLabels; sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() ); @@ -506,7 +506,7 @@ void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& r enlargeData( nNewColumnCount, 0 ); } -vector< vector< OUString > > InternalData::getComplexColumnLabels() const +vector< vector< uno::Any > > InternalData::getComplexColumnLabels() const { return m_aColumnLabels; } diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 4abc51be31af..b3f3058d6f05 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -93,6 +93,24 @@ static const ::rtl::OUString lcl_aCompleteRange( typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > > lcl_tSequenceMap; +Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) +{ + Sequence< OUString > aResult; + aResult.realloc( aAnySeq.getLength() ); + transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), + aResult.getArray(), CommonFunctors::AnyToString() ); + return aResult; +} + +Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq ) +{ + Sequence< uno::Any > aResult; + aResult.realloc( aStringSeq.getLength() ); + transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + return aResult; +} + struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void > { void operator() ( const lcl_tSequenceMap::value_type & rMapEntry ) @@ -154,9 +172,9 @@ struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2:: if( xLabel.is() ) { if( m_bDataInColumns ) - m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); else - m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); if( m_bConnectToModel ) { Reference< chart2::data::XDataSequence > xNewLabel( @@ -187,37 +205,37 @@ private: bool m_bDataInColumns; }; -struct lcl_makeAnyFromLevelVector : public ::std::unary_function< vector< OUString >, uno::Any > +struct lcl_copyFromLevel : public ::std::unary_function< vector< uno::Any >, uno::Any > { public: - explicit lcl_makeAnyFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - uno::Any operator() ( const vector< OUString >& rVector ) + uno::Any operator() ( const vector< uno::Any >& rVector ) { - OUString aString; + uno::Any aRet; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; - return uno::makeAny( aString ); + aRet = rVector[m_nLevel]; + return aRet; } private: sal_Int32 m_nLevel; }; -struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< OUString >, OUString > +struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< uno::Any >, OUString > { public: explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - OUString operator() ( const vector< OUString >& rVector ) + OUString operator() ( const vector< uno::Any >& rVector ) { OUString aString; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; + aString = CommonFunctors::AnyToString()(rVector[m_nLevel]); return aString; } @@ -226,19 +244,39 @@ private: }; -struct lcl_setStringAtLevel : public ::std::binary_function< vector< OUString >, OUString, vector< OUString > > +struct lcl_setAnyAtLevel : public ::std::binary_function< vector< uno::Any >, uno::Any, vector< uno::Any > > +{ +public: + + explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + {} + + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue ) + { + vector< uno::Any > aRet( rVector ); + if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) + aRet.resize( m_nLevel+1 ); + aRet[ m_nLevel ]=rNewValue; + return aRet; + } + +private: + sal_Int32 m_nLevel; +}; + +struct lcl_setAnyAtLevelFromStringSequence : public ::std::binary_function< vector< uno::Any >, OUString, vector< uno::Any > > { public: - explicit lcl_setStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - vector< OUString > operator() ( const vector< OUString >& rVector, const OUString& rNewText ) + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue ) { - vector< OUString > aRet( rVector ); + vector< uno::Any > aRet( rVector ); if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) aRet.resize( m_nLevel+1 ); - aRet[ m_nLevel ]=rNewText; + aRet[ m_nLevel ]=uno::makeAny(rNewValue); return aRet; } @@ -246,41 +284,41 @@ private: sal_Int32 m_nLevel; }; -struct lcl_insertStringAtLevel : public ::std::unary_function< vector< OUString >, void > +struct lcl_insertAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_insertStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) ) rVector.resize( m_nLevel ); - vector< OUString >::iterator aIt( rVector.begin() ); + vector< uno::Any >::iterator aIt( rVector.begin() ); for( sal_Int32 nN=0; aIt, void > +struct lcl_removeAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_removeStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { - vector< OUString >::iterator aIt( rVector.begin() ); + vector< uno::Any >::iterator aIt( rVector.begin() ); for( sal_Int32 nN=0; aIt lcl_AnyToStringVector( const Sequence< uno::Any >& aAnySeq ) -{ - vector< OUString > aStringVec; - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - back_inserter( aStringVec ), CommonFunctors::AnyToString() ); - return aStringVec; -} - -Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) -{ - Sequence< OUString > aResult; - aResult.realloc( aAnySeq.getLength() ); - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - aResult.getArray(), CommonFunctors::AnyToString() ); - return aResult; -} - } // anonymous namespace // ================================================================================ @@ -341,9 +362,11 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum // categories { - vector< vector< OUString > > aNewCategories;//inner count is level + vector< vector< uno::Any > > aNewCategories;//inner count is level { ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); + bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); + const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); for( sal_Int32 nL = 0; nL xLDS( rSplitCategoriesList[nL] ); if( !xLDS.is() ) continue; - Reference< chart2::data::XTextualDataSequence > xSeq( xLDS->getValues(), uno::UNO_QUERY ); - Sequence< OUString > aStringSeq; - if( xSeq.is() ) - aStringSeq = xSeq->getTextualData(); // @todo: be able to deal with XDataSequence, too - sal_Int32 nLength = aStringSeq.getLength(); + Sequence< uno::Any > aDataSeq; + Reference< chart2::data::XTextualDataSequence > xTextSeq( xLDS->getValues(), uno::UNO_QUERY ); + if( !bIsDateAxis && xTextSeq.is() ) + { + aDataSeq = lcl_StringToAnySequence( xTextSeq->getTextualData() ); + } + else + { + Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); + if( xSeq.is() ) + aDataSeq = xSeq->getData(); + } + sal_Int32 nLength = aDataSeq.getLength(); if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) aNewCategories.resize( nLength ); - transform( aNewCategories.begin(), aNewCategories.end(), aStringSeq.getConstArray(), - aNewCategories.begin(), lcl_setStringAtLevel(nL) ); + transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(), + aNewCategories.begin(), lcl_setAnyAtLevel(nL) ); } if( !nLevelCount ) { @@ -369,9 +400,9 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum aNewCategories.reserve( nLength ); for( sal_Int32 nN=0; nN aStringVector(1); - aStringVector[0] = aSimplecategories[nN]; - aNewCategories.push_back( aStringVector ); + vector< uno::Any > aVector(1); + aVector[0] = uno::makeAny( aSimplecategories[nN] ); + aNewCategories.push_back( aVector ); } } } @@ -518,14 +549,14 @@ void InternalDataProvider::createDefaultData() namespace { -sal_Int32 lcl_getInnerLevelCount( const vector< vector< OUString > >& rLabels ) +sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels ) { sal_Int32 nCount = 1;//minimum is 1! - vector< vector< OUString > >::const_iterator aLevelIt( rLabels.begin() ); - vector< vector< OUString > >::const_iterator aLevelEnd( rLabels.end() ); + vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() ); + vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() ); for( ;aLevelIt!=aLevelEnd; ++aLevelIt ) { - const vector< ::rtl::OUString >& rCurrentLevelLabels = *aLevelIt; + const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt; nCount = std::max( rCurrentLevelLabels.size(), nCount ); } return nCount; @@ -549,7 +580,7 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData { //return split complex categories if we have any: ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories; - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( bUseColumns==m_bDataInColumns ) { sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); @@ -731,46 +762,74 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation if( aRange.match( lcl_aLabelRangePrefix ) ) { sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); - vector< OUString > aComplexLabel = m_bDataInColumns + vector< uno::Any > aComplexLabel = m_bDataInColumns ? m_aInternalData.getComplexColumnLabel( nIndex ) : m_aInternalData.getComplexRowLabel( nIndex ); if( !aComplexLabel.empty() ) - { - aResult.realloc( aComplexLabel.size() ); - transform( aComplexLabel.begin(), aComplexLabel.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexLabel); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32(); - vector< OUString > aComplexCategory = m_bDataInColumns + vector< uno::Any > aComplexCategory = m_bDataInColumns ? m_aInternalData.getComplexRowLabel( nPointIndex ) : m_aInternalData.getComplexColumnLabel( nPointIndex ); if( !aComplexCategory.empty() ) - { - aResult.realloc( aComplexCategory.size() ); - transform( aComplexCategory.begin(), aComplexCategory.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexCategory); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32(); - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( nLevel < lcl_getInnerLevelCount( aCategories ) ) { aResult.realloc( aCategories.size() ); transform( aCategories.begin(), aCategories.end(), - aResult.getArray(), lcl_makeAnyFromLevelVector(nLevel) ); + aResult.getArray(), lcl_copyFromLevel(nLevel) ); } } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { - Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); - aResult.realloc( aLabels.getLength() ); - transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), - aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + bool bReturnText = true; + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); + if( nLevelCount == 1 ) + { + sal_Int32 nL=0; + aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) ); + bool bOnlyDatesFound = true; + double fTest = 0.0; + OUString aTest; + for(sal_Int32 nN=aResult.getLength(); nN--;) + { + uno::Any aAny(aResult[nN]); + if( !( aAny >>= fTest) ) + { + if( aAny.hasValue() ) + { + if( (aAny>>=aTest) && !aTest.getLength() ) + { + //empty string does not count as non date value! + aResult[nN] = uno::Any(); + } + else + { + bOnlyDatesFound=false; + break; + } + } + } + } + if( bOnlyDatesFound ) + bReturnText = false; + } + if( bReturnText ) + { + Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); + aResult.realloc( aLabels.getLength() ); + transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + } } else { @@ -798,38 +857,36 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( const OUString& aRange, const Sequence< uno::Any >& aNewData ) throw (uno::RuntimeException) { + vector< uno::Any > aNewVector( ContainerHelper::SequenceToVector(aNewData) ); if( aRange.match( lcl_aLabelRangePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexColumnLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nIndex, aNewVector ); else - m_aInternalData.setComplexRowLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexRowLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector ); else - m_aInternalData.setComplexColumnLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); //ensure equal length - if( aNewStrings.size() > aComplexCategories.size() ) - aComplexCategories.resize( aNewStrings.size() ); - else if( aNewStrings.size() < aComplexCategories.size() ) - aNewStrings.resize( aComplexCategories.size() ); + if( aNewVector.size() > aComplexCategories.size() ) + aComplexCategories.resize( aNewVector.size() ); + else if( aNewVector.size() < aComplexCategories.size() ) + aNewVector.resize( aComplexCategories.size() ); - transform( aComplexCategories.begin(), aComplexCategories.end(), aNewStrings.begin(), - aComplexCategories.begin(), lcl_setStringAtLevel(nLevel) ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); @@ -838,10 +895,14 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { + vector< vector< uno::Any > > aComplexCategories; + aComplexCategories.resize( aNewVector.size() ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(0) ); if( m_bDataInColumns ) - this->setRowDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexRowLabels( aComplexCategories ); else - this->setColumnDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexColumnLabels( aComplexCategories ); } else { @@ -906,8 +967,8 @@ void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -923,8 +984,8 @@ void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -1134,7 +1195,36 @@ OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXM namespace { -Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vector< vector< OUString > >& rIn ) + +template< class Type > +Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn ) +{ + Sequence< Sequence< Type > > aRet; + sal_Int32 nOuterCount = rIn.size(); + if( nOuterCount ) + { + aRet.realloc(nOuterCount); + for( sal_Int32 nN=0; nN +vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn ) +{ + vector< vector< Type > > aRet; + sal_Int32 nOuterCount = rIn.getLength(); + if( nOuterCount ) + { + aRet.resize(nOuterCount); + for( sal_Int32 nN=0; nN > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn ) { Sequence< Sequence< OUString > > aRet; sal_Int32 nOuterCount = rIn.size(); @@ -1142,17 +1232,17 @@ Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vecto { aRet.realloc(nOuterCount); for( sal_Int32 nN=0; nN > lcl_convertComplexSequenceToVector( const Sequence< Sequence< OUString > >& rIn ) +vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn ) { - vector< vector< OUString > > aRet; + vector< vector< uno::Any > > aRet; sal_Int32 nOuterCount = rIn.getLength(); for( sal_Int32 nN=0; nN >& rComplexDescriptions ) + explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< uno::Any > >& rComplexDescriptions ) : m_rComplexDescriptions( rComplexDescriptions ) {} virtual ~SplitCategoriesProvider_ForComplexDescriptions() @@ -1170,7 +1260,7 @@ public: virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const; private: - const ::std::vector< ::std::vector< ::rtl::OUString > >& m_rComplexDescriptions; + const ::std::vector< ::std::vector< uno::Any > >& m_rComplexDescriptions; }; sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const @@ -1191,22 +1281,78 @@ uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::g }//anonymous namespace +// ____ XDateCategories ____ +Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() throw (uno::RuntimeException) +{ + double fNan = InternalDataProvider::getNotANumber(); + double fValue = fNan; + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nCount = aCategories.size(); + Sequence< double > aDoubles( nCount ); + vector< vector< uno::Any > >::iterator aIt( aCategories.begin() ); + vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() ); + for(sal_Int32 nN=0; nNempty() && ((*aIt)[0]>>=fValue) ) ) + fValue = fNan; + aDoubles[nN]=fValue; + } + return aDoubles; +} + +void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + sal_Int32 nCount = rDates.getLength(); + vector< vector< uno::Any > > aNewCategories; + aNewCategories.reserve(nCount); + vector< uno::Any > aSingleLabel(1); + + for(sal_Int32 nN=0; nN > SAL_CALL InternalDataProvider::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexRowLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& aRowDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexRowLabels( lcl_convertSequenceSequenceToVectorVector( aRowDescriptions ) ); +} +Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexColumnLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& aColumnDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexColumnLabels( lcl_convertSequenceSequenceToVectorVector( aColumnDescriptions ) ); +} + // ____ XComplexDescriptionAccess ____ Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexRowLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() ); } void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexRowLabels( lcl_convertComplexSequenceToVector(aRowDescriptions) ); + m_aInternalData.setComplexRowLabels( lcl_convertComplexStringSequenceToAnyVector(aRowDescriptions) ); } Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexColumnLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() ); } void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexColumnLabels( lcl_convertComplexSequenceToVector(aColumnDescriptions) ); + m_aInternalData.setComplexColumnLabels( lcl_convertComplexStringSequenceToAnyVector(aColumnDescriptions) ); } // ____ XChartDataArray ____ @@ -1225,25 +1371,25 @@ void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aRowDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexRowLabels( aComplexDescriptions ); } void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aColumnDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexColumnLabels( aComplexDescriptions ); } Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } @@ -1251,7 +1397,7 @@ Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx new file mode 100644 index 000000000000..45f958ab2898 --- /dev/null +++ b/chart2/source/view/axes/DateHelper.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DateHelper.hxx" +#include "DateScaling.hxx" +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +bool DateHelper::IsInSameYear( const Date& rD1, const Date& rD2 ) +{ + return rD1.GetYear() == rD2.GetYear(); +} +bool DateHelper::IsInSameMonth( const Date& rD1, const Date& rD2 ) +{ + return (rD1.GetYear() == rD2.GetYear()) + && (rD1.GetMonth() == rD2.GetMonth()); +} +long DateHelper::GetMonthsBetweenDates( Date aD1, Date aD2 ) +{ + Date aHelp = aD1; + long nSign = 1; + if( aD1 < aD2 ) + { + aD1 = aD2; + aD2 = aHelp; + nSign = -1; + } + + return nSign*( ( aD1.GetMonth() - aD2.GetMonth() ) + + ( aD1.GetYear() - aD2.GetYear() )*12 ); +} + +Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) +{ + Date aRet(rD); + long nMonth = rD.GetMonth()+nMonthDistance; + long nNewMonth = nMonth%12; + long nNewYear = rD.GetYear() + nMonth/12; + if( nMonth <= 0 || !nNewMonth ) + nNewYear--; + if( nNewMonth <= 0 ) + nNewMonth += 12; + aRet.SetMonth( USHORT(nNewMonth) ); + aRet.SetYear( USHORT(nNewYear) ); + while(!aRet.IsValid()) + aRet--; + return aRet; +} + +Date DateHelper::GetDateSomeYearsAway( const Date& rD, long nYearDistance ) +{ + Date aRet(rD); + aRet.SetYear( static_cast(rD.GetYear()+nYearDistance) ); + while(!aRet.IsValid()) + aRet--; + return aRet; +} + +bool DateHelper::IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ) +{ + Date aDMin( DateHelper::GetDateSomeMonthsAway( rD1, -1 ) ); + Date aDMax( DateHelper::GetDateSomeMonthsAway( rD1, 1 ) ); + + if( rD2 > aDMin && rD2 < aDMax ) + return true; + return false; +} + +bool DateHelper::IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ) +{ + Date aDMin( DateHelper::GetDateSomeYearsAway( rD1, -1 ) ); + Date aDMax( DateHelper::GetDateSomeYearsAway( rD1, 1 ) ); + + if( rD2 > aDMin && rD2 < aDMax ) + return true; + return false; +} + +double DateHelper::RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution ) +{ + Date aDate(rNullDate); aDate += static_cast(::rtl::math::approxFloor(fValue)); + switch(TimeResolution) + { + case ::com::sun::star::chart::TimeUnit::DAY: + break; + case ::com::sun::star::chart::TimeUnit::YEAR: + aDate.SetMonth(1); + aDate.SetDay(1); + break; + case ::com::sun::star::chart::TimeUnit::MONTH: + default: + aDate.SetDay(1); + break; + } + return aDate - rNullDate; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/DateScaling.cxx b/chart2/source/view/axes/DateScaling.cxx new file mode 100644 index 000000000000..65d6771ee2e9 --- /dev/null +++ b/chart2/source/view/axes/DateScaling.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DateScaling.hxx" +#include +#include +#include "com/sun/star/uno/RuntimeException.hpp" + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName_DateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.DateScaling" )); +static const ::rtl::OUString lcl_aServiceName_InverseDateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.InverseDateScaling" )); + +static const ::rtl::OUString lcl_aImplementationName_DateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.DateScaling" )); +static const ::rtl::OUString lcl_aImplementationName_InverseDateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.InverseDateScaling" )); + +static const double lcl_fNumberOfMonths = 12.0;//todo: this needs to be offered by basic tools Date class if it should be more generic +} + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; + +DateScaling::DateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ) + : m_aNullDate( rNullDate ) + , m_nTimeUnit( nTimeUnit ) + , m_bShifted( bShifted ) +{ +} + +DateScaling::~DateScaling() +{ +} + +double SAL_CALL DateScaling::doScaling( double value ) + throw (uno::RuntimeException) +{ + double fResult(value); + if( ::rtl::math::isNan( value ) || ::rtl::math::isInf( value ) ) + ::rtl::math::setNan( & fResult ); + else + { + Date aDate(m_aNullDate); + aDate += static_cast(::rtl::math::approxFloor(value)); + switch( m_nTimeUnit ) + { + case DAY: + fResult = value; + if(m_bShifted) + fResult+=0.5; + break; + case YEAR: + case MONTH: + default: + fResult = aDate.GetYear(); + fResult *= lcl_fNumberOfMonths;//asssuming equal count of months in each year + fResult += aDate.GetMonth(); + + double fDayOfMonth = aDate.GetDay(); + fDayOfMonth -= 1.0; + double fDaysInMonth = aDate.GetDaysInMonth(); + fResult += fDayOfMonth/fDaysInMonth; + if(m_bShifted) + { + if( YEAR==m_nTimeUnit ) + fResult += 0.5*lcl_fNumberOfMonths; + else + fResult += 0.5; + } + break; + } + } + return fResult; +} + +uno::Reference< XScaling > SAL_CALL DateScaling::getInverseScaling() + throw (uno::RuntimeException) +{ + return new InverseDateScaling( m_aNullDate, m_nTimeUnit, m_bShifted ); +} + +::rtl::OUString SAL_CALL DateScaling::getServiceName() + throw (uno::RuntimeException) +{ + return lcl_aServiceName_DateScaling; +} + +uno::Sequence< ::rtl::OUString > DateScaling::getSupportedServiceNames_Static() +{ + return uno::Sequence< ::rtl::OUString >( & lcl_aServiceName_DateScaling, 1 ); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( DateScaling, lcl_aServiceName_DateScaling ) + +// ---------------------------------------- + +InverseDateScaling::InverseDateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ) + : m_aNullDate( rNullDate ) + , m_nTimeUnit( nTimeUnit ) + , m_bShifted( bShifted ) +{ +} + +InverseDateScaling::~InverseDateScaling() +{ +} + +double SAL_CALL InverseDateScaling::doScaling( double value ) + throw (uno::RuntimeException) +{ + double fResult(value); + if( ::rtl::math::isNan( value ) || ::rtl::math::isInf( value ) ) + ::rtl::math::setNan( & fResult ); + else + { + switch( m_nTimeUnit ) + { + case DAY: + if(m_bShifted) + value -= 0.5; + fResult = value; + break; + case YEAR: + case MONTH: + default: + //Date aDate(m_aNullDate); + if(m_bShifted) + { + if( YEAR==m_nTimeUnit ) + value -= 0.5*lcl_fNumberOfMonths; + else + value -= 0.5; + } + Date aDate; + double fYear = ::rtl::math::approxFloor(value/lcl_fNumberOfMonths); + double fMonth = ::rtl::math::approxFloor(value-(fYear*lcl_fNumberOfMonths)); + aDate.SetYear( static_cast(fYear) ); + aDate.SetMonth( static_cast(fMonth) ); + aDate.SetDay( 1 ); + double fMonthCount = (fYear*lcl_fNumberOfMonths)+fMonth; + double fDay = (value-fMonthCount)*aDate.GetDaysInMonth(); + fDay += 1.0; + aDate.SetDay( static_cast(::rtl::math::round(fDay)) ); + fResult = aDate - m_aNullDate; + break; + } + } + return fResult; +} + +uno::Reference< XScaling > SAL_CALL InverseDateScaling::getInverseScaling() + throw (uno::RuntimeException) +{ + return new DateScaling( m_aNullDate, m_nTimeUnit, m_bShifted ); +} + +::rtl::OUString SAL_CALL InverseDateScaling::getServiceName() + throw (uno::RuntimeException) +{ + return lcl_aServiceName_InverseDateScaling; +} + +uno::Sequence< ::rtl::OUString > InverseDateScaling::getSupportedServiceNames_Static() +{ + return uno::Sequence< ::rtl::OUString >( & lcl_aServiceName_InverseDateScaling, 1 ); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( InverseDateScaling, lcl_aServiceName_InverseDateScaling ) + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/DateScaling.hxx b/chart2/source/view/axes/DateScaling.hxx new file mode 100644 index 000000000000..5e550604a957 --- /dev/null +++ b/chart2/source/view/axes/DateScaling.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DATESCALING_HXX +#define _CHART2_DATESCALING_HXX +#include "ServiceMacros.hxx" +#include +#include +#include +#include +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class DateScaling : + public ::cppu::WeakImplHelper3 < + ::com::sun::star::chart2::XScaling, + ::com::sun::star::lang::XServiceName, + ::com::sun::star::lang::XServiceInfo + > +{ +public: + DateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ); + virtual ~DateScaling(); + + /// declare XServiceInfo methods + APPHELPER_XSERVICEINFO_DECL() + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > SAL_CALL + getInverseScaling() throw (::com::sun::star::uno::RuntimeException); + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + +private: + const Date m_aNullDate; + const sal_Int32 m_nTimeUnit; + const bool m_bShifted; +}; + +class InverseDateScaling : + public ::cppu::WeakImplHelper3 < + ::com::sun::star::chart2::XScaling, + ::com::sun::star::lang::XServiceName, + ::com::sun::star::lang::XServiceInfo + > +{ +public: + InverseDateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ); + virtual ~InverseDateScaling(); + + /// declare XServiceInfo methods + APPHELPER_XSERVICEINFO_DECL() + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > SAL_CALL + getInverseScaling() throw (::com::sun::star::uno::RuntimeException); + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + +private: + const Date m_aNullDate; + const sal_Int32 m_nTimeUnit; + const bool m_bShifted; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif + diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx index 88f99b493144..97523d38758f 100644 --- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx +++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx @@ -29,6 +29,9 @@ #include "precompiled_chart2.hxx" #include "MinimumAndMaximumSupplier.hxx" + +#include + #include #include @@ -196,6 +199,24 @@ void MergedMinimumAndMaximumSupplier::clearMinimumAndMaximumSupplierList() m_aMinimumAndMaximumSupplierList.clear(); } +long MergedMinimumAndMaximumSupplier::calculateTimeResolutionOnXAxis() +{ + long nRet = ::com::sun::star::chart::TimeUnit::YEAR; + for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) + { + long nCurrent = (*aIt)->calculateTimeResolutionOnXAxis(); + if(nRet>nCurrent) + nRet=nCurrent; + } + return nRet; +} + +void MergedMinimumAndMaximumSupplier::setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ) +{ + for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) + (*aIt)->setTimeResolutionOnXAxis( nTimeResolution, rNullDate ); +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 890bf87df96e..441592c400eb 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -29,8 +29,12 @@ #include "precompiled_chart2.hxx" #include "ScaleAutomatism.hxx" #include "macros.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks_Equidistant.hxx" +#include "DateHelper.hxx" +#include "DateScaling.hxx" #include "AxisHelper.hxx" +#include + #include #include @@ -40,6 +44,9 @@ namespace chart //............................................................................. using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; const sal_Int32 MAXIMUM_MANUAL_INCREMENT_COUNT = 500; const sal_Int32 MAXIMUM_AUTO_INCREMENT_COUNT = 10; @@ -56,7 +63,42 @@ void lcl_ensureMaximumSubIncrementCount( sal_Int32& rnSubIntervalCount ) }//end anonymous namespace -ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale ) + +//............................................................................. + +ExplicitScaleData::ExplicitScaleData() + : Minimum(0.0) + , Maximum(10.0) + , Origin(0.0) + , Orientation(::com::sun::star::chart2::AxisOrientation_MATHEMATICAL) + , Scaling() + , AxisType(::com::sun::star::chart2::AxisType::REALNUMBER) + , ShiftedCategoryPosition(false) + , TimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , NullDate(30,12,1899) +{ +} + +ExplicitSubIncrement::ExplicitSubIncrement() + : IntervalCount(2) + , PostEquidistant(true) +{ +} + + +ExplicitIncrementData::ExplicitIncrementData() + : MajorTimeInterval(1,::com::sun::star::chart::TimeUnit::DAY) + , MinorTimeInterval(1,::com::sun::star::chart::TimeUnit::DAY) + , Distance(1.0) + , PostEquidistant(true) + , BaseValue(0.0) + , SubIncrements() +{ +} + +//............................................................................. + +ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale, const Date& rNullDate ) : m_aSourceScale( rSourceScale ) , m_fValueMinimum( 0.0 ) , m_fValueMaximum( 0.0 ) @@ -65,6 +107,8 @@ ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale ) , m_bExpandIfValuesCloseToBorder( false ) , m_bExpandWideValuesToZero( false ) , m_bExpandNarrowValuesTowardZero( false ) + , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , m_aNullDate(rNullDate) { ::rtl::math::setNan( &m_fValueMinimum ); ::rtl::math::setNan( &m_fValueMaximum ); @@ -111,14 +155,19 @@ void ScaleAutomatism::setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMa m_nMaximumAutoMainIncrementCount = nMaximumAutoMainIncrementCount; } +void ScaleAutomatism::setAutomaticTimeResolution( sal_Int32 nTimeResolution ) +{ + m_nTimeResolution = nTimeResolution; +} + void ScaleAutomatism::calculateExplicitScaleAndIncrement( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement ) const { // fill explicit scale rExplicitScale.Orientation = m_aSourceScale.Orientation; rExplicitScale.Scaling = m_aSourceScale.Scaling; - rExplicitScale.Breaks = m_aSourceScale.Breaks; rExplicitScale.AxisType = m_aSourceScale.AxisType; + rExplicitScale.NullDate = m_aNullDate; bool bAutoMinimum = !(m_aSourceScale.Minimum >>= rExplicitScale.Minimum); bool bAutoMaximum = !(m_aSourceScale.Maximum >>= rExplicitScale.Maximum); @@ -130,7 +179,12 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( m_aSourceScale.AxisType==AxisType::PERCENT ) rExplicitScale.Minimum = 0.0; else if( ::rtl::math::isNan( m_fValueMinimum ) ) - rExplicitScale.Minimum = 0.0; //@todo get Minimum from scaling or from plotter???? + { + if( m_aSourceScale.AxisType==AxisType::DATE ) + rExplicitScale.Minimum = 36526.0; //1.1.2000 + else + rExplicitScale.Minimum = 0.0; //@todo get Minimum from scaling or from plotter???? + } else rExplicitScale.Minimum = m_fValueMinimum; } @@ -141,7 +195,12 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( m_aSourceScale.AxisType==AxisType::PERCENT ) rExplicitScale.Maximum = 1.0; else if( ::rtl::math::isNan( m_fValueMaximum ) ) - rExplicitScale.Maximum = 10.0; //@todo get Maximum from scaling or from plotter???? + { + if( m_aSourceScale.AxisType==AxisType::DATE ) + rExplicitScale.Maximum = 40179.0; //1.1.2010 + else + rExplicitScale.Maximum = 10.0; //@todo get Maximum from scaling or from plotter???? + } else rExplicitScale.Maximum = m_fValueMaximum; } @@ -149,14 +208,14 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( //--------------------------------------------------------------- //fill explicit increment - rExplicitIncrement.ShiftedPosition = (m_aSourceScale.AxisType==AxisType::SERIES) ? true : false; + rExplicitScale.ShiftedCategoryPosition = m_aSourceScale.ShiftedCategoryPosition; bool bIsLogarithm = false; //minimum and maximum of the ExplicitScaleData may be changed if allowed - if( m_aSourceScale.AxisType==AxisType::CATEGORY || m_aSourceScale.AxisType==AxisType::SERIES ) - { + if( m_aSourceScale.AxisType==AxisType::DATE ) + calculateExplicitIncrementAndScaleForDateTimeAxis( rExplicitScale, rExplicitIncrement, bAutoMinimum, bAutoMaximum ); + else if( m_aSourceScale.AxisType==AxisType::CATEGORY || m_aSourceScale.AxisType==AxisType::SERIES ) calculateExplicitIncrementAndScaleForCategory( rExplicitScale, rExplicitIncrement, bAutoMinimum, bAutoMaximum ); - } else { bIsLogarithm = AxisHelper::isLogarithmic( rExplicitScale.Scaling ); @@ -186,6 +245,11 @@ ScaleData ScaleAutomatism::getScale() const return m_aSourceScale; } +Date ScaleAutomatism::getNullDate() const +{ + return m_aNullDate; +} + // private -------------------------------------------------------------------- void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( @@ -207,9 +271,12 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( // automatic minimum and maximum if( bAutoMinimum && m_bExpandBorderToIncrementRhythm ) - rExplicitScale.Minimum = TickmarkHelper::getMinimumAtIncrement( rExplicitScale.Minimum, rExplicitIncrement ); + rExplicitScale.Minimum = EquidistantTickFactory::getMinimumAtIncrement( rExplicitScale.Minimum, rExplicitIncrement ); if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) - rExplicitScale.Maximum = TickmarkHelper::getMaximumAtIncrement( rExplicitScale.Maximum, rExplicitIncrement ); + rExplicitScale.Maximum = EquidistantTickFactory::getMaximumAtIncrement( rExplicitScale.Maximum, rExplicitIncrement ); + + if( rExplicitScale.ShiftedCategoryPosition ) + rExplicitScale.Maximum += 1.0; //prevent performace killover double fDistanceCount = ::rtl::math::approxFloor( (rExplicitScale.Maximum-rExplicitScale.Minimum) / rExplicitIncrement.Distance ); @@ -223,29 +290,28 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement= m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 2; + aExplicitSubIncrement.IntervalCount = 2; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } -//@todo these method should become part of the scaling interface and implementation somehow -//@todo problem with outparamters at api +//----------------------------------------------------------------------------------------- + void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement, @@ -412,7 +478,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( // round to entire multiples of the distance and add additional space if( bAutoMinimum && m_bExpandBorderToIncrementRhythm ) { - fAxisMinimum = TickmarkHelper::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); + fAxisMinimum = EquidistantTickFactory::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); //ensure valid values after scaling #i100995# if( !bAutoDistance ) @@ -428,7 +494,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( } if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) { - fAxisMaximum = TickmarkHelper::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); + fAxisMaximum = EquidistantTickFactory::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); //ensure valid values after scaling #i100995# if( !bAutoDistance ) @@ -488,27 +554,204 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement = m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 9; + aExplicitSubIncrement.IntervalCount = 9; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } +//----------------------------------------------------------------------------------------- + +void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const +{ + Date aMinDate(m_aNullDate); aMinDate += static_cast(::rtl::math::approxFloor(rExplicitScale.Minimum)); + Date aMaxDate(m_aNullDate); aMaxDate += static_cast(::rtl::math::approxFloor(rExplicitScale.Maximum)); + rExplicitIncrement.PostEquidistant = sal_False; + + if( aMinDate > aMaxDate ) + { + std::swap(aMinDate,aMaxDate); + } + + if( !(m_aSourceScale.TimeIncrement.TimeResolution >>= rExplicitScale.TimeResolution) ) + rExplicitScale.TimeResolution = m_nTimeResolution; + + rExplicitScale.Scaling = new DateScaling(m_aNullDate,rExplicitScale.TimeResolution,false); + + // choose min and max suitable to time resolution + switch( rExplicitScale.TimeResolution ) + { + case DAY: + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate++;//for explicit scales we need one interval more (maximum excluded) + break; + case MONTH: + aMinDate.SetDay(1); + aMaxDate.SetDay(1); + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,1);//for explicit scales we need one interval more (maximum excluded) + if( DateHelper::IsLessThanOneMonthAway( aMinDate, aMaxDate ) ) + { + if( bAutoMaximum || !bAutoMinimum ) + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMinDate,1); + else + aMinDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + } + break; + case YEAR: + aMinDate.SetDay(1); + aMinDate.SetMonth(1); + aMaxDate.SetDay(1); + aMaxDate.SetMonth(1); + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,1);//for explicit scales we need one interval more (maximum excluded) + if( DateHelper::IsLessThanOneYearAway( aMinDate, aMaxDate ) ) + { + if( bAutoMaximum || !bAutoMinimum ) + aMaxDate = DateHelper::GetDateSomeYearsAway(aMinDate,1); + else + aMinDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + } + break; + } + + // set the resulting limits (swap back to negative range if needed) + rExplicitScale.Minimum = aMinDate - m_aNullDate; + rExplicitScale.Maximum = aMaxDate - m_aNullDate; + + bool bAutoMajor = !(m_aSourceScale.TimeIncrement.MajorTimeInterval >>= rExplicitIncrement.MajorTimeInterval); + bool bAutoMinor = !(m_aSourceScale.TimeIncrement.MinorTimeInterval >>= rExplicitIncrement.MinorTimeInterval); + + sal_Int32 nMaxMainIncrementCount = bAutoMajor ? + m_nMaximumAutoMainIncrementCount : MAXIMUM_MANUAL_INCREMENT_COUNT; + if( nMaxMainIncrementCount > 1 ) + nMaxMainIncrementCount--; + + + //choose major time interval: + long nDayCount = (aMaxDate-aMinDate); + long nMainIncrementCount = 1; + if( !bAutoMajor ) + { + long nIntervalDayCount = rExplicitIncrement.MajorTimeInterval.Number; + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + nIntervalDayCount*=31;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + case YEAR: + nIntervalDayCount*=365;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + } + nMainIncrementCount = nDayCount/nIntervalDayCount; + if( nMainIncrementCount > nMaxMainIncrementCount ) + bAutoMajor = true; + } + if( bAutoMajor ) + { + long nNumer = 1; + long nIntervalDays = nDayCount / nMaxMainIncrementCount; + double nDaysPerInterval = 1.0; + if( nIntervalDays>365 ) + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = YEAR; + nDaysPerInterval = 365.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + } + else if( nIntervalDays>31 ) + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = MONTH; + nDaysPerInterval = 31.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + } + else + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = DAY; + nDaysPerInterval = 1.0; + } + + nNumer = static_cast( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) ); + if(nNumer<=0) + nNumer=1; + rExplicitIncrement.MajorTimeInterval.Number = nNumer; + nMainIncrementCount = nDayCount/(nNumer*nDaysPerInterval); + } + + //choose minor time interval: + if( !bAutoMinor ) + { + long nIntervalDayCount = rExplicitIncrement.MinorTimeInterval.Number; + switch( rExplicitIncrement.MinorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + nIntervalDayCount*=31;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + case YEAR: + nIntervalDayCount*=365;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + } + if( nDayCount/nIntervalDayCount > nMaxMainIncrementCount ) + bAutoMinor = true; + } + if( bAutoMinor ) + { + rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; + rExplicitIncrement.MinorTimeInterval.Number = 1; + if( nMainIncrementCount > 100 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + else + { + if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + { + if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; + else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + } + else + { + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; + break; + case YEAR: + rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; + break; + } + } + } + } + +} + +//----------------------------------------------------------------------------------------- + void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement, @@ -692,7 +935,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( { // round to entire multiples of the distance, based on the base value if( m_bExpandBorderToIncrementRhythm ) - fAxisMinimum = TickmarkHelper::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); + fAxisMinimum = EquidistantTickFactory::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); // additional space, if source minimum is to near at axis minimum if( m_bExpandIfValuesCloseToBorder ) if( (fAxisMinimum != 0.0) && ((fAxisMaximum - fSourceMinimum) / (fAxisMaximum - fAxisMinimum) > 20.0 / 21.0) ) @@ -702,7 +945,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( { // round to entire multiples of the distance, based on the base value if( m_bExpandBorderToIncrementRhythm ) - fAxisMaximum = TickmarkHelper::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); + fAxisMaximum = EquidistantTickFactory::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); // additional space, if source maximum is to near at axis maximum if( m_bExpandIfValuesCloseToBorder ) if( (fAxisMaximum != 0.0) && ((fSourceMaximum - fAxisMinimum) / (fAxisMaximum - fAxisMinimum) > 20.0 / 21.0) ) @@ -734,24 +977,23 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement= m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 2; + aExplicitSubIncrement.IntervalCount = 2; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx deleted file mode 100644 index 9e2e2707c035..000000000000 --- a/chart2/source/view/axes/TickmarkHelper.cxx +++ /dev/null @@ -1,937 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" -#include "TickmarkHelper.hxx" -#include "ViewDefines.hxx" -#include -#include -#include - -//............................................................................. -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(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; nNm_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_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; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -//static -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; -} -//static -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( fSub / m_rIncrement.Distance ); - - nIntervalCount+=3; - for(sal_Int32 nN=0; nN1 ) - 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]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(fScaledValuem_fScaledVisibleMax) - { - if( !approxEqual(fScaledValue,m_fScaledVisibleMax) ) - return false; - } - if(fScaledValue >& 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; nMajorTickgetMajorTick( 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; nN1 ) - nCheckCount *= m_rIncrement.SubIncrements[nN].IntervalCount; - } - uno::Sequence< double >& rTicks = aAllTicks[nDepth]; - sal_Int32 nCount = rTicks.getLength(); - //check lower border - for( nTick=0; nTicknCount-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 >& 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; nPartTickgetMinorTick( 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() ); -} - -//static -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(aStart.getX()); - rPoints[nSequenceIndex][0].Y = static_cast(aStart.getY()); - rPoints[nSequenceIndex][1].X = static_cast(aEnd.getX()); - rPoints[nSequenceIndex][1].Y = static_cast(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(m_aAxisStartScreenPosition2D.getX()); - rPoints[0][0].Y = static_cast(m_aAxisStartScreenPosition2D.getY()); - rPoints[0][1].X = static_cast(m_aAxisEndScreenPosition2D.getX()); - rPoints[0][1].Y = static_cast(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/TickmarkHelper.hxx b/chart2/source/view/axes/TickmarkHelper.hxx deleted file mode 100644 index 78fc2fe1c502..000000000000 --- a/chart2/source/view/axes/TickmarkHelper.hxx +++ /dev/null @@ -1,276 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _CHART2_TICKMARKHELPER_HXX -#define _CHART2_TICKMARKHELPER_HXX - -#include "TickmarkProperties.hxx" -#include "VAxisProperties.hxx" -#include -#include -#include -#include -#include -#include - -#include - -//............................................................................. -namespace chart -{ -//............................................................................. - -using ::basegfx::B2DVector; -//----------------------------------------------------------------------------- -/** -*/ - -struct TickInfo -{ - double fScaledTickValue; - double fUnscaledTickValue; - - ::basegfx::B2DVector aTickScreenPosition; - bool bPaintIt; - - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > xTextShape; - - rtl::OUString aText;//used only for complex categories so far - sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category - -//methods: - TickInfo(); - void updateUnscaledValue( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XScaling >& xInverseScaling ); - - sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; -}; -class TickIter -{ -public: - virtual ~TickIter(){}; - virtual TickInfo* firstInfo()=0; - virtual TickInfo* nextInfo()=0; -}; - -class PureTickIter : public TickIter -{ -public: - PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); - virtual ~PureTickIter(); - virtual TickInfo* firstInfo(); - virtual TickInfo* nextInfo(); - -private: - ::std::vector< TickInfo >& m_rTickVector; - ::std::vector< TickInfo >::iterator m_aTickIter; -}; - -class EquidistantTickIter : public TickIter -{ -public: - EquidistantTickIter( const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Sequence< double > >& rTicks - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); - EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); - virtual ~EquidistantTickIter(); - - virtual double* firstValue(); - virtual double* nextValue(); - - virtual TickInfo* firstInfo(); - virtual TickInfo* nextInfo(); - - sal_Int32 getCurrentDepth() const { return m_nCurrentDepth; } - -protected: - bool gotoIndex( sal_Int32 nTickIndex ); - sal_Int32 getCurrentIndex() const; - sal_Int32 getMaxIndex() const; - -private: //methods - sal_Int32 getIntervalCount( sal_Int32 nDepth ); - bool isAtLastPartTick(); - - void initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth ); - sal_Int32 getStartDepth() const; - - bool gotoFirst(); - bool gotoNext(); - - - double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const - { - if(m_pSimpleTicks) - return (*m_pSimpleTicks)[nDepth][nIndex]; - else - return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue; - } - sal_Int32 getTickCount( sal_Int32 nDepth ) const - { - if(m_pSimpleTicks) - return (*m_pSimpleTicks)[nDepth].getLength(); - else - return (*m_pInfoTicks)[nDepth].size(); - } - sal_Int32 getMaxDepth() const - { - if(m_pSimpleTicks) - return (*m_pSimpleTicks).getLength()-1; - else - return (*m_pInfoTicks).size()-1; - } - -private: //member - const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks; - ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks; - const ::com::sun::star::chart2::ExplicitIncrementData& m_rIncrement; - //iteration from m_nMinDepth to m_nMaxDepth - sal_Int32 m_nMinDepth; - sal_Int32 m_nMaxDepth; - sal_Int32 m_nTickCount; - sal_Int32* m_pnPositions; //current positions in the different sequences - sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always, - //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark - bool* m_pbIntervalFinished; - sal_Int32 m_nCurrentDepth; - sal_Int32 m_nCurrentPos; - double m_fCurrentValue; -}; - -class TickmarkHelper -{ -public: - TickmarkHelper( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - virtual ~TickmarkHelper(); - - virtual TickmarkHelper* createShiftedTickmarkHelper() const; - - void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - - // - static double getMinimumAtIncrement( double fMin, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - static double getMaximumAtIncrement( double fMax, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - -protected: //methods - void addSubTicks( sal_Int32 nDepth, - ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const; - double* getMajorTick( sal_Int32 nTick ) const; - double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth - , double fStartParentTick, double fNextParentTick ) const; - sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const; - sal_Int32 getTickDepth() const; - bool isVisible( double fValue ) const; - bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks - - virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} - -protected: //member - ::com::sun::star::chart2::ExplicitScaleData m_rScale; - ::com::sun::star::chart2::ExplicitIncrementData m_rIncrement; - - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > - m_xInverseScaling; - double* m_pfCurrentValues; - //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders - double m_fOuterMajorTickBorderMin; - double m_fOuterMajorTickBorderMax; - double m_fOuterMajorTickBorderMin_Scaled; - double m_fOuterMajorTickBorderMax_Scaled; - - //minimum and maximum of the visible range after scaling - double m_fScaledVisibleMin; - double m_fScaledVisibleMax; -}; - -class TickmarkHelper_2D : public TickmarkHelper -{ -public: - TickmarkHelper_2D( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos - , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); - //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); - virtual ~TickmarkHelper_2D(); - - virtual TickmarkHelper* createShiftedTickmarkHelper() const; - - static sal_Int32 getTickScreenDistance( TickIter& rIter ); - - void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; - void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints - , sal_Int32 nSequenceIndex - , double fScaledLogicTickValue, double fInnerDirectionSign - , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; - ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties - , bool bIncludeFarAwayDistanceIfSo = false - , bool bIncludeSpaceBetweenTickAndText = true ) const; - - virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - - bool isHorizontalAxis() const; - bool isVerticalAxis() const; - -protected: //methods - ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; - -private: //member - ::basegfx::B2DVector m_aAxisStartScreenPosition2D; - ::basegfx::B2DVector m_aAxisEndScreenPosition2D; - - //labels might be posioned high or low on the border of the diagram far away from the axis - //add this vector to go from the axis line to the label line (border of the diagram) - ::basegfx::B2DVector m_aAxisLineToLabelLineShift; - - double m_fStrech_LogicToScreen; - double m_fOffset_LogicToScreen; -}; - -class TickmarkHelper_3D : public TickmarkHelper -{ -public: - TickmarkHelper_3D( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - virtual ~TickmarkHelper_3D(); - - virtual TickmarkHelper* createShiftedTickmarkHelper() const; -}; - -//............................................................................. -} //namespace chart -//............................................................................. -#endif diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx new file mode 100644 index 000000000000..c5e198acea3f --- /dev/null +++ b/chart2/source/view/axes/Tickmarks.cxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "Tickmarks.hxx" +#include "Tickmarks_Equidistant.hxx" +#include "Tickmarks_Dates.hxx" +#include "ViewDefines.hxx" +#include +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; + +TickInfo::TickInfo( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling >& xInverseScaling ) +: fScaledTickValue( 0.0 ) +, xInverseScaling( xInverseScaling ) +, aTickScreenPosition(0.0,0.0) +, bPaintIt( true ) +, xTextShape( NULL ) +, nFactorForLimitedTextWidth(1) +{ +} + +double TickInfo::getUnscaledTickValue() const +{ + if( xInverseScaling.is() ) + return xInverseScaling->doScaling( fScaledTickValue ); + else + return 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(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() +{ + if(m_aTickIter!=m_rTickVector.end()) + { + m_aTickIter++; + if(m_aTickIter!=m_rTickVector.end()) + return &*m_aTickIter; + } + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +TickFactory::TickFactory( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : m_rScale( rScale ) + , m_rIncrement( rIncrement ) + , m_xInverseScaling(NULL) +{ + //@todo: make sure that the scale is valid for the scaling + + if( m_rScale.Scaling.is() ) + { + m_xInverseScaling = m_rScale.Scaling->getInverseScaling(); + DBG_ASSERT( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" ); + } + + m_fScaledVisibleMin = m_rScale.Minimum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMin = m_rScale.Scaling->doScaling(m_fScaledVisibleMin); + + m_fScaledVisibleMax = m_rScale.Maximum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMax = m_rScale.Scaling->doScaling(m_fScaledVisibleMax); +} + +TickFactory::~TickFactory() +{ +} + +bool TickFactory::isDateAxis() const +{ + return m_rScale.AxisType == AxisType::DATE; +} + +void TickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + if( isDateAxis() ) + DateTickFactory( m_rScale, m_rIncrement ).getAllTicks( rAllTickInfos ); + else + EquidistantTickFactory( m_rScale, m_rIncrement ).getAllTicks( rAllTickInfos ); +} + +void TickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + if( isDateAxis() ) + DateTickFactory( m_rScale, m_rIncrement ).getAllTicksShifted( rAllTickInfos ); + else + EquidistantTickFactory( m_rScale, m_rIncrement ).getAllTicksShifted( rAllTickInfos ); +} + +//----------------------------------------------------------------------------- +// ___TickFactory_2D___ +//----------------------------------------------------------------------------- +TickFactory_2D::TickFactory_2D( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement + //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ) + , const B2DVector& rStartScreenPos, const B2DVector& rEndScreenPos + , const B2DVector& rAxisLineToLabelLineShift ) + : TickFactory( 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; + } +} + +TickFactory_2D::~TickFactory_2D() +{ +} + +bool TickFactory_2D::isHorizontalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() ); +} +bool TickFactory_2D::isVerticalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() ); +} + +//static +sal_Int32 TickFactory_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 TickFactory_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const +{ + B2DVector aRet(m_aAxisStartScreenPosition2D); + aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D) + *((fScaledLogicTickValue+m_fOffset_LogicToScreen)*m_fStrech_LogicToScreen); + return aRet; +} + +void TickFactory_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(aStart.getX()); + rPoints[nSequenceIndex][0].Y = static_cast(aStart.getY()); + rPoints[nSequenceIndex][1].X = static_cast(aEnd.getX()); + rPoints[nSequenceIndex][1].Y = static_cast(aEnd.getY()); +} + +B2DVector TickFactory_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 TickFactory_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const +{ + rPoints[0].realloc(2); + rPoints[0][0].X = static_cast(m_aAxisStartScreenPosition2D.getX()); + rPoints[0][0].Y = static_cast(m_aAxisStartScreenPosition2D.getY()); + rPoints[0][1].X = static_cast(m_aAxisEndScreenPosition2D.getX()); + rPoints[0][1].Y = static_cast(m_aAxisEndScreenPosition2D.getY()); +} + +void TickFactory_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 ); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/Tickmarks.hxx b/chart2/source/view/axes/Tickmarks.hxx new file mode 100644 index 000000000000..62fa5fef92d0 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TICKMARKS_HXX +#define _CHART2_TICKMARKS_HXX + +#include "TickmarkProperties.hxx" +#include "VAxisProperties.hxx" +#include "chartview/ExplicitScaleValues.hxx" +#include +#include +#include +#include + +#include + +//............................................................................. +namespace chart +{ +//............................................................................. + +using ::basegfx::B2DVector; +//----------------------------------------------------------------------------- +/** +*/ + +struct TickInfo +{ + double fScaledTickValue; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > xInverseScaling; + + ::basegfx::B2DVector aTickScreenPosition; + bool bPaintIt; + + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > xTextShape; + + rtl::OUString aText;//used only for complex categories so far + sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category + +//methods: + TickInfo( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling >& xInverseScaling ); + + double getUnscaledTickValue() const; + sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; +private: + TickInfo(); +}; +class TickIter +{ +public: + virtual ~TickIter(){}; + virtual TickInfo* firstInfo()=0; + virtual TickInfo* nextInfo()=0; +}; + +class PureTickIter : public TickIter +{ +public: + PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); + virtual ~PureTickIter(); + virtual TickInfo* firstInfo(); + virtual TickInfo* nextInfo(); + +private: + ::std::vector< TickInfo >& m_rTickVector; + ::std::vector< TickInfo >::iterator m_aTickIter; +}; + +class TickFactory +{ +public: + TickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + virtual ~TickFactory(); + + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} + +private: //methods + bool isDateAxis() const; + +protected: //member + ExplicitScaleData m_rScale; + ExplicitIncrementData m_rIncrement; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > + m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; +}; + +class TickFactory_2D : public TickFactory +{ +public: + TickFactory_2D( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement + , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos + , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); + //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); + virtual ~TickFactory_2D(); + + static sal_Int32 getTickScreenDistance( TickIter& rIter ); + + void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; + void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints + , sal_Int32 nSequenceIndex + , double fScaledLogicTickValue, double fInnerDirectionSign + , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; + ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties + , bool bIncludeFarAwayDistanceIfSo = false + , bool bIncludeSpaceBetweenTickAndText = true ) const; + + virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + + bool isHorizontalAxis() const; + bool isVerticalAxis() const; + +protected: //methods + ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; + +private: //member + ::basegfx::B2DVector m_aAxisStartScreenPosition2D; + ::basegfx::B2DVector m_aAxisEndScreenPosition2D; + + //labels might be posioned high or low on the border of the diagram far away from the axis + //add this vector to go from the axis line to the label line (border of the diagram) + ::basegfx::B2DVector m_aAxisLineToLabelLineShift; + + double m_fStrech_LogicToScreen; + double m_fOffset_LogicToScreen; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/Tickmarks_Dates.cxx b/chart2/source/view/axes/Tickmarks_Dates.cxx new file mode 100644 index 000000000000..b5177fe307b8 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Dates.cxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "Tickmarks_Dates.hxx" +#include "DateScaling.hxx" +#include +#include +#include "DateHelper.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; + +DateTickFactory::DateTickFactory( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : m_aScale( rScale ) + , m_aIncrement( rIncrement ) + , m_xInverseScaling(NULL) +{ + //@todo: make sure that the scale is valid for the scaling + + if( m_aScale.Scaling.is() ) + { + m_xInverseScaling = m_aScale.Scaling->getInverseScaling(); + DBG_ASSERT( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" ); + } + + m_fScaledVisibleMin = m_aScale.Minimum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMin = m_aScale.Scaling->doScaling(m_fScaledVisibleMin); + + m_fScaledVisibleMax = m_aScale.Maximum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMax = m_aScale.Scaling->doScaling(m_fScaledVisibleMax); +} + +DateTickFactory::~DateTickFactory() +{ +} + +void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShifted ) const +{ + rAllTickInfos.resize(2); + ::std::vector< TickInfo >& rMajorTicks = rAllTickInfos[0]; + ::std::vector< TickInfo >& rMinorTicks = rAllTickInfos[1]; + rMajorTicks.clear(); + rMinorTicks.clear(); + + Date aNull(m_aScale.NullDate); + + Date aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); + Date aMaxDate = aNull + ::rtl::math::approxFloor(m_aScale.Maximum); + + uno::Reference< chart2::XScaling > xScaling(m_aScale.Scaling); + uno::Reference< chart2::XScaling > xInverseScaling(m_xInverseScaling); + if( bShifted ) + { + xScaling = new DateScaling(aNull,m_aScale.TimeResolution,true/*bShifted*/); + xInverseScaling = xScaling->getInverseScaling(); + } + + //create major date tickinfos + while( aDate<= aMaxDate ) + { + if( bShifted && aDate==aMaxDate ) + break; + + TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull; + + if( xInverseScaling.is() ) + aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue); + rMajorTicks.push_back( aNewTick ); + + if(m_aIncrement.MajorTimeInterval.Number<=0) + break; + + //find next major date + switch( m_aIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + aDate += m_aIncrement.MajorTimeInterval.Number; + break; + case YEAR: + aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MajorTimeInterval.Number ); + break; + case MONTH: + default: + aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MajorTimeInterval.Number ); + break; + } + } + + //create minor date tickinfos + aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); + while( aDate<= aMaxDate ) + { + if( bShifted && aDate==aMaxDate ) + break; + + TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull; + if( xInverseScaling.is() ) + aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue); + rMinorTicks.push_back( aNewTick ); + + if(m_aIncrement.MinorTimeInterval.Number<=0) + break; + + //find next minor date + switch( m_aIncrement.MinorTimeInterval.TimeUnit ) + { + case DAY: + aDate += m_aIncrement.MinorTimeInterval.Number; + break; + case YEAR: + aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MinorTimeInterval.Number ); + break; + case MONTH: + default: + aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MinorTimeInterval.Number ); + break; + } + } +} + +void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + getAllTicks( rAllTickInfos, false ); +} + +void DateTickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + getAllTicks( rAllTickInfos, true ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/Tickmarks_Dates.hxx b/chart2/source/view/axes/Tickmarks_Dates.hxx new file mode 100644 index 000000000000..464e8b4ca24c --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Dates.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TICKMARKS_DATES_HXX +#define _CHART2_TICKMARKS_DATES_HXX + +#include "Tickmarks.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class DateTickFactory +{ +public: + DateTickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + ~DateTickFactory(); + + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + +private: //methods + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShifted ) const; + +private: //member + ExplicitScaleData m_aScale; + ExplicitIncrementData m_aIncrement; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > + m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx new file mode 100644 index 000000000000..9344af1ffac9 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -0,0 +1,671 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "Tickmarks_Equidistant.hxx" +#include "ViewDefines.hxx" +#include +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; + +//static +double EquidistantTickFactory::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; +} +//static +double EquidistantTickFactory::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; +} + +EquidistantTickFactory::EquidistantTickFactory( + 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 = EquidistantTickFactory::getMinimumAtIncrement( fMin, m_rIncrement ); + m_fOuterMajorTickBorderMax = EquidistantTickFactory::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); + } + } +} + +EquidistantTickFactory::~EquidistantTickFactory() +{ + delete[] m_pfCurrentValues; +} + +sal_Int32 EquidistantTickFactory::getTickDepth() const +{ + return static_cast(m_rIncrement.SubIncrements.size()) + 1; +} + +void EquidistantTickFactory::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; nPartTickgetMinorTick( nPartTick, nDepth + , fLastParentTick, *pfNextParentTick ); + if(!pValue) + continue; + + aSubTicks[nRealSubTickCount] = *pValue; + nRealSubTickCount++; + } + } + + aSubTicks.realloc(nRealSubTickCount); + rParentTicks[nDepth] = aSubTicks; + if(static_cast(m_rIncrement.SubIncrements.size())>nDepth) + addSubTicks( nDepth+1, rParentTicks ); +} + + +sal_Int32 EquidistantTickFactory::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( fSub / m_rIncrement.Distance ); + + nIntervalCount+=3; + for(sal_Int32 nN=0; nN1 ) + 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* EquidistantTickFactory::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]doScaling( m_pfCurrentValues[0] ); + + return &m_pfCurrentValues[0]; +} + +double* EquidistantTickFactory::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>static_cast(m_rIncrement.SubIncrements.size()) || 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 EquidistantTickFactory::isWithinOuterBorder( double fScaledValue ) const +{ + if(fScaledValue>m_fOuterMajorTickBorderMax_Scaled) + return false; + if(fScaledValuem_fScaledVisibleMax) + { + if( !approxEqual(fScaledValue,m_fScaledVisibleMax) ) + return false; + } + if(fScaledValue >& 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; nMajorTickgetMajorTick( 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; nN1 ) + nCheckCount *= m_rIncrement.SubIncrements[nN].IntervalCount; + } + uno::Sequence< double >& rTicks = aAllTicks[nDepth]; + sal_Int32 nCount = rTicks.getLength(); + //check lower border + for( nTick=0; nTicknCount-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& rTickInfoVector = rAllTickInfos[nDepth]; + rTickInfoVector.clear(); + rTickInfoVector.reserve( nCount ); + for(sal_Int32 nN = 0; nN >& rAllTickInfos ) const +{ + ExplicitIncrementData aShiftedIncrement( m_rIncrement ); + aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; + EquidistantTickFactory( m_rScale, aShiftedIncrement ).getAllTicks(rAllTickInfos); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +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; nNstatic_cast(m_rIncrement.SubIncrements.size()) || 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_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; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.hxx b/chart2/source/view/axes/Tickmarks_Equidistant.hxx new file mode 100644 index 000000000000..836a93d28db2 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Equidistant.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TICKMARKS_EQUIDISTANT_HXX +#define _CHART2_TICKMARKS_EQUIDISTANT_HXX + +#include "Tickmarks.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +using ::basegfx::B2DVector; +//----------------------------------------------------------------------------- +/** +*/ + +class EquidistantTickIter : public TickIter +{ +public: + EquidistantTickIter( const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< double > >& rTicks + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); + EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); + virtual ~EquidistantTickIter(); + + virtual double* firstValue(); + virtual double* nextValue(); + + virtual TickInfo* firstInfo(); + virtual TickInfo* nextInfo(); + + sal_Int32 getCurrentDepth() const { return m_nCurrentDepth; } + +protected: + bool gotoIndex( sal_Int32 nTickIndex ); + sal_Int32 getCurrentIndex() const; + sal_Int32 getMaxIndex() const; + +private: //methods + sal_Int32 getIntervalCount( sal_Int32 nDepth ); + bool isAtLastPartTick(); + + void initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth ); + sal_Int32 getStartDepth() const; + + bool gotoFirst(); + bool gotoNext(); + + + double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const + { + if(m_pSimpleTicks) + return (*m_pSimpleTicks)[nDepth][nIndex]; + else + return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue; + } + sal_Int32 getTickCount( sal_Int32 nDepth ) const + { + if(m_pSimpleTicks) + return (*m_pSimpleTicks)[nDepth].getLength(); + else + return (*m_pInfoTicks)[nDepth].size(); + } + sal_Int32 getMaxDepth() const + { + if(m_pSimpleTicks) + return (*m_pSimpleTicks).getLength()-1; + else + return (*m_pInfoTicks).size()-1; + } + +private: //member + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks; + ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks; + const ExplicitIncrementData& m_rIncrement; + //iteration from m_nMinDepth to m_nMaxDepth + sal_Int32 m_nMinDepth; + sal_Int32 m_nMaxDepth; + sal_Int32 m_nTickCount; + sal_Int32* m_pnPositions; //current positions in the different sequences + sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always, + //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark + bool* m_pbIntervalFinished; + sal_Int32 m_nCurrentDepth; + sal_Int32 m_nCurrentPos; + double m_fCurrentValue; +}; + +class EquidistantTickFactory +{ +public: + EquidistantTickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + ~EquidistantTickFactory(); + + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + + static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ); + static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ); + +private: //methods + void addSubTicks( sal_Int32 nDepth, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const; + double* getMajorTick( sal_Int32 nTick ) const; + double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth + , double fStartParentTick, double fNextParentTick ) const; + sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const; + sal_Int32 getTickDepth() const; + + bool isVisible( double fValue ) const; + bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks + +private: //member + ExplicitScaleData m_rScale; + ExplicitIncrementData m_rIncrement; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > + m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; + + double* m_pfCurrentValues; + //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders + double m_fOuterMajorTickBorderMin; + double m_fOuterMajorTickBorderMax; + double m_fOuterMajorTickBorderMin_Scaled; + double m_fOuterMajorTickBorderMax_Scaled; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 0159fb20cad6..fb193ec93a95 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -31,7 +31,7 @@ #include "VAxisBase.hxx" #include "ShapeFactory.hxx" #include "CommonConverters.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "macros.hxx" // header for define DBG_ASSERT @@ -70,7 +70,7 @@ sal_Int32 VAxisBase::getDimensionCount() return m_nDimension; } -void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize +void VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) { m_aAxisLabelProperties.m_aFontReferenceSize = rFontReferenceSize; @@ -106,6 +106,15 @@ void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::S m_aAxisLabelProperties.eStaggering = SIDE_BY_SIDE; } +bool VAxisBase::isDateAxis() const +{ + return AxisType::DATE == m_aScale.AxisType; +} +bool VAxisBase::isComplexCategoryAxis() const +{ + return m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels; +} + void VAxisBase::recordMaximumTextSize( const Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) { if( m_bRecordMaximumTextSize && xShape.is() ) @@ -130,7 +139,7 @@ void VAxisBase::setExrtaLinePositionAtOtherAxis( const double& fCrossingAt ) m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = new double(fCrossingAt); } -sal_Bool SAL_CALL VAxisBase::isAnythingToDraw() +sal_Bool VAxisBase::isAnythingToDraw() { if( !m_aAxisProperties.m_xAxisModel.is() ) return false; @@ -150,7 +159,7 @@ sal_Bool SAL_CALL VAxisBase::isAnythingToDraw() return true; } -void SAL_CALL VAxisBase::setExplicitScaleAndIncrement( +void VAxisBase::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -162,8 +171,11 @@ void SAL_CALL VAxisBase::setExplicitScaleAndIncrement( void VAxisBase::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) { - std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); - apTickmarkHelper->getAllTicks( rAllTickInfos ); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); + if( m_aScale.ShiftedCategoryPosition ) + apTickFactory->getAllTicksShifted( rAllTickInfos ); + else + apTickFactory->getAllTicks( rAllTickInfos ); } bool VAxisBase::prepareShapeCreation() @@ -244,7 +256,7 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter& rIter ) for( TickInfo* pTickInfo = rIter.firstInfo() ; pTickInfo; pTickInfo = rIter.nextInfo() ) { - pTickInfo->updateUnscaledValue( xInverseScaling ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); } } diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx index ba7e94b2070c..e51e2d8dbd9b 100644 --- a/chart2/source/view/axes/VAxisBase.hxx +++ b/chart2/source/view/axes/VAxisBase.hxx @@ -29,7 +29,7 @@ #include "VAxisOrGridBase.hxx" #include "VAxisProperties.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include //............................................................................. @@ -52,18 +52,18 @@ public: sal_Int32 getDimensionCount(); - virtual void SAL_CALL createMaximumLabels()=0; - virtual void SAL_CALL createLabels()=0; - virtual void SAL_CALL updatePositions()=0; + virtual void createMaximumLabels()=0; + virtual void createLabels()=0; + virtual void updatePositions()=0; - virtual sal_Bool SAL_CALL isAnythingToDraw(); - virtual void SAL_CALL initAxisLabelProperties( + virtual sal_Bool isAnythingToDraw(); + virtual void initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); @@ -83,6 +83,9 @@ protected: //methods ::com::sun::star::drawing::XShape >& xShape , double fRotationAngleDegree ); + bool isDateAxis() const; + bool isComplexCategoryAxis() const; + protected: //member ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; AxisProperties m_aAxisProperties; diff --git a/chart2/source/view/axes/VAxisOrGridBase.cxx b/chart2/source/view/axes/VAxisOrGridBase.cxx index f2e2e90c1045..715da4972390 100644 --- a/chart2/source/view/axes/VAxisOrGridBase.cxx +++ b/chart2/source/view/axes/VAxisOrGridBase.cxx @@ -31,7 +31,7 @@ #include "VAxisOrGridBase.hxx" #include "ShapeFactory.hxx" #include "CommonConverters.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" // header for define DBG_ASSERT #include @@ -57,7 +57,7 @@ VAxisOrGridBase::~VAxisOrGridBase() { } -void SAL_CALL VAxisOrGridBase::setExplicitScaleAndIncrement( +void VAxisOrGridBase::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -79,18 +79,9 @@ void VAxisOrGridBase::set3DWallPositions( CuboidPlanePosition eLeftWallPos, Cubo m_eBottomPos = eBottomPos; } -TickmarkHelper* VAxisOrGridBase::createTickmarkHelper() +TickFactory* VAxisOrGridBase::createTickFactory() { - TickmarkHelper* pRet=NULL; - if( 2==m_nDimension ) - { - pRet = new TickmarkHelper( m_aScale, m_aIncrement ); - } - else - { - pRet = new TickmarkHelper_3D( m_aScale, m_aIncrement ); - } - return pRet; + return new TickFactory( m_aScale, m_aIncrement ); } //............................................................................. diff --git a/chart2/source/view/axes/VAxisOrGridBase.hxx b/chart2/source/view/axes/VAxisOrGridBase.hxx index 35b32b2b1c03..9091aabf0dc5 100644 --- a/chart2/source/view/axes/VAxisOrGridBase.hxx +++ b/chart2/source/view/axes/VAxisOrGridBase.hxx @@ -29,9 +29,8 @@ #include "PlotterBase.hxx" #include "ThreeDHelper.hxx" +#include "chartview/ExplicitScaleValues.hxx" -#include -#include #include #include #include @@ -46,7 +45,7 @@ namespace chart /** */ class ShapeFactory; -class TickmarkHelper; +class TickFactory; class VAxisOrGridBase : public PlotterBase { @@ -55,22 +54,22 @@ public: virtual ~VAxisOrGridBase(); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); - virtual TickmarkHelper* createTickmarkHelper(); + virtual TickFactory* createTickFactory(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- protected: //member - ::com::sun::star::chart2::ExplicitScaleData m_aScale; - ::com::sun::star::chart2::ExplicitIncrementData m_aIncrement; - sal_Int32 m_nDimensionIndex; + ExplicitScaleData m_aScale; + ExplicitIncrementData m_aIncrement; + sal_Int32 m_nDimensionIndex; - ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; + ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; CuboidPlanePosition m_eLeftWallPos; CuboidPlanePosition m_eBackWallPos; diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 1e3e62894741..d700ee9d27be 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -183,7 +183,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel , m_pfExrtaLinePositionAtOtherAxis(NULL) , m_bCrossingAxisHasReverseDirection(false) , m_bCrossingAxisIsCategoryAxes(false) - , m_bAxisBetweenCategories(false) , m_fLabelDirectionSign(1.0) , m_fInnerDirectionSign(1.0) , m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP) @@ -213,7 +212,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties ) , m_pfExrtaLinePositionAtOtherAxis( NULL ) , m_bCrossingAxisHasReverseDirection( rAxisProperties.m_bCrossingAxisHasReverseDirection ) , m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes ) - , m_bAxisBetweenCategories( rAxisProperties.m_bAxisBetweenCategories ) , m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign ) , m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign ) , m_aLabelAlignment( rAxisProperties.m_aLabelAlignment ) @@ -280,11 +278,7 @@ void AxisProperties::initAxisPositioning( const uno::Reference< beans::XProperty xAxisProp->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue; if( m_bCrossingAxisIsCategoryAxes ) - { fValue = ::rtl::math::round(fValue); - if( m_bAxisBetweenCategories ) - fValue-=0.5; - } m_pfMainLinePositionAtOtherAxis = new double(fValue); } else if( ::com::sun::star::chart::ChartAxisPosition_ZERO == m_eCrossoverType ) @@ -318,8 +312,17 @@ void AxisProperties::init( bool bCartesian ) if( m_nDimensionIndex<2 ) initAxisPositioning( xProp ); + ScaleData aScaleData = m_xAxisModel->getScaleData(); + if( m_nDimensionIndex==0 ) + AxisHelper::checkDateAxis( aScaleData, m_pExplicitCategoriesProvider, bCartesian ); + m_nAxisType = aScaleData.AxisType; + if( bCartesian ) { + if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY + && m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) + m_bComplexCategories = true; + if( ::com::sun::star::chart::ChartAxisPosition_END == m_eCrossoverType ) m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1; else @@ -361,10 +364,6 @@ void AxisProperties::init( bool bCartesian ) //init display labels xProp->getPropertyValue( C2U( "DisplayLabels" ) ) >>= m_bDisplayLabels; - //init categories - ScaleData aScaleData = m_xAxisModel->getScaleData(); - m_nAxisType = aScaleData.AxisType; - //init TickmarkProperties xProp->getPropertyValue( C2U( "MajorTickmarks" ) ) >>= m_nMajorTickmarks; xProp->getPropertyValue( C2U( "MinorTickmarks" ) ) >>= m_nMinorTickmarks; diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx index 5b6bfe98f777..69e0edb82730 100644 --- a/chart2/source/view/axes/VAxisProperties.hxx +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -111,7 +111,6 @@ struct AxisProperties bool m_bCrossingAxisHasReverseDirection; bool m_bCrossingAxisIsCategoryAxes; - bool m_bAxisBetweenCategories; //this direction is used to indicate in which direction the labels are to be drawn double m_fLabelDirectionSign; diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8ec895fbd452..869e1292ed7a 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -41,6 +41,7 @@ #include "TrueGuard.hxx" #include "BaseGFXHelper.hxx" #include "AxisHelper.hxx" +#include "Tickmarks_Equidistant.hxx" #include #include @@ -176,7 +177,7 @@ void removeShapesAtWrongRhythm( TickIter& rIter } } -class EquidistantLabelIterator : public EquidistantTickIter +class LabelIterator : public TickIter { //this Iterator iterates over existing text labels @@ -190,39 +191,36 @@ class EquidistantLabelIterator : public EquidistantTickIter //we iterate through all labels public: - EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + LabelIterator( ::std::vector< TickInfo >& rTickInfoVector , const AxisLabelStaggering eAxisLabelStaggering - , bool bInnerLine - , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); + , bool bInnerLine ); virtual TickInfo* firstInfo(); virtual TickInfo* nextInfo(); private: //methods - EquidistantLabelIterator(); + LabelIterator(); private: //member const AxisLabelStaggering m_eAxisLabelStaggering; - bool m_bInnerLine; + bool m_bInnerLine; + PureTickIter m_aPureTickIter; }; -EquidistantLabelIterator::EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement +LabelIterator::LabelIterator( ::std::vector< TickInfo >& rTickInfoVector , const AxisLabelStaggering eAxisLabelStaggering - , bool bInnerLine - , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) - : EquidistantTickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth ) + , bool bInnerLine ) + : m_aPureTickIter( rTickInfoVector ) , m_eAxisLabelStaggering(eAxisLabelStaggering) , m_bInnerLine(bInnerLine) { } -TickInfo* EquidistantLabelIterator::firstInfo() +TickInfo* LabelIterator::firstInfo() { - TickInfo* pTickInfo = EquidistantTickIter::firstInfo(); + TickInfo* pTickInfo = m_aPureTickIter.firstInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ) - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); if(!pTickInfo) return NULL; if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine) @@ -232,7 +230,7 @@ TickInfo* EquidistantLabelIterator::firstInfo() { //skip first label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); } if(!pTickInfo) @@ -240,12 +238,12 @@ TickInfo* EquidistantLabelIterator::firstInfo() return pTickInfo; } -TickInfo* EquidistantLabelIterator::nextInfo() +TickInfo* LabelIterator::nextInfo() { TickInfo* pTickInfo = NULL; //get next label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); if( STAGGER_EVEN==m_eAxisLabelStaggering @@ -253,7 +251,7 @@ TickInfo* EquidistantLabelIterator::nextInfo() { //skip one label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); } return pTickInfo; @@ -319,30 +317,30 @@ void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance ) } } -class MaxLabelEquidistantTickIter : public EquidistantTickIter +class MaxLabelTickIter : public TickIter { //iterate over first two and last two labels and the longest label public: - MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector , sal_Int32 nLongestLabelIndex ); - virtual ~MaxLabelEquidistantTickIter(); + virtual ~MaxLabelTickIter(); - virtual TickInfo* nextInfo(); + virtual TickInfo* firstInfo(); + virtual TickInfo* nextInfo(); private: + ::std::vector< TickInfo >& m_rTickInfoVector; sal_Int32 m_nLongestLabelIndex; + sal_Int32 m_nCurrentIndex; }; -MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement +MaxLabelTickIter::MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector , sal_Int32 nLongestLabelIndex ) - : EquidistantTickIter( rTickInfos, rIncrement, 0//nMinDepth - , 0//nMaxDepth - ) + : m_rTickInfoVector(rTickInfoVector) , m_nLongestLabelIndex( nLongestLabelIndex ) + , m_nCurrentIndex(0) { - sal_Int32 nMaxIndex = getMaxIndex(); + sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; //ensure correct value: if( m_nLongestLabelIndex<0 || m_nLongestLabelIndex>nMaxIndex) @@ -355,28 +353,43 @@ MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std:: if( m_nLongestLabelIndex+1==nMaxIndex ) m_nLongestLabelIndex = 0; } -MaxLabelEquidistantTickIter::~MaxLabelEquidistantTickIter() +MaxLabelTickIter::~MaxLabelTickIter() +{ +} + +TickInfo* MaxLabelTickIter::firstInfo() { + m_nCurrentIndex = 0; + if( m_nCurrentIndex < m_rTickInfoVector.size() ) + return &m_rTickInfoVector[m_nCurrentIndex]; + return 0; } -TickInfo* MaxLabelEquidistantTickIter::nextInfo() +TickInfo* MaxLabelTickIter::nextInfo() { - sal_Int32 nCurrentPos = getCurrentIndex(); - sal_Int32 nMaxIndex = getMaxIndex(); - if( nCurrentPos>0 ) + sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; + if( m_nLongestLabelIndex >= nMaxIndex-1 ) + m_nLongestLabelIndex = 0; + + if( m_nCurrentIndex==0 ) + m_nCurrentIndex++; + else if( m_nCurrentIndex==1 && m_nCurrentIndex1 && nCurrentPos3 && nCurrentPos2 && nCurrentPos=3 ) + m_nCurrentIndex=nMaxIndex-1; + else if( nMaxIndex>=2 ) + m_nCurrentIndex=nMaxIndex; } + else if( m_nCurrentIndex==nMaxIndex-1 ) + m_nCurrentIndex=nMaxIndex; + else + m_nCurrentIndex=nMaxIndex+1; - return EquidistantTickIter::nextInfo(); + if( m_nCurrentIndex>=0 && m_nCurrentIndex::const_iterator aEnd(aComplexCategories.end()); for(;aIt!=aEnd;++aIt) { - TickInfo aTickInfo; + TickInfo aTickInfo(0); ComplexCategory aCat(*aIt); sal_Int32 nCount = aCat.Count; - if( nCatIndex + 0.5 + nCount >= m_aScale.Maximum ) + if( nCatIndex + 1.0 + nCount >= m_aScale.Maximum ) { - nCount = static_cast(m_aScale.Maximum - 0.5 - nCatIndex); + nCount = static_cast(m_aScale.Maximum - 1.0 - nCatIndex); if( nCount <= 0 ) nCount = 1; } - aTickInfo.fScaledTickValue = nCatIndex + 0.5 + nCount/2.0; + aTickInfo.fScaledTickValue = nCatIndex + 1.0 + nCount/2.0; aTickInfo.nFactorForLimitedTextWidth = nCount; aTickInfo.aText = aCat.Text; aTickInfoVector.push_back(aTickInfo); nCatIndex += nCount; - if( nCatIndex + 0.5 >= m_aScale.Maximum ) + if( nCatIndex + 1.0 >= m_aScale.Maximum ) break; } rAllTickInfos.push_back(aTickInfoVector); } } - else //bShiftedPosition==true + else //bShiftedPosition==false { rAllTickInfos.clear(); sal_Int32 nLevel=0; @@ -480,19 +493,19 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end()); for(;aIt!=aEnd;++aIt) { - TickInfo aTickInfo; + TickInfo aTickInfo(0); ComplexCategory aCat(*aIt); - aTickInfo.fScaledTickValue = nCatIndex + 0.5; + aTickInfo.fScaledTickValue = nCatIndex + 1.0; aTickInfoVector.push_back(aTickInfo); nCatIndex += aCat.Count; - if( nCatIndex + 0.5 > m_aScale.Maximum ) + if( nCatIndex + 1.0 > m_aScale.Maximum ) break; } //fill up with single ticks until maximum scale - while( nCatIndex + 0.5 < m_aScale.Maximum ) + while( nCatIndex + 1.0 < m_aScale.Maximum ) { - TickInfo aTickInfo; - aTickInfo.fScaledTickValue = nCatIndex + 0.5; + TickInfo aTickInfo(0); + aTickInfo.fScaledTickValue = nCatIndex + 1.0; aTickInfoVector.push_back(aTickInfo); nCatIndex ++; if( nLevel>0 ) @@ -500,7 +513,7 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s } //add an additional tick at the end { - TickInfo aTickInfo; + TickInfo aTickInfo(0); aTickInfo.fScaledTickValue = m_aScale.Maximum; aTickInfoVector.push_back(aTickInfo); } @@ -511,7 +524,7 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) createAllTickInfosFromComplexCategories( rAllTickInfos, false ); else VAxisBase::createAllTickInfos(rAllTickInfos); @@ -519,21 +532,13 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo ::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) - { - if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) - return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); - } - else - { - if(nTextLevel==0) - return ::std::auto_ptr< TickIter >( new EquidistantTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 ) ); - } + if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) + return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); return ::std::auto_ptr< TickIter >(); } ::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() || isDateAxis() ) { return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here } @@ -541,8 +546,11 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo { if(nTextLevel==0) { - sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; - return ::std::auto_ptr< TickIter >( new MaxLabelEquidistantTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex ) ); + if( !m_aAllTickInfos.empty() ) + { + sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; + return ::std::auto_ptr< TickIter >( new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ) ); + } } } return ::std::auto_ptr< TickIter >(); @@ -551,7 +559,7 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo sal_Int32 VCartesianAxis::getTextLevelCount() const { sal_Int32 nTextLevelCount = 1; - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount(); return nTextLevelCount; } @@ -560,7 +568,7 @@ bool VCartesianAxis::createTextShapes( const Reference< drawing::XShapes >& xTarget , TickIter& rTickIter , AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper + , TickFactory_2D* pTickFactory , sal_Int32 nScreenDistanceBetweenTicks ) { //returns true if the text shapes have been created succesfully @@ -574,10 +582,10 @@ bool VCartesianAxis::createTextShapes( FixedNumberFormatter aFixedNumberFormatter( m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey ); - const bool bIsHorizontalAxis = pTickmarkHelper->isHorizontalAxis(); - const bool bIsVerticalAxis = pTickmarkHelper->isVerticalAxis(); + const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis(); + const bool bIsVerticalAxis = pTickFactory->isVerticalAxis(); bool bIsStaggered = rAxisLabelProperties.getIsStaggered(); - B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties, true ) ); + B2DVector aTextToTickDistance( pTickFactory->getDistanceAxisTickToText( m_aAxisProperties, true ) ); sal_Int32 nLimitedSpaceForText = -1; if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) ) { @@ -673,7 +681,7 @@ bool VCartesianAxis::createTextShapes( } } - pTickInfo->updateUnscaledValue( xInverseScaling ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); bool bHasExtraColor=false; sal_Int32 nExtraColor=0; @@ -681,7 +689,7 @@ bool VCartesianAxis::createTextShapes( rtl::OUString aLabel; if(pCategories) { - sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->fUnscaledTickValue) - 1; //first category (index 0) matches with real number 1.0 + sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0 if( nIndex>=0 && nIndexgetLength() ) aLabel = (*pCategories)[nIndex]; } @@ -690,7 +698,7 @@ bool VCartesianAxis::createTextShapes( aLabel = pTickInfo->aText; } else - aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor ); if(pColorAny) *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); @@ -1189,12 +1197,12 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub } } -TickmarkHelper* VCartesianAxis::createTickmarkHelper() +TickFactory* VCartesianAxis::createTickFactory() { - return createTickmarkHelper2D(); + return createTickFactory2D(); } -TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D() +TickFactory_2D* VCartesianAxis::createTickFactory2D() { B2DVector aStart, aEnd; this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() ); @@ -1202,7 +1210,7 @@ TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D() B2DVector aLabelLineStart, aLabelLineEnd; this->get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, this->getLogicValueWhereLabelLineCrossesOtherAxis() ); - return new TickmarkHelper_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart ); + return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart ); } void lcl_hideIdenticalScreenValues( TickIter& rTickIter ) @@ -1226,7 +1234,7 @@ void lcl_hideIdenticalScreenValues( TickIter& rTickIter ) //'hide' tickmarks with identical screen values in aAllTickInfos void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() || isDateAxis() ) { sal_Int32 nCount = rTickInfos.size(); for( sal_Int32 nN=0; nN0 ) lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance ); aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ); + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ); } } } else if( rAxisLabelProperties.getIsStaggered() ) { - EquidistantLabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement - , rAxisLabelProperties.eStaggering, true, 0, 0 ); - EquidistantLabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement - , rAxisLabelProperties.eStaggering, false, 0, 0 ); - - lcl_shiftLables( aOuterIter - , lcl_getLabelsDistance( aInnerIter - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + if( !m_aAllTickInfos.empty() ) + { + LabelIterator aInnerIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, true ); + LabelIterator aOuterIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, false ); + + lcl_shiftLables( aOuterIter + , lcl_getLabelsDistance( aInnerIter + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + } } } -void SAL_CALL VCartesianAxis::createLabels() +void VCartesianAxis::createLabels() { if( !prepareShapeCreation() ) return; @@ -1315,14 +1324,14 @@ void SAL_CALL VCartesianAxis::createLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); //----------------------------------------- //'hide' tickmarks with identical screen values in aAllTickInfos hideIdenticalScreenValues( m_aAllTickInfos ); @@ -1339,7 +1348,7 @@ void SAL_CALL VCartesianAxis::createLabels() { if(nTextLevel==0) { - nScreenDistanceBetweenTicks = TickmarkHelper_2D::getTickScreenDistance( *apTickIter.get() ); + nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() ); if( nTextLevelCount>1 ) nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half } @@ -1348,16 +1357,16 @@ void SAL_CALL VCartesianAxis::createLabels() aCopy.bRhythmIsFix = true; aCopy.nRhythm = 1; AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy; - while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickmarkHelper2D, nScreenDistanceBetweenTicks ) ) + while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) ) { }; } } - doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); } } -void SAL_CALL VCartesianAxis::createMaximumLabels() +void VCartesianAxis::createMaximumLabels() { TrueGuard aRecordMaximumTextSize(m_bRecordMaximumTextSize); @@ -1368,20 +1377,20 @@ void SAL_CALL VCartesianAxis::createMaximumLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); //create tick mark text shapes //@todo: iterate through all tick depth wich should be labeled AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); - if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D->isHorizontalAxis(), pTickmarkHelper2D->isVerticalAxis() ) ) + if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) ) aAxisLabelProperties.eStaggering = STAGGER_EVEN; aAxisLabelProperties.bOverlapAllowed = true; aAxisLabelProperties.bLineBreakAllowed = false; @@ -1391,29 +1400,29 @@ void SAL_CALL VCartesianAxis::createMaximumLabels() ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel ); if(apTickIter.get()) { - while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickmarkHelper2D, -1 ) ) + while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) ) { }; } } - doStaggeringOfLabels( aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D ); } } -void SAL_CALL VCartesianAxis::updatePositions() +void VCartesianAxis::updatePositions() { //----------------------------------------- //update positions of labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //update positions of all existing text shapes - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); @@ -1427,7 +1436,7 @@ void SAL_CALL VCartesianAxis::updatePositions() Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape ); if( xShape2DText.is() ) { - B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); + B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition ); aTickScreenPos2D += aTextToTickDistance; awt::Point aAnchorScreenPosition2D( @@ -1459,11 +1468,11 @@ void SAL_CALL VCartesianAxis::updatePositions() } } - doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); } } -void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels ) +void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ) { sal_Int32 nPointCount = rTickInfos.size(); drawing::PointSequenceSequence aPoints(2*nPointCount); @@ -1482,11 +1491,11 @@ void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickI fInnerDirectionSign *= -1.0; bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels; //add ticks at labels: - rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue + rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels ); //add ticks at axis (without lables): if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ) - rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue + rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels ); } aPoints.realloc(nN); @@ -1494,14 +1503,14 @@ void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickI , &rTickmarkProperties.aLineProperties ); } -void SAL_CALL VCartesianAxis::createShapes() +void VCartesianAxis::createShapes() { if( !prepareShapeCreation() ) return; - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- @@ -1510,23 +1519,23 @@ void SAL_CALL VCartesianAxis::createShapes() { //----------------------------------------- //create extra long ticks to separate complex categories (create them only there where the labels are) - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) { ::std::vector< ::std::vector< TickInfo > > aComplexTickInfos; createAllTickInfosFromComplexCategories( aComplexTickInfos, true ); - pTickmarkHelper2D->updateScreenValues( aComplexTickInfos ); + pTickFactory2D->updateScreenValues( aComplexTickInfos ); hideIdenticalScreenValues( aComplexTickInfos ); ::std::vector aTickmarkPropertiesList; static bool bIncludeSpaceBetweenTickAndText = false; - sal_Int32 nOffset = static_cast(pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength()); + sal_Int32 nOffset = static_cast(pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength()); sal_Int32 nTextLevelCount = getTextLevelCount(); for( sal_Int32 nTextLevel=0; nTextLevel apTickIter = createLabelTickIterator( nTextLevel ); if( apTickIter.get() ) { - B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); + B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); sal_Int32 nCurrentLength = static_cast(aLabelsDistance.getLength()); aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); nOffset += nCurrentLength; @@ -1540,20 +1549,20 @@ void SAL_CALL VCartesianAxis::createShapes() { if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks) continue; - createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, true /*bOnlyAtLabels*/ ); + createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickFactory2D, true /*bOnlyAtLabels*/ ); } } //----------------------------------------- //create normal ticks for major and minor intervals { - ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos; - if( m_aIncrement.ShiftedPosition || ( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) ) + ::std::vector< ::std::vector< TickInfo > > aUnshiftedTickInfos; + if( m_aScale.ShiftedCategoryPosition )// if ShiftedCategoryPosition==true the tickmarks in m_aAllTickInfos are shifted { - pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos ); - pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos ); - hideIdenticalScreenValues( aAllShiftedTickInfos ); + pTickFactory2D->getAllTicks( aUnshiftedTickInfos ); + pTickFactory2D->updateScreenValues( aUnshiftedTickInfos ); + hideIdenticalScreenValues( aUnshiftedTickInfos ); } - ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos; + ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aScale.ShiftedCategoryPosition ? aUnshiftedTickInfos : m_aAllTickInfos; ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); @@ -1562,14 +1571,14 @@ void SAL_CALL VCartesianAxis::createShapes() sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size(); for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ ) - createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, false /*bOnlyAtLabels*/ ); + createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ ); } //----------------------------------------- //create axis main lines //it serves also as the handle shape for the axis selection { drawing::PointSequenceSequence aPoints(1); - apTickmarkHelper2D->createPointSequenceForAxisMainLine( aPoints ); + apTickFactory2D->createPointSequenceForAxisMainLine( aPoints ); Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints , &m_aAxisProperties.m_aLineProperties ); diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index 4fbcd2409196..d199a112bab1 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -55,20 +55,11 @@ public: virtual ~VCartesianAxis(); - //------------------------------------------------------------------------- - // partly chart2::XPlotter - //------------------------------------------------------------------------- - - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); @@ -79,7 +70,7 @@ public: sal_Int32 getTextLevelCount() const; //------------------------------------------------------------------------- - virtual TickmarkHelper* createTickmarkHelper(); + virtual TickFactory* createTickFactory(); //------------------------------------------------------------------------- double getLogicValueWhereMainLineCrossesOtherAxis() const; @@ -122,16 +113,16 @@ protected: //methods ::com::sun::star::drawing::XShapes >& xTarget , TickIter& rTickIter , AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper + , TickFactory_2D* pTickFactory , sal_Int32 nScreenDistanceBetweenTicks ); - void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels ); + void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ); - TickmarkHelper_2D* createTickmarkHelper2D(); + TickFactory_2D* createTickFactory2D(); void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const; void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper2D ); + , TickFactory_2D* pTickFactory2D ); bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties , bool bIsHorizontalAxis, bool bIsVerticalAxis ); bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ); diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx index a196397e0e9f..ca83850a88ff 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -151,11 +151,7 @@ void VCartesianCoordinateSystem::createVAxisList( aAxisProperties.m_bCrossingAxisHasReverseDirection = (AxisOrientation_REVERSE==aCrossingScale.Orientation); if( aCrossingScale.AxisType == AxisType::CATEGORY ) - { aAxisProperties.m_bCrossingAxisIsCategoryAxes = true; - aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) ) - || ( aAxisProperties.m_pExplicitCategoriesProvider && aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() ); - } } if( nDimensionIndex == 2 ) @@ -169,25 +165,12 @@ void VCartesianCoordinateSystem::createVAxisList( aAxisProperties.init(true); if(aAxisProperties.m_bDisplayLabels) aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier ); - - if( nDimensionIndex == 0 && aAxisProperties.m_nAxisType == AxisType::CATEGORY - && aAxisProperties.m_pExplicitCategoriesProvider ) - { - if( aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() ) - aAxisProperties.m_bComplexCategories = true; - } //------------------- ::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) ); tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex ); m_aAxisMap[aFullAxisIndex] = apVAxis; apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos ); - //apVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); - //apVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory - // , this->createCIDForAxis( xAxis, nDimensionIndex, nAxisIndex ) ); - //if(2==nDimensionCount) - // apVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); - //apVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); } } diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index 7fe6b9937ca6..0baa9b2b6e9a 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "VCartesianGrid.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" #include "ObjectIdentifier.hxx" @@ -211,7 +211,7 @@ void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector apTickmarkHelper( this->createTickmarkHelper() ); - TickmarkHelper& aTickmarkHelper = *apTickmarkHelper.get(); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); + TickFactory& aTickFactory = *apTickFactory.get(); ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; - if( m_aIncrement.ShiftedPosition ) - aTickmarkHelper.getAllTicksShifted( aAllTickInfos ); - else - aTickmarkHelper.getAllTicks( aAllTickInfos ); + aTickFactory.getAllTicks( aAllTickInfos ); //----------------------------------------- //create tick mark line shapes diff --git a/chart2/source/view/axes/VCartesianGrid.hxx b/chart2/source/view/axes/VCartesianGrid.hxx index 274b543900e3..0a0f8b91716f 100644 --- a/chart2/source/view/axes/VCartesianGrid.hxx +++ b/chart2/source/view/axes/VCartesianGrid.hxx @@ -52,7 +52,7 @@ public: ); virtual ~VCartesianGrid(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); static void fillLinePropertiesFromGridModel( ::std::vector& rLinePropertiesList , const ::com::sun::star::uno::Sequence< diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index bc908acdf85a..f184fbe0a1e3 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -107,7 +107,7 @@ VCoordinateSystem::~VCoordinateSystem() { } -void SAL_CALL VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes >& xLogicTarget +void VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes >& xLogicTarget , const Reference< drawing::XShapes >& xFinalTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory , Reference< drawing::XShapes >& xLogicTargetForSeriesBehindAxis ) @@ -271,9 +271,9 @@ ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider() return m_apExplicitCategoriesProvider.get(); } -Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const +std::vector< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const { - Sequence< ExplicitScaleData > aRet(m_aExplicitScales); + std::vector< ExplicitScaleData > aRet(m_aExplicitScales); impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex ); aRet[nDimensionIndex]=this->getExplicitScale( nDimensionIndex, nAxisIndex ); @@ -281,9 +281,9 @@ Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nD return aRet; } -Sequence< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const +std::vector< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const { - Sequence< ExplicitIncrementData > aRet(m_aExplicitIncrements); + std::vector< ExplicitIncrementData > aRet(m_aExplicitIncrements); impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex ); aRet[nDimensionIndex]=this->getExplicitIncrement( nDimensionIndex, nAxisIndex ); @@ -382,6 +382,17 @@ void VCoordinateSystem::updateScalesAndIncrementsOnAxes() void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ) { + if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 ) + { + sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::MONTH; + if( !(rScaleAutomatism.getScale().TimeIncrement.TimeResolution >>= nTimeResolution) ) + { + nTimeResolution = m_aMergedMinimumAndMaximumSupplier.calculateTimeResolutionOnXAxis(); + rScaleAutomatism.setAutomaticTimeResolution( nTimeResolution ); + } + m_aMergedMinimumAndMaximumSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() ); + } + double fMin = 0.0; double fMax = 0.0; ::rtl::math::setInf(&fMin, false); @@ -403,11 +414,6 @@ void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomat fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumZ(); } - this->prepareScaleAutomatism( rScaleAutomatism, fMin, fMax, nDimIndex, nAxisIndex ); -} - -void VCoordinateSystem::prepareScaleAutomatism( ScaleAutomatism& rScaleAutomatism, double fMin, double fMax, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ) -{ //merge our values with those already contained in rScaleAutomatism rScaleAutomatism.expandValueRange( fMin, fMax ); diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index 865a7848aa9a..dcb7cd5a6303 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -120,17 +120,17 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis( rtl::OUString aLabel; if(pLabels) { - sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->fUnscaledTickValue) - 1; //first category (index 0) matches with real number 1.0 + sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0 if( nIndex>=0 && nIndexgetLength() ) aLabel = (*pLabels)[nIndex]; } else - aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor ); if(pColorAny) *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); - double fLogicAngle = pTickInfo->fUnscaledTickValue; + double fLogicAngle = pTickInfo->getUnscaledTickValue(); LabelAlignment eLabelAlignment(LABEL_ALIGN_CENTER); PolarLabelPositionHelper aPolarLabelPositionHelper(m_pPosHelper,nDimensionCount,xTarget,&aShapeFactory); @@ -154,7 +154,7 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis( return true; } -void SAL_CALL VPolarAngleAxis::createMaximumLabels() +void VPolarAngleAxis::createMaximumLabels() { if( !prepareShapeCreation() ) return; @@ -162,7 +162,7 @@ void SAL_CALL VPolarAngleAxis::createMaximumLabels() createLabels(); } -void SAL_CALL VPolarAngleAxis::updatePositions() +void VPolarAngleAxis::updatePositions() { //todo: really only update the positions @@ -172,7 +172,7 @@ void SAL_CALL VPolarAngleAxis::updatePositions() createLabels(); } -void SAL_CALL VPolarAngleAxis::createLabels() +void VPolarAngleAxis::createLabels() { if( !prepareShapeCreation() ) return; @@ -184,7 +184,7 @@ void SAL_CALL VPolarAngleAxis::createLabels() { //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); //create tick mark text shapes //@todo: iterate through all tick depth wich should be labeled @@ -207,7 +207,7 @@ void SAL_CALL VPolarAngleAxis::createLabels() } } -void SAL_CALL VPolarAngleAxis::createShapes() +void VPolarAngleAxis::createShapes() { if( !prepareShapeCreation() ) return; diff --git a/chart2/source/view/axes/VPolarAngleAxis.hxx b/chart2/source/view/axes/VPolarAngleAxis.hxx index c03cf533e22c..011033faaefa 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.hxx +++ b/chart2/source/view/axes/VPolarAngleAxis.hxx @@ -28,6 +28,7 @@ #define _CHART2_VPOLARANGLEAXIS_HXX #include "VPolarAxis.hxx" +#include "Tickmarks_Equidistant.hxx" //............................................................................. namespace chart @@ -46,11 +47,11 @@ public: , sal_Int32 nDimensionCount ); virtual ~VPolarAngleAxis(); - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); private: //methods bool createTextShapes_ForAngleAxis( diff --git a/chart2/source/view/axes/VPolarAxis.cxx b/chart2/source/view/axes/VPolarAxis.cxx index 23908585ec3a..5f818da6c959 100644 --- a/chart2/source/view/axes/VPolarAxis.cxx +++ b/chart2/source/view/axes/VPolarAxis.cxx @@ -31,7 +31,7 @@ #include "VPolarAngleAxis.hxx" #include "VPolarRadiusAxis.hxx" #include "macros.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "ShapeFactory.hxx" #include @@ -68,12 +68,12 @@ VPolarAxis::~VPolarAxis() m_pPosHelper = NULL; } -void VPolarAxis::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements ) +void VPolarAxis::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) { m_aIncrements = rIncrements; } -sal_Bool SAL_CALL VPolarAxis::isAnythingToDraw() +sal_Bool VPolarAxis::isAnythingToDraw() { return ( 2==m_nDimension && VAxisBase::isAnythingToDraw() ); } diff --git a/chart2/source/view/axes/VPolarAxis.hxx b/chart2/source/view/axes/VPolarAxis.hxx index 8d4c14188258..a72b338416e2 100644 --- a/chart2/source/view/axes/VPolarAxis.hxx +++ b/chart2/source/view/axes/VPolarAxis.hxx @@ -47,10 +47,9 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount ); - void setIncrements( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData >& rIncrements ); + void setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ); - virtual sal_Bool SAL_CALL isAnythingToDraw(); + virtual sal_Bool isAnythingToDraw(); virtual ~VPolarAxis(); @@ -61,8 +60,7 @@ protected: protected: //member PolarPlottingPositionHelper* m_pPosHelper; - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements; + ::std::vector< ExplicitIncrementData > m_aIncrements; }; //............................................................................. diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx index 76e057a2b32d..5d13f5c46f66 100644 --- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx +++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx @@ -107,15 +107,6 @@ void VPolarCoordinateSystem::createVAxisList( tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex ); m_aAxisMap[aFullAxisIndex] = apVAxis; - //apVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) ); - //apVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory - // , this->createCIDForAxis( xAxis, nDimensionIndex, nAxisIndex ) ); - //VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( apVAxis.get() ); - //if( pVPolarAxis ) - // pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) ); - //if(2==nDimensionCount) - // apVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); - //apVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); } } diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index 0bd98b642acb..953b729bd453 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -29,12 +29,13 @@ #include "precompiled_chart2.hxx" #include "VPolarGrid.hxx" #include "VCartesianGrid.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" #include "ObjectIdentifier.hxx" #include "macros.hxx" #include "CommonConverters.hxx" +#include "Tickmarks_Equidistant.hxx" #include #include @@ -64,16 +65,16 @@ VPolarGrid::~VPolarGrid() m_pPosHelper = NULL; } -void VPolarGrid::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements ) +void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) { m_aIncrements = rIncrements; } void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const { - TickmarkHelper aTickmarkHelper( + TickFactory aTickFactory( m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] ); - aTickmarkHelper.getAllTicks( rAllTickInfos ); + aTickFactory.getAllTicks( rAllTickInfos ); } //static @@ -98,8 +99,8 @@ void VPolarGrid::createLinePointSequence_ForAngleAxis( if(nTick>=rPoints[0].getLength()) rPoints[0].realloc(rPoints[0].getLength()+30); - pTickInfo->updateUnscaledValue( xInverseScaling ); - double fLogicAngle = pTickInfo->fUnscaledTickValue; + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); + double fLogicAngle = pTickInfo->getUnscaledTickValue(); drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) ); rPoints[0][nTick].X = static_cast(aScenePosition3D.PositionX); @@ -153,8 +154,8 @@ void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicT if( !rTickInfo.bPaintIt ) continue; - rTickInfo.updateUnscaledValue( xInverseScaling ); - double fLogicAngle = rTickInfo.fUnscaledTickValue; + //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling ); + double fLogicAngle = rTickInfo.getUnscaledTickValue(); drawing::PointSequenceSequence aPoints(1); aPoints[0].realloc(2); @@ -220,8 +221,8 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic if( !rTickInfo.bPaintIt ) continue; - rTickInfo.updateUnscaledValue( xInverseRadiusScaling ); - double fLogicRadius = rTickInfo.fUnscaledTickValue; + //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling ); + double fLogicRadius = rTickInfo.getUnscaledTickValue(); double fLogicZ = -0.5;//as defined drawing::PointSequenceSequence aPoints(1); @@ -238,7 +239,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic } } -void SAL_CALL VPolarGrid::createShapes() +void VPolarGrid::createShapes() { DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized"); if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is())) diff --git a/chart2/source/view/axes/VPolarGrid.hxx b/chart2/source/view/axes/VPolarGrid.hxx index 3289d6c88be8..1ea3bccc1f90 100644 --- a/chart2/source/view/axes/VPolarGrid.hxx +++ b/chart2/source/view/axes/VPolarGrid.hxx @@ -28,7 +28,7 @@ #define _CHART2_VPOLARGRID_HXX #include "VAxisOrGridBase.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "VLineProperties.hxx" #include @@ -55,16 +55,15 @@ public: ); virtual ~VPolarGrid(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); - void setIncrements( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData >& rIncrements ); + void setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ); static void createLinePointSequence_ForAngleAxis( ::com::sun::star::drawing::PointSequenceSequence& rPoints , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , const ::com::sun::star::chart2::ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement + , const ExplicitScaleData& rScale , PolarPlottingPositionHelper* pPosHelper , double fLogicRadius, double fLogicZ ); @@ -73,8 +72,7 @@ private: //member ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > > m_aGridPropertiesList;//main grid, subgrid, subsubgrid etc PolarPlottingPositionHelper* m_pPosHelper; - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements; + ::std::vector< ExplicitIncrementData > m_aIncrements; void getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx index 2206d4d8f559..bc56b3824e6e 100644 --- a/chart2/source/view/axes/VPolarRadiusAxis.cxx +++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx @@ -32,6 +32,7 @@ #include "VCartesianAxis.hxx" #include "PlottingPositionHelper.hxx" #include "CommonConverters.hxx" +#include "Tickmarks_Equidistant.hxx" #include //............................................................................. @@ -70,7 +71,7 @@ void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMat m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix ); } -void SAL_CALL VPolarRadiusAxis::setExplicitScaleAndIncrement( +void VPolarRadiusAxis::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -79,7 +80,7 @@ void SAL_CALL VPolarRadiusAxis::setExplicitScaleAndIncrement( m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement ); } -void SAL_CALL VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget +void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory , const rtl::OUString& rCID ) @@ -89,15 +90,13 @@ void SAL_CALL VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XSh m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); } -void SAL_CALL VPolarRadiusAxis::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (uno::RuntimeException) +void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { VPolarAxis::setScales( rScales, bSwapXAndYAxis ); m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis ); } -void SAL_CALL VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize +void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) { VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); @@ -121,22 +120,22 @@ bool VPolarRadiusAxis::prepareShapeCreation() return true; } -void SAL_CALL VPolarRadiusAxis::createMaximumLabels() +void VPolarRadiusAxis::createMaximumLabels() { m_apAxisWithLabels->createMaximumLabels(); } -void SAL_CALL VPolarRadiusAxis::updatePositions() +void VPolarRadiusAxis::updatePositions() { m_apAxisWithLabels->updatePositions(); } -void SAL_CALL VPolarRadiusAxis::createLabels() +void VPolarRadiusAxis::createLabels() { m_apAxisWithLabels->createLabels(); } -void SAL_CALL VPolarRadiusAxis::createShapes() +void VPolarRadiusAxis::createShapes() { if( !prepareShapeCreation() ) return; @@ -145,8 +144,8 @@ void SAL_CALL VPolarRadiusAxis::createShapes() const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0]; ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos; - TickmarkHelper aAngleTickmarkHelper( rAngleScale, rAngleIncrement ); - aAngleTickmarkHelper.getAllTicks( aAngleTickInfos ); + TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement ); + aAngleTickFactory.getAllTicks( aAngleTickInfos ); uno::Reference< XScaling > xInverseScaling( NULL ); if( rAngleScale.Scaling.is() ) @@ -165,8 +164,8 @@ void SAL_CALL VPolarRadiusAxis::createShapes() continue; } - pTickInfo->updateUnscaledValue( xInverseScaling ); - aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->fUnscaledTickValue ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); + aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() ); aAxisProperties.m_bDisplayLabels=false; //------------------- diff --git a/chart2/source/view/axes/VPolarRadiusAxis.hxx b/chart2/source/view/axes/VPolarRadiusAxis.hxx index b5c5191e4c98..e1dbb8c1b1c0 100644 --- a/chart2/source/view/axes/VPolarRadiusAxis.hxx +++ b/chart2/source/view/axes/VPolarRadiusAxis.hxx @@ -50,7 +50,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~VPolarRadiusAxis(); - virtual void SAL_CALL initPlotter( + virtual void initPlotter( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -62,28 +62,24 @@ public: virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL initAxisLabelProperties( + virtual void initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); protected: //methods virtual bool prepareShapeCreation(); diff --git a/chart2/source/view/axes/makefile.mk b/chart2/source/view/axes/makefile.mk index 96191a3a3a25..af88a61b6b37 100644 --- a/chart2/source/view/axes/makefile.mk +++ b/chart2/source/view/axes/makefile.mk @@ -47,7 +47,11 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES = \ $(SLO)$/VAxisOrGridBase.obj \ $(SLO)$/VAxisBase.obj \ - $(SLO)$/TickmarkHelper.obj \ + $(SLO)$/DateHelper.obj \ + $(SLO)$/DateScaling.obj \ + $(SLO)$/Tickmarks.obj \ + $(SLO)$/Tickmarks_Equidistant.obj \ + $(SLO)$/Tickmarks_Dates.obj \ $(SLO)$/MinimumAndMaximumSupplier.obj \ $(SLO)$/ScaleAutomatism.obj \ $(SLO)$/VAxisProperties.obj \ diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index fd1aaa81c3a0..59cde85a13fe 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -43,6 +43,7 @@ #include "Clipping.hxx" #include "Stripe.hxx" #include "PolarLabelPositionHelper.hxx" +#include "DateHelper.hxx" #include #include @@ -96,6 +97,8 @@ AreaChart::AreaChart( const uno::Reference& xChartTypeModel { if( !m_pMainPosHelper ) m_pMainPosHelper = new PlottingPositionHelper(); + if( m_pMainPosHelper ) + m_pMainPosHelper->DoShiftCategoryXIfShiftIsIndicated(true); PlotterBase::m_pPosHelper = m_pMainPosHelper; VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; @@ -121,18 +124,12 @@ AreaChart::~AreaChart() delete m_pMainPosHelper; } -double AreaChart::getMinimumX() -{ - if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling - return 1.0;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} - double AreaChart::getMaximumX() { + double fMax = VSeriesPlotter::getMaximumX(); if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling - return getPointCount()+1; - return VSeriesPlotter::getMaximumX(); + fMax += 1.0; + return fMax; } bool AreaChart::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) @@ -183,18 +180,6 @@ APPHELPER_XSERVICEINFO_IMPL(AreaChart,CHART2_VIEW_AREACHART_SERVICE_IMPLEMENTATI return aSNS; } */ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL AreaChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const { if( m_nKeepAspectRatio == 1 ) @@ -729,6 +714,8 @@ void AreaChart::createShapes() //collect data point information (logic coordinates, style ): double fLogicX = (*aSeriesIter)->getXValue(nIndex); + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution ); double fLogicY = (*aSeriesIter)->getYValue(nIndex); if( m_bIsPolarCooSys && m_bArea && diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 6924509a62a1..4b6ff3f45251 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -55,17 +55,7 @@ public: ); virtual ~AreaChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- @@ -75,7 +65,6 @@ public: //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - virtual double getMinimumX(); virtual double getMaximumX(); virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx old mode 100755 new mode 100644 index 0d7ef403f87d..6d94cea682dc --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -40,6 +40,7 @@ #include "macros.hxx" #include "AxisIndexDefines.hxx" #include "Clipping.hxx" +#include "DateHelper.hxx" #include @@ -91,7 +92,6 @@ BarChart::~BarChart() PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisIndex ) const { PlottingPositionHelper& rPosHelper = VSeriesPlotter::getPlottingPositionHelper( nAxisIndex ); - BarPositionHelper* pBarPosHelper = dynamic_cast(&rPosHelper); if( pBarPosHelper && nAxisIndex >= 0 ) { @@ -100,7 +100,6 @@ PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisInde if( nAxisIndex < m_aGapwidthSequence.getLength() ) pBarPosHelper->setOuterDistance( m_aGapwidthSequence[nAxisIndex]/100.0 ); } - return rPosHelper; } @@ -118,7 +117,7 @@ drawing::Direction3D BarChart::getPreferredDiagramAspectRatio() const if(!m_aZSlots.empty()) fXSlotCount = m_aZSlots.begin()->size(); - aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getSlotWidth()); + aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getScaledSlotWidth()); } else return VSeriesPlotter::getPreferredDiagramAspectRatio(); @@ -146,54 +145,6 @@ bool BarChart::keepAspectRatio() const return true; } -//------------------------------------------------------------------------- -// MinimumAndMaximumSupplier -//------------------------------------------------------------------------- - -double BarChart::getMinimumX() -{ - if( m_bCategoryXAxis ) - return 0.5;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} -double BarChart::getMaximumX() -{ - if( m_bCategoryXAxis ) - { - //return category count - sal_Int32 nPointCount = getPointCount(); - return nPointCount+0.5;//first category (index 0) matches with real number 1.0 - } - return VSeriesPlotter::getMaximumX(); -} - -//----------------------------------------------------------------- -// lang::XServiceInfo -//----------------------------------------------------------------- -/* -APPHELPER_XSERVICEINFO_IMPL(BarChart,CHART2_VIEW_BARCHART_SERVICE_IMPLEMENTATION_NAME) - - uno::Sequence< rtl::OUString > BarChart -::getSupportedServiceNames_Static() -{ - uno::Sequence< rtl::OUString > aSNS( 1 ); - aSNS.getArray()[ 0 ] = CHART2_VIEW_BARCHART_SERVICE_NAME; - return aSNS; -} -*/ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL BarChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ - awt::Point BarChart::getLabelScreenPositionAndAlignment( LabelAlignment& rAlignment, sal_Int32 nLabelPlacement , double fScaledX, double fScaledLowerYValue, double fScaledUpperYValue, double fScaledZ @@ -514,12 +465,11 @@ void BarChart::createShapes() sal_Int32 nCreatedPoints = 0; // - //(@todo maybe different iteration for breaks in axis ?) - sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive - sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive + sal_Int32 nStartIndex = 0; + sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); //============================================================================= - //iterate through all shown categories - for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex < nEndCategoryIndex; nCatIndex++ ) + //iterate through all x values per indices + for( sal_Int32 nPointIndex = nStartIndex; nPointIndex < nEndIndex; nPointIndex++ ) { ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin(); const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end(); @@ -538,7 +488,7 @@ void BarChart::createShapes() aLogicYSumMap[nAttachedAxisIndex]=0.0; double fMinimumY = 0.0, fMaximumY = 0.0; - aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex + aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex , isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); if( !::rtl::math::isNan( fMaximumY ) && fMaximumY > 0) @@ -574,14 +524,14 @@ void BarChart::createShapes() //update/create information for current group pPosHelper->updateSeriesCount( aZSlotIter->size() ); - double fLogicBaseWidth = pPosHelper->getSlotWidth(); + double fLogicBaseWidth = pPosHelper->getScaledSlotWidth(); ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector); // get distance from base value to maximum and minimum double fMinimumY = 0.0, fMaximumY = 0.0; - aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex + aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex , isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); double fLogicPositiveYSum = 0.0; @@ -633,7 +583,7 @@ void BarChart::createShapes() bOnlyConnectionLinesForThisPoint = false; - if(nCatIndex==nStartCategoryIndex)//do not create a regression line for each point + if(nPointIndex==nStartIndex)//do not create a regression line for each point createRegressionCurvesShapes( **aSeriesIter, xRegressionCurveTarget, xRegressionCurveEquationTarget, m_pPosHelper->maySkipPointsInRegressionCalculation()); @@ -658,8 +608,17 @@ void BarChart::createShapes() getSeriesGroupShape(*aSeriesIter, xSeriesTarget) ); //collect data point information (logic coordinates, style ): - double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nCatIndex ), fSlotX ); - double fLogicBarHeight = (*aSeriesIter)->getYValue( nCatIndex ); + double fUnscaledLogicX = (*aSeriesIter)->getXValue( nPointIndex ); + fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution ); + if(fUnscaledLogicXgetLogicMinX()) + continue;//point not visible + if(fUnscaledLogicX>pPosHelper->getLogicMaxX()) + continue;//point not visible + if(pPosHelper->isStrongLowerXRequested() && fUnscaledLogicX==pPosHelper->getLogicMaxX()) + continue;//point not visible + double fLogicX = pPosHelper->getScaledSlotPos( fUnscaledLogicX, fSlotX ); + + double fLogicBarHeight = (*aSeriesIter)->getYValue( nPointIndex ); if( ::rtl::math::isNan( fLogicBarHeight )) //no value at this category continue; @@ -686,7 +645,7 @@ void BarChart::createShapes() if(m_nDimension==3) fLogicZ = nZ; - drawing::Position3D aUnscaledLogicPosition( fLogicX, fUpperYValue, fLogicZ ); + drawing::Position3D aUnscaledLogicPosition( fUnscaledLogicX, fUpperYValue, fLogicZ ); //@todo ... start an iteration over the different breaks of the axis //each subsystem may add an additional shape to form the whole point @@ -696,7 +655,7 @@ void BarChart::createShapes() // uno::Reference( xPointGroupShape_Shapes, uno::UNO_QUERY ); //as long as we do not iterate we do not need to create an additional group for each point uno::Reference< drawing::XShapes > xPointGroupShape_Shapes = xSeriesGroupShape_Shapes; - uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nCatIndex ) ); + uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nPointIndex ) ); sal_Int32 nGeometry3D = DataPointGeometry3D::CUBOID; if(m_nDimension==3) try { @@ -763,7 +722,7 @@ void BarChart::createShapes() //better performance for big data FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); - if( !pSeries->isAttributedDataPoint(nCatIndex) + if( !pSeries->isAttributedDataPoint(nPointIndex) && pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fUpperY, aFormerPoint.m_fZ , fLogicX, fUpperYValue, fLogicZ ) @@ -883,20 +842,20 @@ void BarChart::createShapes() //set name/classified ObjectID (CID) ShapeFactory::setShapeName(xShape , ObjectIdentifier::createPointCID( - (*aSeriesIter)->getPointCID_Stub(),nCatIndex) ); + (*aSeriesIter)->getPointCID_Stub(),nPointIndex) ); } //create error bar - createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nCatIndex, m_xLogicTarget ); + createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nPointIndex, m_xLogicTarget ); //------------ //create data point label - if( (**aSeriesIter).getDataPointLabelIfLabel(nCatIndex) ) + if( (**aSeriesIter).getDataPointLabelIfLabel(nPointIndex) ) { double fLogicSum = aLogicYSumMap[nAttachedAxisIndex]; LabelAlignment eAlignment(LABEL_ALIGN_CENTER); - sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nCatIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() ); + sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nPointIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() ); double fLowerBarDepth = fLogicBarDepth; double fUpperBarDepth = fLogicBarDepth; @@ -921,7 +880,7 @@ void BarChart::createShapes() if( m_nDimension == 3 ) nOffset = 260; } - this->createDataLabel( xTextTarget, **aSeriesIter, nCatIndex + this->createDataLabel( xTextTarget, **aSeriesIter, nPointIndex , fLogicValueForLabeDisplay, fLogicSum, aScreenPosition2D, eAlignment, nOffset ); } diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx index 403628f7fc43..c20c85168b5d 100644 --- a/chart2/source/view/charttypes/BarChart.hxx +++ b/chart2/source/view/charttypes/BarChart.hxx @@ -47,29 +47,13 @@ public: , sal_Int32 nDimensionCount ); virtual ~BarChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const; virtual bool keepAspectRatio() const; - //------------------------------------------------------------------------- - // MinimumAndMaximumSupplier - //------------------------------------------------------------------------- - virtual double getMinimumX(); - virtual double getMaximumX(); - //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/BarPositionHelper.cxx b/chart2/source/view/charttypes/BarPositionHelper.cxx index b1735e99de5d..bd013b08207d 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.cxx +++ b/chart2/source/view/charttypes/BarPositionHelper.cxx @@ -32,6 +32,8 @@ #include "Linear3DTransformation.hxx" #include "ViewDefines.hxx" #include "CommonConverters.hxx" +#include "DateHelper.hxx" +#include //............................................................................. namespace chart @@ -43,6 +45,7 @@ using namespace ::com::sun::star::chart2; BarPositionHelper::BarPositionHelper( bool /* bSwapXAndY */ ) : CategoryPositionHelper( 1 ) { + DoShiftCategoryXIfShiftIsIndicated(true); } BarPositionHelper::BarPositionHelper( const BarPositionHelper& rSource ) @@ -66,73 +69,23 @@ void BarPositionHelper::updateSeriesCount( double fSeriesCount ) m_fSeriesCount = fSeriesCount; } -uno::Reference< XTransformation > BarPositionHelper::getTransformationScaledLogicToScene() const +double BarPositionHelper::getScaledSlotPos( double fUnscaledLogicX, double fSeriesNumber ) const { - //transformation from 2) to 4) //@todo 2) and 4) need a link to a document + if( m_bDateAxis ) + fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution ); + double fScaledLogicX(fUnscaledLogicX); + doLogicScaling(&fScaledLogicX,NULL,NULL); + fScaledLogicX = CategoryPositionHelper::getScaledSlotPos( fScaledLogicX, fSeriesNumber ); + //MaybeShiftCategoryX( fScaledLogicX ); + return fScaledLogicX; - //we need to apply this transformation to each geometric object because of a bug/problem - //of the old drawing layer (the UNO_NAME_3D_EXTRUDE_DEPTH is an integer value instead of an double ) - - if( !m_xTransformationLogicToScene.is() ) - { - ::basegfx::B3DHomMatrix aMatrix; - - double MinX = getLogicMinX(); - double MinY = getLogicMinY(); - double MinZ = getLogicMinZ(); - double MaxX = getLogicMaxX(); - double MaxY = getLogicMaxY(); - double MaxZ = getLogicMaxZ(); - - AxisOrientation nXAxisOrientation = m_aScales[0].Orientation; - AxisOrientation nYAxisOrientation = m_aScales[1].Orientation; - AxisOrientation nZAxisOrientation = m_aScales[2].Orientation; - - //apply scaling - //scaling of x axis is refused/ignored - doLogicScaling( NULL, &MinY, &MinZ ); - doLogicScaling( NULL, &MaxY, &MaxZ); - - if(m_bSwapXAndY) - { - std::swap(MinX,MinY); - std::swap(MaxX,MaxY); - std::swap(nXAxisOrientation,nYAxisOrientation); - } - - if( AxisOrientation_MATHEMATICAL==nXAxisOrientation ) - aMatrix.translate(-MinX,0.0,0.0); - else - aMatrix.translate(-MaxX,0.0,0.0); - if( AxisOrientation_MATHEMATICAL==nYAxisOrientation ) - aMatrix.translate(0.0,-MinY,0.0); - else - aMatrix.translate(0.0,-MaxY,0.0); - if( AxisOrientation_MATHEMATICAL==nZAxisOrientation ) - aMatrix.translate(0.0,0.0,-MaxZ);//z direction in draw is reverse mathematical direction - else - aMatrix.translate(0.0,0.0,-MinZ); - - double fWidthX = MaxX - MinX; - double fWidthY = MaxY - MinY; - double fWidthZ = MaxZ - MinZ; - - double fScaleDirectionX = AxisOrientation_MATHEMATICAL==nXAxisOrientation ? 1.0 : -1.0; - double fScaleDirectionY = AxisOrientation_MATHEMATICAL==nYAxisOrientation ? 1.0 : -1.0; - double fScaleDirectionZ = AxisOrientation_MATHEMATICAL==nZAxisOrientation ? -1.0 : 1.0; - - aMatrix.scale(fScaleDirectionX*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthX - , fScaleDirectionY*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY - , fScaleDirectionZ*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthZ); - - //if(nDim==2) - aMatrix = m_aMatrixScreenToScene*aMatrix; - - m_xTransformationLogicToScene = new Linear3DTransformation(B3DHomMatrixToHomogenMatrix( aMatrix ),m_bSwapXAndY); - } - return m_xTransformationLogicToScene; } +void BarPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth ) +{ + m_fScaledCategoryWidth = fScaledCategoryWidth; + CategoryPositionHelper::setCategoryWidth( m_fScaledCategoryWidth ); +} //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/charttypes/BarPositionHelper.hxx b/chart2/source/view/charttypes/BarPositionHelper.hxx index 32899de62aef..3a905877bcb9 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.hxx +++ b/chart2/source/view/charttypes/BarPositionHelper.hxx @@ -49,25 +49,10 @@ public: virtual PlottingPositionHelper* clone() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation > - getTransformationScaledLogicToScene() const; - void updateSeriesCount( double fSeriesCount ); /*only enter the size of x stacked series*/ - sal_Int32 getStartCategoryIndex() const { - //first category (index 0) matches with real number 1.0 - sal_Int32 nStart = static_cast(getLogicMinX() - 0.5); - if( nStart < 0 ) - nStart = 0; - return nStart; - } - sal_Int32 getEndCategoryIndex() const { - //first category (index 0) matches with real number 1.0 - sal_Int32 nEnd = static_cast(getLogicMaxX() - 0.5); - if( nEnd < 0 ) - nEnd = 0; - return nEnd; - } + virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const; + virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); }; //............................................................................. diff --git a/chart2/source/view/charttypes/BubbleChart.hxx b/chart2/source/view/charttypes/BubbleChart.hxx index 9c04ce8d3719..ed3d9e051cc4 100644 --- a/chart2/source/view/charttypes/BubbleChart.hxx +++ b/chart2/source/view/charttypes/BubbleChart.hxx @@ -46,11 +46,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~BubbleChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index ddfe50deed2f..b9ce0883d2f0 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -30,8 +30,6 @@ #include "CandleStickChart.hxx" #include "ShapeFactory.hxx" -//#include "chartview/servicenames_charttypes.hxx" -//#include "servicenames_coosystems.hxx" #include "CommonConverters.hxx" #include "ObjectIdentifier.hxx" #include "LabelPositionHelper.hxx" @@ -40,6 +38,7 @@ #include "VLegendSymbolFactory.hxx" #include "FormattedStringHelper.hxx" #include "DataSeriesHelper.hxx" +#include "DateHelper.hxx" #include #include #include @@ -76,22 +75,6 @@ CandleStickChart::~CandleStickChart() // MinimumAndMaximumSupplier //------------------------------------------------------------------------- -double CandleStickChart::getMinimumX() -{ - if( m_bCategoryXAxis ) - return 0.5;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} -double CandleStickChart::getMaximumX() -{ - if( m_bCategoryXAxis ) - { - //return category count - sal_Int32 nPointCount = getPointCount(); - return nPointCount+0.5;//first category (index 0) matches with real number 1.0 - } - return VSeriesPlotter::getMaximumX(); -} bool CandleStickChart::isSeperateStackingForDifferentSigns( sal_Int32 /* nDimensionIndex */ ) { return false; @@ -120,18 +103,6 @@ APPHELPER_XSERVICEINFO_IMPL(CandleStickChart,CHART2_VIEW_CANDLESTICKCHART_SERVIC return aSNS; } */ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL CandleStickChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ drawing::Direction3D CandleStickChart::getPreferredDiagramAspectRatio() const { @@ -205,11 +176,11 @@ void CandleStickChart::createShapes() } //(@todo maybe different iteration for breaks in axis ?) - sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive - sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive + sal_Int32 nStartIndex = 0; + sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); //============================================================================= - //iterate through all shown categories - for( sal_Int32 nIndex = nStartCategoryIndex; nIndex < nEndCategoryIndex; nIndex++ ) + //iterate through all x values per indices + for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ ) { ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin(); const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end(); @@ -247,28 +218,48 @@ void CandleStickChart::createShapes() for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ ) { //collect data point information (logic coordinates, style ): - double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nIndex ), fSlotX ); - double fY_First = (*aSeriesIter)->getY_First( nIndex ); - double fY_Last = (*aSeriesIter)->getY_Last( nIndex ); - double fY_Min = (*aSeriesIter)->getY_Min( nIndex ); - double fY_Max = (*aSeriesIter)->getY_Max( nIndex ); + double fUnscaledX = (*aSeriesIter)->getXValue( nIndex ); + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + fUnscaledX = DateHelper::RasterizeDateValue( fUnscaledX, m_aNullDate, m_nTimeResolution ); + if(fUnscaledXgetLogicMinX() || fUnscaledX>pPosHelper->getLogicMaxX()) + continue;//point not visible + double fScaledX = pPosHelper->getScaledSlotPos( fUnscaledX, fSlotX ); + + double fUnscaledY_First = (*aSeriesIter)->getY_First( nIndex ); + double fUnscaledY_Last = (*aSeriesIter)->getY_Last( nIndex ); + double fUnscaledY_Min = (*aSeriesIter)->getY_Min( nIndex ); + double fUnscaledY_Max = (*aSeriesIter)->getY_Max( nIndex ); bool bBlack=false; - if(fY_Last<=fY_First) + if(fUnscaledY_Last<=fUnscaledY_First) { - std::swap(fY_First,fY_Last); + std::swap(fUnscaledY_First,fUnscaledY_Last); bBlack=true; } - if(fY_Max 4) - double fHalfWidth = pPosHelper->getSlotWidth()/2.0; - drawing::Position3D aPosLeftFirst( pPosHelper->transformLogicToScene( fLogicX-fHalfWidth, fY_First ,0 ,true ) ); - drawing::Position3D aPosRightLast( pPosHelper->transformLogicToScene( fLogicX+fHalfWidth, fY_Last ,0 ,true ) ); - drawing::Position3D aPosMiddleFirst( pPosHelper->transformLogicToScene( fLogicX, fY_First ,0 ,true ) ); - drawing::Position3D aPosMiddleLast( pPosHelper->transformLogicToScene( fLogicX, fY_Last ,0 ,true ) ); - drawing::Position3D aPosMiddleMinimum( pPosHelper->transformLogicToScene( fLogicX, fY_Min ,0 ,true ) ); - drawing::Position3D aPosMiddleMaximum( pPosHelper->transformLogicToScene( fLogicX, fY_Max ,0 ,true ) ); + double fHalfScaledWidth = pPosHelper->getScaledSlotWidth()/2.0; + + double fScaledY_First(fUnscaledY_First); + double fScaledY_Last(fUnscaledY_Last); + double fScaledY_Min(fUnscaledY_Min); + double fScaledY_Max(fUnscaledY_Max); + pPosHelper->clipLogicValues( 0,&fScaledY_First,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Last,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Min,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Max,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_First,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Last,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Min,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Max,0 ); + + drawing::Position3D aPosLeftFirst( pPosHelper->transformScaledLogicToScene( fScaledX-fHalfScaledWidth, fScaledY_First ,0 ,true ) ); + drawing::Position3D aPosRightLast( pPosHelper->transformScaledLogicToScene( fScaledX+fHalfScaledWidth, fScaledY_Last ,0 ,true ) ); + drawing::Position3D aPosMiddleFirst( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_First ,0 ,true ) ); + drawing::Position3D aPosMiddleLast( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Last ,0 ,true ) ); + drawing::Position3D aPosMiddleMinimum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Min ,0 ,true ) ); + drawing::Position3D aPosMiddleMaximum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Max ,0 ,true ) ); uno::Reference< drawing::XShapes > xLossGainTarget( xGainTarget ); if(bBlack) @@ -329,13 +320,13 @@ void CandleStickChart::createShapes() drawing::PolyPolygonShape3D aPoly; sal_Int32 nLineIndex = 0; - if( bShowFirst && pPosHelper->isLogicVisible( fLogicX, fY_First ,0 ) + if( bShowFirst && pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_First ,0 ) && isValidPosition(aPosLeftFirst) && isValidPosition(aPosMiddleFirst) ) { AddPointToPoly( aPoly, aPosLeftFirst, nLineIndex ); AddPointToPoly( aPoly, aPosMiddleFirst, nLineIndex++ ); } - if( pPosHelper->isLogicVisible( fLogicX, fY_Last ,0 ) + if( pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_Last ,0 ) && isValidPosition(aPosMiddleLast) && isValidPosition(aPosRightLast) ) { AddPointToPoly( aPoly, aPosMiddleLast, nLineIndex ); @@ -361,16 +352,16 @@ void CandleStickChart::createShapes() { if(isValidPosition(aPosMiddleFirst)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM ); + , fUnscaledY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM ); if(isValidPosition(aPosMiddleLast)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP ); + , fUnscaledY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP ); if(isValidPosition(aPosMiddleMinimum)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM ); + , fUnscaledY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM ); if(isValidPosition(aPosMiddleMaximum)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP ); + , fUnscaledY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP ); } }//next series in x slot (next y slot) }//next x slot diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index 60018dbe8621..6fbf980058e7 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -47,16 +47,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~CandleStickChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const; @@ -64,8 +55,6 @@ public: //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - virtual double getMinimumX(); - virtual double getMaximumX(); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.cxx b/chart2/source/view/charttypes/CategoryPositionHelper.cxx index d43fd0856e02..76f07168bdf2 100644 --- a/chart2/source/view/charttypes/CategoryPositionHelper.cxx +++ b/chart2/source/view/charttypes/CategoryPositionHelper.cxx @@ -57,7 +57,7 @@ CategoryPositionHelper::~CategoryPositionHelper() { } -double CategoryPositionHelper::getSlotWidth() const +double CategoryPositionHelper::getScaledSlotWidth() const { double fWidth = m_fCategoryWidth / ( m_fSeriesCount @@ -66,14 +66,14 @@ double CategoryPositionHelper::getSlotWidth() const return fWidth; } -double CategoryPositionHelper::getSlotPos( double fCategoryX, double fSeriesNumber ) const +double CategoryPositionHelper::getScaledSlotPos( double fScaledXPos, double fSeriesNumber ) const { //the returned position is in the middle of the rect //fSeriesNumber 0...n-1 - double fPos = fCategoryX - (m_fCategoryWidth/2.0) - + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getSlotWidth() - + getSlotWidth()/2.0; - + double fPos = fScaledXPos + - (m_fCategoryWidth/2.0) + + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getScaledSlotWidth() + + getScaledSlotWidth()/2.0; return fPos; } @@ -95,6 +95,11 @@ void CategoryPositionHelper::setOuterDistance( double fOuterDistance ) m_fOuterDistance = fOuterDistance; } +void CategoryPositionHelper::setCategoryWidth( double fCategoryWidth ) +{ + m_fCategoryWidth = fCategoryWidth; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.hxx b/chart2/source/view/charttypes/CategoryPositionHelper.hxx index 08cb1978faa1..c12d17d40b03 100644 --- a/chart2/source/view/charttypes/CategoryPositionHelper.hxx +++ b/chart2/source/view/charttypes/CategoryPositionHelper.hxx @@ -44,8 +44,9 @@ public: CategoryPositionHelper( const CategoryPositionHelper& rSource ); virtual ~CategoryPositionHelper(); - double getSlotWidth() const; - double getSlotPos( double fCategoryX, double fSeriesNumber ) const; + double getScaledSlotWidth() const; + virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const; + virtual void setCategoryWidth( double fCategoryWidth ); //Distance between two neighboring bars in same category, seen relative to width of the bar void setInnerDistance( double fInnerDistance ); diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index eee13848b11b..1c26f0596c78 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -159,11 +159,9 @@ PieChart::~PieChart() //----------------------------------------------------------------- -void SAL_CALL PieChart::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool /* bSwapXAndYAxis */ ) - throw (uno::RuntimeException) +void PieChart::setScales( const std::vector< ExplicitScaleData >& rScales, bool /* bSwapXAndYAxis */ ) { - DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + DBG_ASSERT(m_nDimension<=static_cast(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); m_pPosHelper->setScales( rScales, true ); } diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index e6fedb05d52e..c306e2db256f 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -49,24 +49,10 @@ public: , sal_Int32 nDimensionCount, bool bExcludingPositioning ); virtual ~PieChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 840cbbe3e1e1..6ec5e1613c45 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -52,6 +52,7 @@ #include "ResId.hxx" #include "Strings.hrc" #include "RelativePositionHelper.hxx" +#include "DateHelper.hxx" //only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory #include "BarChart.hxx" @@ -62,6 +63,7 @@ // #include +#include #include #include #include @@ -155,6 +157,8 @@ VSeriesPlotter::VSeriesPlotter( const uno::Reference& xChartTypeMode , m_xChartTypeModelProps( uno::Reference< beans::XPropertySet >::query( xChartTypeModel )) , m_aZSlots() , m_bCategoryXAxis(bCategoryXAxis) + , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , m_aNullDate(30,12,1899) , m_xColorScheme() , m_pExplicitCategoriesProvider(0) , m_bPointsWereSkipped(false) @@ -201,7 +205,17 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 return; if(m_bCategoryXAxis) - pSeries->setCategoryXAxis(); + { + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + pSeries->setXValues( m_pExplicitCategoriesProvider->getOriginalCategories() ); + else + pSeries->setCategoryXAxis(); + } + else + { + if( m_pExplicitCategoriesProvider ) + pSeries->setXValuesIfNone( m_pExplicitCategoriesProvider->getOriginalCategories() ); + } if(zSlot<0 || zSlot>=static_cast(m_aZSlots.size())) { @@ -936,13 +950,13 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries aRegressionPoly.SequenceZ[0].realloc(nRegressionPointCount); sal_Int32 nRealPointCount=0; - uno::Sequence< chart2::ExplicitScaleData > aScaleDataSeq( m_pPosHelper->getScales()); + std::vector< ExplicitScaleData > aScales( m_pPosHelper->getScales()); uno::Reference< chart2::XScaling > xScalingX; uno::Reference< chart2::XScaling > xScalingY; - if( aScaleDataSeq.getLength() >= 2 ) + if( aScales.size() >= 2 ) { - xScalingX.set( aScaleDataSeq[0].Scaling ); - xScalingY.set( aScaleDataSeq[1].Scaling ); + xScalingX.set( aScales[0].Scaling ); + xScalingY.set( aScales[1].Scaling ); } uno::Sequence< geometry::RealPoint2D > aCalculatedPoints( @@ -1126,19 +1140,71 @@ void VSeriesPlotter::setMappedProperties( PropertyMapper::setMappedProperties(xTargetProp,xSource,rMap,pOverwriteMap); } +void VSeriesPlotter::setTimeResolutionOnXAxis( long TimeResolution, const Date& rNullDate ) +{ + m_nTimeResolution = TimeResolution; + m_aNullDate = rNullDate; +} + //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - +long VSeriesPlotter::calculateTimeResolutionOnXAxis() +{ + long nRet = ::com::sun::star::chart::TimeUnit::YEAR; + if( m_pExplicitCategoriesProvider ) + { + const std::vector< DatePlusIndex >& rDateCategories = m_pExplicitCategoriesProvider->getDateCategories(); + std::vector< DatePlusIndex >::const_iterator aIt = rDateCategories.begin(), aEnd = rDateCategories.end(); + Date aNullDate(30,12,1899); + if( m_apNumberFormatterWrapper.get() ) + aNullDate = m_apNumberFormatterWrapper->getNullDate(); + if( aIt!=aEnd ) + { + Date aPrevious(aNullDate); aPrevious+=rtl::math::approxFloor(aIt->fValue); + ++aIt; + for(;aIt!=aEnd;++aIt) + { + Date aCurrent(aNullDate); aCurrent+=rtl::math::approxFloor(aIt->fValue); + if( ::com::sun::star::chart::TimeUnit::YEAR == nRet ) + { + if( DateHelper::IsInSameYear( aPrevious, aCurrent ) ) + nRet = ::com::sun::star::chart::TimeUnit::MONTH; + } + if( ::com::sun::star::chart::TimeUnit::MONTH == nRet ) + { + if( DateHelper::IsInSameMonth( aPrevious, aCurrent ) ) + nRet = ::com::sun::star::chart::TimeUnit::DAY; + } + if( ::com::sun::star::chart::TimeUnit::DAY == nRet ) + break; + aPrevious=aCurrent; + } + } + } + return nRet; +} double VSeriesPlotter::getMinimumX() { + /* if( m_bCategoryXAxis ) { - double fRet = 1.0;//first category (index 0) matches with real number 1.0 + double fRet = 1.0;//first text category (index 0) matches with real number 1.0 if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) fRet -= 0.5; + else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + { + const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); + DBG_ASSERT(!rDateCategories.empty(),"need date values"); + if(!rDateCategories.empty()) + { + DatePlusIndex aFirst = rDateCategories.front(); + fRet = aFirst.fValue; + } + } return fRet; } + */ double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); @@ -1146,14 +1212,26 @@ double VSeriesPlotter::getMinimumX() } double VSeriesPlotter::getMaximumX() { + /* if( m_bCategoryXAxis ) { - //return category count + //return category count for pure text axis double fRet = getPointCount();//first category (index 0) matches with real number 1.0 if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) fRet += 0.5; + else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + { + const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); + DBG_ASSERT(!rDateCategories.empty(),"need date values"); + if(!rDateCategories.empty()) + { + DatePlusIndex aLast = rDateCategories.back(); + fRet = aLast.fValue; + } + } return fRet; } + */ double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); @@ -1162,7 +1240,7 @@ double VSeriesPlotter::getMaximumX() double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) { - if( !m_bCategoryXAxis ) + if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) ) { double fMinY, fMaxY; this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex ); @@ -1196,7 +1274,7 @@ double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, s double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) { - if( !m_bCategoryXAxis ) + if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) ) { double fMinY, fMaxY; this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex ); @@ -1603,7 +1681,7 @@ double VSeriesPlotter::getTransformedDepth() const return FIXED_SIZE_FOR_3D_CHART_VOLUME/(MaxZ-MinZ); } -void SAL_CALL VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) +void VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) throw (uno::RuntimeException) { if( nAxisIndex<1 ) @@ -1633,9 +1711,9 @@ PlottingPositionHelper& VSeriesPlotter::getPlottingPositionHelper( sal_Int32 nAx } } if( !pRet ) - { pRet = m_pMainPosHelper; - } + if(pRet) + pRet->setTimeResolution( m_nTimeResolution, m_aNullDate ); return *pRet; } diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 4174226b6f62..1e5911b76358 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -107,7 +107,7 @@ VDiagram::~VDiagram() delete m_pShapeFactory; } -void SAL_CALL VDiagram::init( +void VDiagram::init( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xFactory ) diff --git a/chart2/source/view/inc/DateHelper.hxx b/chart2/source/view/inc/DateHelper.hxx new file mode 100644 index 000000000000..c2352e246695 --- /dev/null +++ b/chart2/source/view/inc/DateHelper.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DATEHELPER_HXX +#define _CHART2_DATEHELPER_HXX + +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class DateHelper +{ +public: + static bool IsInSameYear( const Date& rD1, const Date& rD2 ); + static bool IsInSameMonth( const Date& rD1, const Date& rD2 ); + + static long GetMonthsBetweenDates( Date aD1, Date aD2 ); + static Date GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ); + static Date GetDateSomeYearsAway( const Date& rD, long nYearDistance ); + static bool IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ); + static bool IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ); + + static double RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx index 1e53d5c144c5..dee1fec8e67d 100644 --- a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx +++ b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx @@ -29,7 +29,7 @@ #define _CHART2_MINIMUMANDMAXIMUMSUPPLIER_HXX #include - +#include #include //............................................................................. @@ -60,6 +60,10 @@ public: virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) = 0; virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) = 0; virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) = 0; + + //return a constant out of ::com::sun::star::chart::TimeUnit that allows to display the smallest distance between occuring dates + virtual long calculateTimeResolutionOnXAxis() = 0; + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ) = 0; }; class MergedMinimumAndMaximumSupplier : public MinimumAndMaximumSupplier @@ -86,6 +90,9 @@ public: virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); + virtual long calculateTimeResolutionOnXAxis(); + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ); + private: typedef ::std::set< MinimumAndMaximumSupplier* > MinimumAndMaximumSupplierSet; MinimumAndMaximumSupplierSet m_aMinimumAndMaximumSupplierList; diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx index 63e276b19e44..7920845248e4 100644 --- a/chart2/source/view/inc/PlotterBase.hxx +++ b/chart2/source/view/inc/PlotterBase.hxx @@ -27,28 +27,18 @@ #ifndef _CHART2_PLOTTERBASE_HXX #define _CHART2_PLOTTERBASE_HXX +#include "chartview/ExplicitScaleValues.hxx" + #include #include #include #include #include #include -/* -#include -*/ - -//---- -#include - -//---- chart2 -#include #include -/* -#include -*/ -//---- #include +#include //............................................................................. namespace chart @@ -64,8 +54,7 @@ public: PlotterBase( sal_Int32 nDimension ); virtual ~PlotterBase(); - // ___chart2::XPlotter___ - virtual void SAL_CALL initPlotter( + virtual void initPlotter( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -75,21 +64,13 @@ public: , const rtl::OUString& rCID ) throw (::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL createShapes() = 0; + virtual void createShapes() = 0; static bool isValidPosition( const ::com::sun::star::drawing::Position3D& rPos ); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index a1f16883b779..6bd25d8f92e3 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -28,9 +28,10 @@ #define _CHART2_PLOTTINGPOSITIONHELPER_HXX #include "LabelAlignment.hxx" +#include "chartview/ExplicitScaleValues.hxx" + #include #include -#include #include #include #include @@ -62,23 +63,22 @@ public: virtual ~PlottingPositionHelper(); virtual PlottingPositionHelper* clone() const; - virtual PlottingPositionHelper* createSecondaryPosHelper( const ::com::sun::star::chart2::ExplicitScaleData& rSecondaryScale ); + virtual PlottingPositionHelper* createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix); - virtual void setScales( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ); - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& getScales() const; + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); + const ::std::vector< ExplicitScaleData >& getScales() const; //better performance for big data inline void setCoordinateSystemResolution( const ::com::sun::star::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution ); inline bool isSameForGivenResolution( double fX, double fY, double fZ , double fX2, double fY2, double fZ2 ); + inline bool isStrongLowerXRequested() const; inline bool isLogicVisible( double fX, double fY, double fZ ) const; inline void doLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; + inline void doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; inline void clipLogicValues( double* pX, double* pY, double* pZ ) const; void clipScaledLogicValues( double* pX, double* pY, double* pZ ) const; inline bool clipYRange( double& rMin, double& rMax ) const; @@ -123,10 +123,14 @@ public: inline bool maySkipPointsInRegressionCalculation() const; + void setTimeResolution( long nTimeResolution, const Date& rNullDate ); + virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); + void MaybeShiftCategoryX( double& fScaledXValue ) const; + void DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ); + protected: //member - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData > m_aScales; - ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; + ::std::vector< ExplicitScaleData > m_aScales; + ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; //this is calculated based on m_aScales and m_aMatrixScreenToScene mutable ::com::sun::star::uno::Reference< @@ -139,6 +143,13 @@ protected: //member sal_Int32 m_nZResolution; bool m_bMaySkipPointsInRegressionCalculation; + + bool m_bDateAxis; + long m_nTimeResolution; + Date m_aNullDate; + + double m_fScaledCategoryWidth; + bool m_DoShiftCategoryXIfShiftIsIndicated; }; //describes wich axis of the drawinglayer scene or sreen axis are the normal axis @@ -163,9 +174,7 @@ public: virtual PlottingPositionHelper* clone() const; virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix); - virtual void setScales( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ); + virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); ::basegfx::B3DHomMatrix getUnitCartesianToScene() const; @@ -227,14 +236,14 @@ private: bool PolarPlottingPositionHelper::isMathematicalOrientationAngle() const { - const ::com::sun::star::chart2::ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2]; + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2]; if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) return true; return false; } bool PolarPlottingPositionHelper::isMathematicalOrientationRadius() const { - const ::com::sun::star::chart2::ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1]; + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1]; if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) return true; return false; @@ -283,15 +292,39 @@ bool PlottingPositionHelper::isSameForGivenResolution( double fX, double fY, dou return (bSameX && bSameY && bSameZ); } +bool PlottingPositionHelper::isStrongLowerXRequested() const +{ + if( !m_aScales.empty() ) + return m_DoShiftCategoryXIfShiftIsIndicated && m_aScales[0].ShiftedCategoryPosition; + return false; +} + bool PlottingPositionHelper::isLogicVisible( double fX, double fY, double fZ ) const { - return fX >= m_aScales[0].Minimum && fX <= m_aScales[0].Maximum + return fX >= m_aScales[0].Minimum && ( isStrongLowerXRequested() ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum ) && fY >= m_aScales[1].Minimum && fY <= m_aScales[1].Maximum && fZ >= m_aScales[2].Minimum && fZ <= m_aScales[2].Maximum; } void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const +{ + if(bClip) + this->clipLogicValues( pX,pY,pZ ); + + if(pX) + { + if( m_aScales[0].Scaling.is()) + *pX = m_aScales[0].Scaling->doScaling(*pX); + MaybeShiftCategoryX(*pX); + } + if(pY && m_aScales[1].Scaling.is()) + *pY = m_aScales[1].Scaling->doScaling(*pY); + if(pZ && m_aScales[2].Scaling.is()) + *pZ = m_aScales[2].Scaling->doScaling(*pZ); +} + +void PlottingPositionHelper::doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const { if(bClip) this->clipLogicValues( pX,pY,pZ ); diff --git a/chart2/source/view/inc/ScaleAutomatism.hxx b/chart2/source/view/inc/ScaleAutomatism.hxx index 4440ad26ac5a..327027efcf39 100644 --- a/chart2/source/view/inc/ScaleAutomatism.hxx +++ b/chart2/source/view/inc/ScaleAutomatism.hxx @@ -27,10 +27,11 @@ #ifndef _CHART2_SCALEAUTOMATISM_HXX #define _CHART2_SCALEAUTOMATISM_HXX -#include -#include +#include "chartview/ExplicitScaleValues.hxx" #include +#include + //............................................................................. namespace chart { @@ -44,7 +45,7 @@ class ScaleAutomatism { public: explicit ScaleAutomatism( - const ::com::sun::star::chart2::ScaleData& rSourceScale ); + const ::com::sun::star::chart2::ScaleData& rSourceScale, const Date& rNullDate ); virtual ~ScaleAutomatism(); /** Expands own value range with the passed minimum and maximum. */ @@ -75,30 +76,41 @@ public: of the axis and the font size of the axis caption text. */ void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount ); + /** Sets the time resolution to be used in case it is not set explicitly within the scale + */ + void setAutomaticTimeResolution( sal_Int32 nTimeResolution ); + /** Fills the passed scale data and increment data according to the own settings. */ void calculateExplicitScaleAndIncrement( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ) const; + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement ) const; ::com::sun::star::chart2::ScaleData getScale() const; + Date getNullDate() const; private: /** Fills the passed scale data and increment data for category scaling. */ void calculateExplicitIncrementAndScaleForCategory( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; /** Fills the passed scale data and increment data for logarithmic scaling. */ void calculateExplicitIncrementAndScaleForLogarithmic( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; /** Fills the passed scale data and increment data for linear scaling. */ void calculateExplicitIncrementAndScaleForLinear( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + + /** Fills the passed scale data and increment data for date-time axis. */ + void calculateExplicitIncrementAndScaleForDateTimeAxis( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; private: @@ -111,6 +123,9 @@ private: bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders. bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero. bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range). + sal_Int32 m_nTimeResolution;// a constant out of ::com::sun::star::chart::TimeUnit + + Date m_aNullDate; }; //............................................................................. diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx index e884af865d6e..f4fd12547118 100644 --- a/chart2/source/view/inc/VCoordinateSystem.hxx +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -31,9 +31,8 @@ #include "ScaleAutomatism.hxx" #include "ThreeDHelper.hxx" #include "ExplicitCategoriesProvider.hxx" +#include "chartview/ExplicitScaleValues.hxx" -#include -#include #include #include "comphelper/implementationreference.hxx" #include @@ -63,7 +62,7 @@ public: static VCoordinateSystem* createCoordinateSystem( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel ); - virtual void SAL_CALL initPlottingTargets( + virtual void initPlottingTargets( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -83,16 +82,16 @@ public: virtual ::com::sun::star::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const ::com::sun::star::awt::Size& rPageSize , const ::com::sun::star::awt::Size& rPageResolution ); - ::com::sun::star::chart2::ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; - ::com::sun::star::chart2::ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ ); ExplicitCategoriesProvider* getExplicitCategoriesProvider(); // returns a coplete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ::std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; // returns a coplete increment set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ::std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); @@ -101,8 +100,8 @@ public: void prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex - , const ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ); + , const ExplicitScaleData& rExplicitScale + , const ExplicitIncrementData& rExplicitIncrement ); void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); @@ -143,8 +142,6 @@ protected: //methods VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); - void prepareScaleAutomatism( ScaleAutomatism& rScaleAutomatism, double fMin, double fMax, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); - rtl::OUString createCIDForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis , sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); @@ -194,11 +191,11 @@ protected: //member tVAxisMap m_aAxisMap; private: - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > m_aExplicitScales; - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitIncrementData > m_aExplicitIncrements; + std::vector< ExplicitScaleData > m_aExplicitScales; + std::vector< ExplicitIncrementData > m_aExplicitIncrements; - typedef std::map< tFullAxisIndex, ::com::sun::star::chart2::ExplicitScaleData > tFullExplicitScaleMap; - typedef std::map< tFullAxisIndex, ::com::sun::star::chart2::ExplicitIncrementData > tFullExplicitIncrementMap; + typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap; + typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap; tFullExplicitScaleMap m_aSecondaryExplicitScales; tFullExplicitIncrementMap m_aSecondaryExplicitIncrements; diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx index 93aba58dbec4..62d61cb17269 100644 --- a/chart2/source/view/inc/VDataSeries.hxx +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -81,6 +81,10 @@ public: getModel() const; void setCategoryXAxis(); + void setXValues( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence >& xValues ); + void setXValuesIfNone( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence >& xValues ); void setParticle( const rtl::OUString& rSeriesParticle ); void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); void setPageReferenceSize( const ::com::sun::star::awt::Size & rPageRefSize ); diff --git a/chart2/source/view/inc/VDiagram.hxx b/chart2/source/view/inc/VDiagram.hxx index 5df198c2f539..6bcef92111ef 100644 --- a/chart2/source/view/inc/VDiagram.hxx +++ b/chart2/source/view/inc/VDiagram.hxx @@ -56,7 +56,7 @@ public: //methods , sal_Int32 nDimension=3, sal_Bool bPolar=sal_False ); virtual ~VDiagram(); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xFinalTarget diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 6b6b06437542..a786c607c73c 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -174,8 +174,7 @@ public: ) */ - virtual void SAL_CALL addSecondaryValueScale( const - ::com::sun::star::chart2::ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) + virtual void addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) throw (::com::sun::star::uno::RuntimeException); //------------------------------------------------------------------------- @@ -197,6 +196,9 @@ public: virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); + virtual long calculateTimeResolutionOnXAxis(); + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ); + //------ void getMinimumAndMaximiumX( double& rfMinimum, double& rfMaximum ) const; @@ -425,6 +427,8 @@ protected: //member ::std::vector< ::std::vector< VDataSeriesGroup > > m_aZSlots; bool m_bCategoryXAxis;//true->xvalues are indices (this would not be necessary if series for category chart wouldn't have x-values) + long m_nTimeResolution; + Date m_aNullDate; ::std::auto_ptr< NumberFormatterWrapper > m_apNumberFormatterWrapper; AxesNumberFormats m_aAxesNumberFormats;//direct numberformats on axes, if empty ask the data series instead @@ -439,7 +443,7 @@ protected: //member bool m_bPointsWereSkipped; private: //member - typedef std::map< sal_Int32 , ::com::sun::star::chart2::ExplicitScaleData > tSecondaryValueScales; + typedef std::map< sal_Int32 , ExplicitScaleData > tSecondaryValueScales; tSecondaryValueScales m_aSecondaryValueScales; typedef std::map< sal_Int32 , PlottingPositionHelper* > tSecondaryPosHelperMap; diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index d8f997d36da9..525f0a8de951 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -65,52 +65,17 @@ 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_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); + //legend ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); -// ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; + + //text + ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); - ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); - - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Y_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_X_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Z_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_X); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); + //statistic ppPoolDefaults[SCHATTR_STAT_AVERAGE - SCHATTR_START] = new SfxBoolItem (SCHATTR_STAT_AVERAGE); ppPoolDefaults[SCHATTR_STAT_KIND_ERROR - SCHATTR_START] = new SvxChartKindErrorItem (CHERROR_NONE, SCHATTR_STAT_KIND_ERROR); ppPoolDefaults[SCHATTR_STAT_PERCENT - SCHATTR_START] = new SvxDoubleItem (0.0, SCHATTR_STAT_PERCENT); @@ -121,9 +86,6 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_STAT_RANGE_POS - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_POS, String()); ppPoolDefaults[SCHATTR_STAT_RANGE_NEG - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String()); - ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); - ppPoolDefaults[SCHATTR_TEXT_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_OVERLAP,FALSE); - ppPoolDefaults[SCHATTR_STYLE_DEEP - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0); ppPoolDefaults[SCHATTR_STYLE_3D - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0); ppPoolDefaults[SCHATTR_STYLE_VERTICAL - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_VERTICAL, 0); @@ -137,37 +99,43 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_AXIS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS,2); //2 = Y-Achse!!! + //axis scale + ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_REALNUMBER); + ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); ppPoolDefaults[SCHATTR_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MIN); ppPoolDefaults[SCHATTR_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MIN); ppPoolDefaults[SCHATTR_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MAX); ppPoolDefaults[SCHATTR_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MAX); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN); ppPoolDefaults[SCHATTR_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_STEP_MAIN); + ppPoolDefaults[SCHATTR_AXIS_MAIN_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,2); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP); -// ppPoolDefaults[SCHATTR_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_STEP_HELP); - // type changed from double to sal_Int32 ppPoolDefaults[SCHATTR_AXIS_STEP_HELP - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_STEP_HELP,0); + ppPoolDefaults[SCHATTR_AXIS_HELP_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,2); + ppPoolDefaults[SCHATTR_AXIS_AUTO_TIME_RESOLUTION - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION); + ppPoolDefaults[SCHATTR_AXIS_TIME_RESOLUTION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,2); ppPoolDefaults[SCHATTR_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LOGARITHM); + ppPoolDefaults[SCHATTR_AXIS_AUTO_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS); + ppPoolDefaults[SCHATTR_AXIS_ALLOW_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_ALLOW_DATEAXIS); ppPoolDefaults[SCHATTR_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN); ppPoolDefaults[SCHATTR_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_ORIGIN); + //axis position ppPoolDefaults[SCHATTR_AXIS_TICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TICKS,CHAXIS_MARK_OUTER); - ppPoolDefaults[SCHATTR_AXIS_NUMFMT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMT,0); - ppPoolDefaults[SCHATTR_AXIS_NUMFMTPERCENT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMTPERCENT,11); - ppPoolDefaults[SCHATTR_AXIS_SHOWAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWAXIS,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWMAINGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWMAINGRID,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWHELPGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWHELPGRID,0); - ppPoolDefaults[SCHATTR_AXIS_TOPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_TOPDOWN,0); ppPoolDefaults[SCHATTR_AXIS_HELPTICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELPTICKS,0); - ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); - ppPoolDefaults[SCHATTR_AXIS_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_POSITION_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_POSITION_VALUE); ppPoolDefaults[SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT,0); ppPoolDefaults[SCHATTR_AXIS_LABEL_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_LABEL_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_MARK_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MARK_POSITION,0); + //axis label + ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); + ppPoolDefaults[SCHATTR_AXIS_LABEL_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_AXIS_LABEL_ORDER); + ppPoolDefaults[SCHATTR_AXIS_LABEL_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_OVERLAP,FALSE); + ppPoolDefaults[SCHATTR_AXIS_LABEL_BREAK - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_BREAK, FALSE ); + + //-- ppPoolDefaults[SCHATTR_SYMBOL_BRUSH - SCHATTR_START] = new SvxBrushItem(SCHATTR_SYMBOL_BRUSH); ppPoolDefaults[SCHATTR_STOCK_VOLUME - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_VOLUME,0); ppPoolDefaults[SCHATTR_STOCK_UPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_UPDOWN,0); @@ -181,16 +149,16 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_SPLINE_ORDER - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_ORDER, 3 ); ppPoolDefaults[SCHATTR_SPLINE_RESOLUTION - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, 20 ); ppPoolDefaults[SCHATTR_DIAGRAM_STYLE - SCHATTR_START] = new SvxChartStyleItem( CHSTYLE_2D_COLUMN, SCHATTR_DIAGRAM_STYLE ); - ppPoolDefaults[SCHATTR_TEXTBREAK - SCHATTR_START] = new SfxBoolItem( SCHATTR_TEXTBREAK, FALSE ); ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, FALSE); - ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); ppPoolDefaults[SCHATTR_STARTING_ANGLE - SCHATTR_START] = new SfxInt32Item( SCHATTR_STARTING_ANGLE, 90 ); ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, FALSE ); ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0); ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp); + ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); ppPoolDefaults[SCHATTR_AXIS_FOR_ALL_SERIES - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_FOR_ALL_SERIES, 0); + ppPoolDefaults[SCHATTR_REGRESSION_TYPE - SCHATTR_START] = new SvxChartRegressItem (CHREGRESS_NONE, SCHATTR_REGRESSION_TYPE); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_EQUATION - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_EQUATION, 0); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_COEFF - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_COEFF, 0); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 2347824664c5..3098005d6bfa 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -31,6 +31,7 @@ #include "ChartView.hxx" #include "chartview/DrawModelWrapper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" @@ -56,6 +57,7 @@ #include "ControllerLockGuard.hxx" #include "BaseGFXHelper.hxx" #include "DataSeriesHelper.hxx" +#include "DateHelper.hxx" #include #include @@ -78,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -474,7 +475,7 @@ private: }; AxisUsage::AxisUsage() - : aScaleAutomatism(AxisHelper::createDefaultScale()) + : aScaleAutomatism(AxisHelper::createDefaultScale(),Date()) { } @@ -565,7 +566,7 @@ public: ~SeriesPlotterContainer(); void initializeCooSysAndSeriesPlotter( const uno::Reference< frame::XModel >& xChartModel ); - void initAxisUsageList(); + void initAxisUsageList(const Date& rNullDate); void doAutoScaling( const uno::Reference< frame::XModel >& xChartModel ); void updateScalesAndIncrementsOnAxes(); void setScalesFromCooSysToPlotter(); @@ -583,13 +584,13 @@ private: std::vector< VCoordinateSystem* >& m_rVCooSysList; ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList; sal_Int32 m_nMaxAxisIndex; - bool m_bChartTypeUsesShiftedXAxisTicksPerDefault; + bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) - , m_bChartTypeUsesShiftedXAxisTicksPerDefault(false) + , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) { } @@ -684,7 +685,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( uno::Reference< XChartType > xChartType( aChartTypeList[nT] ); if(nT==0) - m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType ); + m_bChartTypeUsesShiftedCategoryPositionPerDefault = ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType ); bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ); VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning ); @@ -795,7 +796,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } } -void SeriesPlotterContainer::initAxisUsageList() +void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) { m_aAxisUsageList.clear(); size_t nC; @@ -805,8 +806,10 @@ void SeriesPlotterContainer::initAxisUsageList() for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++) { uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel(); - if( nDimensionIndex >= xCooSys->getDimension() ) + sal_Int32 nDimensionCount = xCooSys->getDimension(); + if( nDimensionIndex >= nDimensionCount ) continue; + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionCount, nDimensionIndex ); const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex) { @@ -815,7 +818,20 @@ void SeriesPlotterContainer::initAxisUsageList() if( xAxis.is()) { if(m_aAxisUsageList.find(xAxis)==m_aAxisUsageList.end()) - m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(xAxis->getScaleData()); + { + chart2::ScaleData aSourceScale = xAxis->getScaleData(); + ExplicitCategoriesProvider* pExplicitCategoriesProvider = pVCooSys->getExplicitCategoriesProvider(); + if( nDimensionIndex==0 ) + AxisHelper::checkDateAxis( aSourceScale, pExplicitCategoriesProvider, bChartTypeAllowsDateAxis ); + if( (aSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault) + || (aSourceScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) + || aSourceScale.AxisType == AxisType::DATE + || aSourceScale.AxisType == AxisType::SERIES ) + aSourceScale.ShiftedCategoryPosition = true; + else + aSourceScale.ShiftedCategoryPosition = false; + m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale,rNullDate); + } AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis]; rAxisUsage.addCoordinateSystem(pVCooSys,nDimensionIndex,nAxisIndex); } @@ -938,13 +954,7 @@ void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement ); for( nC=0; nC < aVCooSysList_X.size(); nC++) - { - ExplicitCategoriesProvider* pExplicitCategoriesProvider = aVCooSysList_X[nC]->getExplicitCategoriesProvider(); - - if( m_bChartTypeUsesShiftedXAxisTicksPerDefault || (aExplicitScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) ) - aExplicitIncrement.ShiftedPosition = true; aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement ); - } for( nC=0; nC < aVCooSysList_Z.size(); nC++) aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement ); } @@ -1029,7 +1039,6 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation; aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling; - aExplicitScaleDest.Breaks = aExplicitScaleSource.Breaks; aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType; aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue; @@ -1067,7 +1076,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ); if( bAutoMinorInterval ) { - if( aExplicitIncrementDest.SubIncrements.getLength() && aExplicitIncrementSource.SubIncrements.getLength() ) + if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() ) aExplicitIncrementDest.SubIncrements[0].IntervalCount = aExplicitIncrementSource.SubIncrements[0].IntervalCount; } @@ -1382,7 +1391,8 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& // - prepare list of all axis and how they are used - rSeriesPlotterContainer.initAxisUsageList(); + Date aNullDate = NumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >( m_xChartModel, uno::UNO_QUERY ) ).getNullDate(); + rSeriesPlotterContainer.initAxisUsageList(aNullDate); rSeriesPlotterContainer.doAutoScaling( m_xChartModel ); rSeriesPlotterContainer.setScalesFromCooSysToPlotter(); rSeriesPlotterContainer.setNumberFormatsFromAxes(); @@ -1665,6 +1675,29 @@ sal_Bool ChartView::getExplicitValuesForAxis( { rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex); rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex); + if( rExplicitScale.ShiftedCategoryPosition ) + { + //remove 'one' from max + if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + Date aMaxDate(rExplicitScale.NullDate); aMaxDate += static_cast(::rtl::math::approxFloor(rExplicitScale.Maximum)); + //for explicit scales with shifted categories we need one interval more + switch( rExplicitScale.TimeResolution ) + { + case ::com::sun::star::chart::TimeUnit::DAY: + aMaxDate--;break; + case ::com::sun::star::chart::TimeUnit::MONTH: + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + break; + case ::com::sun::star::chart::TimeUnit::YEAR: + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + break; + } + rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate; + } + else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::CATEGORY ) + rExplicitScale.Maximum -= 1.0; + } return sal_True; } return sal_False; @@ -1793,6 +1826,24 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } +sal_Int32 lcl_getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + nRet = aKeySeq[0]; + } + } + return nRet; +} + sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem @@ -1803,23 +1854,35 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) { - bool bPercentFormatSet = false; + bool bFormatSet = false; //check wether we have a percent scale -> use percent format if( xNumberFormatsSupplier.is() ) { - ScaleData aData = xAxis->getScaleData(); + ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); if( aData.AxisType==AxisType::PERCENT ) { sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); if( nPercentFormat != -1 ) { nNumberFormatKey = nPercentFormat; - bPercentFormatSet = true; + bFormatSet = true; + } + } + else if( aData.AxisType==AxisType::DATE ) + { + if( aData.Categories.is() ) + { + Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); + if( xSeq.is() ) + nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); + else + nNumberFormatKey = lcl_getDateNumberFormat( xNumberFormatsSupplier ); + bFormatSet = true; } } } - if( !bPercentFormatSet ) + if( !bFormatSet ) { typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; tNumberformatFrequency aKeyMap; @@ -1857,22 +1920,20 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( continue; } - Sequence< Reference< data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences()); - for( sal_Int32 nLSeqIdx=0; nLSeqIdx xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); + + if( !xLabeledSeq.is() && nDimensionIndex==0 ) { - if(!aLabeledSeq[nLSeqIdx].is()) - continue; - Reference< data::XDataSequence > xSeq( aLabeledSeq[nLSeqIdx]->getValues()); - if(!xSeq.is()) - continue; - Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); - ::rtl::OUString aRole; - bool bTakeIntoAccount = - ( xSeqProp.is() && (aRoleToMatch.getLength() > 0) && - (xSeqProp->getPropertyValue(C2U("Role")) >>= aRole ) && - aRole.equals( aRoleToMatch )); - - if( bTakeIntoAccount ) + ScaleData aData = xAxis->getScaleData(); + if( aData.AxisType==AxisType::REALNUMBER ) + xLabeledSeq = aData.Categories; + } + + if( xLabeledSeq.is() ) + { + Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); + if( xSeq.is() ) { sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); // initialize the value @@ -1954,7 +2015,6 @@ sal_Int32 ExplicitValueProvider::getPercentNumberFormat( const Reference< util:: return nRet; } - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const uno::Reference< XDataSeries >& xSeries, diff --git a/chart2/source/view/main/ChartView.hxx b/chart2/source/view/main/ChartView.hxx index 476adae03674..76c1ce5c4858 100644 --- a/chart2/source/view/main/ChartView.hxx +++ b/chart2/source/view/main/ChartView.hxx @@ -103,8 +103,8 @@ public: // ___ExplicitValueProvider___ virtual sal_Bool getExplicitValuesForAxis( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis - , ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ); + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getShapeForCID( const rtl::OUString& rObjectCID ); diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx index 4e4cd342506c..de7dde79e789 100644 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ b/chart2/source/view/main/NumberFormatterWrapper.cxx @@ -100,6 +100,25 @@ SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const return m_pNumberFormatter; } +Date NumberFormatterWrapper::getNullDate() const +{ + USHORT nYear = 1899,nDay = 30,nMonth = 12; + Date aRet(nDay,nMonth,nYear); + + util::DateTime aUtilDate; + if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) ) + { + aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year); + } + else if( m_pNumberFormatter ) + { + Date* pDate = m_pNumberFormatter->GetNullDate(); + if( pDate ) + aRet = *pDate; + } + return aRet; +} + rtl::OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const { diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index 08f43dc7064d..8a71f45b4dbb 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -56,8 +56,7 @@ PlotterBase::PlotterBase( sal_Int32 nDimensionCount ) { } - void SAL_CALL PlotterBase -::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget +void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory , const rtl::OUString& rCID ) @@ -77,11 +76,9 @@ PlotterBase::~PlotterBase() delete m_pShapeFactory; } -void SAL_CALL PlotterBase::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (uno::RuntimeException) +void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { - DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + DBG_ASSERT(m_nDimension<=static_cast(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); m_pPosHelper->setScales( rScales, bSwapXAndYAxis ); } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index deb390b70a79..5d9105605f62 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -32,12 +32,14 @@ #include "ViewDefines.hxx" #include "Linear3DTransformation.hxx" #include "VPolarTransformation.hxx" - #include "ShapeFactory.hxx" #include "PropertyMapper.hxx" +#include "DateHelper.hxx" + +#include +#include #include #include -#include #include @@ -57,6 +59,11 @@ PlottingPositionHelper::PlottingPositionHelper() , m_nYResolution( 1000 ) , m_nZResolution( 1000 ) , m_bMaySkipPointsInRegressionCalculation( true ) + , m_bDateAxis(false) + , m_nTimeResolution( ::com::sun::star::chart::TimeUnit::DAY ) + , m_aNullDate(30,12,1899) + , m_fScaledCategoryWidth(1.0) + , m_DoShiftCategoryXIfShiftIsIndicated(false) { } PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rSource ) @@ -68,6 +75,11 @@ PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rS , m_nYResolution( rSource.m_nYResolution ) , m_nZResolution( rSource.m_nZResolution ) , m_bMaySkipPointsInRegressionCalculation( rSource.m_bMaySkipPointsInRegressionCalculation ) + , m_nTimeResolution( rSource.m_nTimeResolution ) + , m_aNullDate( rSource.m_aNullDate ) + , m_bDateAxis( rSource.m_bDateAxis ) + , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth ) + , m_DoShiftCategoryXIfShiftIsIndicated( rSource.m_DoShiftCategoryXIfShiftIsIndicated ) { } @@ -95,13 +107,13 @@ void PlottingPositionHelper::setTransformationSceneToScreen( const drawing::Homo m_xTransformationLogicToScene = NULL; } -void PlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { m_aScales = rScales; m_bSwapXAndY = bSwapXAndYAxis; m_xTransformationLogicToScene = NULL; } -const uno::Sequence< ExplicitScaleData >& PlottingPositionHelper::getScales() const +const std::vector< ExplicitScaleData >& PlottingPositionHelper::getScales() const { return m_aScales; } @@ -129,8 +141,8 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale AxisOrientation nZAxisOrientation = m_aScales[2].Orientation; //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(m_bSwapXAndY) { @@ -176,9 +188,9 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale drawing::Position3D PlottingPositionHelper::transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const { - if(bClip) - this->clipLogicValues( &fX,&fY,&fZ ); this->doLogicScaling( &fX,&fY,&fZ ); + if(bClip) + this->clipScaledLogicValues( &fX,&fY,&fZ ); return this->transformScaledLogicToScene( fX, fY, fZ, false ); } @@ -255,8 +267,8 @@ void PlottingPositionHelper::clipScaledLogicValues( double* pX, double* pY, doub double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(pX) { @@ -292,8 +304,8 @@ basegfx::B2DRectangle PlottingPositionHelper::getScaledLogicClipDoubleRect() con double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); basegfx::B2DRectangle aRet( MinX, MaxY, MaxX, MinY ); return aRet; @@ -356,7 +368,7 @@ void PolarPlottingPositionHelper::setTransformationSceneToScreen( const drawing: PlottingPositionHelper::setTransformationSceneToScreen( rMatrix); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); } -void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PolarPlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { PlottingPositionHelper::setScales( rScales, bSwapXAndYAxis ); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); @@ -366,7 +378,7 @@ void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleD { ::basegfx::B3DHomMatrix aRet; - if( !m_aScales.getLength() ) + if( m_aScales.empty() ) return aRet; double fTranslate =1.0; @@ -641,6 +653,46 @@ double PlottingPositionHelper::getBaseValueY() const return m_aScales[1].Origin; } +void PlottingPositionHelper::setTimeResolution( long nTimeResolution, const Date& rNullDate ) +{ + m_nTimeResolution = nTimeResolution; + m_aNullDate = rNullDate; + + //adapt category width + double fCategoryWidth = 1.0; + if( !m_aScales.empty() ) + { + if( m_aScales[0].AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + m_bDateAxis = true; + if( nTimeResolution == ::com::sun::star::chart::TimeUnit::YEAR ) + { + const double fMonthCount = 12.0;//todo: this depends on the DateScaling and must be adjusted in case we use more generic calendars in future + fCategoryWidth = fMonthCount; + } + } + } + setScaledCategoryWidth(fCategoryWidth); +} + +void PlottingPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth ) +{ + m_fScaledCategoryWidth = fScaledCategoryWidth; +} +void PlottingPositionHelper::MaybeShiftCategoryX( double& fScaledXValue ) const +{ + if( m_DoShiftCategoryXIfShiftIsIndicated && !m_aScales.empty() ) + { + if(m_aScales[0].ShiftedCategoryPosition) + fScaledXValue += m_fScaledCategoryWidth/2.0; + } +} + +void PlottingPositionHelper::DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ) +{ + m_DoShiftCategoryXIfShiftIsIndicated = bAllowShift; +} + /* // ____ XTransformation ____ uno::Sequence< double > SAL_CALL PolarPlottingPositionHelper::transform( diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 8bb6a11b4baf..2b9512d4af2a 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -352,6 +352,22 @@ void VDataSeries::setCategoryXAxis() m_bAllowPercentValueInDataLabel = true; } +void VDataSeries::setXValues( const Reference< chart2::data::XDataSequence >& xValues ) +{ + m_aValues_X.clear(); + m_aValues_X.init( xValues ); + m_bAllowPercentValueInDataLabel = true; +} + +void VDataSeries::setXValuesIfNone( const Reference< chart2::data::XDataSequence >& xValues ) +{ + if( m_aValues_X.is() ) + return; + + m_aValues_X.init( xValues ); + lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xValues ); +} + void VDataSeries::setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ) { m_nGlobalSeriesIndex = nGlobalSeriesIndex; diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 7101a984ee24..e247060fe8d4 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -632,7 +632,7 @@ VLegend::VLegend( // ---------------------------------------- -void SAL_CALL VLegend::init( +void VLegend::init( const Reference< drawing::XShapes >& xTargetPage, const Reference< lang::XMultiServiceFactory >& xFactory, const Reference< frame::XModel >& xModel ) diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx index 9587b50f71e7..4534a350f4f4 100644 --- a/chart2/source/view/main/VLegend.hxx +++ b/chart2/source/view/main/VLegend.hxx @@ -56,7 +56,7 @@ public: ::com::sun::star::uno::XComponentContext > & xContext, const std::vector< LegendEntryProvider* >& rLegendEntryProviderList ); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index f62142735b7c..c2aa01163b17 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -65,7 +65,7 @@ VTitle::~VTitle() { } -void SAL_CALL VTitle::init( +void VTitle::init( const uno::Reference< drawing::XShapes >& xTargetPage , const uno::Reference< lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ) diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx index 8a6e7d6e4f16..e097ecd3bbcc 100644 --- a/chart2/source/view/main/VTitle.hxx +++ b/chart2/source/view/main/VTitle.hxx @@ -47,7 +47,7 @@ public: ::com::sun::star::chart2::XTitle > & xTitle ); virtual ~VTitle(); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ); -- cgit From a2f4c6ebfbe3380ae5460c8eab43e3162e352ad7 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 30 Nov 2010 16:24:52 +0100 Subject: chart46: #i25706# implement date axis - remove compiler warnings --- chart2/source/controller/dialogs/DataBrowser.cxx | 1 - chart2/source/view/axes/Tickmarks.cxx | 4 ++-- chart2/source/view/axes/VCartesianAxis.cxx | 6 +++--- chart2/source/view/main/PlottingPositionHelper.cxx | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 38eae1f962d1..8a6c9262b038 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -528,7 +528,6 @@ bool DataBrowser::MayToggleDateCategories() const { return ! IsReadOnly() && DiagramHelper::mayToggleDateCategories( m_xChartDoc ); - return true; } bool DataBrowser::MayInsertRow() const diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx index c5e198acea3f..834fe66eb97b 100644 --- a/chart2/source/view/axes/Tickmarks.cxx +++ b/chart2/source/view/axes/Tickmarks.cxx @@ -45,9 +45,9 @@ using namespace ::rtl::math; using ::basegfx::B2DVector; TickInfo::TickInfo( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XScaling >& xInverseScaling ) + ::com::sun::star::chart2::XScaling >& xInverse ) : fScaledTickValue( 0.0 ) -, xInverseScaling( xInverseScaling ) +, xInverseScaling( xInverse ) , aTickScreenPosition(0.0,0.0) , bPaintIt( true ) , xTextShape( NULL ) diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 869e1292ed7a..cae88c563304 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -202,9 +202,9 @@ private: //methods LabelIterator(); private: //member + PureTickIter m_aPureTickIter; const AxisLabelStaggering m_eAxisLabelStaggering; bool m_bInnerLine; - PureTickIter m_aPureTickIter; }; LabelIterator::LabelIterator( ::std::vector< TickInfo >& rTickInfoVector @@ -360,7 +360,7 @@ MaxLabelTickIter::~MaxLabelTickIter() TickInfo* MaxLabelTickIter::firstInfo() { m_nCurrentIndex = 0; - if( m_nCurrentIndex < m_rTickInfoVector.size() ) + if( m_nCurrentIndex < static_cast(m_rTickInfoVector.size()) ) return &m_rTickInfoVector[m_nCurrentIndex]; return 0; } @@ -387,7 +387,7 @@ TickInfo* MaxLabelTickIter::nextInfo() else m_nCurrentIndex=nMaxIndex+1; - if( m_nCurrentIndex>=0 && m_nCurrentIndex=0 && m_nCurrentIndex(m_rTickInfoVector.size()) ) return &m_rTickInfoVector[m_nCurrentIndex]; return 0; } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 5d9105605f62..db195266a0e5 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -75,9 +75,9 @@ PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rS , m_nYResolution( rSource.m_nYResolution ) , m_nZResolution( rSource.m_nZResolution ) , m_bMaySkipPointsInRegressionCalculation( rSource.m_bMaySkipPointsInRegressionCalculation ) + , m_bDateAxis( rSource.m_bDateAxis ) , m_nTimeResolution( rSource.m_nTimeResolution ) , m_aNullDate( rSource.m_aNullDate ) - , m_bDateAxis( rSource.m_bDateAxis ) , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth ) , m_DoShiftCategoryXIfShiftIsIndicated( rSource.m_DoShiftCategoryXIfShiftIsIndicated ) { -- cgit From 17b91858438b06b0029b07f3c5fb7ba162fb0879 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 30 Nov 2010 19:17:18 +0100 Subject: chart46: #i25706# implement date axis - some docu issues --- chart2/source/controller/dialogs/tp_Scale.cxx | 6 ++++++ chart2/source/controller/dialogs/tp_Scale.src | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 7544faf88bd6..c2099c4ae460 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -460,6 +460,12 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) nPos=TYPE_TEXT; m_aLB_AxisType.SelectEntryPos( nPos ); } + + if( m_bAllowDateAxis ) + aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:MayBeDateAxis"); + else if( m_nAxisType==chart2::AxisType::CATEGORY || m_nAxisType==chart2::AxisType::SERIES ) + aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:Category"); + PlaceIntervalControlsAccordingToAxisType(); aCbxAutoMin.Check( true ); diff --git a/chart2/source/controller/dialogs/tp_Scale.src b/chart2/source/controller/dialogs/tp_Scale.src index f5a9221af20d..0b0e7efcdb9c 100755 --- a/chart2/source/controller/dialogs/tp_Scale.src +++ b/chart2/source/controller/dialogs/tp_Scale.src @@ -70,7 +70,7 @@ TabPage TP_SCALE //--------------------------- CheckBox CBX_REVERSE { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; + HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE:ValueAxis"; Pos = MAP_APPFONT ( X2 , Y1 ) ; Size = MAP_APPFONT ( 244 , 10 ) ; TabStop = TRUE ; -- cgit From 039076d86f2fe956bfe9a13fb774a7ac71c73248 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 1 Dec 2010 11:09:57 +0100 Subject: chart46: #i25706# implement date axis - corrected automatic scaling --- chart2/source/view/axes/ScaleAutomatism.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 441592c400eb..6942871df704 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -651,6 +651,8 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( if( !bAutoMajor ) { long nIntervalDayCount = rExplicitIncrement.MajorTimeInterval.Number; + if( rExplicitIncrement.MajorTimeInterval.TimeUnit < rExplicitScale.TimeResolution ) + rExplicitIncrement.MajorTimeInterval.TimeUnit = rExplicitScale.TimeResolution; switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) { case DAY: @@ -671,12 +673,12 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( long nNumer = 1; long nIntervalDays = nDayCount / nMaxMainIncrementCount; double nDaysPerInterval = 1.0; - if( nIntervalDays>365 ) + if( nIntervalDays>365 || YEAR==rExplicitScale.TimeResolution ) { rExplicitIncrement.MajorTimeInterval.TimeUnit = YEAR; nDaysPerInterval = 365.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... } - else if( nIntervalDays>31 ) + else if( nIntervalDays>31 || MONTH==rExplicitScale.TimeResolution ) { rExplicitIncrement.MajorTimeInterval.TimeUnit = MONTH; nDaysPerInterval = 31.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... @@ -697,6 +699,8 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( //choose minor time interval: if( !bAutoMinor ) { + if( rExplicitIncrement.MinorTimeInterval.TimeUnit > rExplicitIncrement.MajorTimeInterval.TimeUnit ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; long nIntervalDayCount = rExplicitIncrement.MinorTimeInterval.Number; switch( rExplicitIncrement.MinorTimeInterval.TimeUnit ) { @@ -738,10 +742,12 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( case DAY: break; case MONTH: - rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; + if( rExplicitScale.TimeResolution == DAY ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; break; case YEAR: - rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; + if( rExplicitScale.TimeResolution <= MONTH ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; break; } } -- cgit From 4f958ff57dc8654ae10f6ee5da1e7a37a526d6ee Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 1 Dec 2010 13:46:27 +0100 Subject: chart46: #i25706# implement date axis - switching to net chart --- chart2/source/controller/dialogs/tp_Scale.cxx | 2 ++ chart2/source/model/template/ChartTypeTemplate.cxx | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index c2099c4ae460..7314764db49c 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -445,6 +445,8 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) m_nAxisType=chart2::AxisType::REALNUMBER; if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); + if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis ) + m_nAxisType=chart2::AxisType::CATEGORY; if( m_bAllowDateAxis ) { bool bAutoDateAxis = false; diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 498be4e2daf9..82aa3e12075e 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -643,17 +643,21 @@ void ChartTypeTemplate::adaptScales( sal_Int32 nDim( xCooSys->getDimension()); if( nDim > 0 ) { - const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(0); + const sal_Int32 nDimensionX = 0; + const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionX); for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI) { - Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,nI) ); + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(nDimensionX,nI) ); if( xAxis.is()) { ScaleData aData( xAxis->getScaleData() ); aData.Categories = xCategories; if(bSupportsCategories) { - if( aData.AxisType != AxisType::CATEGORY && aData.AxisType != AxisType::DATE ) + + Reference< XChartType > xChartType( getChartTypeForNewSeries(Sequence< Reference< XChartType > >() )); + bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, 2, nDimensionX ); + if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) ) { aData.AxisType = AxisType::CATEGORY; aData.AutoDateAxis = true; -- cgit From 8dec2fc01a0a8b0ec4b92854d0f1d8834759e21e Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Thu, 2 Dec 2010 13:29:10 +0100 Subject: chart46: #i25706# implement date axis - correct helpid --- chart2/source/controller/dialogs/dlg_DataEditor.cxx | 6 +++--- chart2/source/controller/dialogs/dlg_DataEditor.hrc | 2 +- chart2/source/controller/dialogs/dlg_DataEditor.src | 6 +++--- chart2/source/controller/inc/HelpIds.hrc | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index ff365ae460a3..3f073136ef67 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -160,7 +160,7 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) case TBI_DATA_SWAP_ROW : m_apBrwData->SwapRow (); break; - case TBI_DATA_TOGGLE_DATE_CATEGOGRIES: + case TBI_DATA_TOGGLE_DATE_CATEGORIES: m_apBrwData->ToggleDateCategories (); break; } @@ -185,7 +185,7 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); return 0; } @@ -203,7 +203,7 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, FALSE ); } m_apBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc index b4f1cbe1b3a7..794beb40abd3 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -41,7 +41,7 @@ #define TBI_DATA_SWAP_COL 5 #define TBI_DATA_SWAP_ROW 6 #define TBI_DATA_INSERT_TEXT_COL 7 -#define TBI_DATA_TOGGLE_DATE_CATEGOGRIES 8 +#define TBI_DATA_TOGGLE_DATE_CATEGORIES 8 // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src index 64919d64b0b2..a83666553155 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.src +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -118,8 +118,8 @@ ModalDialog DLG_DIAGRAM_DATA }; ToolBoxItem { - HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; - Identifier = TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; + HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES ; + Identifier = TBI_DATA_TOGGLE_DATE_CATEGORIES ; Text [ en-US ] = "Categories: Date/Text" ; }; }; @@ -135,7 +135,7 @@ ModalDialog DLG_DIAGRAM_DATA TBI_DATA_DELETE_COL; \ TBI_DATA_SWAP_COL; \ TBI_DATA_SWAP_ROW; \ - TBI_DATA_TOGGLE_DATE_CATEGOGRIES; \ + TBI_DATA_TOGGLE_DATE_CATEGORIES; \ }; \ IdCount = { 8; } diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index aa9ef0332b76..7d14eebabd78 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -52,7 +52,7 @@ #define HID_SCH_TBI_DATA_SWAP_COL "CHART2_HID_SCH_TBI_DATA_SWAP_COL" #define HID_SCH_TBI_DATA_SWAP_ROW "CHART2_HID_SCH_TBI_DATA_SWAP_ROW" #define HID_SCH_TBI_DATA_INSERT_TEXT_COL "CHART2_HID_SCH_TBI_DATA_INSERT_TEXT_COL" -#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES" +#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES" #define HID_SCH_TBX_DATA "CHART2_HID_SCH_TBX_DATA" #define HID_SCH_ALIGNMENT_CTR_DIAL "CHART2_HID_SCH_ALIGNMENT_CTR_DIAL" -- cgit From 87e71d01405ac56173d8af7748b0619361c5f04a Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 3 Dec 2010 19:44:45 +0100 Subject: chart46: #i25706# implement date axis - correct axis layout --- chart2/source/view/axes/VCartesianAxis.cxx | 56 ++++++++++-------------------- 1 file changed, 19 insertions(+), 37 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index cae88c563304..23d1d7985b90 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -330,28 +330,29 @@ public: private: ::std::vector< TickInfo >& m_rTickInfoVector; - sal_Int32 m_nLongestLabelIndex; + ::std::vector< sal_Int32 > m_aValidIndices; sal_Int32 m_nCurrentIndex; }; MaxLabelTickIter::MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector , sal_Int32 nLongestLabelIndex ) : m_rTickInfoVector(rTickInfoVector) - , m_nLongestLabelIndex( nLongestLabelIndex ) , m_nCurrentIndex(0) { sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; - - //ensure correct value: - if( m_nLongestLabelIndex<0 || m_nLongestLabelIndex>nMaxIndex) - m_nLongestLabelIndex = 0; - - //last label is checked anyhow - if( m_nLongestLabelIndex==nMaxIndex ) - m_nLongestLabelIndex = 0; - //label before last is checked anyhow - if( m_nLongestLabelIndex+1==nMaxIndex ) - m_nLongestLabelIndex = 0; + if( nLongestLabelIndex<0 || nLongestLabelIndex>=nMaxIndex-1 ) + nLongestLabelIndex = 0; + + if( nMaxIndex>=0 ) + m_aValidIndices.push_back(0); + if( nMaxIndex>=1 ) + m_aValidIndices.push_back(1); + if( nLongestLabelIndex>1 ) + m_aValidIndices.push_back(nLongestLabelIndex); + if( nMaxIndex > 2 ) + m_aValidIndices.push_back(nMaxIndex-1); + if( nMaxIndex > 1 ) + m_aValidIndices.push_back(nMaxIndex); } MaxLabelTickIter::~MaxLabelTickIter() { @@ -360,35 +361,16 @@ MaxLabelTickIter::~MaxLabelTickIter() TickInfo* MaxLabelTickIter::firstInfo() { m_nCurrentIndex = 0; - if( m_nCurrentIndex < static_cast(m_rTickInfoVector.size()) ) - return &m_rTickInfoVector[m_nCurrentIndex]; + if( m_nCurrentIndex < static_cast(m_aValidIndices.size()) ) + return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; return 0; } TickInfo* MaxLabelTickIter::nextInfo() { - sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; - if( m_nLongestLabelIndex >= nMaxIndex-1 ) - m_nLongestLabelIndex = 0; - - if( m_nCurrentIndex==0 ) - m_nCurrentIndex++; - else if( m_nCurrentIndex==1 && m_nCurrentIndex=3 ) - m_nCurrentIndex=nMaxIndex-1; - else if( nMaxIndex>=2 ) - m_nCurrentIndex=nMaxIndex; - } - else if( m_nCurrentIndex==nMaxIndex-1 ) - m_nCurrentIndex=nMaxIndex; - else - m_nCurrentIndex=nMaxIndex+1; - - if( m_nCurrentIndex>=0 && m_nCurrentIndex(m_rTickInfoVector.size()) ) - return &m_rTickInfoVector[m_nCurrentIndex]; + m_nCurrentIndex++; + if( m_nCurrentIndex>=0 && m_nCurrentIndex(m_aValidIndices.size()) ) + return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; return 0; } -- cgit From bd36338009672fdabd5b6d585f8c1092b617196a Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 3 Dec 2010 23:01:44 +0100 Subject: chart46: #i25706# implement date axis - simplify axis access in chart api --- .../controller/chartapiwrapper/AxisWrapper.cxx | 94 ++++++++ .../controller/chartapiwrapper/AxisWrapper.hxx | 17 +- .../controller/chartapiwrapper/DiagramWrapper.cxx | 236 +++++++++++---------- .../controller/chartapiwrapper/DiagramWrapper.hxx | 86 +++----- .../controller/chartapiwrapper/GridWrapper.cxx | 13 +- .../controller/chartapiwrapper/GridWrapper.hxx | 13 +- .../chartapiwrapper/WrappedScaleProperty.cxx | 28 ++- .../chartapiwrapper/WrappedScaleProperty.hxx | 1 + 8 files changed, 296 insertions(+), 192 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index fe24a0bf4eb0..7bdc5459ca20 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -29,10 +29,15 @@ #include "precompiled_chart2.hxx" #include "AxisWrapper.hxx" #include "AxisHelper.hxx" +#include "TitleHelper.hxx" #include "Chart2ModelContact.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" #include "WrappedDirectStateProperty.hxx" +#include "GridWrapper.hxx" +#include "TitleWrapper.hxx" +#include "DisposeHelper.hxx" + #include #include #include @@ -84,6 +89,7 @@ enum PROP_AXIS_AUTO_STEPHELP, PROP_AXIS_TYPE, PROP_AXIS_TIME_INCREMENT, + PROP_AXIS_EXPLICIT_TIME_INCREMENT, PROP_AXIS_LOGARITHMIC, PROP_AXIS_REVERSEDIRECTION, PROP_AXIS_VISIBLE, @@ -189,6 +195,13 @@ void lcl_AddPropertiesToVector( //#i111967# no PropertyChangeEvent is fired on change so far beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "ExplicitTimeIncrement" ), + PROP_AXIS_EXPLICIT_TIME_INCREMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)), + beans::PropertyAttribute::READONLY | + beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( Property( C2U( "Logarithmic" ), PROP_AXIS_LOGARITHMIC, @@ -388,6 +401,83 @@ AxisWrapper::~AxisWrapper() { } +// ____ chart::XAxis ____ +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException) +{ + if( !m_xAxisTitle.is() ) + { + TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE ); + switch( m_eType ) + { + case X_AXIS: + eTitleType = TitleHelper::X_AXIS_TITLE; + break; + case Y_AXIS: + eTitleType = TitleHelper::Y_AXIS_TITLE; + break; + case Z_AXIS: + eTitleType = TitleHelper::Z_AXIS_TITLE; + break; + case SECOND_X_AXIS: + eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; + break; + case SECOND_Y_AXIS: + eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; + break; + default: + return 0; + } + m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact ); + } + return m_xAxisTitle; +} +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException) +{ + if( !m_xMajorGrid.is() ) + { + GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); + switch( m_eType ) + { + case X_AXIS: + eGridType = GridWrapper::X_MAJOR_GRID; + break; + case Y_AXIS: + eGridType = GridWrapper::Y_MAJOR_GRID; + break; + case Z_AXIS: + eGridType = GridWrapper::Z_MAJOR_GRID; + break; + default: + return 0; + } + m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); + } + return m_xMajorGrid; +} +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException) +{ + if( !m_xMinorGrid.is() ) + { + GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); + switch( m_eType ) + { + case X_AXIS: + eGridType = GridWrapper::X_MINOR_GRID; + break; + case Y_AXIS: + eGridType = GridWrapper::Y_MINOR_GRID; + break; + case Z_AXIS: + eGridType = GridWrapper::Z_MINOR_GRID; + break; + default: + return 0; + } + m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); + } + return m_xMinorGrid; +} + // ____ XShape ____ awt::Point SAL_CALL AxisWrapper::getPosition() throw (uno::RuntimeException) @@ -469,6 +559,10 @@ void SAL_CALL AxisWrapper::dispose() Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + DisposeHelper::DisposeAndClear( m_xAxisTitle ); + DisposeHelper::DisposeAndClear( m_xMajorGrid ); + DisposeHelper::DisposeAndClear( m_xMinorGrid ); + clearWrappedPropertySet(); } diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx index 86bd52367bbe..f7a7d514e1f4 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx @@ -30,9 +30,10 @@ #include "WrappedPropertySet.hxx" #include "ReferenceSizePropertyProvider.hxx" #include "ServiceMacros.hxx" -#include +#include #include #include +#include #include #include #include @@ -45,14 +46,13 @@ namespace chart { - namespace wrapper { - class Chart2ModelContact; -class AxisWrapper : public ::cppu::ImplInheritanceHelper4< +class AxisWrapper : public ::cppu::ImplInheritanceHelper5< WrappedPropertySet + , com::sun::star::chart::XAxis , com::sun::star::drawing::XShape , com::sun::star::lang::XComponent , com::sun::star::lang::XServiceInfo @@ -93,6 +93,11 @@ public: ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + // ____ chart::XAxis ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getAxisTitle( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMajorGrid( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMinorGrid( ) throw (::com::sun::star::uno::RuntimeException); + // ____ XShape ____ virtual ::com::sun::star::awt::Point SAL_CALL getPosition() throw (::com::sun::star::uno::RuntimeException); @@ -131,6 +136,10 @@ private: //member tAxisType m_eType; ::com::sun::star::uno::Any m_aTemporaryHelpStepValue; + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAxisTitle; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xMajorGrid; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xMinorGrid; }; } // namespace wrapper diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index c0be0ddcbf0d..16992ac02b51 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -30,14 +30,11 @@ #include "DiagramWrapper.hxx" #include "macros.hxx" #include "servicenames_charttypes.hxx" -#include "TitleWrapper.hxx" #include "DataSeriesPointWrapper.hxx" #include "AxisWrapper.hxx" #include "AxisHelper.hxx" #include "Chart2ModelContact.hxx" #include "PositionAndSizeHelper.hxx" -#include "TitleHelper.hxx" -#include "GridWrapper.hxx" #include "WallFloorWrapper.hxx" #include "MinMaxLineWrapper.hxx" #include "UpDownBarWrapper.hxx" @@ -88,6 +85,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; +using ::com::sun::star::chart::XAxis; using ::osl::MutexGuard; using ::rtl::OUString; @@ -883,193 +881,209 @@ void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( cons return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); } -// ____ XAxisZSupplier ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() +// ____ XAxisSupplier ____ +Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) throw (uno::RuntimeException) { - if( !m_xZAxisTitle.is() ) + Reference< XAxis > xAxis; + if(!nDimensionIndex) + { + if( !m_xXAxis.is() ) + m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); + xAxis = m_xXAxis; + } + else if(1==nDimensionIndex) + { + if( !m_xYAxis.is() ) + m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); + xAxis = m_xYAxis; + } + else if(2==nDimensionIndex) { - m_xZAxisTitle = new TitleWrapper( TitleHelper::Z_AXIS_TITLE, m_spChart2ModelContact ); + if( !m_xZAxis.is() ) + m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); + xAxis = m_xZAxis; } - return m_xZAxisTitle; + return xAxis; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() +Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex ) throw (uno::RuntimeException) { - if( ! m_xZMainGrid.is()) + Reference< XAxis > xAxis; + if(!nDimensionIndex) { - m_xZMainGrid = new GridWrapper( GridWrapper::Z_MAIN_GRID, m_spChart2ModelContact ); + if( !m_xSecondXAxis.is() ) + m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); + xAxis = m_xSecondXAxis; } - return m_xZMainGrid; + else if(1==nDimensionIndex) + { + if( !m_xSecondYAxis.is() ) + m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); + xAxis = m_xSecondYAxis; + } + return xAxis; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() +// ____ XAxisZSupplier ____ +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() throw (uno::RuntimeException) { - if( !m_xZHelpGrid.is() ) - { - m_xZHelpGrid = new GridWrapper( GridWrapper::Z_SUB_GRID, m_spChart2ModelContact ); - } - return m_xZHelpGrid; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; +} + +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; +} + +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() throw (uno::RuntimeException) { if( ! m_xZAxis.is()) - { m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); - } - return m_xZAxis; + return Reference< beans::XPropertySet >( m_xZAxis, uno::UNO_QUERY ); } // ____ XTwoAxisXSupplier ____ -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() throw (uno::RuntimeException) { if( ! m_xSecondXAxis.is()) - { m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); - } - return m_xSecondXAxis; + return Reference< beans::XPropertySet >( m_xSecondXAxis, uno::UNO_QUERY ); } // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() throw (uno::RuntimeException) { - - if( !m_xXAxisTitle.is() ) - { - m_xXAxisTitle = new TitleWrapper( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xXAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() throw (uno::RuntimeException) { if( ! m_xXAxis.is()) - { m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); - } - - return m_xXAxis; + return Reference< beans::XPropertySet >( m_xXAxis, uno::UNO_QUERY ); } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() throw (uno::RuntimeException) { - if( ! m_xXMainGrid.is()) - { - m_xXMainGrid = new GridWrapper( GridWrapper::X_MAIN_GRID, m_spChart2ModelContact ); - } - - return m_xXMainGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() throw (uno::RuntimeException) { - if( ! m_xXHelpGrid.is()) - { - m_xXHelpGrid = new GridWrapper( GridWrapper::X_SUB_GRID, m_spChart2ModelContact ); - } - return m_xXHelpGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; } // ____ XTwoAxisYSupplier ____ -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() throw (uno::RuntimeException) { if( ! m_xSecondYAxis.is()) - { m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); - } - return m_xSecondYAxis; + return Reference< beans::XPropertySet >( m_xSecondYAxis, uno::UNO_QUERY ); } // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() throw (uno::RuntimeException) { - if( !m_xYAxisTitle.is() ) - { - m_xYAxisTitle = new TitleWrapper( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xYAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() throw (uno::RuntimeException) { if( ! m_xYAxis.is()) - { m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); - } - return m_xYAxis; + return Reference< beans::XPropertySet >( m_xYAxis, uno::UNO_QUERY ); } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() throw (uno::RuntimeException) { - if( ! m_xYHelpGrid.is()) - { - m_xYHelpGrid = new GridWrapper( GridWrapper::Y_SUB_GRID, m_spChart2ModelContact ); - } - return m_xYHelpGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() throw (uno::RuntimeException) { - if( ! m_xYMainGrid.is()) - { - m_xYMainGrid = new GridWrapper( GridWrapper::Y_MAIN_GRID, m_spChart2ModelContact ); - } - return m_xYMainGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; } // ____ XSecondAxisTitleSupplier ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() throw (uno::RuntimeException) { - if( !m_xSecondXAxisTitle.is() ) - { - m_xSecondXAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_X_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xSecondXAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getSecondaryAxis(0) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() throw (uno::RuntimeException) { - if( !m_xSecondYAxisTitle.is() ) - { - m_xSecondYAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_Y_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xSecondYAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getSecondaryAxis(1) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } // ____ XStatisticDisplay ____ @@ -1162,22 +1176,11 @@ void SAL_CALL DiagramWrapper::dispose() // /-- MutexGuard aGuard( GetMutex()); - DisposeHelper::DisposeAndClear( m_xXAxisTitle ); - DisposeHelper::DisposeAndClear( m_xYAxisTitle ); - DisposeHelper::DisposeAndClear( m_xZAxisTitle ); - DisposeHelper::DisposeAndClear( m_xSecondXAxisTitle ); - DisposeHelper::DisposeAndClear( m_xSecondYAxisTitle ); DisposeHelper::DisposeAndClear( m_xXAxis ); DisposeHelper::DisposeAndClear( m_xYAxis ); DisposeHelper::DisposeAndClear( m_xZAxis ); DisposeHelper::DisposeAndClear( m_xSecondXAxis ); DisposeHelper::DisposeAndClear( m_xSecondYAxis ); - DisposeHelper::DisposeAndClear( m_xXMainGrid ); - DisposeHelper::DisposeAndClear( m_xYMainGrid ); - DisposeHelper::DisposeAndClear( m_xZMainGrid ); - DisposeHelper::DisposeAndClear( m_xXHelpGrid ); - DisposeHelper::DisposeAndClear( m_xYHelpGrid ); - DisposeHelper::DisposeAndClear( m_xZHelpGrid ); DisposeHelper::DisposeAndClear( m_xWall ); DisposeHelper::DisposeAndClear( m_xFloor ); DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper ); @@ -2146,3 +2149,4 @@ APPHELPER_XSERVICEINFO_IMPL( DiagramWrapper, lcl_aServiceName ); } // namespace wrapper } // namespace chart + diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index 111e24bd6a8b..678041420cf3 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -30,7 +30,13 @@ #include "WrappedPropertySet.hxx" #include "ServiceMacros.hxx" #include "DiagramHelper.hxx" -#include + +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13 +#include "comphelper/implbase_var.hxx" +#endif + #include #include #include @@ -41,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -56,15 +63,15 @@ namespace chart { - namespace wrapper { class Chart2ModelContact; -class DiagramWrapper : public ::cppu::ImplInheritanceHelper12< +class DiagramWrapper : public ::comphelper::ImplInheritanceHelper13< WrappedPropertySet , ::com::sun::star::chart::XDiagram + , ::com::sun::star::chart::XAxisSupplier , ::com::sun::star::chart::XAxisZSupplier , ::com::sun::star::chart::XTwoAxisXSupplier // : XAxisXSupplier , ::com::sun::star::chart::XTwoAxisYSupplier // : XAxisYSupplier @@ -123,6 +130,14 @@ public: virtual ::rtl::OUString SAL_CALL getShapeType() throw (::com::sun::star::uno::RuntimeException); + // ____ XAxisSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XAxis > SAL_CALL getAxis( sal_Int32 nDimensionIndex ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XAxis > SAL_CALL getSecondaryAxis( sal_Int32 nDimensionIndex ) + throw (::com::sun::star::uno::RuntimeException); + // ____ XAxisZSupplier ____ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SAL_CALL getZAxisTitle() @@ -244,72 +259,27 @@ private: ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xXAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xYAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xZAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xSecondXAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xSecondYAxisTitle; - - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xSecondXAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xSecondYAxis; - - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXMainGrid; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYMainGrid; + ::com::sun::star::chart::XAxis > m_xXAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZMainGrid; + ::com::sun::star::chart::XAxis > m_xYAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXHelpGrid; + ::com::sun::star::chart::XAxis > m_xZAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYHelpGrid; + ::com::sun::star::chart::XAxis > m_xSecondXAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZHelpGrid; + ::com::sun::star::chart::XAxis > m_xSecondYAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xWall; + ::com::sun::star::beans::XPropertySet > m_xWall; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xFloor; + ::com::sun::star::beans::XPropertySet > m_xFloor; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xMinMaxLineWrapper; + ::com::sun::star::beans::XPropertySet > m_xMinMaxLineWrapper; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xUpBarWrapper; + ::com::sun::star::beans::XPropertySet > m_xUpBarWrapper; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xDownBarWrapper; + ::com::sun::star::beans::XPropertySet > m_xDownBarWrapper; }; } // namespace wrapper diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index ff36c4cebcc7..9d50a76557f8 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -112,17 +112,17 @@ void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDime switch( eType ) { - case X_MAIN_GRID: + case X_MAJOR_GRID: rnDimensionIndex = 0; rbSubGrid = false; break; - case Y_MAIN_GRID: + case Y_MAJOR_GRID: rnDimensionIndex = 1; rbSubGrid = false; break; - case Z_MAIN_GRID: + case Z_MAJOR_GRID: rnDimensionIndex = 2; rbSubGrid = false; break; - case X_SUB_GRID: + case X_MINOR_GRID: rnDimensionIndex = 0; rbSubGrid = true; break; - case Y_SUB_GRID: + case Y_MINOR_GRID: rnDimensionIndex = 1; rbSubGrid = true; break; - case Z_SUB_GRID: + case Z_MINOR_GRID: rnDimensionIndex = 2; rbSubGrid = true; break; } } @@ -209,3 +209,4 @@ APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName ); } // namespace wrapper } // namespace chart + diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx index c731b6c22666..653c46353676 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx @@ -42,7 +42,6 @@ namespace chart { - namespace wrapper { @@ -57,12 +56,12 @@ class GridWrapper : public ::cppu::ImplInheritanceHelper2< public: enum tGridType { - X_MAIN_GRID, - Y_MAIN_GRID, - Z_MAIN_GRID, - X_SUB_GRID, - Y_SUB_GRID, - Z_SUB_GRID + X_MAJOR_GRID, + Y_MAJOR_GRID, + Z_MAJOR_GRID, + X_MINOR_GRID, + Y_MINOR_GRID, + Z_MINOR_GRID }; GridWrapper( tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index 037a5795baa5..61abab9e7209 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -97,6 +97,9 @@ WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty case SCALE_PROP_DATE_INCREMENT: m_aOuterName = C2U("TimeIncrement"); break; + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + m_aOuterName = C2U("ExplicitTimeIncrement"); + break; case SCALE_PROP_LOGARITHMIC: m_aOuterName = C2U("Logarithmic"); break; @@ -130,6 +133,7 @@ void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* > rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); } @@ -308,6 +312,9 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons bSetScaleData = true; break; } + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + //read only property + break; case SCALE_PROP_LOGARITHMIC: { if( rOuterValue >>= bBool ) @@ -550,6 +557,25 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const aRet = uno::makeAny( aScaleData.TimeIncrement ); break; } + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + { + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); + if( aExplicitScale.AxisType == AxisType::DATE ) + { + TimeIncrement aTimeIncrement; + aTimeIncrement.MajorTimeInterval = uno::makeAny( aExplicitIncrement.MajorTimeInterval ); + aTimeIncrement.MinorTimeInterval = uno::makeAny( aExplicitIncrement.MinorTimeInterval ); + aTimeIncrement.TimeResolution = uno::makeAny( aExplicitScale.TimeResolution ); + aRet = uno::makeAny(aTimeIncrement); + } + } + + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + aRet = uno::makeAny( aScaleData.TimeIncrement ); + break; + } case SCALE_PROP_LOGARITHMIC: { aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) ); @@ -571,5 +597,5 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const } } // namespace wrapper -} //namespace chart +} // namespace chart //............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 1543d7b645fb..8df55339a46e 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -57,6 +57,7 @@ public: , SCALE_PROP_AUTO_STEPHELP , SCALE_PROP_AXIS_TYPE , SCALE_PROP_DATE_INCREMENT + , SCALE_PROP_EXPLICIT_DATE_INCREMENT , SCALE_PROP_LOGARITHMIC , SCALE_PROP_REVERSEDIRECTION }; -- cgit From 23a41b480633914a7a0db19f5b23e61dd28dfca0 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 7 Dec 2010 17:18:10 +0100 Subject: chart46: #i25706# implement date axis - corrected z-axis layout --- chart2/source/view/axes/ScaleAutomatism.cxx | 6 +-- chart2/source/view/axes/VCoordinateSystem.cxx | 4 +- chart2/source/view/axes/VPolarAngleAxis.cxx | 4 +- chart2/source/view/axes/VPolarGrid.cxx | 4 +- chart2/source/view/charttypes/AreaChart.cxx | 7 +++- chart2/source/view/charttypes/BarChart.cxx | 6 +-- .../source/view/charttypes/BarPositionHelper.cxx | 4 +- chart2/source/view/charttypes/BubbleChart.cxx | 4 +- chart2/source/view/charttypes/PieChart.cxx | 6 +-- chart2/source/view/charttypes/VSeriesPlotter.cxx | 49 ++-------------------- chart2/source/view/inc/PlottingPositionHelper.hxx | 35 ++++++++++------ chart2/source/view/main/ChartView.cxx | 2 + chart2/source/view/main/PlottingPositionHelper.cxx | 19 ++++----- 13 files changed, 61 insertions(+), 89 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 6942871df704..075ad16347c2 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -260,6 +260,9 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( // no scaling for categories rExplicitScale.Scaling.clear(); + if( rExplicitScale.ShiftedCategoryPosition ) + rExplicitScale.Maximum += 1.0; + // ensure that at least one category is visible if( rExplicitScale.Maximum <= rExplicitScale.Minimum ) rExplicitScale.Maximum = rExplicitScale.Minimum + 1.0; @@ -275,9 +278,6 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) rExplicitScale.Maximum = EquidistantTickFactory::getMaximumAtIncrement( rExplicitScale.Maximum, rExplicitIncrement ); - if( rExplicitScale.ShiftedCategoryPosition ) - rExplicitScale.Maximum += 1.0; - //prevent performace killover double fDistanceCount = ::rtl::math::approxFloor( (rExplicitScale.Maximum-rExplicitScale.Minimum) / rExplicitIncrement.Distance ); if( static_cast< sal_Int32 >( fDistanceCount ) > MAXIMUM_MANUAL_INCREMENT_COUNT ) diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index f184fbe0a1e3..a99ab4368d60 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -98,8 +98,8 @@ VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCoo { if( !m_xCooSysModel.is() || m_xCooSysModel->getDimension()<3 ) { - m_aExplicitScales[2].Minimum = -0.5; - m_aExplicitScales[2].Maximum = 0.5; + m_aExplicitScales[2].Minimum = 1.0; + m_aExplicitScales[2].Maximum = 2.0; m_aExplicitScales[2].Orientation = AxisOrientation_MATHEMATICAL; } } diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index dcb7cd5a6303..0a10ee25e1c4 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -178,7 +178,7 @@ void VPolarAngleAxis::createLabels() return; double fLogicRadius = m_pPosHelper->getOuterLogicRadius(); - double fLogicZ = -0.5;//as defined + double fLogicZ = 1.0;//as defined if( m_aAxisProperties.m_bDisplayLabels ) { @@ -213,7 +213,7 @@ void VPolarAngleAxis::createShapes() return; double fLogicRadius = m_pPosHelper->getOuterLogicRadius(); - double fLogicZ = -0.5;//as defined + double fLogicZ = 1.0;//as defined //----------------------------------------- //create axis main lines diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index 953b729bd453..c3554fd4876b 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -131,7 +131,7 @@ void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicT double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius(); double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius(); - double fLogicZ = -0.5;//as defined + double fLogicZ = 1.0;//as defined sal_Int32 nLinePropertiesCount = rLinePropertiesList.size(); ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAngleTickInfos.begin(); @@ -223,7 +223,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling ); double fLogicRadius = rTickInfo.getUnscaledTickValue(); - double fLogicZ = -0.5;//as defined + double fLogicZ = 1.0;//as defined drawing::PointSequenceSequence aPoints(1); VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 59cde85a13fe..06e09d60fcf1 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -98,7 +98,10 @@ AreaChart::AreaChart( const uno::Reference& xChartTypeModel if( !m_pMainPosHelper ) m_pMainPosHelper = new PlottingPositionHelper(); if( m_pMainPosHelper ) - m_pMainPosHelper->DoShiftCategoryXIfShiftIsIndicated(true); + { + m_pMainPosHelper->AllowShiftXAxisPos(true); + m_pMainPosHelper->AllowShiftZAxisPos(true); + } PlotterBase::m_pPosHelper = m_pMainPosHelper; VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; @@ -613,7 +616,7 @@ void AreaChart::createShapes() //check necessary here that different Y axis can not be stacked in the same group? ... hm? //update/create information for current group - double fLogicZ = 0.5;//as defined + double fLogicZ = 1.0;//as defined sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 6d94cea682dc..9e4484727a2d 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -450,7 +450,7 @@ void BarChart::createShapes() m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() )); //check necessary here that different Y axis can not be stacked in the same group? ... hm? - double fLogicZ = 0.0;//as defined + double fLogicZ = 1.0;//as defined bool bDrawConnectionLines = false; bool bDrawConnectionLinesInited = false; @@ -614,7 +614,7 @@ void BarChart::createShapes() continue;//point not visible if(fUnscaledLogicX>pPosHelper->getLogicMaxX()) continue;//point not visible - if(pPosHelper->isStrongLowerXRequested() && fUnscaledLogicX==pPosHelper->getLogicMaxX()) + if(pPosHelper->isStrongLowerRequested(0) && fUnscaledLogicX==pPosHelper->getLogicMaxX()) continue;//point not visible double fLogicX = pPosHelper->getScaledSlotPos( fUnscaledLogicX, fSlotX ); @@ -643,7 +643,7 @@ void BarChart::createShapes() fNegativeLogicYForNextSeries += fLogicBarHeight; if(m_nDimension==3) - fLogicZ = nZ; + fLogicZ = nZ+0.5; drawing::Position3D aUnscaledLogicPosition( fUnscaledLogicX, fUpperYValue, fLogicZ ); diff --git a/chart2/source/view/charttypes/BarPositionHelper.cxx b/chart2/source/view/charttypes/BarPositionHelper.cxx index bd013b08207d..45dab527da11 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.cxx +++ b/chart2/source/view/charttypes/BarPositionHelper.cxx @@ -45,7 +45,8 @@ using namespace ::com::sun::star::chart2; BarPositionHelper::BarPositionHelper( bool /* bSwapXAndY */ ) : CategoryPositionHelper( 1 ) { - DoShiftCategoryXIfShiftIsIndicated(true); + AllowShiftXAxisPos(true); + AllowShiftZAxisPos(true); } BarPositionHelper::BarPositionHelper( const BarPositionHelper& rSource ) @@ -76,7 +77,6 @@ double BarPositionHelper::getScaledSlotPos( double fUnscaledLogicX, double fSeri double fScaledLogicX(fUnscaledLogicX); doLogicScaling(&fScaledLogicX,NULL,NULL); fScaledLogicX = CategoryPositionHelper::getScaledSlotPos( fScaledLogicX, fSeriesNumber ); - //MaybeShiftCategoryX( fScaledLogicX ); return fScaledLogicX; } diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index c5454edcc6fd..0cbcff33bfcd 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -121,7 +121,7 @@ void BubbleChart::calculateMaximumLogicBubbleSize() void BubbleChart::calculateBubbleSizeScalingFactor() { - double fLogicZ=0.5; + double fLogicZ=1.0; drawing::Position3D aSceneMinPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMinX(),m_pMainPosHelper->getLogicMinY(),fLogicZ, false ) ); drawing::Position3D aSceneMaxPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMaxX(),m_pMainPosHelper->getLogicMaxY(),fLogicZ, false ) ); @@ -223,7 +223,7 @@ void BubbleChart::createShapes() m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() )); //update/create information for current group - double fLogicZ = 0.5;//as defined + double fLogicZ = 1.0;//as defined sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 1c26f0596c78..abb30c2a67a9 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -409,7 +409,7 @@ void PieChart::createShapes() if( !bIsVisible ) continue; - double fLogicZ = -0.5;//as defined + double fLogicZ = -1.0;//as defined double fDepth = this->getTransformedDepth(); //============================================================================= @@ -493,11 +493,11 @@ void PieChart::createShapes() awt::Point aScreenPosition2D( aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement , fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree - , fUnitCircleInnerRadius, fUnitCircleOuterRadius, 0.0, 0 )); + , fUnitCircleInnerRadius, fUnitCircleOuterRadius, fLogicZ+0.5, 0 )); PieLabelInfo aPieLabelInfo; aPieLabelInfo.aFirstPosition = basegfx::B2IVector( aScreenPosition2D.X, aScreenPosition2D.Y ); - awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, 0.5 ) ) ); + awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, fLogicZ+1.0 ) ) ); aPieLabelInfo.aOrigin = basegfx::B2IVector( aOrigin.X, aOrigin.Y ); //add a scaling independent Offset if requested diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 6ec5e1613c45..f03138d869b7 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1186,53 +1186,12 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis() } double VSeriesPlotter::getMinimumX() { - /* - if( m_bCategoryXAxis ) - { - double fRet = 1.0;//first text category (index 0) matches with real number 1.0 - if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) - fRet -= 0.5; - else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) - { - const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); - DBG_ASSERT(!rDateCategories.empty(),"need date values"); - if(!rDateCategories.empty()) - { - DatePlusIndex aFirst = rDateCategories.front(); - fRet = aFirst.fValue; - } - } - return fRet; - } - */ - double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); return fMinimum; } double VSeriesPlotter::getMaximumX() { - /* - if( m_bCategoryXAxis ) - { - //return category count for pure text axis - double fRet = getPointCount();//first category (index 0) matches with real number 1.0 - if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) - fRet += 0.5; - else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) - { - const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); - DBG_ASSERT(!rDateCategories.empty(),"need date values"); - if(!rDateCategories.empty()) - { - DatePlusIndex aLast = rDateCategories.back(); - fRet = aLast.fValue; - } - } - return fRet; - } - */ - double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); return fMaximum; @@ -1309,13 +1268,13 @@ double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, s double VSeriesPlotter::getMinimumZ() { //this is the default for all charts without a meaningfull z axis - return 0.5; + return 1.0; } double VSeriesPlotter::getMaximumZ() { - if( 3!=m_nDimension ) - return 0.5; - return m_aZSlots.size()+0.5; + if( 3!=m_nDimension || !m_aZSlots.size() ) + return getMinimumZ()+1; + return m_aZSlots.size(); } namespace diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index 6bd25d8f92e3..42c7a90a0116 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -75,7 +75,7 @@ public: inline bool isSameForGivenResolution( double fX, double fY, double fZ , double fX2, double fY2, double fZ2 ); - inline bool isStrongLowerXRequested() const; + inline bool isStrongLowerRequested( sal_Int32 nDimensionIndex ) const; inline bool isLogicVisible( double fX, double fY, double fZ ) const; inline void doLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; inline void doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; @@ -125,8 +125,8 @@ public: void setTimeResolution( long nTimeResolution, const Date& rNullDate ); virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); - void MaybeShiftCategoryX( double& fScaledXValue ) const; - void DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ); + void AllowShiftXAxisPos( bool bAllowShift ); + void AllowShiftZAxisPos( bool bAllowShift ); protected: //member ::std::vector< ExplicitScaleData > m_aScales; @@ -149,7 +149,8 @@ protected: //member Date m_aNullDate; double m_fScaledCategoryWidth; - bool m_DoShiftCategoryXIfShiftIsIndicated; + bool m_bAllowShiftXAxisPos; + bool m_bAllowShiftZAxisPos; }; //describes wich axis of the drawinglayer scene or sreen axis are the normal axis @@ -292,19 +293,23 @@ bool PlottingPositionHelper::isSameForGivenResolution( double fX, double fY, dou return (bSameX && bSameY && bSameZ); } -bool PlottingPositionHelper::isStrongLowerXRequested() const +bool PlottingPositionHelper::isStrongLowerRequested( sal_Int32 nDimensionIndex ) const { - if( !m_aScales.empty() ) - return m_DoShiftCategoryXIfShiftIsIndicated && m_aScales[0].ShiftedCategoryPosition; + if( m_aScales.empty() ) + return false; + if( 0==nDimensionIndex ) + return m_bAllowShiftXAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition; + else if( 2==nDimensionIndex ) + return m_bAllowShiftZAxisPos && m_aScales[nDimensionIndex].ShiftedCategoryPosition; return false; } bool PlottingPositionHelper::isLogicVisible( double fX, double fY, double fZ ) const { - return fX >= m_aScales[0].Minimum && ( isStrongLowerXRequested() ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum ) + return fX >= m_aScales[0].Minimum && ( isStrongLowerRequested(0) ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum ) && fY >= m_aScales[1].Minimum && fY <= m_aScales[1].Maximum - && fZ >= m_aScales[2].Minimum && fZ <= m_aScales[2].Maximum; + && fZ >= m_aScales[2].Minimum && ( isStrongLowerRequested(2) ? fZ < m_aScales[2].Maximum : fZ <= m_aScales[2].Maximum ); } void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const @@ -316,12 +321,18 @@ void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ, { if( m_aScales[0].Scaling.is()) *pX = m_aScales[0].Scaling->doScaling(*pX); - MaybeShiftCategoryX(*pX); + if( m_bAllowShiftXAxisPos && m_aScales[0].ShiftedCategoryPosition ) + (*pX) += m_fScaledCategoryWidth/2.0; } if(pY && m_aScales[1].Scaling.is()) *pY = m_aScales[1].Scaling->doScaling(*pY); - if(pZ && m_aScales[2].Scaling.is()) - *pZ = m_aScales[2].Scaling->doScaling(*pZ); + if(pZ) + { + if( m_aScales[2].Scaling.is()) + *pZ = m_aScales[2].Scaling->doScaling(*pZ); + if( m_bAllowShiftZAxisPos && m_aScales[2].ShiftedCategoryPosition) + (*pZ) += 0.5; + } } void PlottingPositionHelper::doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 3098005d6bfa..cff3ab3d1c14 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1697,6 +1697,8 @@ sal_Bool ChartView::getExplicitValuesForAxis( } else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::CATEGORY ) rExplicitScale.Maximum -= 1.0; + else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::SERIES ) + rExplicitScale.Maximum -= 1.0; } return sal_True; } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index db195266a0e5..3f77115d9cf4 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -63,7 +63,8 @@ PlottingPositionHelper::PlottingPositionHelper() , m_nTimeResolution( ::com::sun::star::chart::TimeUnit::DAY ) , m_aNullDate(30,12,1899) , m_fScaledCategoryWidth(1.0) - , m_DoShiftCategoryXIfShiftIsIndicated(false) + , m_bAllowShiftXAxisPos(false) + , m_bAllowShiftZAxisPos(false) { } PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rSource ) @@ -79,7 +80,8 @@ PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rS , m_nTimeResolution( rSource.m_nTimeResolution ) , m_aNullDate( rSource.m_aNullDate ) , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth ) - , m_DoShiftCategoryXIfShiftIsIndicated( rSource.m_DoShiftCategoryXIfShiftIsIndicated ) + , m_bAllowShiftXAxisPos( rSource.m_bAllowShiftXAxisPos ) + , m_bAllowShiftZAxisPos( rSource.m_bAllowShiftZAxisPos ) { } @@ -679,18 +681,13 @@ void PlottingPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth { m_fScaledCategoryWidth = fScaledCategoryWidth; } -void PlottingPositionHelper::MaybeShiftCategoryX( double& fScaledXValue ) const +void PlottingPositionHelper::AllowShiftXAxisPos( bool bAllowShift ) { - if( m_DoShiftCategoryXIfShiftIsIndicated && !m_aScales.empty() ) - { - if(m_aScales[0].ShiftedCategoryPosition) - fScaledXValue += m_fScaledCategoryWidth/2.0; - } + m_bAllowShiftXAxisPos = bAllowShift; } - -void PlottingPositionHelper::DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ) +void PlottingPositionHelper::AllowShiftZAxisPos( bool bAllowShift ) { - m_DoShiftCategoryXIfShiftIsIndicated = bAllowShift; + m_bAllowShiftZAxisPos = bAllowShift; } /* -- cgit From c80ab47dfbc42e360d30f0018ab207d475a5095c Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 7 Dec 2010 19:32:19 +0100 Subject: chart46: #i25706# implement date axis - corrected error bars --- chart2/source/view/charttypes/BarChart.cxx | 2 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 41 ++++++++++++++++++++---- chart2/source/view/inc/VSeriesPlotter.hxx | 4 ++- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 9e4484727a2d..dbf01165bf79 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -846,7 +846,7 @@ void BarChart::createShapes() } //create error bar - createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nPointIndex, m_xLogicTarget ); + createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nPointIndex, m_xLogicTarget, &fLogicX ); //------------ //create data point label diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index f03138d869b7..dbafa59c0588 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -772,6 +772,17 @@ void lcl_AddErrorBottomLine( const drawing::Position3D& rPosition, ::basegfx::B2 return aMainDirection; } +drawing::Position3D lcl_transformMixedToScene( PlottingPositionHelper* pPosHelper + , double fX /*scaled*/, double fY /*unscaled*/, double fZ /*unscaled*/, bool bClip ) +{ + if(!pPosHelper) + return drawing::Position3D(0,0,0); + pPosHelper->doLogicScaling( 0,&fY,&fZ ); + if(bClip) + pPosHelper->clipScaledLogicValues( &fX,&fY,&fZ ); + return pPosHelper->transformScaledLogicToScene( fX, fY, fZ, false ); +} + } // anonymous namespace // virtual @@ -782,6 +793,7 @@ void VSeriesPlotter::createErrorBar( , const VDataSeries& rVDataSeries , sal_Int32 nIndex , bool bYError /* = true */ + , double* pfScaledLogicX ) { if( !ChartTypeHelper::isSupportingStatisticProperties( m_xChartTypeModel, m_nDimension ) ) @@ -816,7 +828,13 @@ void VSeriesPlotter::createErrorBar( const double fX = aUnscaledLogicPosition.PositionX; const double fY = aUnscaledLogicPosition.PositionY; const double fZ = aUnscaledLogicPosition.PositionZ; - aMiddle = m_pPosHelper->transformLogicToScene( fX, fY, fZ, true ); + double fScaledX = fX; + if( pfScaledLogicX ) + fScaledX = *pfScaledLogicX; + else + m_pPosHelper->doLogicScaling( &fScaledX, 0, 0 ); + + aMiddle = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fY, fZ, true ); drawing::Position3D aNegative(aMiddle); drawing::Position3D aPositive(aMiddle); @@ -831,11 +849,16 @@ void VSeriesPlotter::createErrorBar( double fLocalX = fX; double fLocalY = fY; if( bYError ) + { fLocalY+=fLength; + aPositive = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fLocalY, fZ, true ); + } else + { fLocalX+=fLength; + aPositive = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); + } bCreatePositiveBorder = m_pPosHelper->isLogicVisible(fLocalX, fLocalY, fZ); - aPositive = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); } else bShowPositive = false; @@ -849,12 +872,16 @@ void VSeriesPlotter::createErrorBar( double fLocalX = fX; double fLocalY = fY; if( bYError ) + { fLocalY-=fLength; + aNegative = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fLocalY, fZ, true ); + } else + { fLocalX-=fLength; - + aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); + } bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ); - aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); } else bShowNegative = false; @@ -898,7 +925,8 @@ void VSeriesPlotter::createErrorBar( // virtual void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogicPosition , VDataSeries& rVDataSeries, sal_Int32 nPointIndex - , const uno::Reference< drawing::XShapes >& xTarget ) + , const uno::Reference< drawing::XShapes >& xTarget + , double* pfScaledLogicX ) { if(m_nDimension!=2) return; @@ -912,7 +940,8 @@ void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogic createErrorBar( xErrorBarsGroup_Shapes , rUnscaledLogicPosition, xErrorBarProp , rVDataSeries, nPointIndex - , true /* bYError */ ); + , true /* bYError */ + , pfScaledLogicX ); } } diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index a786c607c73c..8147c3443ec6 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -381,12 +381,14 @@ protected: //methods , const VDataSeries& rVDataSeries , sal_Int32 nIndex , bool bVertical + , double* pfScaledLogicX ); virtual void createErrorBar_Y( const ::com::sun::star::drawing::Position3D& rUnscaledLogicPosition , VDataSeries& rVDataSeries, sal_Int32 nPointIndex , const ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShapes >& xTarget ); + ::com::sun::star::drawing::XShapes >& xTarget + , double* pfScaledLogicX=0 ); virtual void createRegressionCurvesShapes( VDataSeries& rVDataSeries , const ::com::sun::star::uno::Reference< -- cgit From 318558f1b5f9f86a94b0b98df5fa2300c91041fa Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 7 Dec 2010 20:06:05 +0100 Subject: chart46: #i25706# implement date axis - corrected stock charts --- chart2/source/view/charttypes/CandleStickChart.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index b9ce0883d2f0..61c49c61d4a0 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -178,6 +178,7 @@ void CandleStickChart::createShapes() //(@todo maybe different iteration for breaks in axis ?) sal_Int32 nStartIndex = 0; sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); + double fLogicZ = 1.5;//as defined //============================================================================= //iterate through all x values per indices for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ ) @@ -320,13 +321,13 @@ void CandleStickChart::createShapes() drawing::PolyPolygonShape3D aPoly; sal_Int32 nLineIndex = 0; - if( bShowFirst && pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_First ,0 ) + if( bShowFirst && pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_First ,fLogicZ ) && isValidPosition(aPosLeftFirst) && isValidPosition(aPosMiddleFirst) ) { AddPointToPoly( aPoly, aPosLeftFirst, nLineIndex ); AddPointToPoly( aPoly, aPosMiddleFirst, nLineIndex++ ); } - if( pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_Last ,0 ) + if( pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_Last ,fLogicZ ) && isValidPosition(aPosMiddleLast) && isValidPosition(aPosRightLast) ) { AddPointToPoly( aPoly, aPosMiddleLast, nLineIndex ); -- cgit From c8b75257f0fe4a6f13922a9cbd78acf0e72d7e91 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 8 Dec 2010 09:57:08 +0100 Subject: chart46: #i25706# implement date axis - compiler warnings --- chart2/source/inc/chartview/ExplicitScaleValues.hxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'chart2') diff --git a/chart2/source/inc/chartview/ExplicitScaleValues.hxx b/chart2/source/inc/chartview/ExplicitScaleValues.hxx index a2902391b6c2..48c9ef942d03 100644 --- a/chart2/source/inc/chartview/ExplicitScaleValues.hxx +++ b/chart2/source/inc/chartview/ExplicitScaleValues.hxx @@ -57,10 +57,10 @@ struct OOO_DLLPUBLIC_CHARTVIEW ExplicitScaleData ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > Scaling; - long AxisType;//see ::com::sun::star::chart2::AxisType - bool ShiftedCategoryPosition; - long TimeResolution; //constant of type ::com::sun::star::chart::TimeUnit - Date NullDate; + sal_Int32 AxisType;//see ::com::sun::star::chart2::AxisType + bool ShiftedCategoryPosition; + sal_Int32 TimeResolution; //constant of type ::com::sun::star::chart::TimeUnit + Date NullDate; }; struct OOO_DLLPUBLIC_CHARTVIEW ExplicitSubIncrement @@ -72,13 +72,13 @@ struct OOO_DLLPUBLIC_CHARTVIEW ExplicitSubIncrement sub-tick-marks are displayed between two superior ticks. */ - long IntervalCount; + sal_Int32 IntervalCount; /** If , the distance between two sub-tick-marks on the screen is always the same. If , the distances may differ depending on the XScaling. */ - bool PostEquidistant; + bool PostEquidistant; }; /** describes how tickmarks are positioned on the scale of an axis. -- cgit From 63ef1c015c97d5c4cda0b8be76654a3e08d96324 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 8 Dec 2010 13:48:48 +0100 Subject: chart46: #i25706# implement date axis - detect manual date formats + corrected drop range dialog --- chart2/source/tools/DiagramHelper.cxx | 2 +- chart2/source/tools/ExplicitCategoriesProvider.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2') diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index d19e8819f069..e92bdb14505f 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1125,7 +1125,7 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c sal_Int32 nType = util::NumberFormat::UNDEFINED; if( xKeyProps.is() ) xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - if( nType!=util::NumberFormat::DATE && nType!=util::NumberFormat::DATETIME ) + if( !(nType&util::NumberFormat::DATE) && !(nType&util::NumberFormat::DATETIME) ) { //set a date format to the axis sal_Bool bCreate = sal_True; diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 5411e94ee18c..26cd7b264b1f 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -404,7 +404,7 @@ bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFo { sal_Int32 nType = util::NumberFormat::DATETIME; xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - bIsDate = (nType==util::NumberFormat::DATE || nType==util::NumberFormat::DATETIME); + bIsDate = (nType&util::NumberFormat::DATE || nType&util::NumberFormat::DATETIME); } return bIsDate; } -- cgit From 928cbecafc2f64e4a38bb91b4ec6a9b6093f0728 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Thu, 9 Dec 2010 18:32:46 +0100 Subject: chart46: #i25706# implement date axis - remove explicit scaling in case of auto --- chart2/source/controller/dialogs/tp_Scale.cxx | 2 +- chart2/source/tools/AxisHelper.cxx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 7314764db49c..c12c5bdb3814 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -421,7 +421,7 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp)); rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN)); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,bAutoScale || aCbxAutoStepMain.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked())); diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 506c0a96295a..ec437cf7fd34 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -137,7 +137,10 @@ chart2::ScaleData AxisHelper::getDateCheckedScale( const Reference< chart2::XAxi void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ) { if( rScale.AutoDateAxis && rScale.AxisType == AxisType::CATEGORY && bChartTypeAllowsDateAxis ) + { rScale.AxisType = AxisType::DATE; + removeExplicitScaling( rScale ); + } if( rScale.AxisType == AxisType::DATE && (!pExplicitCategoriesProvider || !pExplicitCategoriesProvider->isDateAxis()) ) { rScale.AxisType = AxisType::CATEGORY; -- cgit From b2b21642beea1db9120e99e5a0a64d7ece700d09 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 10 Dec 2010 14:10:17 +0100 Subject: chart46: #i25706# implement date axis - cleanup --- .../chartapiwrapper/ChartDataWrapper.cxx | 27 +------- .../controller/main/ChartDropTargetHelper.cxx | 77 ++++++++++------------ chart2/source/model/inc/Diagram.hxx | 11 ++-- chart2/source/model/main/ChartModel.cxx | 23 ++----- chart2/source/model/main/Diagram.cxx | 17 +++++ chart2/source/tools/DataSourceHelper.cxx | 19 +----- 6 files changed, 66 insertions(+), 108 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 6ab0e6c5f483..fd94ae0e3076 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -739,30 +739,9 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) return; uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); - // determine a template - uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram()); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDia, xFact ); - ::rtl::OUString aServiceName( aTemplateAndService.second ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first; - - // (fall-back) - if( ! xTemplate.is()) - { - if( aServiceName.getLength() == 0 ) - aServiceName = C2U("com.sun.star.chart2.template.Column"); - xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY ); - } - OSL_ASSERT( xTemplate.is()); - - if( xTemplate.is() && xSource.is()) - { - // argument detection works with internal knowledge of the - // ArrayDataProvider - OSL_ASSERT( xDia.is()); - xTemplate->changeDiagramData( xDia, xSource, aArguments ); - } + uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() ); + if( xDia.is() ) + xDia->setDiagramData( xSource, aArguments ); //correct stacking mode if( bStacked || bPercent || bDeep ) diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx index 8749ca1bc062..fd7dc3ad1744 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.cxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -137,58 +137,47 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) // parent) if( bDataComesFromParent ) { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); - if( xDataProvider.is() && + if( xDataProvider.is() && xDiagram.is() && DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument )) { - DiagramHelper::tTemplateWithServiceName aTempWithServ( - DiagramHelper::getTemplateForDiagram( - m_xChartDocument->getFirstDiagram(), - Reference< lang::XMultiServiceFactory >( - m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ))); - if( aTempWithServ.first.is()) + Reference< chart2::data::XDataSource > xDataSource( + DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); + Sequence< beans::PropertyValue > aArguments( + xDataProvider->detectArguments( xDataSource )); + + OUString aOldRange; + beans::PropertyValue * pCellRange = 0; + for( sal_Int32 i=0; i xDataSource( - DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); - Sequence< beans::PropertyValue > aArguments( - xDataProvider->detectArguments( xDataSource )); - - OUString aOldRange; - beans::PropertyValue * pCellRange = 0; - for( sal_Int32 i=0; i>= aOldRange; - break; - } + pCellRange = (aArguments.getArray() + i); + aArguments[i].Value >>= aOldRange; + break; } - if( pCellRange ) + } + if( pCellRange ) + { + // copy means add ranges, move means replace + if( rEvt.mnAction == DND_ACTION_COPY ) + { + // @todo: using implcit knowledge that ranges can be + // merged with ";". This should be done more general + pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString ); + } + // move means replace range + else { - // copy means add ranges, move means replace - if( rEvt.mnAction == DND_ACTION_COPY ) - { - // @todo: using implcit knowledge that ranges can be - // merged with ";". This should be done more general - pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString ); - } - // move means replace range - else - { - pCellRange->Value <<= aRangeString; - } - - xDataSource.set( xDataProvider->createDataSource( aArguments )); - aTempWithServ.first->changeDiagramData( - m_xChartDocument->getFirstDiagram(), - xDataSource, - aArguments ); - - // always return copy state to avoid deletion of the - // dragged range - nResult = DND_ACTION_COPY; + pCellRange->Value <<= aRangeString; } + + xDataSource.set( xDataProvider->createDataSource( aArguments )); + xDiagram->setDiagramData( xDataSource, aArguments ); + + // always return copy state to avoid deletion of the dragged range + nResult = DND_ACTION_COPY; } } } diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx index fc672e29b24c..658cfb2b4d6e 100644 --- a/chart2/source/model/inc/Diagram.hxx +++ b/chart2/source/model/inc/Diagram.hxx @@ -31,11 +31,13 @@ #include "MutexContainer.hxx" #include #include -#include +#include +#include #include #include #include #include +#include #include #include #include @@ -117,8 +119,6 @@ protected: // throw (::com::sun::star::lang::IllegalArgumentException); // ____ XDiagram ____ -// virtual ::rtl::OUString SAL_CALL getChartTypeTemplateServiceName() -// throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getWall() throw (::com::sun::star::uno::RuntimeException); @@ -136,7 +136,10 @@ protected: virtual void SAL_CALL setDefaultColorScheme( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XColorScheme >& xColorScheme ) throw (::com::sun::star::uno::RuntimeException); - + virtual void SAL_CALL setDiagramData( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) + throw (::com::sun::star::uno::RuntimeException); // ____ XCoordinateSystemContainer ____ virtual void SAL_CALL addCoordinateSystem( diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 5a30d97118c5..046fe7034012 100755 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -865,28 +865,15 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) ); if( xDataSource.is() ) { - // set new data - Reference< chart2::XChartTypeTemplate > xTemplate; Reference< chart2::XDiagram > xDia( getFirstDiagram() ); - if( xDia.is()) + if( !xDia.is() ) { - // apply new data - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( - xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY )); - xTemplate.set( aTemplateAndService.first ); - } - - if( !xTemplate.is()) - xTemplate.set( impl_createDefaultChartTypeTemplate() ); - - if( xTemplate.is()) - { - if( xDia.is()) - xTemplate->changeDiagramData( xDia, xDataSource, aArguments ); - else + Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() ); + if( xTemplate.is()) setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) ); } + else + xDia->setDiagramData( xDataSource, aArguments ); } } catch( lang::IllegalArgumentException & ) diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index ff8a0c4030bc..94334a836b3e 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -33,6 +33,7 @@ #include "Wall.hxx" #include "UserDefinedProperties.hxx" #include "ConfigColorScheme.hxx" +#include "DiagramHelper.hxx" #include "ContainerHelper.hxx" #include "ThreeDHelper.hxx" #include "CloneHelper.hxx" @@ -397,6 +398,22 @@ void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorSch fireModifyEvent(); } +void SAL_CALL Diagram::setDiagramData( + const Reference< chart2::data::XDataSource >& xDataSource, + const Sequence< beans::PropertyValue >& aArguments ) + throw (uno::RuntimeException) +{ + uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager ); + uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first ); + if( !xTemplate.is() ) + xTemplate.set( xChartTypeManager->createInstance( C2U("com.sun.star.chart2.template.Column") ), uno::UNO_QUERY ); + if(!xTemplate.is()) + return; + xTemplate->changeDiagramData( this, xDataSource, aArguments ); +} + // ____ XTitled ____ uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject() throw (uno::RuntimeException) diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 0cc6ef4a4315..21fc16156397 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -461,25 +461,8 @@ void DataSourceHelper::setRangeSegmentation( if( !xDataSource.is() ) return; - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateFactory ); - - rtl::OUString aServiceName( aTemplateAndService.second ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first; - - if( !xTemplate.is() ) - { - if( aServiceName.getLength() == 0 ) - aServiceName = C2U("com.sun.star.chart2.template.Column"); - xTemplate.set( xTemplateFactory->createInstance( aServiceName ), uno::UNO_QUERY ); - } - if( !xTemplate.is() ) - return; - - // /-- locked controllers ControllerLockGuard aCtrlLockGuard( xChartModel ); - xTemplate->changeDiagramData( xDiagram, xDataSource, aArguments ); - // \-- locked controllers + xDiagram->setDiagramData( xDataSource, aArguments ); } Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence( -- cgit From eb3c9dfa087679efb697b3c7b41096021cd67a6b Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 10 Dec 2010 17:07:53 +0100 Subject: chart46: #i25706# implement date axis - switching to scatter or bubble --- .../model/template/BubbleDataInterpreter.cxx | 43 +++++++++++----------- chart2/source/model/template/DataInterpreter.cxx | 8 ++++ chart2/source/model/template/DataInterpreter.hxx | 4 ++ chart2/source/model/template/XYDataInterpreter.cxx | 31 +++++++--------- 4 files changed, 48 insertions(+), 38 deletions(-) (limited to 'chart2') diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx index 1f26fff907e4..27fee7d35aff 100644 --- a/chart2/source/model/template/BubbleDataInterpreter.cxx +++ b/chart2/source/model/template/BubbleDataInterpreter.cxx @@ -77,16 +77,17 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( Reference< data::XLabeledDataSequence > xCategories; bool bHasCategories = HasCategories( aArguments, aData ); + bool bUseCategoriesAsX = UseCategoriesAsX( aArguments ); - bool bHasXValues = false; + bool bSetXValues = false; sal_Int32 nDataSeqCount = aData.getLength(); - bHasXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 ) + bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 ) :( nDataSeqCount > 2 && nDataSeqCount % 2 != 0 ); bool bCategoriesUsed = false; bool bNextIsYValues = bHasCategories ? nDataSeqCount>2 : nDataSeqCount>1; - for( sal_Int32 nDataIdx = 0; nDataIdx < aData.getLength(); ++nDataIdx ) + for( sal_Int32 nDataIdx = 0; nDataIdx < nDataSeqCount; ++nDataIdx ) { try { @@ -94,10 +95,17 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( { xCategories.set( aData[nDataIdx] ); if( xCategories.is()) + { SetRole( xCategories->getValues(), C2U("categories")); + if( bUseCategoriesAsX ) + { + bSetXValues = false; + bNextIsYValues = nDataSeqCount > 2; + } + } bCategoriesUsed = true; } - else if( !xValuesX.is() && bHasXValues ) + else if( !xValuesX.is() && bSetXValues ) { xValuesX.set( aData[nDataIdx] ); if( xValuesX.is()) @@ -115,7 +123,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( aSizeValuesVector.push_back( aData[nDataIdx] ); if( aData[nDataIdx].is()) SetRole( aData[nDataIdx]->getValues(), C2U("values-size")); - bNextIsYValues = true; + bNextIsYValues = (nDataSeqCount-(nDataIdx+1)) >= 2;//two or more left } } catch( uno::Exception & ex ) @@ -132,26 +140,19 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX; Reference< util::XCloneable > xCloneableX( xValuesX, uno::UNO_QUERY ); - for( size_t nCount = 0; nCount < aSizeValuesVector.size(); ++nCount, ++nSeriesIndex ) + for( size_t nN = 0; nN < aSizeValuesVector.size(); ++nN, ++nSeriesIndex ) { - sal_Int32 nDataSequenceCount = 2; - if( xValuesX.is() ) - nDataSequenceCount = 3; - else if( aYValuesVector.empty() ) - nDataSequenceCount = 1; - - Sequence< Reference< data::XLabeledDataSequence > > aNewData( nDataSequenceCount ); - sal_Int32 nDataIndex = 0; + vector< Reference< data::XLabeledDataSequence > > aNewData; if( xValuesX.is() ) { - if( nCount > 0 && xCloneableX.is() ) + if( nN > 0 && xCloneableX.is() ) xClonedXValues.set( xCloneableX->createClone(), uno::UNO_QUERY ); - aNewData[nDataIndex++] = xClonedXValues; + aNewData.push_back( xClonedXValues ); } - if( aYValuesVector.size() > nCount ) - aNewData[nDataIndex++] = aYValuesVector[nCount]; - if( aSizeValuesVector.size() > nCount ) - aNewData[nDataIndex++] = aSizeValuesVector[nCount]; + if( aYValuesVector.size() > nN ) + aNewData.push_back( aYValuesVector[nN] ); + if( aSizeValuesVector.size() > nN ) + aNewData.push_back( aSizeValuesVector[nN] ); Reference< XDataSeries > xSeries; if( nSeriesIndex < aSeriesToReUse.getLength()) @@ -161,7 +162,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( OSL_ASSERT( xSeries.is() ); Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY ); OSL_ASSERT( xSink.is() ); - xSink->setData( aNewData ); + xSink->setData( ContainerHelper::ContainerToSequence( aNewData ) ); aSeriesVec.push_back( xSeries ); } diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index b619553ee959..b4a748e4e022 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -394,6 +394,14 @@ bool DataInterpreter::HasCategories( return bHasCategories; } +bool DataInterpreter::UseCategoriesAsX( const Sequence< beans::PropertyValue > & rArguments ) +{ + bool bUseCategoriesAsX = true; + if( rArguments.getLength() > 0 ) + GetProperty( rArguments, C2U(("UseCategoriesAsX"))) >>= bUseCategoriesAsX; + return bUseCategoriesAsX; +} + // ------------------------------------------------------------ Sequence< OUString > DataInterpreter::getSupportedServiceNames_Static() diff --git a/chart2/source/model/template/DataInterpreter.hxx b/chart2/source/model/template/DataInterpreter.hxx index a2d6201fc023..d0f2ee922059 100644 --- a/chart2/source/model/template/DataInterpreter.hxx +++ b/chart2/source/model/template/DataInterpreter.hxx @@ -73,6 +73,10 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > & rData ); + static bool UseCategoriesAsX( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > & rArguments ); + protected: // ____ XDataInterpreter ____ virtual ::com::sun::star::chart2::InterpretedData SAL_CALL interpretDataSource( diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx index 839c0cbac510..965e3a058f58 100644 --- a/chart2/source/model/template/XYDataInterpreter.cxx +++ b/chart2/source/model/template/XYDataInterpreter.cxx @@ -75,11 +75,12 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource( vector< Reference< data::XLabeledDataSequence > > aSequencesVec; Reference< data::XLabeledDataSequence > xCategories; - // check for categories. If true, the the categories bet parked in the axis scale, but not used via setting the Axistype to Not CATEGORY bool bHasCategories = HasCategories( aArguments, aData ); + bool bUseCategoriesAsX = UseCategoriesAsX( aArguments ); // parse data bool bCategoriesUsed = false; + bool bSetXValues = aData.getLength()>(bCategoriesUsed?2:1); for( sal_Int32 nDataIdx= 0; nDataIdx < aData.getLength(); ++nDataIdx ) { try @@ -88,10 +89,14 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource( { xCategories.set( aData[nDataIdx] ); if( xCategories.is()) + { SetRole( xCategories->getValues(), C2U("categories")); + if( bUseCategoriesAsX ) + bSetXValues = false; + } bCategoriesUsed = true; } - else if( !xValuesX.is() && (aData.getLength()>(bCategoriesUsed?2:1)) ) + else if( !xValuesX.is() && bSetXValues ) { xValuesX.set( aData[nDataIdx] ); if( xValuesX.is()) @@ -123,22 +128,14 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource( for( ;aSequencesVecIt != aSequencesVec.end(); ++aSequencesVecIt, ++nSeriesIndex ) { - Sequence< Reference< data::XLabeledDataSequence > > aNewData(xValuesX.is()?2:1); - if( aSequencesVecIt != aSequencesVec.begin() && - xCloneable.is() ) - { - xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY ); - } + vector< Reference< data::XLabeledDataSequence > > aNewData; + if( aSequencesVecIt != aSequencesVec.begin() && xCloneable.is() ) + xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY ); if( xValuesX.is() ) - { - aNewData[0] = xClonedXValues; - aNewData[1] = (*aSequencesVecIt); - } - else - { - aNewData[0] = (*aSequencesVecIt); - } + aNewData.push_back( xClonedXValues ); + + aNewData.push_back( *aSequencesVecIt ); Reference< XDataSeries > xSeries; if( nSeriesIndex < aSeriesToReUse.getLength()) @@ -148,7 +145,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource( OSL_ASSERT( xSeries.is() ); Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY ); OSL_ASSERT( xSink.is() ); - xSink->setData( aNewData ); + xSink->setData( ContainerHelper::ContainerToSequence( aNewData ) ); aSeriesVec.push_back( xSeries ); } -- cgit From 5c0e59cd81b619b0674076e5bcb4be792b1f403b Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 14 Dec 2010 14:49:54 +0100 Subject: chart46: #i25706# implement date axis - no date axis for pure time format --- chart2/source/tools/DiagramHelper.cxx | 2 +- chart2/source/tools/ExplicitCategoriesProvider.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'chart2') diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index e92bdb14505f..e9f060248afe 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1125,7 +1125,7 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c sal_Int32 nType = util::NumberFormat::UNDEFINED; if( xKeyProps.is() ) xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - if( !(nType&util::NumberFormat::DATE) && !(nType&util::NumberFormat::DATETIME) ) + if( !( nType & util::NumberFormat::DATE ) ) { //set a date format to the axis sal_Bool bCreate = sal_True; diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 26cd7b264b1f..c1b3ae4daf39 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -402,9 +402,9 @@ bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFo Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); if( xKeyProps.is() ) { - sal_Int32 nType = util::NumberFormat::DATETIME; + sal_Int32 nType = util::NumberFormat::UNDEFINED; xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - bIsDate = (nType&util::NumberFormat::DATE || nType&util::NumberFormat::DATETIME); + bIsDate = nType & util::NumberFormat::DATE; } return bIsDate; } -- cgit From 7623d8ea4e3f512a18ff074a38a5e682e24de9ba Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 13:07:07 +0100 Subject: undoapi: post-rebase problems fixed --- chart2/source/controller/main/UndoCommandDispatch.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 4d19e6f901af..a008c492886d 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -29,6 +29,7 @@ #include "precompiled_chart2.hxx" #include "UndoCommandDispatch.hxx" +#include "ResId.hxx" #include "macros.hxx" #include -- cgit From d1959d69204893ee006c14dcb6f389e4dfe15449 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 5 Jan 2011 15:00:17 +0100 Subject: undoapi: fixed wrong resolution of merge conflict --- chart2/source/controller/main/UndoCommandDispatch.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index a008c492886d..487def377d5c 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -83,13 +83,13 @@ void UndoCommandDispatch::fireStatusEvent( if( m_xUndoManager->isUndoPossible()) { // 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->getCurrentUndoActionTitle()); } if( m_xUndoManager->isRedoPossible()) { // 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->getCurrentRedoActionTitle()); } -- cgit From 634f59e5c4817d57a13cebc0bea277b44c3099e8 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Tue, 11 Jan 2011 16:05:26 +0100 Subject: chart46: #i25706# implement date axis - #i116406# december dates wrongly interpreted --- chart2/source/view/axes/DateScaling.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/DateScaling.cxx b/chart2/source/view/axes/DateScaling.cxx index 65d6771ee2e9..6802fba67bd2 100644 --- a/chart2/source/view/axes/DateScaling.cxx +++ b/chart2/source/view/axes/DateScaling.cxx @@ -171,7 +171,12 @@ double SAL_CALL InverseDateScaling::doScaling( double value ) } Date aDate; double fYear = ::rtl::math::approxFloor(value/lcl_fNumberOfMonths); - double fMonth = ::rtl::math::approxFloor(value-(fYear*lcl_fNumberOfMonths)); + double fMonth = ::rtl::math::approxFloor(value-(fYear*lcl_fNumberOfMonths)); + if( fMonth==0.0 ) + { + fYear--; + fMonth=12.0; + } aDate.SetYear( static_cast(fYear) ); aDate.SetMonth( static_cast(fMonth) ); aDate.SetDay( 1 ); -- cgit From 9a8ff5c2508f78394dfda2e22c0b3b600000a284 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 12 Jan 2011 10:50:47 +0100 Subject: chart46: #i25706# implement date axis - #i116411# number format during editing --- chart2/source/controller/dialogs/DataBrowser.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 8a6c9262b038..a05b3171ccbb 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -868,6 +868,9 @@ void DataBrowser::SetDataFromModel( new NumberFormatterWrapper( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ))); + if( m_spNumberFormatterWrapper.get() ) + m_aNumberEditField.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); + RenewTable(); const sal_Int32 nColCnt = m_apDataBrowserModel->getColumnCount(); -- cgit From bb15dfd763af19c547a27c40882d9cdf1477f375 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 12 Jan 2011 14:36:07 +0100 Subject: chart46: #i25706# implement date axis - #i116425# interpret no data as text axis --- .../source/controller/dialogs/DataBrowserModel.cxx | 16 ++++++++++++-- chart2/source/tools/ExplicitCategoriesProvider.cxx | 25 ++++++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 7e93afd3b42e..a075f6c3a5c6 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -43,6 +43,7 @@ #include "ExplicitCategoriesProvider.hxx" #include +#include #include #include #include @@ -800,8 +801,19 @@ void DataBrowserModel::updateFromModel() if( lcl_ShowCategories( xDiagram )) { Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY ); - ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); - bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel ); + bool bIsDateAxis = false; + if( xCooSys.is() ) + { + Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + if( xAxis.is() ) + { + chart2::ScaleData aScale( xAxis->getScaleData() ); + bIsDateAxis = (aScale.AxisType == chart2::AxisType::DATE); + } + } + sal_Int32 nDateCategoriesNumberFormat = 0; if( bIsDateAxis && aCooSysSeq.getLength() ) nDateCategoriesNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[0], 0, 0 ); diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index c1b3ae4daf39..1c52a3c3e622 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -412,6 +412,7 @@ bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFo bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataSequence, std::vector< DatePlusIndex >& rDateCategories, bool bIsAutoDate, Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier ) { bool bOnlyDatesFound = true; + bool bAnyDataFound = false; if( xDataSequence.is() ) { @@ -451,18 +452,28 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS else bIsDate = true; + bool bContainsEmptyString = false; + bool bContainsNan = false; uno::Any aAny = aValues[nN]; + if( aAny.hasValue() ) + { + OUString aTest; + double fTest; + if( (aAny>>=aTest) && !aTest.getLength() ) //empty String + bContainsEmptyString = true; + else if( (aAny>>=fTest) && ::rtl::math::isNan(fTest) ) + bContainsNan = true; + + if( !bContainsEmptyString && !bContainsNan ) + bAnyDataFound = true; + } DatePlusIndex aDatePlusIndex( 1.0, nN ); if( bIsDate && (aAny >>= aDatePlusIndex.fValue) ) rDateCategories.push_back( aDatePlusIndex ); else { - if( aAny.hasValue() ) - { - OUString aTest; - if( !( (aAny>>=aTest) && !aTest.getLength() ) )//empty string does not count as non date value! - bOnlyDatesFound=false; - } + if( aAny.hasValue() && !bContainsEmptyString )//empty string does not count as non date value! + bOnlyDatesFound=false; ::rtl::math::setNan( &aDatePlusIndex.fValue ); rDateCategories.push_back( aDatePlusIndex ); } @@ -470,7 +481,7 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS ::std::sort( rDateCategories.begin(), rDateCategories.end(), DatePlusIndexComparator() ); } - return bOnlyDatesFound; + return bAnyDataFound && bOnlyDatesFound; } void ExplicitCategoriesProvider::init() -- cgit From 3d6a5a98cda10e18dacd96028f2bf0ec0b478988 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 14 Jan 2011 15:18:08 +0100 Subject: removetooltypes01: #i112600# remove tooltypes from chart2 --- .../accessibility/AccessibleViewForwarder.cxx | 2 +- .../accessibility/AccessibleViewForwarder.hxx | 2 +- chart2/source/controller/dialogs/DataBrowser.cxx | 40 ++++++------- chart2/source/controller/dialogs/DataBrowser.hxx | 6 +- .../source/controller/dialogs/DataBrowserModel.hxx | 4 +- .../controller/dialogs/dlg_CreationWizard.cxx | 4 +- .../source/controller/dialogs/dlg_DataEditor.cxx | 24 ++++---- .../source/controller/dialogs/dlg_DataSource.cxx | 6 +- .../controller/dialogs/dlg_InsertAxis_Grid.cxx | 2 +- .../source/controller/dialogs/dlg_NumberFormat.cxx | 2 +- .../controller/dialogs/dlg_ObjectProperties.cxx | 8 +-- chart2/source/controller/dialogs/dlg_ShapeFont.cxx | 2 +- .../controller/dialogs/dlg_ShapeParagraph.cxx | 2 +- chart2/source/controller/dialogs/dlg_View3D.cxx | 2 +- .../source/controller/dialogs/res_BarGeometry.cxx | 6 +- .../source/controller/dialogs/res_BarGeometry.hxx | 6 +- chart2/source/controller/dialogs/res_DataLabel.cxx | 50 ++++++++-------- chart2/source/controller/dialogs/res_DataLabel.hxx | 10 ++-- chart2/source/controller/dialogs/res_ErrorBar.cxx | 36 ++++++------ .../controller/dialogs/res_LegendPosition.cxx | 12 ++-- .../controller/dialogs/res_TextSeparator.cxx | 6 +- .../controller/dialogs/res_TextSeparator.hxx | 4 +- chart2/source/controller/dialogs/res_Titles.cxx | 2 +- chart2/source/controller/dialogs/res_Trendline.cxx | 18 +++--- chart2/source/controller/dialogs/res_Trendline.hxx | 2 +- .../controller/dialogs/tp_3D_SceneAppearance.cxx | 44 +++++++------- .../controller/dialogs/tp_3D_SceneGeometry.cxx | 2 +- .../controller/dialogs/tp_3D_SceneIllumination.cxx | 8 +-- chart2/source/controller/dialogs/tp_AxisLabel.cxx | 42 ++++++------- chart2/source/controller/dialogs/tp_AxisLabel.hxx | 6 +- .../source/controller/dialogs/tp_AxisPositions.cxx | 52 ++++++++--------- .../source/controller/dialogs/tp_AxisPositions.hxx | 2 +- chart2/source/controller/dialogs/tp_ChartType.cxx | 10 ++-- chart2/source/controller/dialogs/tp_DataLabel.cxx | 2 +- chart2/source/controller/dialogs/tp_DataLabel.hxx | 2 +- chart2/source/controller/dialogs/tp_DataSource.cxx | 18 +++--- chart2/source/controller/dialogs/tp_DataSource.hxx | 6 +- chart2/source/controller/dialogs/tp_ErrorBars.cxx | 2 +- chart2/source/controller/dialogs/tp_ErrorBars.hxx | 2 +- .../controller/dialogs/tp_LegendPosition.cxx | 6 +- .../controller/dialogs/tp_LegendPosition.hxx | 2 +- .../source/controller/dialogs/tp_PointGeometry.cxx | 8 +-- .../source/controller/dialogs/tp_PointGeometry.hxx | 2 +- .../source/controller/dialogs/tp_PolarOptions.cxx | 26 ++++----- .../source/controller/dialogs/tp_PolarOptions.hxx | 2 +- .../source/controller/dialogs/tp_RangeChooser.cxx | 8 +-- chart2/source/controller/dialogs/tp_Scale.cxx | 40 ++++++------- chart2/source/controller/dialogs/tp_Scale.hxx | 4 +- .../source/controller/dialogs/tp_SeriesToAxis.cxx | 68 +++++++++++----------- .../source/controller/dialogs/tp_SeriesToAxis.hxx | 2 +- .../source/controller/dialogs/tp_TitleRotation.cxx | 8 +-- .../source/controller/dialogs/tp_TitleRotation.hxx | 2 +- chart2/source/controller/dialogs/tp_Trendline.cxx | 2 +- chart2/source/controller/dialogs/tp_Trendline.hxx | 2 +- .../controller/drawinglayer/DrawViewWrapper.cxx | 8 +-- .../drawinglayer/ViewElementListProvider.cxx | 8 +-- chart2/source/controller/inc/AxisItemConverter.hxx | 6 +- .../inc/CharacterPropertyItemConverter.hxx | 6 +- .../controller/inc/DataPointItemConverter.hxx | 6 +- chart2/source/controller/inc/DrawViewWrapper.hxx | 8 +-- .../controller/inc/ErrorBarItemConverter.hxx | 6 +- .../inc/GraphicPropertyItemConverter.hxx | 6 +- chart2/source/controller/inc/ItemConverter.hxx | 12 ++-- .../source/controller/inc/LegendItemConverter.hxx | 6 +- .../controller/inc/MultipleChartConverters.hxx | 10 ++-- .../controller/inc/MultipleItemConverter.hxx | 2 +- .../inc/RegressionCurveItemConverter.hxx | 6 +- .../inc/RegressionEquationItemConverter.hxx | 6 +- .../controller/inc/SeriesOptionsItemConverter.hxx | 6 +- .../controller/inc/StatisticsItemConverter.hxx | 6 +- .../source/controller/inc/TitleItemConverter.hxx | 6 +- chart2/source/controller/inc/dlg_DataEditor.hxx | 2 +- chart2/source/controller/inc/dlg_DataSource.hxx | 2 +- .../source/controller/inc/dlg_InsertAxis_Grid.hxx | 2 +- .../source/controller/inc/dlg_ObjectProperties.hxx | 6 +- chart2/source/controller/inc/dlg_ShapeFont.hxx | 2 +- .../source/controller/inc/dlg_ShapeParagraph.hxx | 2 +- chart2/source/controller/inc/dlg_View3D.hxx | 2 +- chart2/source/controller/inc/res_ErrorBar.hxx | 2 +- .../itemsetwrapper/AxisItemConverter.cxx | 8 +-- .../CharacterPropertyItemConverter.cxx | 6 +- .../itemsetwrapper/DataPointItemConverter.cxx | 16 ++--- .../itemsetwrapper/ErrorBarItemConverter.cxx | 6 +- .../GraphicPropertyItemConverter.cxx | 12 ++-- .../controller/itemsetwrapper/ItemConverter.cxx | 22 +++---- .../itemsetwrapper/LegendItemConverter.cxx | 6 +- .../itemsetwrapper/MultipleChartConverters.cxx | 10 ++-- .../RegressionCurveItemConverter.cxx | 10 ++-- .../RegressionEquationItemConverter.cxx | 6 +- .../controller/itemsetwrapper/SchWhichPairs.hxx | 42 ++++++------- .../itemsetwrapper/SeriesOptionsItemConverter.cxx | 8 +-- .../itemsetwrapper/StatisticsItemConverter.cxx | 8 +-- .../itemsetwrapper/TitleItemConverter.cxx | 10 ++-- chart2/source/controller/main/ChartController.hxx | 4 +- .../controller/main/ChartController_Position.cxx | 10 ++-- .../controller/main/ChartController_TextEdit.cxx | 12 ++-- .../controller/main/ChartController_Window.cxx | 14 ++--- .../source/controller/main/ChartTransferable.cxx | 2 +- chart2/source/controller/main/ChartWindow.cxx | 10 ++-- chart2/source/controller/main/ChartWindow.hxx | 6 +- .../source/controller/main/DrawCommandDispatch.cxx | 10 ++-- .../source/controller/main/DrawCommandDispatch.hxx | 2 +- chart2/source/controller/main/ElementSelector.cxx | 10 ++-- chart2/source/controller/main/ShapeController.cxx | 24 ++++---- .../controller/main/ShapeToolbarController.cxx | 10 ++-- chart2/source/inc/AxisHelper.hxx | 4 +- chart2/source/inc/DiagramHelper.hxx | 6 +- chart2/source/inc/InternalData.hxx | 2 +- chart2/source/inc/OPropertySet.hxx | 2 +- chart2/source/inc/ReferenceSizeProvider.hxx | 2 +- chart2/source/inc/RelativePositionHelper.hxx | 8 +-- .../inc/chartview/NumberFormatterWrapper.hxx | 2 +- chart2/source/view/main/ChartItemPool.cxx | 22 +++---- chart2/source/view/main/ChartItemPool.hxx | 2 +- chart2/source/view/main/ChartView.cxx | 8 +-- chart2/source/view/main/Clipping.cxx | 4 +- chart2/source/view/main/DrawModelWrapper.cxx | 6 +- chart2/source/view/main/NumberFormatterWrapper.cxx | 2 +- 118 files changed, 563 insertions(+), 563 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx index 5014198761f8..7936efb3d899 100644 --- a/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx +++ b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx @@ -52,7 +52,7 @@ AccessibleViewForwarder::~AccessibleViewForwarder() // ________ IAccessibleViewforwarder ________ -BOOL AccessibleViewForwarder::IsValid() const +sal_Bool AccessibleViewForwarder::IsValid() const { return sal_True; } diff --git a/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx b/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx index e70aa58b8df7..e85e68b23830 100644 --- a/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx +++ b/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx @@ -44,7 +44,7 @@ public: virtual ~AccessibleViewForwarder(); // ________ IAccessibleViewforwarder ________ - virtual BOOL IsValid() const; + virtual sal_Bool IsValid() const; virtual Rectangle GetVisibleArea() const; virtual Point LogicToPixel( const Point& rPoint ) const; virtual Size LogicToPixel( const Size& rSize ) const; diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index fedcfaffebc4..120639b9d339 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -105,7 +105,7 @@ sal_Int32 lcl_getRowInData( long nRow ) return static_cast< sal_Int32 >( nRow ); } -sal_Int32 lcl_getColumnInData( USHORT nCol ) +sal_Int32 lcl_getColumnInData( sal_uInt16 nCol ) { return static_cast< sal_Int32 >( nCol ) - 1; } @@ -215,7 +215,7 @@ private: DECL_LINK( SeriesNameChanged, void * ); DECL_LINK( SeriesNameEdited, void * ); - /// @param bHC for hight-contrast image + /// @param bHC for hight-contrast image static Image GetChartTypeImage( const Reference< chart2::XChartType > & xChartType, bool bSwapXAndYAxis, @@ -476,13 +476,13 @@ bool lcl_SeriesHeaderHasFocus( } sal_Int32 lcl_getColumnInDataOrHeader( - USHORT nCol, const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader ) + sal_uInt16 nCol, const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader ) { sal_Int32 nColIdx = 0; bool bHeaderHasFocus( lcl_SeriesHeaderHasFocus( rSeriesHeader, &nColIdx )); if( bHeaderHasFocus ) - nColIdx = lcl_getColumnInData( static_cast< USHORT >( rSeriesHeader[nColIdx]->GetStartColumn())); + nColIdx = lcl_getColumnInData( static_cast< sal_uInt16 >( rSeriesHeader[nColIdx]->GetStartColumn())); else nColIdx = lcl_getColumnInData( nCol ); @@ -507,7 +507,7 @@ DataBrowser::DataBrowser( Window* pParent, const ResId& rId, bool bLiveUpdate ) double fNan; ::rtl::math::setNan( & fNan ); m_aNumberEditField.SetDefaultValue( fNan ); - m_aNumberEditField.TreatAsNumber( TRUE ); + m_aNumberEditField.TreatAsNumber( sal_True ); RenewTable(); SetClean(); } @@ -583,10 +583,10 @@ void DataBrowser::RenewTable() return; long nOldRow = GetCurRow(); - USHORT nOldColId = GetCurColumnId(); + sal_uInt16 nOldColId = GetCurColumnId(); - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); if( IsModified() ) SaveModified(); @@ -614,7 +614,7 @@ void DataBrowser::RenewTable() RowInserted( 1, nRowCountLocal ); GoToRow( ::std::min( nOldRow, GetRowCount() - 1 )); - GoToColumnId( ::std::min( nOldColId, static_cast< USHORT >( ColCount() - 1 ))); + GoToColumnId( ::std::min( nOldColId, static_cast< sal_uInt16 >( ColCount() - 1 ))); Window * pWin = this->GetParent(); if( !pWin ) @@ -671,7 +671,7 @@ String DataBrowser::GetRowString( sal_Int32 nRow ) const return String::CreateFromInt32( nRow + 1 ); } -String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const +String DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const { String aResult; @@ -706,7 +706,7 @@ String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const return aResult; } -double DataBrowser::GetCellNumber( long nRow, USHORT nColumnId ) const +double DataBrowser::GetCellNumber( long nRow, sal_uInt16 nColumnId ) const { double fResult; ::rtl::math::setNan( & fResult ); @@ -723,8 +723,8 @@ double DataBrowser::GetCellNumber( long nRow, USHORT nColumnId ) const void DataBrowser::Resize() { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); ::svt::EditBrowseBox::Resize(); ImplAdjustHeaderControls(); @@ -1210,10 +1210,10 @@ sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const return GetFirstVisibleColNumber(); } -void DataBrowser::ColumnResized( USHORT nColId ) +void DataBrowser::ColumnResized( sal_uInt16 nColId ) { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); EditBrowseBox::ColumnResized( nColId ); ImplAdjustHeaderControls(); @@ -1224,8 +1224,8 @@ void DataBrowser::ColumnResized( USHORT nColId ) void DataBrowser::EndScroll() { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); EditBrowseBox::EndScroll(); RenewSeriesHeaders(); @@ -1354,8 +1354,8 @@ IMPL_LINK( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit*, pEdit ) sal_Int32 DataBrowser::GetTotalWidth() const { - ULONG nWidth = 0; - for ( USHORT nCol = 0; nCol < ColCount(); ++nCol ) + sal_uLong nWidth = 0; + for ( sal_uInt16 nCol = 0; nCol < ColCount(); ++nCol ) nWidth += GetColumnWidth( nCol ); return static_cast< sal_Int32 >( nWidth ); } diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 3583db2770c0..cb9696770fcd 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -68,7 +68,7 @@ protected: virtual void CursorMoved(); // called whenever the control of the current cell has been modified virtual void CellModified(); - virtual void ColumnResized( USHORT nColId ); + virtual void ColumnResized( sal_uInt16 nColId ); virtual void EndScroll(); virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ); @@ -86,12 +86,12 @@ public: @return the text out of the cell */ - virtual String GetCellText(long nRow, USHORT nColId) const; + virtual String GetCellText(long nRow, sal_uInt16 nColId) const; /** returns the number in the given cell. If a cell is empty or contains a string, the result will be Nan */ - double GetCellNumber( long nRow, USHORT nColumnId ) const; + double GetCellNumber( long nRow, sal_uInt16 nColumnId ) const; // Window virtual void Resize(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index a4378972f70f..d16bbe24ce1e 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -90,9 +90,9 @@ public: ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - /// returns
if the number could successfully be set at the given position + /// returns if the number could successfully be set at the given position bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); - /// returns if the text could successfully be set at the given position + /// returns if the text could successfully be set at the given position bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText ); bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue ); diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx index e7a7a8bd43d8..fe035acb09e4 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx @@ -96,7 +96,7 @@ CreationWizard::CreationWizard( Window* pParent, const uno::Reference< frame::XM m_apDialogModel.reset( new DialogModel( m_xChartModel, m_xCC )); // Do not call FreeResource(), because there are no sub-elements defined in // the dialog resource - ShowButtonFixedLine( TRUE ); + ShowButtonFixedLine( sal_True ); defaultButton( WZB_FINISH ); if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount ) @@ -236,7 +236,7 @@ void CreationWizard::setValidPage( TabPage * /* pTabPage */ ) String CreationWizard::getStateDisplayName( WizardState nState ) const { - USHORT nResId = 0; + sal_uInt16 nResId = 0; switch( nState ) { case STATE_CHARTTYPE: diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index f1d441921a6a..fc8e5a040321 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -191,13 +191,13 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_bReadOnly = bReadOnly; if( m_bReadOnly ) { - m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, sal_False ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, sal_False ); } m_apBrwData->SetReadOnly( m_bReadOnly ); @@ -258,7 +258,7 @@ void DataEditor::UpdateData() // } // { -// BOOL bRet = TRUE; +// sal_Bool bRet = sal_True; // // confirm changes currently made and not saved // m_apBrwData->EndEditing(); @@ -281,7 +281,7 @@ void DataEditor::UpdateData() // if( bRet ) // { // // close child window -// SfxBoolItem aItem( SID_DIAGRAM_DATA, FALSE ); +// SfxBoolItem aItem( SID_DIAGRAM_DATA, sal_False ); // if( m_pBindings ) // { // SfxDispatcher* pDisp = m_pBindings->GetDispatcher(); @@ -292,7 +292,7 @@ void DataEditor::UpdateData() // } // } -// return ( bRet? SfxFloatingWindow::Close(): FALSE ); +// return ( bRet? SfxFloatingWindow::Close(): sal_False ); // } void DataEditor::AdaptBrowseBoxSize() @@ -313,12 +313,12 @@ void DataEditor::Resize() // ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); } -BOOL DataEditor::Close() +sal_Bool DataEditor::Close() { if( ApplyChangesToModel() ) return ModalDialog::Close(); else - return TRUE; + return sal_True; } bool DataEditor::ApplyChangesToModel() diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx index 3e4cba6b23ad..694a165cd411 100644 --- a/chart2/source/controller/dialogs/dlg_DataSource.cxx +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -146,7 +146,7 @@ void DataSourceTabControl::EnableTabToggling() // ---------------------------------------- -USHORT DataSourceDialog::m_nLastPageId = 0; +sal_uInt16 DataSourceDialog::m_nLastPageId = 0; DataSourceDialog::DataSourceDialog( Window * pParent, @@ -220,7 +220,7 @@ void DataSourceDialog::setInvalidPage( TabPage * pTabPage ) if( ! (m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid )) { - m_aBtnOK.Enable( FALSE ); + m_aBtnOK.Enable( sal_False ); OSL_ASSERT( m_pTabControl ); // note: there seems to be no suitable mechanism to address pages by // identifier, at least it is unclear what the page identifiers are. @@ -242,7 +242,7 @@ void DataSourceDialog::setValidPage( TabPage * pTabPage ) if( m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid ) { - m_aBtnOK.Enable( TRUE ); + m_aBtnOK.Enable( sal_True ); OSL_ASSERT( m_pTabControl ); m_pTabControl->EnableTabToggling(); } diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx index 0a250b5bf874..66ffb011690f 100644 --- a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx @@ -63,7 +63,7 @@ InsertAxisOrGridDialogData::InsertAxisOrGridDialogData() //============================== SchAxisDlg::SchAxisDlg( Window* pWindow - , const InsertAxisOrGridDialogData& rInput, BOOL bAxisDlg ) + , const InsertAxisOrGridDialogData& rInput, sal_Bool bAxisDlg ) : ModalDialog( pWindow, SchResId( DLG_AXIS_OR_GRID )), diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx index d7491156358e..51df0eb21dc4 100644 --- a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx @@ -69,7 +69,7 @@ NumberFormatDialog::~NumberFormatDialog() SfxItemSet NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ) { - static const USHORT nWhichPairs[] = + static const sal_uInt16 nWhichPairs[] = { SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2a41d35313e8..36d9cd83574f 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -323,8 +323,8 @@ uno::Reference< chart2::XChartDocument > ObjectPropertiesDialogParameter::getDoc return m_xChartDocument; } -//const USHORT nNoArrowDlg = 1100; -const USHORT nNoArrowNoShadowDlg = 1101; +//const sal_uInt16 nNoArrowDlg = 1100; +const sal_uInt16 nNoArrowNoShadowDlg = 1101; //------------------------------------------------------------------- //------------------------------------------------------------------- @@ -505,7 +505,7 @@ SchAttribTabDlg::~SchAttribTabDlg() delete m_pAutoSymbolGraphic; } -void SchAttribTabDlg::PageCreated(USHORT nId, SfxTabPage &rPage) +void SchAttribTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) { SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); switch (nId) @@ -609,7 +609,7 @@ void SchAttribTabDlg::PageCreated(USHORT nId, SfxTabPage &rPage) break; case RID_SVXPAGE_NUMBERFORMAT: - aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const USHORT)SID_ATTR_NUMBERFORMAT_INFO)); + aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const sal_uInt16)SID_ATTR_NUMBERFORMAT_INFO)); rPage.PageCreated(aSet); break; diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx index 280a1adecba2..0c9edc0e1553 100644 --- a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx +++ b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx @@ -63,7 +63,7 @@ ShapeFontDialog::~ShapeFontDialog() { } -void ShapeFontDialog::PageCreated( USHORT nId, SfxTabPage& rPage ) +void ShapeFontDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage ) { SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) ); switch ( nId ) diff --git a/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx index 2f0173fc8408..38373df5e9a8 100644 --- a/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx +++ b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx @@ -69,7 +69,7 @@ ShapeParagraphDialog::~ShapeParagraphDialog() { } -void ShapeParagraphDialog::PageCreated( USHORT nId, SfxTabPage& rPage ) +void ShapeParagraphDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage ) { SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) ); switch ( nId ) diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx index 3c868f6aeaff..e77d180e87b3 100644 --- a/chart2/source/controller/dialogs/dlg_View3D.cxx +++ b/chart2/source/controller/dialogs/dlg_View3D.cxx @@ -57,7 +57,7 @@ using namespace ::com::sun::star::chart2; //------------------------------------------------------------------- //------------------------------------------------------------------- -USHORT View3DDialog::m_nLastPageId = 0; +sal_uInt16 View3DDialog::m_nLastPageId = 0; View3DDialog::View3DDialog(Window* pParent, const uno::Reference< frame::XModel > & xChartModel, XColorTable* pColorTable ) : TabDialog(pParent,SchResId(DLG_3D_VIEW)) diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx b/chart2/source/controller/dialogs/res_BarGeometry.cxx index f2c31fe461a9..ee2278589b89 100644 --- a/chart2/source/controller/dialogs/res_BarGeometry.cxx +++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx @@ -92,15 +92,15 @@ void BarGeometryResources::Enable( bool bEnable ) m_aLB_Geometry.Enable( bEnable ); } -USHORT BarGeometryResources::GetSelectEntryCount() const +sal_uInt16 BarGeometryResources::GetSelectEntryCount() const { return m_aLB_Geometry.GetSelectEntryCount(); } -USHORT BarGeometryResources::GetSelectEntryPos() const +sal_uInt16 BarGeometryResources::GetSelectEntryPos() const { return m_aLB_Geometry.GetSelectEntryPos(); } -void BarGeometryResources::SelectEntryPos( USHORT nPos ) +void BarGeometryResources::SelectEntryPos( sal_uInt16 nPos ) { if( nPos < m_aLB_Geometry.GetEntryCount() ) m_aLB_Geometry.SelectEntryPos( nPos ); diff --git a/chart2/source/controller/dialogs/res_BarGeometry.hxx b/chart2/source/controller/dialogs/res_BarGeometry.hxx index db2f71e2f178..4d91f74179eb 100644 --- a/chart2/source/controller/dialogs/res_BarGeometry.hxx +++ b/chart2/source/controller/dialogs/res_BarGeometry.hxx @@ -49,9 +49,9 @@ public: void Show( bool bShow ); void Enable( bool bEnable ); - USHORT GetSelectEntryCount() const; - USHORT GetSelectEntryPos() const; - void SelectEntryPos( USHORT nPos ); + sal_uInt16 GetSelectEntryCount() const; + sal_uInt16 GetSelectEntryPos() const; + void SelectEntryPos( sal_uInt16 nPos ); void SetSelectHdl( const Link& rLink ); diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 25d279eaad37..e466163bd0a3 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -65,11 +65,11 @@ namespace chart namespace { -bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, USHORT nValueWhich, USHORT nSourceFormatWhich, ULONG& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) +bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, sal_uInt16 nValueWhich, sal_uInt16 nSourceFormatWhich, sal_uLong& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) { bool bSet = false; const SfxPoolItem *pItem1 = NULL; - if( rSet.GetItemState( nValueWhich, TRUE, &pItem1 ) == SFX_ITEM_SET ) + if( rSet.GetItemState( nValueWhich, sal_True, &pItem1 ) == SFX_ITEM_SET ) { const SfxUInt32Item * pNumItem = dynamic_cast< const SfxUInt32Item * >( pItem1 ); if( pNumItem ) @@ -81,7 +81,7 @@ bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, USHORT nValueWhich rbSourceFormatMixedStateOut=true; const SfxPoolItem *pItem2 = NULL; - if( rSet.GetItemState( nSourceFormatWhich, TRUE, &pItem2 ) == SFX_ITEM_SET ) + if( rSet.GetItemState( nSourceFormatWhich, sal_True, &pItem2 ) == SFX_ITEM_SET ) { const SfxBoolItem * pBoolItem = dynamic_cast< const SfxBoolItem * >( pItem2 ); if( pBoolItem ) @@ -93,16 +93,16 @@ bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, USHORT nValueWhich return bSet; } -void lcl_setBoolItemToCheckBox( const SfxItemSet& rInAttrs, USHORT nWhichId, CheckBox& rCheckbox ) +void lcl_setBoolItemToCheckBox( const SfxItemSet& rInAttrs, sal_uInt16 nWhichId, CheckBox& rCheckbox ) { - rCheckbox.EnableTriState( FALSE ); + rCheckbox.EnableTriState( sal_False ); const SfxPoolItem *pPoolItem = NULL; - if( rInAttrs.GetItemState(nWhichId, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(nWhichId, sal_True, &pPoolItem) == SFX_ITEM_SET ) rCheckbox.Check( ((const SfxBoolItem*)pPoolItem)->GetValue() ); else { - rCheckbox.EnableTriState( TRUE ); + rCheckbox.EnableTriState( sal_True ); rCheckbox.SetState( STATE_DONTKNOW ); } } @@ -140,17 +140,17 @@ DataLabelResources::DataLabelResources( Window* pWindow, const SfxItemSet& rInAt //fill label placement list std::map< sal_Int32, XubString > aPlacementToStringMap; for( sal_Int32 nEnum=0; nEnum(nEnum)); + aPlacementToStringMap[nEnum]=m_aLB_LabelPlacement.GetEntry(static_cast(nEnum)); ::com::sun::star::uno::Sequence < sal_Int32 > aAvailabelPlacementList; const SfxPoolItem *pPoolItem = NULL; - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, sal_True, &pPoolItem) == SFX_ITEM_SET ) aAvailabelPlacementList =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); m_aLB_LabelPlacement.Clear(); for( sal_Int32 nN=0; nN( nN ); + sal_uInt16 nListBoxPos = static_cast( nN ); sal_Int32 nPlacement = aAvailabelPlacementList[nN]; m_aPlacementToListBoxMap[nPlacement]=nListBoxPos; m_aListBoxToPlacementMap[nListBoxPos]=nPlacement; @@ -212,7 +212,7 @@ DataLabelResources::DataLabelResources( Window* pWindow, const SfxItemSet& rInAt m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_NO_PERCENTVALUE, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_NO_PERCENTVALUE, sal_True, &pPoolItem) == SFX_ITEM_SET ) { bool bForbidPercentValue = (static_cast< const SfxBoolItem & >( rInAttrs.Get( SCHATTR_DATADESCR_NO_PERCENTVALUE )).GetValue() ); if( bForbidPercentValue ) @@ -245,11 +245,11 @@ IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) m_aCBPercent.Check(); SfxItemSet aNumberSet = NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( *m_pPool ); - aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const USHORT)SID_ATTR_NUMBERFORMAT_INFO)); + aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const sal_uInt16)SID_ATTR_NUMBERFORMAT_INFO)); bool bPercent = ( pButton == &m_aPB_NumberFormatForPercent ); - ULONG& rnFormatKey = bPercent ? m_nNumberFormatForPercent : m_nNumberFormatForValue; + sal_uLong& rnFormatKey = bPercent ? m_nNumberFormatForPercent : m_nNumberFormatForValue; bool& rUseSourceFormat = bPercent ? m_bSourceFormatForPercent : m_bSourceFormatForValue; bool& rbMixedState = bPercent ? m_bPercentFormatMixedState : m_bNumberFormatMixedState; bool& rbSourceMixedState = bPercent ? m_bPercentSourceMixedState : m_bSourceFormatMixedState; @@ -267,7 +267,7 @@ IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) if( pResult ) { bool bOldSource = rUseSourceFormat; - ULONG nOldFormat = rnFormatKey; + sal_uLong nOldFormat = rnFormatKey; bool bOldMixedState = rbMixedState || rbSourceMixedState; rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); @@ -283,7 +283,7 @@ IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) IMPL_LINK( DataLabelResources, CheckHdl, CheckBox*, pBox ) { if( pBox ) - pBox->EnableTriState( FALSE ); + pBox->EnableTriState( sal_False ); EnableControls(); return 0; } @@ -320,7 +320,7 @@ void DataLabelResources::EnableControls() m_aNF_Degrees.Enable( bEnableRotation ); } -BOOL DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const +sal_Bool DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const { if( m_aCBNumber.IsChecked() ) { @@ -347,7 +347,7 @@ BOOL DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_aCBSymbol.IsChecked()) ); rOutAttrs.Put( SfxStringItem( SCHATTR_DATADESCR_SEPARATOR, m_aSeparatorResources.GetValue() ) ); - ::std::map< USHORT, sal_Int32 >::const_iterator aIt( m_aListBoxToPlacementMap.find(m_aLB_LabelPlacement.GetSelectEntryPos()) ); + ::std::map< sal_uInt16, sal_Int32 >::const_iterator aIt( m_aListBoxToPlacementMap.find(m_aLB_LabelPlacement.GetSelectEntryPos()) ); if(aIt!=m_aListBoxToPlacementMap.end()) { sal_Int32 nValue = aIt->second; @@ -363,13 +363,13 @@ BOOL DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const rOutAttrs.Put(SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); } - return TRUE; + return sal_True; } void DataLabelResources::Reset(const SfxItemSet& rInAttrs) { // default state - m_aCBSymbol.Enable( FALSE ); + m_aCBSymbol.Enable( sal_False ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_NUMBER, m_aCBNumber ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, m_aCBPercent ); @@ -380,18 +380,18 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); const SfxPoolItem *pPoolItem = NULL; - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, sal_True, &pPoolItem) == SFX_ITEM_SET ) m_aSeparatorResources.SetValue( ((const SfxStringItem*)pPoolItem)->GetValue() ); else m_aSeparatorResources.SetDefault(); - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, sal_True, &pPoolItem) == SFX_ITEM_SET ) { sal_Int32 nPlacement = ((const SfxInt32Item*)pPoolItem)->GetValue(); - ::std::map< sal_Int32, USHORT >::const_iterator aIt( m_aPlacementToListBoxMap.find(nPlacement) ); + ::std::map< sal_Int32, sal_uInt16 >::const_iterator aIt( m_aPlacementToListBoxMap.find(nPlacement) ); if(aIt!=m_aPlacementToListBoxMap.end()) { - USHORT nPos = aIt->second; + sal_uInt16 nPos = aIt->second; m_aLB_LabelPlacement.SelectEntryPos( nPos ); } else @@ -400,10 +400,10 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) else m_aLB_LabelPlacement.SetNoSelection(); - if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET ) m_aLB_TextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); - if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_True, &pPoolItem ) == SFX_ITEM_SET ) { sal_Int32 nDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); m_aDC_Dial.SetRotation( nDegrees ); diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx index ef34e004bb07..37e14e7077e0 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -49,7 +49,7 @@ public: DataLabelResources( Window* pParent, const SfxItemSet& rInAttrs ); virtual ~DataLabelResources(); - BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + sal_Bool FillItemSet(SfxItemSet& rOutAttrs) const; void Reset(const SfxItemSet& rInAttrs); void SetNumberFormatter( SvNumberFormatter* pFormatter ); @@ -75,14 +75,14 @@ private: FixedText m_aFT_TextDirection; TextDirectionListBox m_aLB_TextDirection; - ::std::map< sal_Int32, USHORT > m_aPlacementToListBoxMap; - ::std::map< USHORT, sal_Int32 > m_aListBoxToPlacementMap; + ::std::map< sal_Int32, sal_uInt16 > m_aPlacementToListBoxMap; + ::std::map< sal_uInt16, sal_Int32 > m_aListBoxToPlacementMap; SvNumberFormatter* m_pNumberFormatter; bool m_bNumberFormatMixedState; bool m_bPercentFormatMixedState; - ULONG m_nNumberFormatForValue; - ULONG m_nNumberFormatForPercent; + sal_uLong m_nNumberFormatForValue; + sal_uLong m_nNumberFormatForPercent; bool m_bSourceFormatMixedState; bool m_bPercentSourceMixedState; diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 8b649072538e..d2b62e07214f 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -51,8 +51,8 @@ void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) { if( pDialog ) { - pDialog->Show( bEnable ? FALSE : TRUE ); - pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + pDialog->Show( bEnable ? sal_False : sal_True ); + pDialog->SetModalInputMode( bEnable ? sal_False : sal_True ); } } @@ -162,7 +162,7 @@ ErrorBarResources::ErrorBarResources( Window* pParent, Dialog * pParentDialog, m_aRbRange.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); m_aLbFunction.SetSelectHdl( LINK( this, ErrorBarResources, CategoryChosen )); - m_aCbSyncPosNeg.Check( FALSE ); + m_aCbSyncPosNeg.Check( sal_False ); m_aCbSyncPosNeg.SetToggleHdl( LINK( this, ErrorBarResources, SynchronizePosAndNeg )); m_aMfPositive.SetModifyHdl( LINK( this, ErrorBarResources, PosValueChanged )); @@ -520,7 +520,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) // category m_eErrorKind = CHERROR_NONE; - aState = rInAttrs.GetItemState( SCHATTR_STAT_KIND_ERROR, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_KIND_ERROR, sal_True, &pPoolItem ); m_bErrorKindUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET ) @@ -554,14 +554,14 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) } else { - m_aRbNone.Check( FALSE ); - m_aRbConst.Check( FALSE ); - m_aRbPercent.Check( FALSE ); - m_aRbFunction.Check( FALSE ); + m_aRbNone.Check( sal_False ); + m_aRbConst.Check( sal_False ); + m_aRbPercent.Check( sal_False ); + m_aRbFunction.Check( sal_False ); } // parameters - aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTPLUS, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTPLUS, sal_True, &pPoolItem ); m_bPlusUnique = ( aState != SFX_ITEM_DONTCARE ); double fPlusValue = 0.0; if( aState == SFX_ITEM_SET ) @@ -571,7 +571,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) m_aMfPositive.SetValue( nPlusValue ); } - aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTMINUS, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTMINUS, sal_True, &pPoolItem ); m_bMinusUnique = ( aState != SFX_ITEM_DONTCARE ); double fMinusValue = 0.0; if( aState == SFX_ITEM_SET ) @@ -586,7 +586,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) } // indicator - aState = rInAttrs.GetItemState( SCHATTR_STAT_INDICATE, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_INDICATE, sal_True, &pPoolItem ); m_bIndicatorUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET) m_eIndicate = ((const SvxChartIndicateItem * ) pPoolItem)->GetValue(); @@ -609,13 +609,13 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) } else { - m_aRbBoth.Check( FALSE ); - m_aRbPositive.Check( FALSE ); - m_aRbNegative.Check( FALSE ); + m_aRbBoth.Check( sal_False ); + m_aRbPositive.Check( sal_False ); + m_aRbNegative.Check( sal_False ); } // ranges - aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_POS, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_POS, sal_True, &pPoolItem ); m_bRangePosUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET ) { @@ -623,7 +623,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) m_aEdRangePositive.SetText( sRangePositive ); } - aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_NEG, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_NEG, sal_True, &pPoolItem ); m_bRangeNegUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET ) { @@ -638,7 +638,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) UpdateControlStates(); } -BOOL ErrorBarResources::FillItemSet(SfxItemSet& rOutAttrs) const +sal_Bool ErrorBarResources::FillItemSet(SfxItemSet& rOutAttrs) const { if( m_bErrorKindUnique ) rOutAttrs.Put( SvxChartKindErrorItem( m_eErrorKind, SCHATTR_STAT_KIND_ERROR )); @@ -691,7 +691,7 @@ BOOL ErrorBarResources::FillItemSet(SfxItemSet& rOutAttrs) const } } - return TRUE; + return sal_True; } void ErrorBarResources::FillValueSets() diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx index c9206a5428df..0bbfcb7eee68 100644 --- a/chart2/source/controller/dialogs/res_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx @@ -183,7 +183,7 @@ void LegendPositionResources::writeToModel( const ::com::sun::star::uno::Referen IMPL_LINK( LegendPositionResources, PositionEnableHdl, void*, EMPTYARG ) { - BOOL bEnable = m_aCbxShow.IsChecked(); + sal_Bool bEnable = m_aCbxShow.IsChecked(); m_aRbtLeft.Enable( bEnable ); m_aRbtTop.Enable( bEnable ); @@ -201,7 +201,7 @@ void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) const SfxPoolItem* pPoolItem = NULL; if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, - TRUE, &pPoolItem ) != SFX_ITEM_SET ) + sal_True, &pPoolItem ) != SFX_ITEM_SET ) pPoolItem = &(rInAttrs.GetPool()->GetDefaultItem( SCHATTR_LEGEND_POS )); if( pPoolItem ) @@ -210,16 +210,16 @@ void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) switch( ePos ) { case CHLEGEND_LEFT: - m_aRbtLeft.Check(TRUE); + m_aRbtLeft.Check(sal_True); break; case CHLEGEND_TOP: - m_aRbtTop.Check(TRUE); + m_aRbtTop.Check(sal_True); break; case CHLEGEND_RIGHT: - m_aRbtRight.Check(TRUE); + m_aRbtRight.Check(sal_True); break; case CHLEGEND_BOTTOM: - m_aRbtBottom.Check(TRUE); + m_aRbtBottom.Check(sal_True); break; default: break; diff --git a/chart2/source/controller/dialogs/res_TextSeparator.cxx b/chart2/source/controller/dialogs/res_TextSeparator.cxx index 45efd2f5e5b3..8878f5f77ffc 100644 --- a/chart2/source/controller/dialogs/res_TextSeparator.cxx +++ b/chart2/source/controller/dialogs/res_TextSeparator.cxx @@ -124,7 +124,7 @@ Size TextSeparatorResources::GetCurrentListBoxSize() const void TextSeparatorResources::SetValue( const rtl::OUString& rSeparator ) { - ::std::map< ::rtl::OUString, USHORT >::iterator aIter( m_aEntryMap.find(rSeparator) ); + ::std::map< ::rtl::OUString, sal_uInt16 >::iterator aIter( m_aEntryMap.find(rSeparator) ); if( aIter == m_aEntryMap.end() ) m_aLB_Separator.SelectEntryPos( m_nDefaultPos ); else @@ -138,8 +138,8 @@ void TextSeparatorResources::SetDefault() rtl::OUString TextSeparatorResources::GetValue() const { - USHORT nPos = m_aLB_Separator.GetSelectEntryPos(); - ::std::map< ::rtl::OUString, USHORT >::const_iterator aIter( m_aEntryMap.begin() ); + sal_uInt16 nPos = m_aLB_Separator.GetSelectEntryPos(); + ::std::map< ::rtl::OUString, sal_uInt16 >::const_iterator aIter( m_aEntryMap.begin() ); while( aIter != m_aEntryMap.end() ) { if(aIter->second==nPos ) diff --git a/chart2/source/controller/dialogs/res_TextSeparator.hxx b/chart2/source/controller/dialogs/res_TextSeparator.hxx index 4895a442fa0b..e7effee4e88a 100644 --- a/chart2/source/controller/dialogs/res_TextSeparator.hxx +++ b/chart2/source/controller/dialogs/res_TextSeparator.hxx @@ -63,9 +63,9 @@ private: FixedText m_aFT_Separator; ListBox m_aLB_Separator; - ::std::map< ::rtl::OUString, USHORT > m_aEntryMap; + ::std::map< ::rtl::OUString, sal_uInt16 > m_aEntryMap; - const USHORT m_nDefaultPos; + const sal_uInt16 m_nDefaultPos; }; //............................................................................. diff --git a/chart2/source/controller/dialogs/res_Titles.cxx b/chart2/source/controller/dialogs/res_Titles.cxx index 225c8fe8748b..8620b81de4ab 100644 --- a/chart2/source/controller/dialogs/res_Titles.cxx +++ b/chart2/source/controller/dialogs/res_Titles.cxx @@ -126,7 +126,7 @@ TitleResources::~TitleResources() void TitleResources::SetUpdateDataHdl( const Link& rLink ) { - ULONG nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; + sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; m_aEd_Main.EnableUpdateData( nTimeout ); m_aEd_Main.SetUpdateDataHdl( rLink ); diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index a395d32c2efa..ed5ed2686aba 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -187,7 +187,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) const SfxPoolItem *pPoolItem = NULL; SfxItemState aState = SFX_ITEM_UNKNOWN; - aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ); m_bTrendLineUnique = ( aState != SFX_ITEM_DONTCARE ); if( aState == SFX_ITEM_SET ) { @@ -196,28 +196,28 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_eTrendLineType = pItem->GetValue(); } - aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, sal_True, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { - m_aCBShowEquation.EnableTriState( TRUE ); + m_aCBShowEquation.EnableTriState( sal_True ); m_aCBShowEquation.SetState( STATE_DONTKNOW ); } else { - m_aCBShowEquation.EnableTriState( FALSE ); + m_aCBShowEquation.EnableTriState( sal_False ); if( aState == SFX_ITEM_SET ) m_aCBShowEquation.Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); } - aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, TRUE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, sal_True, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { - m_aCBShowCorrelationCoeff.EnableTriState( TRUE ); + m_aCBShowCorrelationCoeff.EnableTriState( sal_True ); m_aCBShowCorrelationCoeff.SetState( STATE_DONTKNOW ); } else { - m_aCBShowCorrelationCoeff.EnableTriState( FALSE ); + m_aCBShowCorrelationCoeff.EnableTriState( sal_False ); if( aState == SFX_ITEM_SET ) m_aCBShowCorrelationCoeff.Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); } @@ -246,7 +246,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } } -BOOL TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const +sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const { if( m_bTrendLineUnique ) rOutAttrs.Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE )); @@ -254,7 +254,7 @@ BOOL TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_aCBShowEquation.IsChecked() )); if( m_aCBShowCorrelationCoeff.GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_aCBShowCorrelationCoeff.IsChecked() )); - return TRUE; + return sal_True; } void TrendlineResources::FillValueSets() diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx index 248a677edd21..f9c1160677b4 100644 --- a/chart2/source/controller/dialogs/res_Trendline.hxx +++ b/chart2/source/controller/dialogs/res_Trendline.hxx @@ -44,7 +44,7 @@ public: virtual ~TrendlineResources(); void Reset(const SfxItemSet& rInAttrs); - BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + sal_Bool FillItemSet(SfxItemSet& rOutAttrs) const; void FillValueSets(); diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx index 6b3b63495126..8e32a4f6a262 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -128,9 +128,9 @@ ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( m_aCB_Shading.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) ); m_aCB_ObjectLines.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); - m_aCB_RoundedEdge.EnableTriState( TRUE ); - m_aCB_Shading.EnableTriState( TRUE ); - m_aCB_ObjectLines.EnableTriState( TRUE ); + m_aCB_RoundedEdge.EnableTriState( sal_True ); + m_aCB_Shading.EnableTriState( sal_True ); + m_aCB_ObjectLines.EnableTriState( sal_True ); initControlsFromModel(); } @@ -220,50 +220,50 @@ void ThreeD_SceneAppearance_TabPage::initControlsFromModel() if(aProps.m_aShadeMode == drawing::ShadeMode_FLAT) { - m_aCB_Shading.EnableTriState( FALSE ); - m_aCB_Shading.Check(FALSE); + m_aCB_Shading.EnableTriState( sal_False ); + m_aCB_Shading.Check(sal_False); } else if(aProps.m_aShadeMode == drawing::ShadeMode_SMOOTH) { - m_aCB_Shading.EnableTriState( FALSE ); - m_aCB_Shading.Check(TRUE); + m_aCB_Shading.EnableTriState( sal_False ); + m_aCB_Shading.Check(sal_True); } else { - m_aCB_Shading.EnableTriState( TRUE ); + m_aCB_Shading.EnableTriState( sal_True ); m_aCB_Shading.SetState( STATE_DONTKNOW ); } if(aProps.m_nObjectLines == 0) { - m_aCB_ObjectLines.EnableTriState( FALSE ); - m_aCB_ObjectLines.Check(FALSE); + m_aCB_ObjectLines.EnableTriState( sal_False ); + m_aCB_ObjectLines.Check(sal_False); } else if(aProps.m_nObjectLines==1) { - m_aCB_ObjectLines.EnableTriState( FALSE ); - m_aCB_ObjectLines.Check(TRUE); + m_aCB_ObjectLines.EnableTriState( sal_False ); + m_aCB_ObjectLines.Check(sal_True); } else { - m_aCB_ObjectLines.EnableTriState( TRUE ); + m_aCB_ObjectLines.EnableTriState( sal_True ); m_aCB_ObjectLines.SetState( STATE_DONTKNOW ); } if(aProps.m_nRoundedEdges >= 5) { - m_aCB_RoundedEdge.EnableTriState( FALSE ); - m_aCB_RoundedEdge.Check(TRUE); + m_aCB_RoundedEdge.EnableTriState( sal_False ); + m_aCB_RoundedEdge.Check(sal_True); } else if(aProps.m_nRoundedEdges<0) { - m_aCB_RoundedEdge.EnableTriState( FALSE ); + m_aCB_RoundedEdge.EnableTriState( sal_False ); m_aCB_RoundedEdge.SetState( STATE_DONTKNOW ); } else { - m_aCB_RoundedEdge.EnableTriState( TRUE ); - m_aCB_RoundedEdge.Check(FALSE); + m_aCB_RoundedEdge.EnableTriState( sal_True ); + m_aCB_RoundedEdge.Check(sal_False); } m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); @@ -332,7 +332,7 @@ IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectShading, void*, EMPTYARG ) if( !m_bUpdateOtherControls ) return 0; - m_aCB_Shading.EnableTriState( FALSE ); + m_aCB_Shading.EnableTriState( sal_False ); applyShadeModeToModel(); updateScheme(); return 0; @@ -344,15 +344,15 @@ IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, Check if( pCheckBox == &m_aCB_ObjectLines ) { - m_aCB_ObjectLines.EnableTriState( FALSE ); + m_aCB_ObjectLines.EnableTriState( sal_False ); m_bUpdateOtherControls = false; m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); if(!m_aCB_RoundedEdge.IsEnabled()) - m_aCB_RoundedEdge.Check(FALSE); + m_aCB_RoundedEdge.Check(sal_False); m_bUpdateOtherControls = true; } else - m_aCB_RoundedEdge.EnableTriState( FALSE ); + m_aCB_RoundedEdge.EnableTriState( sal_False ); applyRoundedEdgeAndObjectLinesToModel(); updateScheme(); return 0; diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index 39175695a48b..ff1e784b5ff9 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -116,7 +116,7 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( Window* pWindow m_aMFYRotation.SetValue(m_nYRotation); m_aMFZRotation.SetValue(m_nZRotation); - const ULONG nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; + const sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; Link aAngleChangedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleChanged )); Link aAngleEditedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleEdited )); diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index 25b379481b7e..2310e193e5ba 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -164,13 +164,13 @@ namespace rtl::OUString lcl_makeColorName( Color rColor ) { String aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R)); - aStr += String::CreateFromInt32((INT32)rColor.GetRed()); + aStr += String::CreateFromInt32((sal_Int32)rColor.GetRed()); aStr += sal_Unicode(' '); aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_G)); - aStr += String::CreateFromInt32((INT32)rColor.GetGreen()); + aStr += String::CreateFromInt32((sal_Int32)rColor.GetGreen()); aStr += sal_Unicode(' '); aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_B)); - aStr += String::CreateFromInt32((INT32)rColor.GetBlue()); + aStr += String::CreateFromInt32((sal_Int32)rColor.GetBlue()); return aStr; } void lcl_selectColor( ColorListBox& rListBox, const Color& rColor ) @@ -179,7 +179,7 @@ namespace rListBox.SelectEntry( rColor ); if( rListBox.GetSelectEntryCount() == 0 ) { - USHORT nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) ); + sal_uInt16 nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) ); rListBox.SelectEntryPos( nPos ); } } diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 3dcaa3092e57..d1f33b2e4b3b 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -82,7 +82,7 @@ SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rIn { FreeResource(); - aCbStacked.EnableTriState( FALSE ); + aCbStacked.EnableTriState( sal_False ); aOrientHlp.AddDependentWindow( aFlOrient ); aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK ); @@ -107,7 +107,7 @@ SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAtt return new SchAxisLabelTabPage( pParent, rAttrs ); } -BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +sal_Bool SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) { bool bStacked = false; if( aOrientHlp.GetStackedState() != STATE_DONTKNOW ) @@ -154,7 +154,7 @@ BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) if( m_aLbTextDirection.GetSelectEntryCount() > 0 ) rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) ); - return TRUE; + return sal_True; } void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) @@ -163,16 +163,16 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) SfxItemState aState = SFX_ITEM_UNKNOWN; // show description ---------- - aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, sal_False, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { - aCbShowDescription.EnableTriState( TRUE ); + aCbShowDescription.EnableTriState( sal_True ); aCbShowDescription.SetState( STATE_DONTKNOW ); } else { - aCbShowDescription.EnableTriState( FALSE ); - BOOL bCheck = FALSE; + aCbShowDescription.EnableTriState( sal_False ); + sal_Bool bCheck = sal_False; if( aState == SFX_ITEM_SET ) bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); aCbShowDescription.Check( bCheck ); @@ -185,7 +185,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // check new degree item m_nInitialDegrees = 0; - aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_False, &pPoolItem ); if( aState == SFX_ITEM_SET ) m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); @@ -197,7 +197,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // check stacked item m_bInitialStacking = false; - aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, sal_False, &pPoolItem ); if( aState == SFX_ITEM_SET ) m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); @@ -207,20 +207,20 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) else aOrientHlp.SetStackedState( STATE_DONTKNOW ); - if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET ) m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); // Text overlap ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, sal_False, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { - aCbTextOverlap.EnableTriState( TRUE ); + aCbTextOverlap.EnableTriState( sal_True ); aCbTextOverlap.SetState( STATE_DONTKNOW ); } else { - aCbTextOverlap.EnableTriState( FALSE ); - BOOL bCheck = FALSE; + aCbTextOverlap.EnableTriState( sal_False ); + sal_Bool bCheck = sal_False; if( aState == SFX_ITEM_SET ) bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); aCbTextOverlap.Check( bCheck ); @@ -230,16 +230,16 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) } // text break ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, sal_False, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { - aCbTextBreak.EnableTriState( TRUE ); + aCbTextBreak.EnableTriState( sal_True ); aCbTextBreak.SetState( STATE_DONTKNOW ); } else { - aCbTextBreak.EnableTriState( FALSE ); - BOOL bCheck = FALSE; + aCbTextBreak.EnableTriState( sal_False ); + sal_Bool bCheck = sal_False; if( aState == SFX_ITEM_SET ) bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); aCbTextBreak.Check( bCheck ); @@ -255,7 +255,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { - aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, sal_False, &pPoolItem ); if( aState == SFX_ITEM_SET ) { SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); @@ -281,7 +281,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) ToggleShowLabel( (void*)0 ); } -void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls ) +void SchAxisLabelTabPage::ShowStaggeringControls( sal_Bool bShowStaggeringControls ) { m_bShowStaggeringControls = bShowStaggeringControls; @@ -300,7 +300,7 @@ void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls ) IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG ) { - BOOL bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK ); + sal_Bool bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK ); aOrientHlp.Enable( bEnable ); aFlOrder.Enable( bEnable ); diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx index 6043b16001ac..0961141aaffe 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.hxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -70,7 +70,7 @@ private: FixedText m_aFtTextDirection; TextDirectionListBox m_aLbTextDirection; - BOOL m_bShowStaggeringControls; + sal_Bool m_bShowStaggeringControls; sal_Int32 m_nInitialDegrees; bool m_bHasInitialDegrees; /// false = DialControl in tristate @@ -86,10 +86,10 @@ public: void Construct(); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); - virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual sal_Bool FillItemSet( SfxItemSet& rOutAttrs ); virtual void Reset( const SfxItemSet& rInAttrs ); - void ShowStaggeringControls( BOOL bShowStaggeringControls ); + void ShowStaggeringControls( sal_Bool bShowStaggeringControls ); }; //............................................................................. } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx index ab4e36ff1f84..3538277c2004 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -229,10 +229,10 @@ SfxTabPage* AxisPositionsTabPage::Create(Window* pWindow,const SfxItemSet& rOutA return new AxisPositionsTabPage(pWindow, rOutAttrs); } -BOOL AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) { // axis line - USHORT nPos = m_aLB_CrossesAt.GetSelectEntryPos(); + sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos(); rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_POSITION, nPos+1 )); if( 2==nPos ) { @@ -243,7 +243,7 @@ BOOL AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) } // labels - USHORT nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); + sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); if( nLabelPos != LISTBOX_ENTRY_NOTFOUND ) rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_LABEL_POSITION, nLabelPos )); @@ -263,11 +263,11 @@ BOOL AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TICKS,nTicks)); rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELPTICKS,nMinorTicks)); - USHORT nMarkPos = m_aLB_PlaceTicks.GetSelectEntryPos(); + sal_uInt16 nMarkPos = m_aLB_PlaceTicks.GetSelectEntryPos(); if( nMarkPos != LISTBOX_ENTRY_NOTFOUND ) rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_MARK_POSITION, nMarkPos )); - return TRUE; + return sal_True; } void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) @@ -281,7 +281,7 @@ void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) for( sal_Int32 nN=0; nN30 ) nCount=30; m_aED_CrossesAtCategory.SetDropDownLineCount( nCount ); @@ -299,10 +299,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) const SfxPoolItem *pPoolItem = NULL; //axis line - if(rInAttrs.GetItemState(SCHATTR_AXIS_POSITION,TRUE, &pPoolItem)== SFX_ITEM_SET) + if(rInAttrs.GetItemState(SCHATTR_AXIS_POSITION,sal_True, &pPoolItem)== SFX_ITEM_SET) { bool bZero = false; - USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); if(nPos==0) { //switch to value @@ -316,13 +316,13 @@ void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) m_aLB_CrossesAt.SelectEntryPos( nPos ); CrossesAtSelectHdl( (void*)0 ); - if( rInAttrs.GetItemState(SCHATTR_AXIS_POSITION_VALUE,TRUE, &pPoolItem)== SFX_ITEM_SET || bZero ) + if( rInAttrs.GetItemState(SCHATTR_AXIS_POSITION_VALUE,sal_True, &pPoolItem)== SFX_ITEM_SET || bZero ) { double fCrossover = 0.0; if( !bZero ) fCrossover = (((const SvxDoubleItem*)pPoolItem)->GetValue()); if( m_bCrossingAxisIsCategoryAxis ) - m_aED_CrossesAtCategory.SelectEntryPos( static_cast(::rtl::math::round(fCrossover-1.0)) ); + m_aED_CrossesAtCategory.SelectEntryPos( static_cast(::rtl::math::round(fCrossover-1.0)) ); else m_aED_CrossesAt.SetValue(fCrossover); } @@ -335,13 +335,13 @@ void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) else { m_aLB_CrossesAt.SetNoSelection(); - m_aED_CrossesAt.Enable( FALSE ); + m_aED_CrossesAt.Enable( sal_False ); } // Labels - if( rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_POSITION, FALSE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET ) { - USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); if( nPos < m_aLB_PlaceLabels.GetEntryCount() ) m_aLB_PlaceLabels.SelectEntryPos( nPos ); } @@ -351,20 +351,20 @@ void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) // Tick marks long nTicks=0,nMinorTicks=0; - if(rInAttrs.GetItemState(SCHATTR_AXIS_TICKS,TRUE, &pPoolItem)== SFX_ITEM_SET) + if(rInAttrs.GetItemState(SCHATTR_AXIS_TICKS,sal_True, &pPoolItem)== SFX_ITEM_SET) nTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); - if(rInAttrs.GetItemState(SCHATTR_AXIS_HELPTICKS,TRUE, &pPoolItem)== SFX_ITEM_SET) + if(rInAttrs.GetItemState(SCHATTR_AXIS_HELPTICKS,sal_True, &pPoolItem)== SFX_ITEM_SET) nMinorTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); - m_aCB_TicksInner.Check(BOOL(nTicks&CHAXIS_MARK_INNER)); - m_aCB_TicksOuter.Check(BOOL(nTicks&CHAXIS_MARK_OUTER)); - m_aCB_MinorInner.Check(BOOL(nMinorTicks&CHAXIS_MARK_INNER)); - m_aCB_MinorOuter.Check(BOOL(nMinorTicks&CHAXIS_MARK_OUTER)); + m_aCB_TicksInner.Check(sal_Bool(nTicks&CHAXIS_MARK_INNER)); + m_aCB_TicksOuter.Check(sal_Bool(nTicks&CHAXIS_MARK_OUTER)); + m_aCB_MinorInner.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_INNER)); + m_aCB_MinorOuter.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_OUTER)); // Tick position - if( rInAttrs.GetItemState( SCHATTR_AXIS_MARK_POSITION, FALSE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState( SCHATTR_AXIS_MARK_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET ) { - USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); if( nPos < m_aLB_PlaceTicks.GetEntryCount() ) m_aLB_PlaceTicks.SelectEntryPos( nPos ); } @@ -439,9 +439,9 @@ void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) m_aED_CrossesAt.UseInputStringForFormatting(); const SfxPoolItem *pPoolItem = NULL; - if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, sal_True, &pPoolItem ) == SFX_ITEM_SET ) { - ULONG nFmt = (ULONG)((const SfxInt32Item*)pPoolItem)->GetValue(); + sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue(); m_aED_CrossesAt.SetFormatKey( nFmt ); } } @@ -463,7 +463,7 @@ void AxisPositionsTabPage::SupportAxisPositioning( bool bSupportAxisPositioning IMPL_LINK ( AxisPositionsTabPage, CrossesAtSelectHdl, void *, EMPTYARG ) { - USHORT nPos = m_aLB_CrossesAt.GetSelectEntryPos(); + sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos(); m_aED_CrossesAt.Show( (2==nPos) && !m_bCrossingAxisIsCategoryAxis ); m_aED_CrossesAtCategory.Show( (2==nPos) && m_bCrossingAxisIsCategoryAxis ); @@ -478,12 +478,12 @@ IMPL_LINK ( AxisPositionsTabPage, CrossesAtSelectHdl, void *, EMPTYARG ) IMPL_LINK ( AxisPositionsTabPage, PlaceLabelsSelectHdl, void *, EMPTYARG ) { - USHORT nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); + sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); bool bEnableTickmarkPlacement = (nLabelPos>1); if( bEnableTickmarkPlacement ) { - USHORT nAxisPos = m_aLB_CrossesAt.GetSelectEntryPos(); + sal_uInt16 nAxisPos = m_aLB_CrossesAt.GetSelectEntryPos(); if( nLabelPos-2 == nAxisPos ) bEnableTickmarkPlacement=false; } diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.hxx b/chart2/source/controller/dialogs/tp_AxisPositions.hxx index 0784a7854c5e..ba23268e6c38 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.hxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.hxx @@ -47,7 +47,7 @@ public: AxisPositionsTabPage( Window* pParent, const SfxItemSet& rInAttrs ); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); - virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual sal_Bool FillItemSet( SfxItemSet& rOutAttrs ); virtual void Reset( const SfxItemSet& rInAttrs ); using TabPage::DeactivatePage; virtual int DeactivatePage( SfxItemSet* pItemSet = NULL ); diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index ec6c1d2a1c10..0504ecee4161 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -228,7 +228,7 @@ void Dim3DLookResourceGroup::fillControls( const ChartTypeParameter& rParameter void Dim3DLookResourceGroup::fillParameter( ChartTypeParameter& rParameter ) { rParameter.b3DLook = m_aCB_3DLook.IsChecked(); - USHORT nPos = m_aLB_Scheme.GetSelectEntryPos(); + sal_uInt16 nPos = m_aLB_Scheme.GetSelectEntryPos(); if( POS_3DSCHEME_SIMPLE == nPos ) rParameter.eThreeDLookScheme = ThreeDLookScheme_Simple; else if( POS_3DSCHEME_REALISTIC == nPos ) @@ -707,7 +707,7 @@ IMPL_LINK( SplineResourceGroup, SplineDetailsDialogHdl, void*, EMPTYARG ) ChartTypeParameter aOldParameter; getSplinePropertiesDialog().fillParameter( aOldParameter, m_aCB_Splines.IsChecked() ); - BOOL bOldSmoothLines = m_aCB_Splines.IsChecked(); + sal_Bool bOldSmoothLines = m_aCB_Splines.IsChecked(); m_aCB_Splines.Check(); if( RET_OK == getSplinePropertiesDialog().Execute() ) { @@ -768,7 +768,7 @@ void GeometryResourceGroup::setPosition( const Point& rPoint ) void GeometryResourceGroup::fillControls( const ChartTypeParameter& rParameter ) { - USHORT nGeometry3D = static_cast(rParameter.nGeometry3D); + sal_uInt16 nGeometry3D = static_cast(rParameter.nGeometry3D); m_aGeometryResources.SelectEntryPos(nGeometry3D); m_aGeometryResources.Enable(rParameter.b3DLook); } @@ -1090,7 +1090,7 @@ void ChartTypeTabPage::fillAllControls( const ChartTypeParameter& rParameter, bo bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); m_pCurrentMainType->fillSubTypeList( m_aSubTypeList, bIsHighContrast, rParameter ); } - m_aSubTypeList.SelectItem( static_cast( rParameter.nSubTypeIndex) ); + m_aSubTypeList.SelectItem( static_cast( rParameter.nSubTypeIndex) ); m_pAxisTypeResourceGroup->fillControls( rParameter ); m_pDim3DLookResourceGroup->fillControls( rParameter ); m_pStackingResourceGroup->fillControls( rParameter ); @@ -1115,7 +1115,7 @@ void ChartTypeTabPage::initializePage() ::std::vector< ChartTypeDialogController* >::iterator aIter = m_aChartTypeDialogControllerList.begin(); const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end(); - for( USHORT nM=0; aIter != aEnd; aIter++, nM++ ) + for( sal_uInt16 nM=0; aIter != aEnd; aIter++, nM++ ) { if( (*aIter)->isSubType(aServiceName) ) { diff --git a/chart2/source/controller/dialogs/tp_DataLabel.cxx b/chart2/source/controller/dialogs/tp_DataLabel.cxx index 909c263ba83b..9b94ae18b7a6 100644 --- a/chart2/source/controller/dialogs/tp_DataLabel.cxx +++ b/chart2/source/controller/dialogs/tp_DataLabel.cxx @@ -54,7 +54,7 @@ SfxTabPage* DataLabelsTabPage::Create(Window* pWindow, return new DataLabelsTabPage(pWindow, rOutAttrs); } -BOOL DataLabelsTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool DataLabelsTabPage::FillItemSet(SfxItemSet& rOutAttrs) { return m_aDataLabelResources.FillItemSet(rOutAttrs); } diff --git a/chart2/source/controller/dialogs/tp_DataLabel.hxx b/chart2/source/controller/dialogs/tp_DataLabel.hxx index 25bdf977ef0e..9a3ac3cbd7c8 100644 --- a/chart2/source/controller/dialogs/tp_DataLabel.hxx +++ b/chart2/source/controller/dialogs/tp_DataLabel.hxx @@ -52,7 +52,7 @@ public: void SetNumberFormatter( SvNumberFormatter* pFormatter ); virtual void Reset(const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); private: DataLabelResources m_aDataLabelResources; diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index 70a478ea8c39..ed48747e5502 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -151,7 +151,7 @@ static long lcl_pRoleListBoxTabs[] = void lcl_ShowChooserButton( ::chart::RangeSelectionButton & rChooserButton, Edit & rEditField, - BOOL bShow ) + sal_Bool bShow ) { if( rChooserButton.IsVisible() != bShow ) { @@ -169,8 +169,8 @@ void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) { if( pDialog ) { - pDialog->Show( bEnable ? FALSE : TRUE ); - pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + pDialog->Show( bEnable ? sal_False : sal_True ); + pDialog->SetModalInputMode( bEnable ? sal_False : sal_True ); } } @@ -459,7 +459,7 @@ void DataSourceTabPage::updateControlsFromDialogModel() void DataSourceTabPage::fillSeriesListBox() { - m_apLB_SERIES->SetUpdateMode( FALSE ); + m_apLB_SERIES->SetUpdateMode( sal_False ); Reference< XDataSeries > xSelected; SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); @@ -511,7 +511,7 @@ void DataSourceTabPage::fillSeriesListBox() if( bHasSelectedEntry && pSelectedEntry ) m_apLB_SERIES->Select( pSelectedEntry ); - m_apLB_SERIES->SetUpdateMode( TRUE ); + m_apLB_SERIES->SetUpdateMode( sal_True ); } void DataSourceTabPage::fillRoleListBox() @@ -520,7 +520,7 @@ void DataSourceTabPage::fillRoleListBox() bool bHasSelectedEntry = (pSeriesEntry != 0); SvLBoxEntry * pRoleEntry = m_aLB_ROLE.FirstSelected(); - ULONG nRoleIndex = SAL_MAX_UINT32; + sal_uLong nRoleIndex = SAL_MAX_UINT32; if( pRoleEntry ) nRoleIndex = m_aLB_ROLE.GetModel()->GetAbsPos( pRoleEntry ); @@ -533,7 +533,7 @@ void DataSourceTabPage::fillRoleListBox() pSeriesEntry->m_xChartType )); // fill role list - m_aLB_ROLE.SetUpdateMode( FALSE ); + m_aLB_ROLE.SetUpdateMode( sal_False ); m_aLB_ROLE.Clear(); m_aLB_ROLE.RemoveSelection(); @@ -551,7 +551,7 @@ void DataSourceTabPage::fillRoleListBox() m_aLB_ROLE.Select( m_aLB_ROLE.GetEntry( nRoleIndex )); } - m_aLB_ROLE.SetUpdateMode( TRUE ); + m_aLB_ROLE.SetUpdateMode( sal_True ); } } @@ -578,7 +578,7 @@ void DataSourceTabPage::updateControlState() m_aFT_DATALABELS.Show(!bHasCategories); m_aFT_CATEGORIES.Show( bHasCategories); - BOOL bShowIB = bHasRangeChooser; + sal_Bool bShowIB = bHasRangeChooser; lcl_ShowChooserButton( m_aIMB_RANGE_CAT, m_aEDT_CATEGORIES, bShowIB ); m_aFT_SERIES.Enable(); diff --git a/chart2/source/controller/dialogs/tp_DataSource.hxx b/chart2/source/controller/dialogs/tp_DataSource.hxx index e65b503bfcc2..f7826ef744e5 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.hxx +++ b/chart2/source/controller/dialogs/tp_DataSource.hxx @@ -126,12 +126,12 @@ protected: ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelectionListener > getSelectionRangeListener(); - /** @return , if the edit field contains a valid range entry. if no - XCellRangesAccess can be obtained, is returned. + /** @return , if the edit field contains a valid range entry. if no + XCellRangesAccess can be obtained, is returned. */ bool isRangeFieldContentValid( Edit & rEdit ); - /** @return , if the tab-page is in a consistent (commitable) state + /** @return , if the tab-page is in a consistent (commitable) state */ bool isValid(); void setDirty(); diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.cxx b/chart2/source/controller/dialogs/tp_ErrorBars.cxx index 395c956372ea..71c843dfb313 100644 --- a/chart2/source/controller/dialogs/tp_ErrorBars.cxx +++ b/chart2/source/controller/dialogs/tp_ErrorBars.cxx @@ -61,7 +61,7 @@ SfxTabPage* ErrorBarsTabPage::Create( return new ErrorBarsTabPage( pParent, rOutAttrs ); } -BOOL ErrorBarsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +sal_Bool ErrorBarsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) { return m_aErrorBarResources.FillItemSet( rOutAttrs ); } diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.hxx b/chart2/source/controller/dialogs/tp_ErrorBars.hxx index f6d6779d34a9..ec33c66108a9 100644 --- a/chart2/source/controller/dialogs/tp_ErrorBars.hxx +++ b/chart2/source/controller/dialogs/tp_ErrorBars.hxx @@ -49,7 +49,7 @@ public: ::com::sun::star::chart2::XChartDocument > & xChartDocument ); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); - virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual sal_Bool FillItemSet( SfxItemSet& rOutAttrs ); virtual void Reset( const SfxItemSet& rInAttrs ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx index e3d23366a820..e08bd83f869d 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -64,14 +64,14 @@ SfxTabPage* SchLegendPosTabPage::Create(Window* pWindow, return new SchLegendPosTabPage(pWindow, rOutAttrs); } -BOOL SchLegendPosTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool SchLegendPosTabPage::FillItemSet(SfxItemSet& rOutAttrs) { m_apLegendPositionResources->writeToItemSet(rOutAttrs); if( m_aLbTextDirection.GetSelectEntryCount() > 0 ) rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) ); - return TRUE; + return sal_True; } void SchLegendPosTabPage::Reset(const SfxItemSet& rInAttrs) @@ -79,7 +79,7 @@ void SchLegendPosTabPage::Reset(const SfxItemSet& rInAttrs) m_apLegendPositionResources->initFromItemSet(rInAttrs); const SfxPoolItem* pPoolItem = 0; - if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET ) m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); } diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx index 4c0e7ce545d7..479a3993aa19 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx @@ -57,7 +57,7 @@ public: virtual ~SchLegendPosTabPage(); static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); virtual void Reset(const SfxItemSet& rInAttrs); }; diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx b/chart2/source/controller/dialogs/tp_PointGeometry.cxx index 661bae6ac326..298ae43ef8d6 100644 --- a/chart2/source/controller/dialogs/tp_PointGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx @@ -66,7 +66,7 @@ SfxTabPage* SchLayoutTabPage::Create(Window* pWindow, return new SchLayoutTabPage(pWindow, rOutAttrs); } -BOOL SchLayoutTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool SchLayoutTabPage::FillItemSet(SfxItemSet& rOutAttrs) { if(m_pGeometryResources && m_pGeometryResources->GetSelectEntryCount()) @@ -81,19 +81,19 @@ BOOL SchLayoutTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxInt32Item(SCHATTR_STYLE_SHAPE,nShape)); rOutAttrs.Put(Svx3DHorizontalSegmentsItem(nSegs)); } - return TRUE; + return sal_True; } void SchLayoutTabPage::Reset(const SfxItemSet& rInAttrs) { const SfxPoolItem *pPoolItem = NULL; - if (rInAttrs.GetItemState(SCHATTR_STYLE_SHAPE,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_STYLE_SHAPE,sal_True, &pPoolItem) == SFX_ITEM_SET) { long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); if(m_pGeometryResources) { - m_pGeometryResources->SelectEntryPos(static_cast(nVal)); + m_pGeometryResources->SelectEntryPos(static_cast(nVal)); m_pGeometryResources->Show( true ); } } diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.hxx b/chart2/source/controller/dialogs/tp_PointGeometry.hxx index d26ce62732eb..a18c3a945254 100644 --- a/chart2/source/controller/dialogs/tp_PointGeometry.hxx +++ b/chart2/source/controller/dialogs/tp_PointGeometry.hxx @@ -43,7 +43,7 @@ public: virtual ~SchLayoutTabPage(); static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); virtual void Reset(const SfxItemSet& rInAttrs); private: diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.cxx b/chart2/source/controller/dialogs/tp_PolarOptions.cxx index 9a193c028e05..b682cd304762 100644 --- a/chart2/source/controller/dialogs/tp_PolarOptions.cxx +++ b/chart2/source/controller/dialogs/tp_PolarOptions.cxx @@ -65,7 +65,7 @@ SfxTabPage* PolarOptionsTabPage::Create( Window* pWindow,const SfxItemSet& rOutA return new PolarOptionsTabPage( pWindow, rOutAttrs ); } -BOOL PolarOptionsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +sal_Bool PolarOptionsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) { if( m_aAngleDial.IsVisible() ) { @@ -79,7 +79,7 @@ BOOL PolarOptionsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) if (m_aCB_IncludeHiddenCells.IsVisible()) rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCB_IncludeHiddenCells.IsChecked())); - return TRUE; + return sal_True; } void PolarOptionsTabPage::Reset(const SfxItemSet& rInAttrs) @@ -87,7 +87,7 @@ void PolarOptionsTabPage::Reset(const SfxItemSet& rInAttrs) const SfxPoolItem *pPoolItem = NULL; long nTmp; - if (rInAttrs.GetItemState(SCHATTR_STARTING_ANGLE, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_STARTING_ANGLE, sal_True, &pPoolItem) == SFX_ITEM_SET) { nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); @@ -95,29 +95,29 @@ void PolarOptionsTabPage::Reset(const SfxItemSet& rInAttrs) } else { - m_aFL_StartingAngle.Show(FALSE); - m_aAngleDial.Show(FALSE); - m_aNF_StartingAngle.Show(FALSE); - m_aFT_Degrees.Show(FALSE); + m_aFL_StartingAngle.Show(sal_False); + m_aAngleDial.Show(sal_False); + m_aNF_StartingAngle.Show(sal_False); + m_aFT_Degrees.Show(sal_False); } - if (rInAttrs.GetItemState(SCHATTR_CLOCKWISE, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_CLOCKWISE, sal_True, &pPoolItem) == SFX_ITEM_SET) { - BOOL bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + sal_Bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); m_aCB_Clockwise.Check(bCheck); } else { - m_aCB_Clockwise.Show(FALSE); + m_aCB_Clockwise.Show(sal_False); } - if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True, &pPoolItem) == SFX_ITEM_SET) { bool bVal = static_cast(pPoolItem)->GetValue(); m_aCB_IncludeHiddenCells.Check(bVal); } else { - m_aCB_IncludeHiddenCells.Show(FALSE); - m_aFL_PlotOptions.Show(FALSE); + m_aCB_IncludeHiddenCells.Show(sal_False); + m_aFL_PlotOptions.Show(sal_False); } } diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.hxx b/chart2/source/controller/dialogs/tp_PolarOptions.hxx index 1465790c34bd..3ac1c70c2736 100644 --- a/chart2/source/controller/dialogs/tp_PolarOptions.hxx +++ b/chart2/source/controller/dialogs/tp_PolarOptions.hxx @@ -46,7 +46,7 @@ public: virtual ~PolarOptionsTabPage(); static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); virtual void Reset(const SfxItemSet& rInAttrs); private: diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 3ba6ca0f74b2..c2632d4be2e1 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -48,7 +48,7 @@ namespace void lcl_ShowChooserButton( ::chart::RangeSelectionButton & rChooserButton, Edit & rEditField, - BOOL bShow ) + sal_Bool bShow ) { if( rChooserButton.IsVisible() != bShow ) { @@ -65,8 +65,8 @@ void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) { if( pDialog ) { - pDialog->Show( bEnable ? FALSE : TRUE ); - pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + pDialog->Show( bEnable ? sal_False : sal_True ); + pDialog->SetModalInputMode( bEnable ? sal_False : sal_True ); } } void lcl_shiftControlY( Control & rControl, long nYOffset ) @@ -341,7 +341,7 @@ bool RangeChooserTabPage::isValid() m_aCB_FirstRowAsLabel.Enable( bIsValid ); m_aCB_FirstColumnAsLabel.Enable( bIsValid ); } - BOOL bShowIB = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); + sal_Bool bShowIB = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); lcl_ShowChooserButton( m_aIB_Range, m_aED_Range, bShowIB ); return bIsValid; diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 34fc0702bafe..7d1fd9b7e026 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -252,7 +252,7 @@ SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) return new ScaleTabPage(pWindow, rOutAttrs); } -BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) { DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); @@ -270,7 +270,7 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); - return TRUE; + return sal_True; } void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) @@ -281,52 +281,52 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) const SfxPoolItem *pPoolItem = NULL; nAxisType=chart2::AxisType::REALNUMBER; - if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, sal_True, &pPoolItem) == SFX_ITEM_SET) { nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); EnableControls(); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,sal_True,&pPoolItem) == SFX_ITEM_SET) aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,sal_True, &pPoolItem) == SFX_ITEM_SET) { fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldMin.SetValue( fMin ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxAutoMax.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET) { fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldMax.SetValue( fMax ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxAutoStepMain.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET) { fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldStepMain.SetValue( fStepMain ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxLogarithm.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxReverse.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET) { nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue(); aMtStepHelp.SetValue( nStepHelp ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET) aCbxAutoOrigin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET) { fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldOrigin.SetValue( fOrigin ); @@ -349,7 +349,7 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); const SfxPoolItem *pPoolItem = NULL; - if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); else { @@ -357,7 +357,7 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) } Edit* pEdit = NULL; - USHORT nErrStrId = 0; + sal_uInt16 nErrStrId = 0; double fDummy; fMax = aFmtFldMax.GetValue(); @@ -457,9 +457,9 @@ void ScaleTabPage::SetNumFormat() { const SfxPoolItem *pPoolItem = NULL; - if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) { - ULONG nFmt = (ULONG)((const SfxInt32Item*)pPoolItem)->GetValue(); + sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue(); aFmtFldMax.SetFormatKey( nFmt ); aFmtFldMin.SetFormatKey( nFmt ); @@ -499,7 +499,7 @@ void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) m_bShowAxisOrigin = true; } -bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ ) +bool ScaleTabPage::ShowWarning( sal_uInt16 nResIdMessage, Edit * pControl /* = NULL */ ) { if( nResIdMessage == 0 ) return false; diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 8d0e02186c38..2ae2d8290f86 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -49,7 +49,7 @@ public: ScaleTabPage( Window* pParent, const SfxItemSet& rInAttrs ); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); - virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual sal_Bool FillItemSet( SfxItemSet& rOutAttrs ); virtual void Reset( const SfxItemSet& rInAttrs ); using TabPage::DeactivatePage; virtual int DeactivatePage( SfxItemSet* pItemSet = NULL ); @@ -115,7 +115,7 @@ private: @return false, if nResIdMessage was 0, true otherwise */ - bool ShowWarning( USHORT nResIdMessage, Edit * pControl = NULL ); + bool ShowWarning( sal_uInt16 nResIdMessage, Edit * pControl = NULL ); }; //............................................................................. diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx index fbe2f4bf1907..aec48d5e6ce7 100644 --- a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx @@ -96,7 +96,7 @@ SfxTabPage* SchOptionTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs return new SchOptionTabPage(pWindow, rOutAttrs); } -BOOL SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs) { if(aRbtAxis2.IsChecked()) rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y)); @@ -127,113 +127,113 @@ BOOL SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs) if (m_aCBIncludeHiddenCells.IsVisible()) rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCBIncludeHiddenCells.IsChecked())); - return TRUE; + return sal_True; } void SchOptionTabPage::Reset(const SfxItemSet& rInAttrs) { const SfxPoolItem *pPoolItem = NULL; - aRbtAxis1.Check(TRUE); - aRbtAxis2.Check(FALSE); - if (rInAttrs.GetItemState(SCHATTR_AXIS,TRUE, &pPoolItem) == SFX_ITEM_SET) + aRbtAxis1.Check(sal_True); + aRbtAxis2.Check(sal_False); + if (rInAttrs.GetItemState(SCHATTR_AXIS,sal_True, &pPoolItem) == SFX_ITEM_SET) { long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); if(nVal==CHART_AXIS_SECONDARY_Y) { - aRbtAxis2.Check(TRUE); - aRbtAxis1.Check(FALSE); + aRbtAxis2.Check(sal_True); + aRbtAxis1.Check(sal_False); } } long nTmp; - if (rInAttrs.GetItemState(SCHATTR_BAR_GAPWIDTH, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_BAR_GAPWIDTH, sal_True, &pPoolItem) == SFX_ITEM_SET) { nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); aMTGap.SetValue(nTmp); } - if (rInAttrs.GetItemState(SCHATTR_BAR_OVERLAP, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_BAR_OVERLAP, sal_True, &pPoolItem) == SFX_ITEM_SET) { nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); aMTOverlap.SetValue(nTmp); } - if (rInAttrs.GetItemState(SCHATTR_BAR_CONNECT, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_BAR_CONNECT, sal_True, &pPoolItem) == SFX_ITEM_SET) { - BOOL bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + sal_Bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); aCBConnect.Check(bCheck); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, sal_True, &pPoolItem) == SFX_ITEM_SET) { m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); aCBAxisSideBySide.Disable(); } - if (rInAttrs.GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) { // model property is "group bars per axis", UI feature is the other way // round: "show bars side by side" - BOOL bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + sal_Bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); aCBAxisSideBySide.Check( bCheck ); } else { - aCBAxisSideBySide.Show(FALSE); + aCBAxisSideBySide.Show(sal_False); } //missing value treatment { ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments; - if( rInAttrs.GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( rInAttrs.GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, sal_True, &pPoolItem) == SFX_ITEM_SET ) aMissingValueTreatments =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); - if ( aMissingValueTreatments.getLength()>1 && rInAttrs.GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,TRUE, &pPoolItem) == SFX_ITEM_SET) + if ( aMissingValueTreatments.getLength()>1 && rInAttrs.GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,sal_True, &pPoolItem) == SFX_ITEM_SET) { - m_aRB_DontPaint.Enable(FALSE); - m_aRB_AssumeZero.Enable(FALSE); - m_aRB_ContinueLine.Enable(FALSE); + m_aRB_DontPaint.Enable(sal_False); + m_aRB_AssumeZero.Enable(sal_False); + m_aRB_ContinueLine.Enable(sal_False); for( sal_Int32 nN =0; nNGetValue(); if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP) - m_aRB_DontPaint.Check(TRUE); + m_aRB_DontPaint.Check(sal_True); else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO) - m_aRB_AssumeZero.Check(TRUE); + m_aRB_AssumeZero.Check(sal_True); else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE) - m_aRB_ContinueLine.Check(TRUE); + m_aRB_ContinueLine.Check(sal_True); } else { - m_aFT_MissingValues.Show(FALSE); - m_aRB_DontPaint.Show(FALSE); - m_aRB_AssumeZero.Show(FALSE); - m_aRB_ContinueLine.Show(FALSE); + m_aFT_MissingValues.Show(sal_False); + m_aRB_DontPaint.Show(sal_False); + m_aRB_AssumeZero.Show(sal_False); + m_aRB_ContinueLine.Show(sal_False); } } // Include hidden cells - if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True, &pPoolItem) == SFX_ITEM_SET) { bool bVal = static_cast(pPoolItem)->GetValue(); m_aCBIncludeHiddenCells.Check(bVal); } else { - m_aCBIncludeHiddenCells.Show(FALSE); + m_aCBIncludeHiddenCells.Show(sal_False); if(!m_aFT_MissingValues.IsVisible()) - m_aFL_PlotOptions.Show(FALSE); + m_aFL_PlotOptions.Show(sal_False); } AdaptControlPositionsAndVisibility(); @@ -275,7 +275,7 @@ void SchOptionTabPage::AdaptControlPositionsAndVisibility() if( !aMTGap.IsVisible() && !aMTOverlap.IsVisible() ) { - aGrpBar.Show(FALSE); + aGrpBar.Show(sal_False); Point aPos; if( !aRbtAxis1.IsVisible() && !aRbtAxis2.IsVisible() ) aPos = aGrpAxis.GetPosPixel(); diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx index 63caf2885910..86a5280a00aa 100644 --- a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx @@ -50,7 +50,7 @@ public: virtual ~SchOptionTabPage(); static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); virtual void Reset(const SfxItemSet& rInAttrs); void Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors ); diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx b/chart2/source/controller/dialogs/tp_TitleRotation.cxx index 5b1d5647dc6c..9d87f4979ebc 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.cxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx @@ -58,7 +58,7 @@ SchAlignmentTabPage::SchAlignmentTabPage(Window* pWindow, { FreeResource(); - aCbStacked.EnableTriState( FALSE ); + aCbStacked.EnableTriState( sal_False ); aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK ); if( !bWithRotation ) @@ -88,7 +88,7 @@ SfxTabPage* SchAlignmentTabPage::CreateWithoutRotation(Window* pParent, return new SchAlignmentTabPage(pParent, rInAttrs, false); } -BOOL SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs) +sal_Bool SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs) { //Seit 4/1998 koennen Texte frei gedreht werden: SCHATTR_TEXT_DEGREES bool bStacked = aOrientHlp.GetStackedState() == STATE_CHECK; @@ -100,7 +100,7 @@ BOOL SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs) SvxFrameDirection aDirection( aLbTextDirection.GetSelectEntryValue() ); rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, aDirection ) ); - return TRUE; + return sal_True; } void SchAlignmentTabPage::Reset(const SfxItemSet& rInAttrs) @@ -115,7 +115,7 @@ void SchAlignmentTabPage::Reset(const SfxItemSet& rInAttrs) aOrientHlp.SetStackedState( bStacked ? STATE_CHECK : STATE_NOCHECK ); - if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, TRUE, &pItem) == SFX_ITEM_SET) + if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, sal_True, &pItem) == SFX_ITEM_SET) aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pItem)->GetValue()) ); } diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.hxx b/chart2/source/controller/dialogs/tp_TitleRotation.hxx index e02b0f29078d..ae782a792864 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.hxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.hxx @@ -58,7 +58,7 @@ public: static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); static SfxTabPage* CreateWithoutRotation(Window* pParent, const SfxItemSet& rInAttrs); - virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual sal_Bool FillItemSet(SfxItemSet& rOutAttrs); virtual void Reset(const SfxItemSet& rInAttrs); }; diff --git a/chart2/source/controller/dialogs/tp_Trendline.cxx b/chart2/source/controller/dialogs/tp_Trendline.cxx index 31b35b24a5b4..f336a620c8a4 100644 --- a/chart2/source/controller/dialogs/tp_Trendline.cxx +++ b/chart2/source/controller/dialogs/tp_Trendline.cxx @@ -54,7 +54,7 @@ SfxTabPage* TrendlineTabPage::Create( return new TrendlineTabPage( pParent, rOutAttrs ); } -BOOL TrendlineTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +sal_Bool TrendlineTabPage::FillItemSet( SfxItemSet& rOutAttrs ) { return m_aTrendlineResources.FillItemSet( rOutAttrs ); } diff --git a/chart2/source/controller/dialogs/tp_Trendline.hxx b/chart2/source/controller/dialogs/tp_Trendline.hxx index f1c6eb5609fd..bd7f97a3c8e8 100644 --- a/chart2/source/controller/dialogs/tp_Trendline.hxx +++ b/chart2/source/controller/dialogs/tp_Trendline.hxx @@ -43,7 +43,7 @@ public: virtual ~TrendlineTabPage (); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); - virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual sal_Bool FillItemSet( SfxItemSet& rOutAttrs ); virtual void Reset( const SfxItemSet& rInAttrs ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index 9da7f7536d28..102393dd59f8 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -126,7 +126,7 @@ void lcl_initOutliner( SdrOutliner* pTargetOutliner, SdrOutliner* pSourceOutline //if( bInit ) { pTargetOutliner->EraseVirtualDevice(); - pTargetOutliner->SetUpdateMode(FALSE); + pTargetOutliner->SetUpdateMode(sal_False); pTargetOutliner->SetEditTextObjectPool( pSourceOutliner->GetEditTextObjectPool() ); pTargetOutliner->SetDefTab( pSourceOutliner->GetDefTab() ); } @@ -140,7 +140,7 @@ void lcl_initOutliner( SdrOutliner* pTargetOutliner, SdrOutliner* pSourceOutline pTargetOutliner->SetDefaultLanguage( pSourceOutliner->GetDefaultLanguage() ); pTargetOutliner->SetHyphenator( pSourceOutliner->GetHyphenator() ); - USHORT nX, nY; + sal_uInt16 nX, nY; pSourceOutliner->GetGlobalCharStretching( nX, nY ); pTargetOutliner->SetGlobalCharStretching( nX, nY ); @@ -234,8 +234,8 @@ void DrawViewWrapper::SetMarkHandles() SdrObject* DrawViewWrapper::getHitObject( const Point& rPnt ) const { SdrObject* pRet = NULL; - //ULONG nOptions =SDRSEARCH_DEEP|SDRSEARCH_PASS2BOUND|SDRSEARCH_PASS3NEAREST; - ULONG nOptions = SDRSEARCH_DEEP | SDRSEARCH_TESTMARKABLE; + //sal_uLong nOptions =SDRSEARCH_DEEP|SDRSEARCH_PASS2BOUND|SDRSEARCH_PASS3NEAREST; + sal_uLong nOptions = SDRSEARCH_DEEP | SDRSEARCH_TESTMARKABLE; SdrPageView* pSdrPageView = this->GetPageView(); this->SdrView::PickObj(rPnt, lcl_getHitTolerance( this->GetFirstOutputDevice() ), pRet, pSdrPageView, nOptions); diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx index 755058050a2d..eb2168e07d8f 100644 --- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx +++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx @@ -181,7 +181,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co aVDev.SetMapMode(MapMode(MAP_100TH_MM)); SdrModel* pModel = new SdrModel(); pModel->GetItemPool().FreezeIdRanges(); - SdrPage* pPage = new SdrPage( *pModel, FALSE ); + SdrPage* pPage = new SdrPage( *pModel, sal_False ); pPage->SetSize(Size(1000,1000)); pModel->InsertPage( pPage, 0 ); SdrView* pView = new SdrView( pModel, &aVDev ); @@ -224,7 +224,7 @@ FontList* ViewElementListProvider::getFontList() const OutputDevice* pDefaultOut = Application::GetDefaultDevice(); // #67730# m_pFontList = new FontList( pRefDev ? pRefDev : pDefaultOut , pRefDev ? pDefaultOut : NULL - , FALSE ); + , sal_False ); } return m_pFontList; } @@ -243,14 +243,14 @@ SfxPrinter* ObjectPropertiesDialogParameter::getPrinter() bool bOwnPrinter = true; if (!pPrinter) { - SfxBoolItem aItem(SID_PRINTER_NOTFOUND_WARN, TRUE); + SfxBoolItem aItem(SID_PRINTER_NOTFOUND_WARN, sal_True); // ItemSet mit speziellem Poolbereich anlegen SfxItemSet* pSet = new SfxItemSet(GetPool(), SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 0); pSet->Put(aItem); pPrinter = new SfxPrinter(pSet); //@todo ->need to remember and delete - bOwnPrinter = TRUE; + bOwnPrinter = sal_True; MapMode aMapMode = pPrinter->GetMapMode(); aMapMode.SetMapUnit(MAP_100TH_MM); diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 7c8f83452963..e26cd22060d1 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -65,12 +65,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx index d2590c37759c..e77323831b3d 100644 --- a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx @@ -59,12 +59,12 @@ public: virtual ~CharacterPropertyItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index d738cf8f6245..12cabb55c79c 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -81,12 +81,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/DrawViewWrapper.hxx b/chart2/source/controller/inc/DrawViewWrapper.hxx index 1dbdf6a85a53..4251dbef077e 100644 --- a/chart2/source/controller/inc/DrawViewWrapper.hxx +++ b/chart2/source/controller/inc/DrawViewWrapper.hxx @@ -69,11 +69,11 @@ public: SdrPageView* GetPageView() const; SdrObject* getHitObject( const Point& rPnt ) const; - //BOOL PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions, SdrObject** ppRootObj, ULONG* pnMarkNum=NULL, USHORT* pnPassNum=NULL) const; - //BOOL PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions=0) const; - //BOOL PickObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions=0) const { return PickObj(rPnt,nHitTolLog,rpObj,rpPV,nOptions); } + //sal_Bool PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uLong nOptions, SdrObject** ppRootObj, sal_uLong* pnMarkNum=NULL, sal_uInt16* pnPassNum=NULL) const; + //sal_Bool PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uLong nOptions=0) const; + //sal_Bool PickObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uLong nOptions=0) const { return PickObj(rPnt,nHitTolLog,rpObj,rpPV,nOptions); } - //void MarkObj(SdrObject* pObj, SdrPageView* pPV, BOOL bUnmark=FALSE, BOOL bImpNoSetMarkHdl=FALSE); + //void MarkObj(SdrObject* pObj, SdrPageView* pPV, sal_Bool bUnmark=sal_False, sal_Bool bImpNoSetMarkHdl=sal_False); void MarkObject( SdrObject* pObj ); //---------------------- diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx index 9dffde68cd5b..adedf29bf5bb 100755 --- a/chart2/source/controller/inc/ErrorBarItemConverter.hxx +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -63,12 +63,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx index c10e1d4e5b86..8e01ceaa28b0 100644 --- a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx @@ -63,12 +63,12 @@ public: virtual ~GraphicPropertyItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/ItemConverter.hxx b/chart2/source/controller/inc/ItemConverter.hxx index 2f52e45f070c..f803934c7f1a 100644 --- a/chart2/source/controller/inc/ItemConverter.hxx +++ b/chart2/source/controller/inc/ItemConverter.hxx @@ -89,9 +89,9 @@ public: // typedefs ------------------------------- - typedef USHORT tWhichIdType; + typedef sal_uInt16 tWhichIdType; typedef ::rtl::OUString tPropertyNameType; - typedef BYTE tMemberIdType; + typedef sal_uInt8 tMemberIdType; typedef ::std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId; @@ -133,7 +133,7 @@ protected: /** implement this method to provide an array of which-ranges of the form: - const USHORT aMyPairs[] = + const sal_uInt16 aMyPairs[] = { from_1, to_1, from_2, to_2, @@ -142,7 +142,7 @@ protected: 0 }; */ - virtual const USHORT * GetWhichPairs() const = 0; + virtual const sal_uInt16 * GetWhichPairs() const = 0; /** implement this method to return a Property object for a given which id. @@ -161,7 +161,7 @@ protected: The default implementation does nothing except showing an assertion */ - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); /** for items that can not be mapped directly to a property. @@ -173,7 +173,7 @@ protected: @return true if the item changed a property, false otherwise. */ - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); // ________ diff --git a/chart2/source/controller/inc/LegendItemConverter.hxx b/chart2/source/controller/inc/LegendItemConverter.hxx index b1b0bcdeea75..897cf1c691da 100644 --- a/chart2/source/controller/inc/LegendItemConverter.hxx +++ b/chart2/source/controller/inc/LegendItemConverter.hxx @@ -60,12 +60,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/MultipleChartConverters.hxx b/chart2/source/controller/inc/MultipleChartConverters.hxx index 9b0555ec82e1..1535f8af4405 100644 --- a/chart2/source/controller/inc/MultipleChartConverters.hxx +++ b/chart2/source/controller/inc/MultipleChartConverters.hxx @@ -55,7 +55,7 @@ public: virtual ~AllAxisItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; class AllGridItemConverter : public ::comphelper::MultipleItemConverter @@ -71,7 +71,7 @@ public: virtual ~AllGridItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; class AllDataLabelItemConverter : public ::comphelper::MultipleItemConverter @@ -89,7 +89,7 @@ public: virtual ~AllDataLabelItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; class AllTitleItemConverter : public ::comphelper::MultipleItemConverter @@ -107,7 +107,7 @@ public: virtual ~AllTitleItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; class AllSeriesStatisticsConverter : public ::comphelper::MultipleItemConverter @@ -120,7 +120,7 @@ public: virtual ~AllSeriesStatisticsConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; } // namespace wrapper diff --git a/chart2/source/controller/inc/MultipleItemConverter.hxx b/chart2/source/controller/inc/MultipleItemConverter.hxx index 32c48ca8e7db..e7c0f3ce31bd 100644 --- a/chart2/source/controller/inc/MultipleItemConverter.hxx +++ b/chart2/source/controller/inc/MultipleItemConverter.hxx @@ -36,7 +36,7 @@ namespace comphelper { -/** Note: virtual const USHORT * GetWhichPairs() const; is still pure virtual +/** Note: virtual const sal_uInt16 * GetWhichPairs() const; is still pure virtual */ class MultipleItemConverter : public ItemConverter { diff --git a/chart2/source/controller/inc/RegressionCurveItemConverter.hxx b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx index ab2d29cb5e0d..fa5c0b6b41c5 100644 --- a/chart2/source/controller/inc/RegressionCurveItemConverter.hxx +++ b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx @@ -61,12 +61,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/RegressionEquationItemConverter.hxx b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx index 5fe5313c8d4a..29b092788bf0 100644 --- a/chart2/source/controller/inc/RegressionEquationItemConverter.hxx +++ b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx @@ -64,12 +64,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx index 207a6ab7f0ee..051c581bfdd4 100644 --- a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx +++ b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx @@ -54,12 +54,12 @@ public: virtual ~SeriesOptionsItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx index cb4227185093..6fe72d90a4f3 100644 --- a/chart2/source/controller/inc/StatisticsItemConverter.hxx +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -55,12 +55,12 @@ public: virtual ~StatisticsItemConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/TitleItemConverter.hxx b/chart2/source/controller/inc/TitleItemConverter.hxx index 535e36226a12..2f382a9483ce 100644 --- a/chart2/source/controller/inc/TitleItemConverter.hxx +++ b/chart2/source/controller/inc/TitleItemConverter.hxx @@ -61,12 +61,12 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/dlg_DataEditor.hxx b/chart2/source/controller/inc/dlg_DataEditor.hxx index e5cd252df69d..5f985d8f55d1 100644 --- a/chart2/source/controller/inc/dlg_DataEditor.hxx +++ b/chart2/source/controller/inc/dlg_DataEditor.hxx @@ -62,7 +62,7 @@ public: virtual void Resize(); // Dialog - virtual BOOL Close(); + virtual sal_Bool Close(); void SetReadOnly( bool bReadOnly ); bool ApplyChangesToModel(); diff --git a/chart2/source/controller/inc/dlg_DataSource.hxx b/chart2/source/controller/inc/dlg_DataSource.hxx index f94c95b33370..732b1532ad64 100644 --- a/chart2/source/controller/inc/dlg_DataSource.hxx +++ b/chart2/source/controller/inc/dlg_DataSource.hxx @@ -91,7 +91,7 @@ private: bool m_bRangeChooserTabIsValid; bool m_bDataSourceTabIsValid; - static USHORT m_nLastPageId; + static sal_uInt16 m_nLastPageId; }; } // namespace chart diff --git a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx index 5ed06d365fa2..5d084d7d68b3 100644 --- a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx +++ b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx @@ -75,7 +75,7 @@ protected: HelpButton aPbHelp; public: - SchAxisDlg( Window* pParent, const InsertAxisOrGridDialogData& rInput, BOOL bAxisDlg=true ); + SchAxisDlg( Window* pParent, const InsertAxisOrGridDialogData& rInput, sal_Bool bAxisDlg=true ); virtual ~SchAxisDlg(); void getResult( InsertAxisOrGridDialogData& rOutput ); diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx index 8ceabdbe33b7..9b232b944691 100644 --- a/chart2/source/controller/inc/dlg_ObjectProperties.hxx +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -111,8 +111,8 @@ class SchAttribTabDlg : public SfxTabDialog private: ObjectType eObjectType; bool bAffectsMultipleObjects;//is true if more than one object of the given type will be changed (e.g. all axes or all titles) - USHORT nDlgType; - USHORT nPageType; + sal_uInt16 nDlgType; + sal_uInt16 nPageType; const ObjectPropertiesDialogParameter * const m_pParameter; const ViewElementListProvider* const m_pViewElementListProvider; @@ -124,7 +124,7 @@ private: double m_fAxisMinorStepWidthForErrorBarDecimals; bool m_bOKPressed; - virtual void PageCreated(USHORT nId, SfxTabPage& rPage); + virtual void PageCreated(sal_uInt16 nId, SfxTabPage& rPage); Link m_aOriginalOKClickHdl; DECL_LINK( OKPressed, void * ); diff --git a/chart2/source/controller/inc/dlg_ShapeFont.hxx b/chart2/source/controller/inc/dlg_ShapeFont.hxx index ec1b6553bd64..a84dac07ec43 100644 --- a/chart2/source/controller/inc/dlg_ShapeFont.hxx +++ b/chart2/source/controller/inc/dlg_ShapeFont.hxx @@ -46,7 +46,7 @@ public: virtual ~ShapeFontDialog(); private: - virtual void PageCreated( USHORT nId, SfxTabPage& rPage ); + virtual void PageCreated( sal_uInt16 nId, SfxTabPage& rPage ); const ViewElementListProvider* m_pViewElementListProvider; }; diff --git a/chart2/source/controller/inc/dlg_ShapeParagraph.hxx b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx index 2bc57bfcffc2..cb1c250694eb 100644 --- a/chart2/source/controller/inc/dlg_ShapeParagraph.hxx +++ b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx @@ -43,7 +43,7 @@ public: virtual ~ShapeParagraphDialog(); private: - virtual void PageCreated( USHORT nId, SfxTabPage& rPage ); + virtual void PageCreated( sal_uInt16 nId, SfxTabPage& rPage ); }; //............................................................................. diff --git a/chart2/source/controller/inc/dlg_View3D.hxx b/chart2/source/controller/inc/dlg_View3D.hxx index 91b16d3512d8..0cc5024683ff 100644 --- a/chart2/source/controller/inc/dlg_View3D.hxx +++ b/chart2/source/controller/inc/dlg_View3D.hxx @@ -74,7 +74,7 @@ private: ControllerLockHelper m_aControllerLocker; - static USHORT m_nLastPageId; + static sal_uInt16 m_nLastPageId; }; //............................................................................. diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index 0b5f33b5c128..e428c9c9b581 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -73,7 +73,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDocument ); void Reset(const SfxItemSet& rInAttrs); - BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + sal_Bool FillItemSet(SfxItemSet& rOutAttrs) const; void FillValueSets(); diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 8cf07aabad08..d2b0d6f9c737 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -143,7 +143,7 @@ bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * AxisItemConverter::GetWhichPairs() const +const sal_uInt16 * AxisItemConverter::GetWhichPairs() const { // must span all used items! return nAxisWhichPairs; @@ -162,7 +162,7 @@ bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWit return true; } -void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const +void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { if( ! m_xAxis.is() ) @@ -217,7 +217,7 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS case SCHATTR_AXIS_LOGARITHM: { - BOOL bValue = AxisHelper::isLogarithmic( aScale.Scaling ); + sal_Bool bValue = AxisHelper::isLogarithmic( aScale.Scaling ); rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); } break; @@ -396,7 +396,7 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS } } -bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) +bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { if( !m_xAxis.is() ) diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx index 3382ae1ff085..aa50b1fc41df 100644 --- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -111,7 +111,7 @@ CharacterPropertyItemConverter::CharacterPropertyItemConverter( CharacterPropertyItemConverter::~CharacterPropertyItemConverter() {} -const USHORT * CharacterPropertyItemConverter::GetWhichPairs() const +const sal_uInt16 * CharacterPropertyItemConverter::GetWhichPairs() const { return nCharacterPropertyWhichPairs; } @@ -129,7 +129,7 @@ bool CharacterPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPr } void CharacterPropertyItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) @@ -297,7 +297,7 @@ void CharacterPropertyItemConverter::FillSpecialItem( } bool CharacterPropertyItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 14590b6f6f9c..01b71c87d5fd 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -108,13 +108,13 @@ sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol ) return nStyle; } -bool lcl_NumberFormatFromItemToPropertySet( USHORT nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) +bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) { bool bChanged = false; if( !xPropertySet.is() ) return bChanged; rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" ); - USHORT nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE; + sal_uInt16 nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE; if( SFX_ITEM_SET != rItemSet.GetItemState( nSourceWhich ) ) return bChanged; @@ -155,13 +155,13 @@ bool lcl_NumberFormatFromItemToPropertySet( USHORT nWhichId, const SfxItemSet & return bChanged; } -bool lcl_UseSourceFormatFromItemToPropertySet( USHORT nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) +bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) { bool bChanged = false; if( !xPropertySet.is() ) return bChanged; rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" ); - USHORT nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE; + sal_uInt16 nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE; if( SFX_ITEM_SET != rItemSet.GetItemState( nWhichId ) ) return bChanged; @@ -291,7 +291,7 @@ bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * DataPointItemConverter::GetWhichPairs() const +const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const { // must span all used items! if( m_bDataSeries ) @@ -313,7 +313,7 @@ bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNa bool DataPointItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -545,7 +545,7 @@ bool DataPointItemConverter::ApplySpecialItem( } void DataPointItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) @@ -643,7 +643,7 @@ void DataPointItemConverter::FillSpecialItem( { SvULongs aList; for ( sal_Int32 nN=0; nN(nN) ); + aList.Insert( m_aAvailableLabelPlacements[nN], sal::static_int_cast< sal_uInt16 >(nN) ); rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) ); } break; diff --git a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx index 0e2e6cdd4644..8718c76c95b7 100755 --- a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx @@ -133,7 +133,7 @@ bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * ErrorBarItemConverter::GetWhichPairs() const +const sal_uInt16 * ErrorBarItemConverter::GetWhichPairs() const { // must span all used items! return nErrorBarWhichPairs; @@ -147,7 +147,7 @@ bool ErrorBarItemConverter::GetItemProperty( } bool ErrorBarItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -342,7 +342,7 @@ bool ErrorBarItemConverter::ApplySpecialItem( } void ErrorBarItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx index c732dfe80ede..ce7b2577767e 100644 --- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -152,7 +152,7 @@ bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter: bool lcl_SetContentForNamedProperty( const uno::Reference< lang::XMultiServiceFactory > & xFactory, const ::rtl::OUString & rTableName, - NameOrIndex & rItem, BYTE nMemberId ) + NameOrIndex & rItem, sal_uInt8 nMemberId ) { bool bResult = false; if( xFactory.is()) @@ -196,9 +196,9 @@ GraphicPropertyItemConverter::GraphicPropertyItemConverter( GraphicPropertyItemConverter::~GraphicPropertyItemConverter() {} -const USHORT * GraphicPropertyItemConverter::GetWhichPairs() const +const sal_uInt16 * GraphicPropertyItemConverter::GetWhichPairs() const { - const USHORT * pResult = NULL; + const sal_uInt16 * pResult = NULL; switch( m_eGraphicObjectType ) { @@ -263,7 +263,7 @@ bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tProp } void GraphicPropertyItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { // if( m_eGraphicObjectType == LINE_DATA_POINT || @@ -310,7 +310,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( if( (aValue >>= aName) && aName.getLength()) { - aItem.SetEnabled( TRUE ); + aItem.SetEnabled( sal_True ); rOutItemSet.Put( aItem ); } } @@ -470,7 +470,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( } bool GraphicPropertyItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index 5754559ce8ae..f1a6f90f3bfe 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -100,7 +100,7 @@ void ItemConverter::_disposing( const lang::EventObject& rSource ) void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const { - const USHORT * pRanges = rOutItemSet.GetRanges(); + const sal_uInt16 * pRanges = rOutItemSet.GetRanges(); tPropertyNameWithMemberId aProperty; SfxItemPool & rPool = GetItemPool(); @@ -110,13 +110,13 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const while( (*pRanges) != 0) { - USHORT nBeg = (*pRanges); + sal_uInt16 nBeg = (*pRanges); ++pRanges; - USHORT nEnd = (*pRanges); + sal_uInt16 nEnd = (*pRanges); ++pRanges; OSL_ASSERT( nBeg <= nEnd ); - for( USHORT nWhich = nBeg; nWhich <= nEnd; ++nWhich ) + for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich ) { if( GetItemProperty( nWhich, aProperty )) { @@ -171,14 +171,14 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const } void ItemConverter::FillSpecialItem( - USHORT /*nWhichId*/, SfxItemSet & /*rOutItemSet*/ ) const + sal_uInt16 /*nWhichId*/, SfxItemSet & /*rOutItemSet*/ ) const throw( uno::Exception ) { OSL_ENSURE( false, "ItemConverter: Unhandled special item found!" ); } bool ItemConverter::ApplySpecialItem( - USHORT /*nWhichId*/, const SfxItemSet & /*rItemSet*/ ) + sal_uInt16 /*nWhichId*/, const SfxItemSet & /*rItemSet*/ ) throw( uno::Exception ) { OSL_ENSURE( false, "ItemConverter: Unhandled special item found!" ); @@ -197,7 +197,7 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) while( pItem ) { - if( rItemSet.GetItemState( pItem->Which(), FALSE ) == SFX_ITEM_SET ) + if( rItemSet.GetItemState( pItem->Which(), sal_False ) == SFX_ITEM_SET ) { if( GetItemProperty( pItem->Which(), aProperty )) { @@ -242,13 +242,13 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItemSet &rSourceSet ) { SfxWhichIter aIter (rSourceSet); - USHORT nWhich = aIter.FirstWhich (); + sal_uInt16 nWhich = aIter.FirstWhich (); const SfxPoolItem *pPoolItem = NULL; while (nWhich) { - if ((rSourceSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_SET) && - (rDestSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_SET)) + if ((rSourceSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_SET) && + (rDestSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_SET)) { if (rSourceSet.Get(nWhich) != rDestSet.Get(nWhich)) { @@ -258,7 +258,7 @@ void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItem } } } - else if( rSourceSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_DONTCARE ) + else if( rSourceSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_DONTCARE ) rDestSet.InvalidateItem(nWhich); nWhich = aIter.NextWhich (); diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index 3af6d9342f33..ae812d72d723 100644 --- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -91,7 +91,7 @@ bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * LegendItemConverter::GetWhichPairs() const +const sal_uInt16 * LegendItemConverter::GetWhichPairs() const { // must span all used items! return nLegendWhichPairs; @@ -105,7 +105,7 @@ bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyN bool LegendItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -185,7 +185,7 @@ bool LegendItemConverter::ApplySpecialItem( } void LegendItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx index e111eb314360..75965a2426fd 100644 --- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx +++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx @@ -83,7 +83,7 @@ AllAxisItemConverter::~AllAxisItemConverter() { } -const USHORT * AllAxisItemConverter::GetWhichPairs() const +const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const { // must span all used items! return nAllAxisWhichPairs; @@ -113,7 +113,7 @@ AllGridItemConverter::~AllGridItemConverter() { } -const USHORT * AllGridItemConverter::GetWhichPairs() const +const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const { // must span all used items! return nGridWhichPairs; @@ -161,7 +161,7 @@ AllDataLabelItemConverter::~AllDataLabelItemConverter() { } -const USHORT * AllDataLabelItemConverter::GetWhichPairs() const +const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const { // must span all used items! return nDataLabelWhichPairs; @@ -195,7 +195,7 @@ AllTitleItemConverter::~AllTitleItemConverter() { } -const USHORT * AllTitleItemConverter::GetWhichPairs() const +const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const { // must span all used items! return nTitleWhichPairs; @@ -223,7 +223,7 @@ AllSeriesStatisticsConverter::AllSeriesStatisticsConverter( AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter() {} -const USHORT * AllSeriesStatisticsConverter::GetWhichPairs() const +const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const { // must span all used items! return nStatWhichPairs; diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx index 2fee8702e6d8..7cfd879ba85d 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -111,7 +111,7 @@ bool RegressionCurveItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * RegressionCurveItemConverter::GetWhichPairs() const +const sal_uInt16 * RegressionCurveItemConverter::GetWhichPairs() const { // must span all used items! return nRegressionCurveWhichPairs; @@ -126,7 +126,7 @@ bool RegressionCurveItemConverter::GetItemProperty( bool RegressionCurveItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY ); @@ -171,7 +171,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( OSL_ASSERT( xCurve.is()); if( xCurve.is()) { - bool bNewShow = static_cast< BOOL >( + bool bNewShow = static_cast< sal_Bool >( static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue()); @@ -194,7 +194,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( OSL_ASSERT( xCurve.is()); if( xCurve.is()) { - bool bNewShow = static_cast< BOOL >( + bool bNewShow = static_cast< sal_Bool >( static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue()); @@ -217,7 +217,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( } void RegressionCurveItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY ); diff --git a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx index 6035f21696a9..c8bdff5f24b8 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx @@ -116,7 +116,7 @@ bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet & rItemSet return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * RegressionEquationItemConverter::GetWhichPairs() const +const sal_uInt16 * RegressionEquationItemConverter::GetWhichPairs() const { // must span all used items! return nRegEquationWhichPairs; @@ -135,7 +135,7 @@ bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId, tP } bool RegressionEquationItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -166,7 +166,7 @@ bool RegressionEquationItemConverter::ApplySpecialItem( } void RegressionEquationItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index f7ddeb42c11e..3795ddb139ea 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -43,7 +43,7 @@ namespace EE_ITEMS_START, EE_ITEMS_END, \ SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING -const USHORT nTitleWhichPairs[] = +const sal_uInt16 nTitleWhichPairs[] = { SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx @@ -54,7 +54,7 @@ const USHORT nTitleWhichPairs[] = 0 }; -const USHORT nAxisWhichPairs[] = +const sal_uInt16 nAxisWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx CHARACTER_WHICHPAIRS, @@ -69,7 +69,7 @@ const USHORT nAxisWhichPairs[] = 0 }; -const USHORT nAllAxisWhichPairs[] = +const sal_uInt16 nAllAxisWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx CHARACTER_WHICHPAIRS, @@ -81,13 +81,13 @@ const USHORT nAllAxisWhichPairs[] = 0 }; -const USHORT nGridWhichPairs[] = +const sal_uInt16 nGridWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx 0 }; -const USHORT nLegendWhichPairs[] = +const sal_uInt16 nLegendWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx @@ -97,7 +97,7 @@ const USHORT nLegendWhichPairs[] = 0 }; -const USHORT nDataLabelWhichPairs[] = +const sal_uInt16 nDataLabelWhichPairs[] = { SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ @@ -125,7 +125,7 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_SYMBOL_SIZE,SCHATTR_SYMBOL_SIZE, /* 97 sch/schattr.hxx*/ \ SDRATTR_3D_FIRST, SDRATTR_3D_LAST /* 1244 - 1334 svx/svddef.hxx */ -const USHORT nDataPointWhichPairs[] = +const sal_uInt16 nDataPointWhichPairs[] = { CHART_POINT_WHICHPAIRS, 0 @@ -141,20 +141,20 @@ const USHORT nDataPointWhichPairs[] = SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, \ SCHATTR_INCLUDE_HIDDEN_CELLS,SCHATTR_INCLUDE_HIDDEN_CELLS -const USHORT nSeriesOptionsWhichPairs[] = +const sal_uInt16 nSeriesOptionsWhichPairs[] = { CHART_SERIES_OPTIONS_WHICHPAIRS, 0 }; -const USHORT nRowWhichPairs[] = +const sal_uInt16 nRowWhichPairs[] = { CHART_POINT_WHICHPAIRS, CHART_SERIES_OPTIONS_WHICHPAIRS, 0 }; -const USHORT nAreaWhichPairs[] = +const sal_uInt16 nAreaWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx @@ -162,7 +162,7 @@ const USHORT nAreaWhichPairs[] = 0 }; -const USHORT nTextWhichPairs[] = +const sal_uInt16 nTextWhichPairs[] = { CHARACTER_WHICHPAIRS, SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx @@ -170,7 +170,7 @@ const USHORT nTextWhichPairs[] = 0 }; -const USHORT nTextOrientWhichPairs[] = +const sal_uInt16 nTextOrientWhichPairs[] = { CHARACTER_WHICHPAIRS, SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx @@ -178,14 +178,14 @@ const USHORT nTextOrientWhichPairs[] = 0 }; -const USHORT nStatWhichPairs[]= +const sal_uInt16 nStatWhichPairs[]= { SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 0 }; -const USHORT nErrorBarWhichPairs[]= +const sal_uInt16 nErrorBarWhichPairs[]= { SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx @@ -194,26 +194,26 @@ const USHORT nErrorBarWhichPairs[]= // for CharacterProperties -const USHORT nCharacterPropertyWhichPairs[] = +const sal_uInt16 nCharacterPropertyWhichPairs[] = { CHARACTER_WHICHPAIRS, 0 }; -const USHORT nLinePropertyWhichPairs[] = +const sal_uInt16 nLinePropertyWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx 0 }; -const USHORT nFillPropertyWhichPairs[] = +const sal_uInt16 nFillPropertyWhichPairs[] = { XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx 0 }; -const USHORT nLineAndFillPropertyWhichPairs[] = +const sal_uInt16 nLineAndFillPropertyWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx @@ -221,7 +221,7 @@ const USHORT nLineAndFillPropertyWhichPairs[] = 0 }; -const USHORT nChartStyleWhichPairs[] = +const sal_uInt16 nChartStyleWhichPairs[] = { SCHATTR_DIAGRAM_STYLE, SCHATTR_DIAGRAM_STYLE, SCHATTR_STYLE_SHAPE, SCHATTR_STYLE_SHAPE, @@ -231,14 +231,14 @@ const USHORT nChartStyleWhichPairs[] = 0 }; -const USHORT nRegressionCurveWhichPairs[] = +const sal_uInt16 nRegressionCurveWhichPairs[] = { SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx 0 }; -const USHORT nRegEquationWhichPairs[] = +const sal_uInt16 nRegEquationWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index b1931d63cfbb..db7aa21c7a1a 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -186,7 +186,7 @@ SeriesOptionsItemConverter::~SeriesOptionsItemConverter() { } -const USHORT * SeriesOptionsItemConverter::GetWhichPairs() const +const sal_uInt16 * SeriesOptionsItemConverter::GetWhichPairs() const { // must span all used items! return nSeriesOptionsWhichPairs; @@ -197,7 +197,7 @@ bool SeriesOptionsItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPr return false; } -bool SeriesOptionsItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) +bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -372,7 +372,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxIte } void SeriesOptionsItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) @@ -434,7 +434,7 @@ void SeriesOptionsItemConverter::FillSpecialItem( { SvULongs aList; for ( sal_Int32 nN=0; nN(nN) ); + aList.Insert( m_aSupportedMissingValueTreatments[nN], sal::static_int_cast< sal_uInt16 >(nN) ); rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) ); break; } diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index f2df5c96dd71..8d35d5c6b2fe 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -153,7 +153,7 @@ uno::Reference< beans::XPropertySet > lcl_getEquationProperties( { SvxChartRegress eRegress = CHREGRESS_NONE; const SfxPoolItem *pPoolItem = NULL; - if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) { eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue(); bEquationExists = ( eRegress != CHREGRESS_NONE ); @@ -203,7 +203,7 @@ StatisticsItemConverter::StatisticsItemConverter( StatisticsItemConverter::~StatisticsItemConverter() {} -const USHORT * StatisticsItemConverter::GetWhichPairs() const +const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const { // must span all used items! return nStatWhichPairs; @@ -217,7 +217,7 @@ bool StatisticsItemConverter::GetItemProperty( } bool StatisticsItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -521,7 +521,7 @@ bool StatisticsItemConverter::ApplySpecialItem( } void StatisticsItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx index f745dd37e9c3..7db0c06822ea 100644 --- a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx @@ -75,7 +75,7 @@ public: virtual ~FormattedStringsConverter(); protected: - virtual const USHORT * GetWhichPairs() const; + virtual const sal_uInt16 * GetWhichPairs() const; }; // ---------------------------------------- @@ -109,7 +109,7 @@ FormattedStringsConverter::~FormattedStringsConverter() { } -const USHORT * FormattedStringsConverter::GetWhichPairs() const +const sal_uInt16 * FormattedStringsConverter::GetWhichPairs() const { return nCharacterPropertyWhichPairs; } @@ -170,7 +170,7 @@ bool TitleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const USHORT * TitleItemConverter::GetWhichPairs() const +const sal_uInt16 * TitleItemConverter::GetWhichPairs() const { // must span all used items! return nTitleWhichPairs; @@ -190,7 +190,7 @@ bool TitleItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWi bool TitleItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) + sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; @@ -221,7 +221,7 @@ bool TitleItemConverter::ApplySpecialItem( } void TitleItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const + sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { switch( nWhichId ) diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index f2b64eb7a9c5..70a8b7048bea 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -124,7 +124,7 @@ public: @param rOutEqualRect is filled with a rectangle that denotes the region in which the quick help does not change. - @return , if a quick help should be shown. + @return , if a quick help should be shown. */ virtual bool requestQuickHelp( ::Point aAtLogicPosition, bool bIsBalloonHelp, @@ -700,7 +700,7 @@ private: MOVE_OBJECT, CENTERED_RESIZE_OBJECT }; - /// @return , if resize/move was successful + /// @return , if resize/move was successful bool impl_moveOrResizeObject( const ::rtl::OUString & rCID, eMoveOrResizeType eType, double fAmountLogicX, double fAmountLogicY ); bool impl_DragDataPoint( const ::rtl::OUString & rCID, double fOffset ); diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 619d308ffad2..8e90178ca331 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -72,16 +72,16 @@ void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, Rectangle& r const SfxPoolItem* pPoolItem=NULL; //read position - if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,TRUE,&pPoolItem)) + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,sal_True,&pPoolItem)) nPosX=((const SfxInt32Item*)pPoolItem)->GetValue(); - if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,TRUE,&pPoolItem)) + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,sal_True,&pPoolItem)) nPosY=((const SfxInt32Item*)pPoolItem)->GetValue(); //read size - if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,TRUE,&pPoolItem)) + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,sal_True,&pPoolItem)) nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue(); - if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,TRUE,&pPoolItem)) + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,sal_True,&pPoolItem)) nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue(); - if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,TRUE,&pPoolItem)) + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,sal_True,&pPoolItem)) eRP=(RECT_POINT)((const SfxAllEnumItem*)pPoolItem)->GetValue(); switch( eRP ) diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 6091fd8ef3f8..05061377bd76 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -203,10 +203,10 @@ void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() DBG_ASSERT( pFact, "No dialog factory" ); SfxAllItemSet aSet( m_pDrawModelWrapper->GetItemPool() ); - aSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) ); + aSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); //set fixed current font - aSet.Put( SfxBoolItem( FN_PARAM_2, TRUE ) ); //maybe not necessary in future + aSet.Put( SfxBoolItem( FN_PARAM_2, sal_True ) ); //maybe not necessary in future Font aCurFont = m_pDrawViewWrapper->getOutliner()->GetRefDevice()->GetFont(); aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) ); @@ -218,7 +218,7 @@ void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() const SfxItemSet* pSet = pDlg->GetOutputItemSet(); const SfxPoolItem* pItem=0; String aString; - if ( pSet && pSet->GetItemState( SID_CHARMAP, TRUE, &pItem) == SFX_ITEM_SET && + if ( pSet && pSet->GetItemState( SID_CHARMAP, sal_True, &pItem) == SFX_ITEM_SET && pItem->ISA(SfxStringItem) ) aString = dynamic_cast(pItem)->GetValue(); @@ -232,7 +232,7 @@ void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() // prevent flicker pOutlinerView->HideCursor(); - pOutliner->SetUpdateMode(FALSE); + pOutliner->SetUpdateMode(sal_False); // delete current selection by inserting empty String, so current // attributes become unique (sel. has to be erased anyway) @@ -240,7 +240,7 @@ void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() //SfxUndoManager& rUndoMgr = pOutliner->GetUndoManager(); //rUndoMgr.EnterListAction( String( SchResId( STR_UNDO_INSERT_SPECCHAR )), String( SchResId( STR_UNDO_INSERT_SPECCHAR ))); - pOutlinerView->InsertText(aString, TRUE); + pOutlinerView->InsertText(aString, sal_True); ESelection aSel = pOutlinerView->GetSelection(); aSel.nStartPara = aSel.nEndPara; @@ -250,7 +250,7 @@ void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() //rUndoMgr.LeaveListAction(); // show changes - pOutliner->SetUpdateMode(TRUE); + pOutliner->SetUpdateMode(sal_True); pOutlinerView->ShowCursor(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 885e37126dc2..8645fc388a34 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -565,7 +565,7 @@ void ChartController::startDoubleClickWaiting() m_bWaitingForDoubleClick = true; - ULONG nDblClkTime = 500; + sal_uLong nDblClkTime = 500; if( m_pChartWindow ) { const MouseSettings& rMSettings = m_pChartWindow->GetSettings().GetMouseSettings(); @@ -593,7 +593,7 @@ IMPL_LINK( ChartController, DoubleClickWaitingHdl, void*, EMPTYARG ) { Window::PointerState aPointerState( m_pChartWindow->GetPointerState() ); MouseEvent aMouseEvent( aPointerState.maPos,1/*nClicks*/, - 0/*nMode*/, static_cast< USHORT >( aPointerState.mnState )/*nButtons*/, + 0/*nMode*/, static_cast< sal_uInt16 >( aPointerState.mnState )/*nButtons*/, 0/*nModifier*/ ); impl_SetMousePointer( aMouseEvent ); } @@ -711,7 +711,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) && !rMEvt.IsRight() ) { //start drag - USHORT nDrgLog = (USHORT)m_pChartWindow->PixelToLogic(Size(DRGPIX,0)).Width(); + sal_uInt16 nDrgLog = (sal_uInt16)m_pChartWindow->PixelToLogic(Size(DRGPIX,0)).Width(); SdrDragMethod* pDragMethod = NULL; //change selection to 3D scene if rotate mode @@ -974,12 +974,12 @@ void ChartController::execute_Resize() } void ChartController::execute_Activate() { - ///// pDrawViewWrapper->SetEditMode(TRUE); + ///// pDrawViewWrapper->SetEditMode(sal_True); } void ChartController::execute_Deactivate() { /* - pDrawViewWrapper->SetEditMode(FALSE); + pDrawViewWrapper->SetEditMode(sal_False); this->ReleaseMouse(); */ } @@ -1593,7 +1593,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { // 3D-Kontext wieder zerstoeren GetWindow()->Invalidate(); - bReturn = TRUE; + bReturn = sal_True; } } */ @@ -1890,7 +1890,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { Point aMousePos( m_pChartWindow->PixelToLogic( rEvent.GetPosPixel())); sal_uInt16 nModifier = rEvent.GetModifier(); - BOOL bLeftDown = rEvent.IsLeft(); + sal_Bool bLeftDown = rEvent.IsLeft(); if ( m_pDrawViewWrapper->IsTextEdit() ) { diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx index 80041d4c3818..f0c4ca80f9f2 100644 --- a/chart2/source/controller/main/ChartTransferable.cxx +++ b/chart2/source/controller/main/ChartTransferable.cxx @@ -64,7 +64,7 @@ ChartTransferable::ChartTransferable( SdrModel* pDrawModel, SdrObject* pSelected pExchgView->MarkObj( pSelectedObj, pPv ); else pExchgView->MarkAllObj( pPv ); - Graphic aGraphic( pExchgView->GetMarkedObjMetaFile( TRUE )); + Graphic aGraphic( pExchgView->GetMarkedObjMetaFile( sal_True )); m_xMetaFileGraphic.set( aGraphic.GetXGraphic()); if ( m_bDrawing ) { diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 54add217fb76..9d7f16faff68 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -64,9 +64,9 @@ ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, adjustHighContrastMode(); // chart does not depend on exact pixel painting => enable antialiased drawing SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | GetAntialiasing() ); - EnableRTL( FALSE ); + EnableRTL( sal_False ); if( pParent ) - pParent->EnableRTL( FALSE );// #i96215# necessary for a correct position of the context menu in rtl mode + pParent->EnableRTL( sal_False );// #i96215# necessary for a correct position of the context menu in rtl mode } ChartWindow::~ChartWindow() @@ -247,19 +247,19 @@ void ChartWindow::ForceInvalidate() { ::Window::Invalidate(); } -void ChartWindow::Invalidate( USHORT nFlags ) +void ChartWindow::Invalidate( sal_uInt16 nFlags ) { if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" return; ::Window::Invalidate( nFlags ); } -void ChartWindow::Invalidate( const Rectangle& rRect, USHORT nFlags ) +void ChartWindow::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags ) { if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" return; ::Window::Invalidate( rRect, nFlags ); } -void ChartWindow::Invalidate( const Region& rRegion, USHORT nFlags ) +void ChartWindow::Invalidate( const Region& rRegion, sal_uInt16 nFlags ) { if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" return; diff --git a/chart2/source/controller/main/ChartWindow.hxx b/chart2/source/controller/main/ChartWindow.hxx index 2325d6be7803..2085214f0b81 100644 --- a/chart2/source/controller/main/ChartWindow.hxx +++ b/chart2/source/controller/main/ChartWindow.hxx @@ -68,9 +68,9 @@ public: virtual void RequestHelp( const HelpEvent& rHEvt ); void ForceInvalidate(); - virtual void Invalidate( USHORT nFlags = 0 ); - virtual void Invalidate( const Rectangle& rRect, USHORT nFlags = 0 ); - virtual void Invalidate( const Region& rRegion, USHORT nFlags = 0 ); + virtual void Invalidate( sal_uInt16 nFlags = 0 ); + virtual void Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + virtual void Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index aa28028c4861..f5380846dbbe 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -386,7 +386,7 @@ void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequen { ::vos::OGuard aGuard( Application::GetSolarMutex() ); m_pChartController->setDrawMode( eDrawMode ); - setInsertObj( sal::static_int_cast< USHORT >( eKind ) ); + setInsertObj( sal::static_int_cast< sal_uInt16 >( eKind ) ); if ( bCreate ) { pDrawViewWrapper->SetCreateMode(); @@ -443,7 +443,7 @@ void DrawCommandDispatch::describeSupportedFeatures() implDescribeSupportedFeature( ".uno:StarShapes", COMMAND_ID_DRAWTBX_CS_STAR, CommandGroup::INSERT ); } -void DrawCommandDispatch::setInsertObj( USHORT eObj ) +void DrawCommandDispatch::setInsertObj( sal_uInt16 eObj ) { DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL ); if ( pDrawViewWrapper ) @@ -527,13 +527,13 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) if ( pTextObj ) { pTextObj->SetLogicRect( aRect ); - BOOL bVertical = ( nID == SID_DRAW_TEXT_VERTICAL ); + sal_Bool bVertical = ( nID == SID_DRAW_TEXT_VERTICAL ); pTextObj->SetVerticalWriting( bVertical ); if ( bVertical ) { SfxItemSet aSet( pDrawModelWrapper->GetItemPool() ); - aSet.Put( SdrTextAutoGrowWidthItem( TRUE ) ); - aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) ); + aSet.Put( SdrTextAutoGrowWidthItem( sal_True ) ); + aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) ); aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_TOP ) ); aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) ); pTextObj->SetMergedItemSet( aSet ); diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx index 38c886e29abb..63ddd1b7c75c 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.hxx +++ b/chart2/source/controller/main/DrawCommandDispatch.hxx @@ -76,7 +76,7 @@ protected: virtual void describeSupportedFeatures(); private: - void setInsertObj( USHORT eObj ); + void setInsertObj( sal_uInt16 eObj ); SdrObject* createDefaultObject( const sal_uInt16 nID ); bool parseCommandURL( const ::rtl::OUString& rCommandURL, sal_uInt16* pnFeatureId, ::rtl::OUString* pBaseCommand, ::rtl::OUString* pCustomShapeType ); diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx index 3b41fd1b6b66..e0c4162e785a 100644 --- a/chart2/source/controller/main/ElementSelector.cxx +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -162,9 +162,9 @@ void SelectorListBox::UpdateChartElementsListAndSelection() } } - USHORT nEntryPosToSelect = 0; bool bSelectionFound = false; + sal_uInt16 nEntryPosToSelect = 0; bool bSelectionFound = false; aIt = m_aEntries.begin(); - for( USHORT nN=0; aIt != m_aEntries.end(); ++aIt, ++nN ) + for( sal_uInt16 nN=0; aIt != m_aEntries.end(); ++aIt, ++nN ) { InsertEntry( aIt->UIName ); if ( !bSelectionFound && aSelectedOID == aIt->OID ) @@ -177,7 +177,7 @@ void SelectorListBox::UpdateChartElementsListAndSelection() if( bSelectionFound ) SelectEntryPos(nEntryPosToSelect); - USHORT nEntryCount = GetEntryCount(); + sal_uInt16 nEntryCount = GetEntryCount(); if( nEntryCount > 100 ) nEntryCount = 100; SetDropDownLineCount( nEntryCount ); @@ -205,7 +205,7 @@ void SelectorListBox::Select() if ( !IsTravelSelect() ) { - USHORT nPos = GetSelectEntryPos(); + sal_uInt16 nPos = GetSelectEntryPos(); if( nPos < m_aEntries.size() ) { ObjectHierarchy::tOID aOID = m_aEntries[nPos].OID; @@ -223,7 +223,7 @@ long SelectorListBox::Notify( NotifyEvent& rNEvt ) if ( rNEvt.GetType() == EVENT_KEYINPUT ) { - USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); switch ( nCode ) { diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index b2eccae6c98d..983d7cd83980 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -272,10 +272,10 @@ void ShapeController::executeDispatch_FormatLine() { SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); if ( bHasMarked ) { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); + pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False ); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) @@ -288,11 +288,11 @@ void ShapeController::executeDispatch_FormatLine() const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); if ( bHasMarked ) { - pDrawViewWrapper->SetAttrToMarked( *pOutAttr, FALSE ); + pDrawViewWrapper->SetAttrToMarked( *pOutAttr, sal_False ); } else { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE ); + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False ); } } } @@ -311,10 +311,10 @@ void ShapeController::executeDispatch_FormatArea() if ( pParent && pDrawModelWrapper && pDrawViewWrapper ) { SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); if ( bHasMarked ) { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); + pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False ); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) @@ -336,11 +336,11 @@ void ShapeController::executeDispatch_FormatArea() const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); if ( bHasMarked ) { - pDrawViewWrapper->SetAttrToMarked( *pOutAttr, FALSE ); + pDrawViewWrapper->SetAttrToMarked( *pOutAttr, sal_False ); } else { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE ); + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False ); } } } @@ -359,10 +359,10 @@ void ShapeController::executeDispatch_TextAttributes() if ( pParent && pDrawViewWrapper ) { SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + sal_Bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); if ( bHasMarked ) { - pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE ); + pDrawViewWrapper->MergeAttrFromMarked( aAttr, sal_False ); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) @@ -378,7 +378,7 @@ void ShapeController::executeDispatch_TextAttributes() } else { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE ); + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, sal_False ); } } } @@ -410,7 +410,7 @@ void ShapeController::executeDispatch_TransformDialog() pFact->CreateCaptionDialog( pParent, pDrawViewWrapper ) ); if ( pDlg.get() ) { - const USHORT* pRange = pDlg->GetInputRanges( *aAttr.GetPool() ); + const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() ); SfxItemSet aCombAttr( *aAttr.GetPool(), pRange ); aCombAttr.Put( aAttr ); aCombAttr.Put( aGeoAttr ); diff --git a/chart2/source/controller/main/ShapeToolbarController.cxx b/chart2/source/controller/main/ShapeToolbarController.cxx index 9c6ed747e1d5..f9cfc202e2ad 100644 --- a/chart2/source/controller/main/ShapeToolbarController.cxx +++ b/chart2/source/controller/main/ShapeToolbarController.cxx @@ -126,10 +126,10 @@ void ShapeToolbarController::initialize( const Sequence< uno::Any >& rArguments ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) ); if ( pToolBox ) { - const USHORT nCount = pToolBox->GetItemCount(); - for ( USHORT nPos = 0; nPos < nCount; ++nPos ) + const sal_uInt16 nCount = pToolBox->GetItemCount(); + for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos ) { - const USHORT nItemId = pToolBox->GetItemId( nPos ); + const sal_uInt16 nItemId = pToolBox->GetItemId( nPos ); if ( pToolBox->GetItemCommand( nItemId ) == String( m_aCommandURL ) ) { m_nToolBoxId = nItemId; @@ -201,9 +201,9 @@ void ShapeToolbarController::statusChanged( const frame::FeatureStateEvent& Even sal_Bool bCheckmark = sal_False; ToolBox& rTb = m_pToolbarController->GetToolBox(); - for ( USHORT i = 0; i < rTb.GetItemCount(); ++i ) + for ( sal_uInt16 i = 0; i < rTb.GetItemCount(); ++i ) { - USHORT nId = rTb.GetItemId( i ); + sal_uInt16 nId = rTb.GetItemId( i ); if ( nId == 0 ) { continue; diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index 75e69436a784..2be511519db8 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -178,7 +178,7 @@ public: , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex ); /** @param bOnlyVisible if , only axes with property "Show" set to - are returned + are returned */ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< @@ -188,7 +188,7 @@ public: , bool bOnlyVisible = false ); /** @param bOnlyVisible if , only axes with property "Show" set to - are returned + are returned */ SAL_DLLPRIVATE static std::vector< ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index c7cda6189680..b01255a81698 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -108,7 +108,7 @@ public: ); /** @param bOnlyAtFirstChartType - If , the stacking mode is only set at the series found inside + If , the stacking mode is only set at the series found inside the first chart type. This is the standard for all current templates (the only template that has more than one chart-type and allows stacking is bar/line combi, and for this the stacking only @@ -270,7 +270,7 @@ public: * @param bForward * Direction of the move to be checked. * - * @returns if the series can be moved. + * @returns if the series can be moved. * */ static bool isSeriesMoveable( @@ -292,7 +292,7 @@ public: * @param bForward * Direction in which the series should be moved. * - * @returns if the series was moved successfully. + * @returns if the series was moved successfully. * */ static bool moveSeries( diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx index 6b6590cffdac..38c81cdb6c33 100755 --- a/chart2/source/inc/InternalData.hxx +++ b/chart2/source/inc/InternalData.hxx @@ -91,7 +91,7 @@ private: //methods /** resizes the data if at least one of the given dimensions is larger than before. The data is never becoming smaller only larger. - @return , if the data was enlarged + @return , if the data was enlarged */ bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount ); diff --git a/chart2/source/inc/OPropertySet.hxx b/chart2/source/inc/OPropertySet.hxx index 93dce272bf6e..85a7e4d88fe5 100644 --- a/chart2/source/inc/OPropertySet.hxx +++ b/chart2/source/inc/OPropertySet.hxx @@ -102,7 +102,7 @@ protected: Overload this method to take influence in modification of properties. - If the conversion changed , is returned and the converted value + If the conversion changed , is returned and the converted value is in rConvertedValue. The former value is contained in rOldValue. diff --git a/chart2/source/inc/ReferenceSizeProvider.hxx b/chart2/source/inc/ReferenceSizeProvider.hxx index 35819ba111cb..e5c98d900379 100644 --- a/chart2/source/inc/ReferenceSizeProvider.hxx +++ b/chart2/source/inc/ReferenceSizeProvider.hxx @@ -84,7 +84,7 @@ public: /** Sets the ReferencePageSize according to the internal settings of this class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes - is . + is . */ SAL_DLLPRIVATE void setValuesAtPropertySet( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/RelativePositionHelper.hxx b/chart2/source/inc/RelativePositionHelper.hxx index 1dd0617236ad..eb67de9d1f16 100644 --- a/chart2/source/inc/RelativePositionHelper.hxx +++ b/chart2/source/inc/RelativePositionHelper.hxx @@ -84,10 +84,10 @@ public: position such that the resize is relative to the former rectangle's center. - @param bCheck If , the resize is only done, if after + @param bCheck If , the resize is only done, if after transformation, the position and size are within the bounds [0,1]. - @return , if changes were applied. + @return , if changes were applied.

That means, if the position's alignment is center, the position will not change at all.

@@ -100,12 +100,12 @@ public: /** shifts a relative position about the given amount - @param bCheck If , the shift is only done, if after + @param bCheck If , the shift is only done, if after transformation, the object represented by the position rInOutPosition and its size rObjectSize the position and size are within the bounds [0,1]. - @return , if changes were applied. + @return , if changes were applied. */ static bool moveObject( ::com::sun::star::chart2::RelativePosition & rInOutPosition, diff --git a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx index 9f5f44107997..bb4474bfd218 100644 --- a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx @@ -73,7 +73,7 @@ public: private: NumberFormatterWrapper m_aNumberFormatterWrapper; - ULONG m_nNumberFormatKey; + sal_uLong m_nNumberFormatKey; }; //............................................................................. diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index c997f9ee483d..11b05051e812 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -68,7 +68,7 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); // ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; - ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); + ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,sal_False); ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MIN); @@ -122,7 +122,7 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_STAT_RANGE_NEG - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String()); ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); - ppPoolDefaults[SCHATTR_TEXT_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_OVERLAP,FALSE); + ppPoolDefaults[SCHATTR_TEXT_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_OVERLAP,sal_False); ppPoolDefaults[SCHATTR_STYLE_DEEP - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0); ppPoolDefaults[SCHATTR_STYLE_3D - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0); @@ -176,16 +176,16 @@ ChartItemPool::ChartItemPool(): // new for New Chart ppPoolDefaults[SCHATTR_BAR_OVERLAP - SCHATTR_START] = new SfxInt32Item(SCHATTR_BAR_OVERLAP,0); ppPoolDefaults[SCHATTR_BAR_GAPWIDTH - SCHATTR_START] = new SfxInt32Item(SCHATTR_BAR_GAPWIDTH,0); - ppPoolDefaults[SCHATTR_BAR_CONNECT - SCHATTR_START] = new SfxBoolItem(SCHATTR_BAR_CONNECT, FALSE); + ppPoolDefaults[SCHATTR_BAR_CONNECT - SCHATTR_START] = new SfxBoolItem(SCHATTR_BAR_CONNECT, sal_False); ppPoolDefaults[SCHATTR_NUM_OF_LINES_FOR_BAR - SCHATTR_START] = new SfxInt32Item( SCHATTR_NUM_OF_LINES_FOR_BAR, 0 ); ppPoolDefaults[SCHATTR_SPLINE_ORDER - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_ORDER, 3 ); ppPoolDefaults[SCHATTR_SPLINE_RESOLUTION - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, 20 ); ppPoolDefaults[SCHATTR_DIAGRAM_STYLE - SCHATTR_START] = new SvxChartStyleItem( CHSTYLE_2D_COLUMN, SCHATTR_DIAGRAM_STYLE ); - ppPoolDefaults[SCHATTR_TEXTBREAK - SCHATTR_START] = new SfxBoolItem( SCHATTR_TEXTBREAK, FALSE ); - ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, FALSE); - ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); + ppPoolDefaults[SCHATTR_TEXTBREAK - SCHATTR_START] = new SfxBoolItem( SCHATTR_TEXTBREAK, sal_False ); + ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, sal_False); + ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True); ppPoolDefaults[SCHATTR_STARTING_ANGLE - SCHATTR_START] = new SfxInt32Item( SCHATTR_STARTING_ANGLE, 90 ); - ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, FALSE ); + ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, sal_False ); ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0); ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp); @@ -200,7 +200,7 @@ ChartItemPool::ChartItemPool(): **************************************************************************/ pItemInfos = new SfxItemInfo[SCHATTR_END - SCHATTR_START + 1]; - USHORT i; + sal_uInt16 i; for( i = SCHATTR_START; i <= SCHATTR_END; i++ ) { pItemInfos[i - SCHATTR_START]._nSID = 0; @@ -229,8 +229,8 @@ ChartItemPool::~ChartItemPool() delete[] pItemInfos; - const USHORT nMax = SCHATTR_END - SCHATTR_START + 1; - for( USHORT i=0; i& aArguments m_pDrawModelWrapper = ::boost::shared_ptr< DrawModelWrapper >( new DrawModelWrapper( m_xCC ) ); m_xShapeFactory = m_pDrawModelWrapper->getShapeFactory(); m_xDrawPage = m_pDrawModelWrapper->getMainDrawPage(); - StartListening( m_pDrawModelWrapper->getSdrModel(), FALSE /*bPreventDups*/ ); + StartListening( m_pDrawModelWrapper->getSdrModel(), sal_False /*bPreventDups*/ ); // \-- } } @@ -210,7 +210,7 @@ ChartView::~ChartView() { if( m_pDrawModelWrapper.get() ) { - EndListening( m_pDrawModelWrapper->getSdrModel(), FALSE /*bAllDups*/ ); + EndListening( m_pDrawModelWrapper->getSdrModel(), sal_False /*bAllDups*/ ); ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); m_pDrawModelWrapper.reset(); } @@ -2599,7 +2599,7 @@ void ChartView::createShapes() // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); // #i12587# support for shapes in chart - m_pDrawModelWrapper->getSdrModel().EnableUndo( FALSE ); + m_pDrawModelWrapper->getSdrModel().EnableUndo( sal_False ); m_pDrawModelWrapper->clearMainDrawPage(); // \-- } @@ -2763,7 +2763,7 @@ void ChartView::createShapes() if ( m_pDrawModelWrapper ) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - m_pDrawModelWrapper->getSdrModel().EnableUndo( TRUE ); + m_pDrawModelWrapper->getSdrModel().EnableUndo( sal_True ); } #if OSL_DEBUG_LEVEL > 0 diff --git a/chart2/source/view/main/Clipping.cxx b/chart2/source/view/main/Clipping.cxx index e61096e5a0ba..7eced29eb271 100644 --- a/chart2/source/view/main/Clipping.cxx +++ b/chart2/source/view/main/Clipping.cxx @@ -86,7 +86,7 @@ bool lcl_CLIPt(double fDenom,double fNum, double & fTE, double & fTL) } /** @descr The line given by it's two endpoints rP0 and rP1 is clipped at the rectangle - rRectangle. If there is at least a part of it visible then TRUE is returned and + rRectangle. If there is at least a part of it visible then sal_True is returned and the endpoints of that part are stored in rP0 and rP1. The points rP0 and rP1 may have the same coordinates. @param rP0 Start point of the line to clip. Modified to contain a start point inside @@ -95,7 +95,7 @@ bool lcl_CLIPt(double fDenom,double fNum, double & fTE, double & fTL) the clipping area if possible. @param rRectangle Clipping area. @return If the line lies completely or partly inside the clipping area then TRUE - is returned. If the line lies completely outside then FALSE is returned and rP0 and + is returned. If the line lies completely outside then sal_False is returned and rP0 and rP1 are left unmodified. */ bool lcl_clip2d(B2DTuple& rPoint0, B2DTuple& rPoint1, const B2DRectangle& rRectangle) diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 83544d6a8f2b..a23041ada673 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -135,7 +135,7 @@ DrawModelWrapper::DrawModelWrapper( SfxItemPool* pMasterPool = &GetItemPool(); pMasterPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM); - pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, TRUE) ); + pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, sal_True) ); pMasterPool->SetPoolDefaultItem(Svx3DPercentDiagonalItem (5)); SfxItemPool* pPool = pMasterPool; @@ -374,8 +374,8 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const String& rObjectCID, SdrObj { if(!pSearchList || rObjectCID.Len()==0) return 0; - ULONG nCount = pSearchList->GetObjCount(); - for( ULONG nN=0; nNGetObjCount(); + for( sal_uLong nN=0; nNGetObj(nN); if(!pObj) diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx index 4e4cd342506c..b09f9ff15e9b 100644 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ b/chart2/source/view/main/NumberFormatterWrapper.cxx @@ -111,7 +111,7 @@ rtl::OUString NumberFormatterWrapper::getFormattedString( return aText; } // i99104 handle null date correctly - USHORT nYear = 1899,nDay = 30,nMonth = 12; + sal_uInt16 nYear = 1899,nDay = 30,nMonth = 12; if ( m_aNullDate.hasValue() ) { Date* pDate = m_pNumberFormatter->GetNullDate(); -- cgit From dbf69a6612a5471d7ae23b1bf41afd1e9fec23a2 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 14 Jan 2011 18:11:00 +0100 Subject: chart46: #i25706# implement date axis - #i116467# change behaviour of own data table --- chart2/source/controller/dialogs/DataBrowser.cxx | 81 +++++---- chart2/source/controller/dialogs/DataBrowser.hxx | 7 +- .../source/controller/dialogs/DataBrowserModel.cxx | 69 +++----- .../source/controller/dialogs/DataBrowserModel.hxx | 8 +- chart2/source/controller/dialogs/DialogModel.cxx | 6 - chart2/source/controller/dialogs/DialogModel.hxx | 1 - .../controller/dialogs/ObjectNameProvider.cxx | 2 +- chart2/source/controller/dialogs/Strings.src | 4 - .../source/controller/dialogs/dlg_DataEditor.cxx | 8 +- .../source/controller/dialogs/dlg_DataEditor.hrc | 1 - .../source/controller/dialogs/dlg_DataEditor.src | 9 +- .../controller/dialogs/dlg_ObjectProperties.cxx | 2 +- .../controller/inc/DataPointItemConverter.hxx | 2 +- .../controller/inc/ErrorBarItemConverter.hxx | 2 +- chart2/source/controller/inc/HelpIds.hrc | 1 - .../controller/inc/StatisticsItemConverter.hxx | 2 +- .../controller/main/ChartController_Insert.cxx | 2 +- chart2/source/inc/AxisHelper.hxx | 7 + chart2/source/inc/DiagramHelper.hxx | 17 +- chart2/source/inc/ExplicitCategoriesProvider.hxx | 5 + chart2/source/inc/NumberFormatterWrapper.hxx | 83 +++++++++ chart2/source/inc/Strings.hrc | 4 +- .../source/inc/chartview/ExplicitValueProvider.hxx | 3 - .../inc/chartview/NumberFormatterWrapper.hxx | 83 --------- chart2/source/tools/AxisHelper.cxx | 142 +++++++++++++++ chart2/source/tools/DiagramHelper.cxx | 93 +++++----- chart2/source/tools/ExplicitCategoriesProvider.cxx | 135 ++++++++------ chart2/source/tools/InternalDataProvider.cxx | 42 +---- chart2/source/tools/NumberFormatterWrapper.cxx | 188 ++++++++++++++++++++ chart2/source/tools/makefile.mk | 1 + chart2/source/view/axes/VCartesianAxis.cxx | 2 +- chart2/source/view/axes/VPolarAngleAxis.cxx | 2 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 5 +- chart2/source/view/main/ChartView.cxx | 196 ++------------------- chart2/source/view/main/NumberFormatterWrapper.cxx | 188 -------------------- chart2/source/view/main/makefile.mk | 1 - 36 files changed, 683 insertions(+), 721 deletions(-) create mode 100755 chart2/source/inc/NumberFormatterWrapper.hxx delete mode 100644 chart2/source/inc/chartview/NumberFormatterWrapper.hxx create mode 100755 chart2/source/tools/NumberFormatterWrapper.cxx delete mode 100644 chart2/source/view/main/NumberFormatterWrapper.cxx (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index a05b3171ccbb..550aee7132d9 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -47,7 +47,7 @@ #include "ChartModelHelper.hxx" #include "CommonConverters.hxx" #include "macros.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "servicenames_charttypes.hxx" #include "ResId.hxx" #include "Bitmaps.hrc" @@ -64,6 +64,7 @@ #include #include +#include #include #include @@ -517,19 +518,6 @@ DataBrowser::~DataBrowser() { } -bool DataBrowser::HasDateCategories() const -{ - if( m_apDataBrowserModel.get() ) - return m_apDataBrowserModel->hasDateCategories(); - return false; -} - -bool DataBrowser::MayToggleDateCategories() const -{ - return ! IsReadOnly() - && DiagramHelper::mayToggleDateCategories( m_xChartDoc ); -} - bool DataBrowser::MayInsertRow() const { return ! IsReadOnly() @@ -710,6 +698,23 @@ String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const GetNumberFormatKey( nRow, nColumnId ), fData, nLabelColor, bColorChanged )); } + else if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXTORDATE ) + { + uno::Any aAny = m_apDataBrowserModel->getCellAny( nColIndex, nRow ); + OUString aText; + double fDouble=0.0; + if( aAny>>=aText ) + aResult = aText; + else if( aAny>>=fDouble ) + { + sal_Int32 nLabelColor; + bool bColorChanged = false; + sal_Int32 nDateNumberFormat = DiagramHelper::getDateNumberFormat( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY) ); + if( ! ::rtl::math::isNan( fDouble ) && m_spNumberFormatterWrapper.get() ) + aResult = String( m_spNumberFormatterWrapper->getFormattedString( + nDateNumberFormat, fDouble, nLabelColor, bColorChanged )); + } + } else { OSL_ASSERT( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXT ); @@ -1009,19 +1014,6 @@ void DataBrowser::SwapRow() } } -void DataBrowser::ToggleDateCategories() -{ - if( m_apDataBrowserModel.get() ) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); - - m_apDataBrowserModel->toggleDateCategories(); - RenewTable(); - } -} - void DataBrowser::SetCursorMovedHdl( const Link& rLink ) { m_aCursorMovedHdlLink = rLink; @@ -1164,6 +1156,22 @@ sal_uInt32 DataBrowser::GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) co return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )); } +bool DataBrowser::isDateString( rtl::OUString aInputString, double& fOutDateValue ) +{ + sal_uInt32 nNumberFormat=0; + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; + if( aInputString.getLength() > 0 && pSvNumberFormatter && pSvNumberFormatter->IsNumberFormat( aInputString, nNumberFormat, fOutDateValue ) ) + { + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_xChartDoc, uno::UNO_QUERY ); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + if( DiagramHelper::isDateNumberFormat( nNumberFormat, xNumberFormats ) ) + return true; + } + return false; +} + sal_Bool DataBrowser::SaveModified() { if( ! IsModified() ) @@ -1176,6 +1184,7 @@ sal_Bool DataBrowser::SaveModified() DBG_ASSERT( nRow >= 0 || nCol >= 0, "This cell should not be modified!" ); + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; switch( m_apDataBrowserModel->getCellType( nCol, nRow )) { case DataBrowserModel::NUMBER: @@ -1185,11 +1194,8 @@ sal_Bool DataBrowser::SaveModified() String aText( m_aNumberEditField.GetText()); // an empty string is valid, if no numberformatter exists, all // values are treated as valid - if( aText.Len() > 0 && - m_spNumberFormatterWrapper.get() && - m_spNumberFormatterWrapper->getSvNumberFormatter() && - ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( - aText, nDummy, fDummy )) + if( aText.Len() > 0 && pSvNumberFormatter && + ! pSvNumberFormatter->IsNumberFormat( aText, nDummy, fDummy ) ) { bChangeValid = sal_False; } @@ -1200,6 +1206,17 @@ sal_Bool DataBrowser::SaveModified() } } break; + case DataBrowserModel::TEXTORDATE: + { + OUString aText( m_aTextEditField.GetText() ); + double fDateValue=0.0; + bChangeValid = sal_False; + if( isDateString( aText, fDateValue ) ) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( fDateValue ) ); + if(!bChangeValid) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( aText ) ); + } + break; case DataBrowserModel::TEXT: { OUString aText( m_aTextEditField.GetText()); diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 7a7cd120fb5f..b5cd2a731f7b 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -93,6 +93,8 @@ public: */ double GetCellNumber( long nRow, USHORT nColumnId ) const; + bool isDateString( rtl::OUString aInputString, double& fOutDateValue ); + // Window virtual void Resize(); @@ -113,9 +115,6 @@ public: // predicates to determine what actions are possible at the current cursor // position. This depends on the implementation of the according mutators // below. (They are used for enabling toolbar icons) - bool HasDateCategories() const; - bool MayToggleDateCategories() const; - bool MayInsertRow() const; bool MayInsertColumn() const; bool MayDeleteRow() const; @@ -134,8 +133,6 @@ public: using BrowseBox::RemoveColumn; using BrowseBox::MouseButtonDown; - void ToggleDateCategories(); - void SwapRow(); void SwapColumn(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index a075f6c3a5c6..23fda0f472af 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -569,12 +569,6 @@ void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) // unlockControllers } -void DataBrowserModel::toggleDateCategories() -{ - DiagramHelper::toggleDateCategories( Reference( m_apDialogModel->getChartModel(), uno::UNO_QUERY ) ); - updateFromModel(); -} - DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( const Reference< chart2::XDataSeries > & xSeries ) const { @@ -626,6 +620,26 @@ double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) return fResult; } +uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ) +{ + uno::Any aResult; + + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size() && + m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) + { + Reference< chart2::data::XDataSequence > xData( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues() ); + if( xData.is() ) + { + Sequence< uno::Any > aValues( xData->getData()); + if( nAtRow < aValues.getLength()) + aResult = aValues[nAtRow]; + } + } + return aResult; +} + OUString DataBrowserModel::getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { OUString aResult; @@ -762,12 +776,6 @@ sal_Int32 DataBrowserModel::getCategoryColumnCount() } return nLastTextColumnIndex+1; } -bool DataBrowserModel::hasDateCategories() const -{ - if( NUMBER == getCellType( 0, 0 ) ) - return true; - return false; -} const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const { @@ -784,10 +792,6 @@ void DataBrowserModel::updateFromModel() Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); if( !xDiagram.is()) return; - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) - return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); // set template at DialogModel uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ); @@ -801,22 +805,7 @@ void DataBrowserModel::updateFromModel() if( lcl_ShowCategories( xDiagram )) { Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY ); - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel ); - bool bIsDateAxis = false; - if( xCooSys.is() ) - { - Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - chart2::ScaleData aScale( xAxis->getScaleData() ); - bIsDateAxis = (aScale.AxisType == chart2::AxisType::DATE); - } - } - - sal_Int32 nDateCategoriesNumberFormat = 0; - if( bIsDateAxis && aCooSysSeq.getLength() ) - nDateCategoriesNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[0], 0, 0 ); + ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); @@ -830,24 +819,18 @@ void DataBrowserModel::updateFromModel() aCategories.m_xLabeledDataSequence.set( xCategories ); if( lcl_ShowCategoriesAsDataLabel( xDiagram )) aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); - else if( bIsDateAxis ) - aCategories.m_aUIRoleName = DialogModel::GetRoleDates(); else aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); - if( bIsDateAxis ) - { - aCategories.m_eCellType = NUMBER; - aCategories.m_nNumberFormatKey = nDateCategoriesNumberFormat; - } - else - { - aCategories.m_eCellType = TEXT; - } + aCategories.m_eCellType = TEXTORDATE; m_aColumns.push_back( aCategories ); ++nHeaderStart; } } + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); + if( !xCooSysCnt.is()) + return; + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); for( sal_Int32 nCooSysIdx=0; nCooSysIdx xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index d6c82a2f15ea..bde29f1771e4 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -78,18 +78,18 @@ public: void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); void removeDataPointForAllSeries( sal_Int32 nAtIndex ); - void toggleDateCategories(); - enum eCellType { NUMBER, - TEXT + TEXT, + TEXTORDATE }; eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); /// returns if the number could successfully be set at the given position @@ -105,8 +105,6 @@ public: ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; - bool hasDateCategories() const; - struct tDataHeader { ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 00b25fb701fb..49e28e304975 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -736,12 +736,6 @@ OUString DialogModel::GetRoleDataLabel() return OUString( String( ::chart::SchResId( STR_OBJECT_DATALABELS ))); } -// static -OUString DialogModel::GetRoleDates() -{ - return OUString( String( ::chart::SchResId( STR_DATA_DATE_CATEGORIES ))); -} - // static sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 25bbc2669a9b..dcca6c716b8d 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -152,7 +152,6 @@ public: static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); static ::rtl::OUString GetRoleDataLabel(); - static ::rtl::OUString GetRoleDates(); // pass a role string (not translated) and get an index that serves for // relative ordering, to get e.g. x-values and y-values in the right order diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 0836ab9ca93a..81ec9c6c2ca7 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -40,7 +40,7 @@ #include "AxisIndexDefines.hxx" #include "ExplicitCategoriesProvider.hxx" #include "CommonConverters.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "RegressionCurveHelper.hxx" #include #include diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index b25c99454cef..4b4cec65426e 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -548,10 +548,6 @@ String STR_DATA_ROLE_CATEGORIES { Text [ en-US ] = "Categories"; }; -String STR_DATA_DATE_CATEGORIES -{ - Text [ en-US ] = "Dates"; -}; String STR_DATA_UNNAMED_SERIES { diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index 3f073136ef67..f1d441921a6a 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -160,9 +160,6 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) case TBI_DATA_SWAP_ROW : m_apBrwData->SwapRow (); break; - case TBI_DATA_TOGGLE_DATE_CATEGORIES: - m_apBrwData->ToggleDateCategories (); - break; } return 0; @@ -178,15 +175,13 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() ); m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() && !m_apBrwData->HasDateCategories() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); - return 0; } @@ -203,7 +198,6 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, FALSE ); } m_apBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc index 794beb40abd3..d2675c5bb29e 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -41,7 +41,6 @@ #define TBI_DATA_SWAP_COL 5 #define TBI_DATA_SWAP_ROW 6 #define TBI_DATA_INSERT_TEXT_COL 7 -#define TBI_DATA_TOGGLE_DATE_CATEGORIES 8 // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src index a83666553155..02ccc98b7a82 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.src +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -116,12 +116,6 @@ ModalDialog DLG_DIAGRAM_DATA { Type = TOOLBOXITEM_SEPARATOR ; }; - ToolBoxItem - { - HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES ; - Identifier = TBI_DATA_TOGGLE_DATE_CATEGORIES ; - Text [ en-US ] = "Categories: Date/Text" ; - }; }; }; @@ -135,9 +129,8 @@ ModalDialog DLG_DIAGRAM_DATA TBI_DATA_DELETE_COL; \ TBI_DATA_SWAP_COL; \ TBI_DATA_SWAP_ROW; \ - TBI_DATA_TOGGLE_DATE_CATEGORIES; \ }; \ - IdCount = { 8; } + IdCount = { 7; } ImageList IL_DIAGRAM_DATA { diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 5b3b96c705b3..431616714c00 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -56,7 +56,7 @@ #include "ChartTypeHelper.hxx" #include "ObjectNameProvider.hxx" #include "DiagramHelper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "AxisIndexDefines.hxx" #include "AxisHelper.hxx" diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index d738cf8f6245..c5072e26f648 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include #include diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx index 9dffde68cd5b..484458a63a84 100755 --- a/chart2/source/controller/inc/ErrorBarItemConverter.hxx +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include #include diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index 7d14eebabd78..5e20b7980c8b 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -52,7 +52,6 @@ #define HID_SCH_TBI_DATA_SWAP_COL "CHART2_HID_SCH_TBI_DATA_SWAP_COL" #define HID_SCH_TBI_DATA_SWAP_ROW "CHART2_HID_SCH_TBI_DATA_SWAP_ROW" #define HID_SCH_TBI_DATA_INSERT_TEXT_COL "CHART2_HID_SCH_TBI_DATA_INSERT_TEXT_COL" -#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES" #define HID_SCH_TBX_DATA "CHART2_HID_SCH_TBX_DATA" #define HID_SCH_ALIGNMENT_CTR_DIAL "CHART2_HID_SCH_ALIGNMENT_CTR_DIAL" diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx index cb4227185093..cb706e92cc97 100644 --- a/chart2/source/controller/inc/StatisticsItemConverter.hxx +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -31,7 +31,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 0a7a4057ef9a..14a1421f913a 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -44,7 +44,7 @@ #include "DiagramHelper.hxx" #include "macros.hxx" #include "chartview/DrawModelWrapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewElementListProvider.hxx" #include "MultipleChartConverters.hxx" #include "ControllerLockGuard.hxx" diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index eaaee11abe10..33430807c3e2 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -62,6 +63,12 @@ public: static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ); static ::com::sun::star::chart2::ScaleData getDateCheckedScale( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static sal_Int32 getExplicitNumberFormatKeyForAxis( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis + , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCorrespondingCoordinateSystem + , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier + , bool bSearchForParallelAxisIfNothingIsFound ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > createAxis( sal_Int32 nDimensionIndex, bool bMainAxis diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 858454497db5..e4fc0ea2ecfc 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include @@ -240,14 +242,6 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCooSys ); - static bool mayToggleDateCategories( - const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > & xChartDoc ); - - static void toggleDateCategories( - const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > & xChartDoc ); - static void switchToDateCategories( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ); @@ -256,6 +250,13 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram ); + static bool isDateNumberFormat( sal_Int32 nNumberFormat, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& xNumberFormats ); + static sal_Int32 getDateNumberFormat( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + + static sal_Int32 getPercentNumberFormat( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > getChartTypeByIndex( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx index dfa6379a42a1..f8d17c277036 100644 --- a/chart2/source/inc/ExplicitCategoriesProvider.hxx +++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx @@ -104,6 +104,10 @@ public: static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories( const SplitCategoriesProvider& rSplitCategoriesProvider ); + static void convertCategoryAnysToText( ::com::sun::star::uno::Sequence< rtl::OUString >& rOutTexts + , const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInAnys + , ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xChartModel ); + bool hasComplexCategories() const; sal_Int32 getCategoryLevelCount() const; @@ -122,6 +126,7 @@ private: //member ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories; + bool m_bIsExplicitCategoriesInited; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/NumberFormatterWrapper.hxx b/chart2/source/inc/NumberFormatterWrapper.hxx new file mode 100755 index 000000000000..964fd3f79f06 --- /dev/null +++ b/chart2/source/inc/NumberFormatterWrapper.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TOOLS_NUMBERFORMATTERWRAPPER_HXX +#define _CHART2_TOOLS_NUMBERFORMATTERWRAPPER_HXX + +#include "charttoolsdllapi.hxx" +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class FixedNumberFormatter; + +class OOO_DLLPUBLIC_CHARTTOOLS NumberFormatterWrapper +{ +public: + NumberFormatterWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier ); + virtual ~NumberFormatterWrapper(); + + SvNumberFormatter* getSvNumberFormatter() const; + ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > + getNumberFormatsSupplier() { return m_xNumberFormatsSupplier; }; + + rtl::OUString getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; + Date getNullDate() const; + +private: //private member + ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > + m_xNumberFormatsSupplier; + + SvNumberFormatter* m_pNumberFormatter; + ::com::sun::star::uno::Any m_aNullDate; +}; + + +class FixedNumberFormatter +{ +public: + FixedNumberFormatter( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier + , sal_Int32 nNumberFormatKey ); + virtual ~FixedNumberFormatter(); + + rtl::OUString getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; + +private: + NumberFormatterWrapper m_aNumberFormatterWrapper; + ULONG m_nNumberFormatKey; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index d263881a0905..fa7917ff7c5a 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -30,7 +30,7 @@ // this includes no link dependency #include -//next free is 294 +//next free is 293 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -194,8 +194,6 @@ #define STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS (RID_APP_START + 21) #define STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS (RID_APP_START + 267) -#define STR_DATA_DATE_CATEGORIES (RID_APP_START + 293) - //----------------------------------------------------------------------------- //chart objects //e.g. used as titles for insert dialogs and object properties dialog diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index 231b1acef6db..6e2fef8feb36 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -99,9 +99,6 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); - SAL_DLLPRIVATE static sal_Int32 getPercentNumberFormat( const ::com::sun::star::uno::Reference< - ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); - static sal_Int32 getExplicitNumberFormatKeyForDataLabel( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesOrPointProp , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xSeries diff --git a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx deleted file mode 100644 index 5eb2160a8765..000000000000 --- a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _CHART2_VIEW_NUMBERFORMATTERWRAPPER_HXX -#define _CHART2_VIEW_NUMBERFORMATTERWRAPPER_HXX - -#include -#include -#include "chartviewdllapi.hxx" - -//............................................................................. -namespace chart -{ -//............................................................................. - -//----------------------------------------------------------------------------- -/** -*/ -class FixedNumberFormatter; - -class OOO_DLLPUBLIC_CHARTVIEW NumberFormatterWrapper -{ -public: - NumberFormatterWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier ); - virtual ~NumberFormatterWrapper(); - - SvNumberFormatter* getSvNumberFormatter() const; - ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > - getNumberFormatsSupplier() { return m_xNumberFormatsSupplier; }; - - rtl::OUString getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; - Date getNullDate() const; - -private: //private member - ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > - m_xNumberFormatsSupplier; - - SvNumberFormatter* m_pNumberFormatter; - ::com::sun::star::uno::Any m_aNullDate; -}; - - -class FixedNumberFormatter -{ -public: - FixedNumberFormatter( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier - , sal_Int32 nNumberFormatKey ); - virtual ~FixedNumberFormatter(); - - rtl::OUString getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; - -private: - NumberFormatterWrapper m_aNumberFormatterWrapper; - ULONG m_nNumberFormatKey; -}; - -//............................................................................. -} //namespace chart -//............................................................................. -#endif diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index ec437cf7fd34..75bde77c801f 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -148,6 +148,148 @@ void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesPro } } +sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( + const Reference< chart2::XAxis >& xAxis + , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem + , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier + , bool bSearchForParallelAxisIfNothingIsFound ) +{ + sal_Int32 nNumberFormatKey(0); + Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); + if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) + { + bool bFormatSet = false; + //check wether we have a percent scale -> use percent format + if( xNumberFormatsSupplier.is() ) + { + ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); + if( aData.AxisType==AxisType::PERCENT ) + { + sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier ); + if( nPercentFormat != -1 ) + { + nNumberFormatKey = nPercentFormat; + bFormatSet = true; + } + } + else if( aData.AxisType==AxisType::DATE ) + { + if( aData.Categories.is() ) + { + Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); + Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); + if( xSeq.is() && !( xChartDoc.is() && xChartDoc->hasInternalDataProvider()) ) + nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); + else + nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); + bFormatSet = true; + } + } + } + + if( !bFormatSet ) + { + typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; + tNumberformatFrequency aKeyMap; + + bool bNumberFormatKeyFoundViaAttachedData = false; + sal_Int32 nAxisIndex = 0; + sal_Int32 nDimensionIndex = 1; + + try + { + Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); + if( xCTCnt.is() ) + { + AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); + ::rtl::OUString aRoleToMatch; + if( nDimensionIndex == 0 ) + aRoleToMatch = C2U("values-x"); + Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); + for( sal_Int32 nSeriesIdx=0; nSeriesIdx xDataSeries(aDataSeriesSeq[nSeriesIdx]); + Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); + + if( nDimensionIndex == 1 ) + { + //only take those series into accoutn that are attached to this axis + sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + if( nAttachedAxisIndex != nAxisIndex ) + continue; + } + + Reference< data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); + + if( !xLabeledSeq.is() && nDimensionIndex==0 ) + { + ScaleData aData = xAxis->getScaleData(); + xLabeledSeq = aData.Categories; + } + + if( xLabeledSeq.is() ) + { + Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); + if( xSeq.is() ) + { + sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); + // initialize the value + if( aKeyMap.find( nKey ) == aKeyMap.end()) + aKeyMap[ nKey ] = 0; + // increase frequency + aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); + } + } + } + } + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + if( ! aKeyMap.empty()) + { + sal_Int32 nMaxFreq = 0; + // find most frequent key + for( tNumberformatFrequency::const_iterator aIt = aKeyMap.begin(); + aIt != aKeyMap.end(); ++aIt ) + { + OSL_TRACE( "NumberFormatKey %d appears %d times", (*aIt).first, (*aIt).second ); + // all values must at least be 1 + if( (*aIt).second > nMaxFreq ) + { + nNumberFormatKey = (*aIt).first; + bNumberFormatKeyFoundViaAttachedData = true; + nMaxFreq = (*aIt).second; + } + } + } + + if( bSearchForParallelAxisIfNothingIsFound ) + { + //no format is set to this axis and no data is set to this axis + //--> try to obtain the format from the parallel y-axis + if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 ) + { + sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1; + Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) ); + nNumberFormatKey = AxisHelper::getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false ); + } + } + } + } + return nNumberFormatKey; +} + //static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index e9f060248afe..772994bf2498 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1045,26 +1045,6 @@ Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories( return aRet; } -bool DiagramHelper::mayToggleDateCategories( const Reference< XChartDocument >& xChartDoc ) -{ - Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); - if(xChartModel.is()) - { - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - if( xCooSys.is() ) - { - Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - ScaleData aScale( xAxis->getScaleData() ); - if( aScale.AxisType == chart2::AxisType::DATE || aScale.AxisType == chart2::AxisType::CATEGORY ) - return true; - } - } - } - return false; -} - namespace { void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) @@ -1194,35 +1174,62 @@ void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& x } } -void DiagramHelper::toggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +bool DiagramHelper::isSupportingDateAxis( const Reference< chart2::XDiagram >& xDiagram ) { - Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); - if(xChartModel.is()) + return ::chart::ChartTypeHelper::isSupportingDateAxis( + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), DiagramHelper::getDimension( xDiagram ), 0 ); +} + +bool DiagramHelper::isDateNumberFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) +{ + bool bIsDate = false; + if( !xNumberFormats.is() ) + return bIsDate; + + Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + if( xKeyProps.is() ) { - ControllerLockGuard aCtrlLockGuard( xChartModel ); + sal_Int32 nType = util::NumberFormat::UNDEFINED; + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + bIsDate = nType & util::NumberFormat::DATE; + } + return bIsDate; +} - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - if( xCooSys.is() ) +sal_Int32 DiagramHelper::getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) { - Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - ScaleData aScale( xAxis->getScaleData() ); - if( aScale.AxisType == chart2::AxisType::DATE ) - { - lcl_switchToTextCategories( xChartDoc, xAxis ); - } - else if( aScale.AxisType == chart2::AxisType::CATEGORY ) - { - lcl_switchToDateCategories( xChartDoc, xAxis ); - } - else - { - DBG_ERROR("Cannot toggle Date Categories for this axis type"); - } - } + nRet = aKeySeq[0]; + } + } + return nRet; +} + +sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + nRet = aKeySeq[0]; } } + return nRet; } // static diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 1c52a3c3e622..ef2d6ac22bf2 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -37,6 +37,7 @@ #include "ChartModelHelper.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" +#include "NumberFormatterWrapper.hxx" #include #include @@ -61,6 +62,7 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: , m_xCooSysModel( xCooSysModel ) , m_xChartModel( xChartModel ) , m_xOriginalCategories() + , m_bIsExplicitCategoriesInited(false) , m_bIsDateAxis(false) , m_bIsAutoDate(false) { @@ -188,30 +190,52 @@ std::vector lcl_getLimitingBorders( const std::vector< ComplexCategor return aLimitingBorders; } -uno::Sequence< rtl::OUString > lcl_DataToStringSequence( const uno::Reference< data::XDataSequence >& xDataSequence ) +void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< rtl::OUString >& rOutTexts, const uno::Sequence< uno::Any >& rInAnys, Reference< frame::XModel > xChartModel ) { - uno::Sequence< rtl::OUString > aStrings; + sal_Int32 nCount = rInAnys.getLength(); + if(!nCount) + return; + rOutTexts.realloc(nCount); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + + sal_Int32 nAxisNumberFormat = 0; + Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSysModel.is() ) + { + Reference< chart2::XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) ); + nAxisNumberFormat = AxisHelper::getExplicitNumberFormatKeyForAxis( + xAxis, xCooSysModel, xNumberFormatsSupplier, false ); + } - OSL_ASSERT( xDataSequence.is()); - if( !xDataSequence.is() ) - return aStrings; + sal_Int32 nLabelColor; + bool bColorChanged = false; + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + SvNumberFormatter* pSvNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); - uno::Reference< data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); - if( xTextualDataSequence.is() ) + for(sal_Int32 nN=0;nNgetTextualData(); - } - else - { - uno::Sequence< uno::Any > aValues = xDataSequence->getData(); - aStrings.realloc(aValues.getLength()); - - for(sal_Int32 nN=aValues.getLength();nN--;) - aValues[nN] >>= aStrings[nN]; + rtl::OUString aText; + uno::Any aAny = rInAnys[nN]; + if( aAny.hasValue() ) + { + double fDouble; + if( aAny>>=fDouble ) + { + if( !::rtl::math::isNan(fDouble) ) + aText = aNumberFormatterWrapper.getFormattedString( + nAxisNumberFormat, fDouble, nLabelColor, bColorChanged ); + } + else + { + aAny>>=aText; + } + } + rOutTexts[nN] = aText; } - - return aStrings; } SplitCategoriesProvider::~SplitCategoriesProvider() @@ -222,9 +246,13 @@ class SplitCategoriesProvider_ForLabeledDataSequences : public SplitCategoriesPr { public: - explicit SplitCategoriesProvider_ForLabeledDataSequences( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList ) + explicit SplitCategoriesProvider_ForLabeledDataSequences( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList + , const Reference< frame::XModel >& xChartModel ) : m_rSplitCategoriesList( rSplitCategoriesList ) + , m_xChartModel( xChartModel ) {} virtual ~SplitCategoriesProvider_ForLabeledDataSequences() {} @@ -235,6 +263,8 @@ public: private: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> >& m_rSplitCategoriesList; + + Reference< frame::XModel > m_xChartModel; }; sal_Int32 SplitCategoriesProvider_ForLabeledDataSequences::getLevelCount() const @@ -246,7 +276,11 @@ uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForLabeledDataSequences:: uno::Sequence< rtl::OUString > aRet; Reference< data::XLabeledDataSequence > xLabeledDataSequence( m_rSplitCategoriesList[nLevel] ); if( xLabeledDataSequence.is() ) - aRet = lcl_DataToStringSequence( xLabeledDataSequence->getValues() ); + { + uno::Reference< data::XDataSequence > xDataSequence( xLabeledDataSequence->getValues() ); + if( xDataSequence.is() ) + ExplicitCategoriesProvider::convertCategoryAnysToText( aRet, xDataSequence->getData(), m_xChartModel ); + } return aRet; } @@ -393,22 +427,6 @@ struct DatePlusIndexComparator } }; -bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) -{ - bool bIsDate = false; - if( !xNumberFormats.is() ) - return bIsDate; - - Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); - if( xKeyProps.is() ) - { - sal_Int32 nType = util::NumberFormat::UNDEFINED; - xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - bIsDate = nType & util::NumberFormat::DATE; - } - return bIsDate; -} - bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataSequence, std::vector< DatePlusIndex >& rDateCategories, bool bIsAutoDate, Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier ) { bool bOnlyDatesFound = true; @@ -424,8 +442,8 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); bool bOwnData = false; - bool bOwnDataAndDateFormat = false; - sal_Int32 nAxisNumberFormat = 0; + bool bOwnDataAnddAxisHasAnyFormat = false; + bool bOwnDataAnddAxisHasDateFormat = false; Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ) ); if( xChartDoc.is() && xCooSysModel.is() ) @@ -434,8 +452,12 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS { bOwnData = true; Reference< beans::XPropertySet > xAxisProps( xCooSysModel->getAxisByDimension(0,0), uno::UNO_QUERY ); + sal_Int32 nAxisNumberFormat = 0; if( xAxisProps.is() && (xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nAxisNumberFormat) ) - bOwnDataAndDateFormat = lcl_isDateFormat( nAxisNumberFormat, xNumberFormats ); + { + bOwnDataAnddAxisHasAnyFormat = true; + bOwnDataAnddAxisHasDateFormat = DiagramHelper::isDateNumberFormat( nAxisNumberFormat, xNumberFormats ); + } } } @@ -445,9 +467,9 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS if( bIsAutoDate ) { if( bOwnData ) - bIsDate = bOwnDataAndDateFormat; + bIsDate = bOwnDataAnddAxisHasAnyFormat ? bOwnDataAnddAxisHasDateFormat : true; else - bIsDate = lcl_isDateFormat( xDataSequence->getNumberFormatKeyByIndex( nN ), xNumberFormats ); + bIsDate = DiagramHelper::isDateNumberFormat( xDataSequence->getNumberFormatKeyByIndex( nN ), xNumberFormats ); } else bIsDate = true; @@ -488,7 +510,6 @@ void ExplicitCategoriesProvider::init() { if( m_bDirty ) { - m_aExplicitCategories.realloc(0); m_aComplexCats.clear();//not one per index m_aDateCategories.clear(); @@ -496,7 +517,6 @@ void ExplicitCategoriesProvider::init() { if( !hasComplexCategories() ) { - m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues()); if(m_bIsDateAxis) { if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 2, 0 ) ) @@ -507,15 +527,11 @@ void ExplicitCategoriesProvider::init() } else { - m_aExplicitCategories = lcl_getExplicitSimpleCategories( - SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats ); m_bIsDateAxis = false; } } else m_bIsDateAxis=false; - if(!m_aExplicitCategories.getLength()) - m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); m_bDirty = false; } } @@ -523,7 +539,28 @@ void ExplicitCategoriesProvider::init() Sequence< ::rtl::OUString > ExplicitCategoriesProvider::getSimpleCategories() { - init(); + if( !m_bIsExplicitCategoriesInited ) + { + init(); + m_aExplicitCategories.realloc(0); + if( m_xOriginalCategories.is() ) + { + if( !hasComplexCategories() ) + { + uno::Reference< data::XDataSequence > xDataSequence( m_xOriginalCategories->getValues() ); + if( xDataSequence.is() ) + ExplicitCategoriesProvider::convertCategoryAnysToText( m_aExplicitCategories, xDataSequence->getData(), m_xChartModel ); + } + else + { + m_aExplicitCategories = lcl_getExplicitSimpleCategories( + SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList, m_xChartModel ), m_aComplexCats ); + } + } + if(!m_aExplicitCategories.getLength()) + m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); + m_bIsExplicitCategoriesInited = true; + } return m_aExplicitCategories; } diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index b3f3058d6f05..88de8c94e977 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -375,17 +375,9 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum if( !xLDS.is() ) continue; Sequence< uno::Any > aDataSeq; - Reference< chart2::data::XTextualDataSequence > xTextSeq( xLDS->getValues(), uno::UNO_QUERY ); - if( !bIsDateAxis && xTextSeq.is() ) - { - aDataSeq = lcl_StringToAnySequence( xTextSeq->getTextualData() ); - } - else - { - Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); - if( xSeq.is() ) - aDataSeq = xSeq->getData(); - } + Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); + if( xSeq.is() ) + aDataSeq = xSeq->getData(); sal_Int32 nLength = aDataSeq.getLength(); if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) aNewCategories.resize( nLength ); @@ -790,40 +782,14 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { - bool bReturnText = true; vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); if( nLevelCount == 1 ) { sal_Int32 nL=0; aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) ); - bool bOnlyDatesFound = true; - double fTest = 0.0; - OUString aTest; - for(sal_Int32 nN=aResult.getLength(); nN--;) - { - uno::Any aAny(aResult[nN]); - if( !( aAny >>= fTest) ) - { - if( aAny.hasValue() ) - { - if( (aAny>>=aTest) && !aTest.getLength() ) - { - //empty string does not count as non date value! - aResult[nN] = uno::Any(); - } - else - { - bOnlyDatesFound=false; - break; - } - } - } - } - if( bOnlyDatesFound ) - bReturnText = false; } - if( bReturnText ) + else { Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); aResult.realloc( aLabels.getLength() ); diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx new file mode 100755 index 000000000000..829a64cc6617 --- /dev/null +++ b/chart2/source/tools/NumberFormatterWrapper.cxx @@ -0,0 +1,188 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "NumberFormatterWrapper.hxx" +#include "macros.hxx" +#include +// header for class SvNumberFormatsSupplierObj +#include +// header for class SvNumberformat +#include +#include +#include +#include +#include + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +FixedNumberFormatter::FixedNumberFormatter( + const uno::Reference< util::XNumberFormatsSupplier >& xSupplier + , sal_Int32 nNumberFormatKey ) + : m_aNumberFormatterWrapper(xSupplier) + , m_nNumberFormatKey( nNumberFormatKey ) +{ +} + +FixedNumberFormatter::~FixedNumberFormatter() +{ +} + +/* +sal_Int32 FixedNumberFormatter::getTextAndColor( double fUnscaledValueForText, rtl::OUString& rLabel ) const +{ + sal_Int32 nLabelColor = Color(COL_BLUE).GetColor(); //@todo get this from somewheres + rLabel = getFormattedString( fUnscaledValueForText, nLabelColor ); + return nLabelColor; +} +*/ + +rtl::OUString FixedNumberFormatter::getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const +{ + return m_aNumberFormatterWrapper.getFormattedString( + m_nNumberFormatKey, fValue, rLabelColor, rbColorChanged ); +} + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +NumberFormatterWrapper::NumberFormatterWrapper( const uno::Reference< util::XNumberFormatsSupplier >& xSupplier ) + : m_xNumberFormatsSupplier(xSupplier) + , m_pNumberFormatter(NULL) + +{ + uno::Reference xProp(m_xNumberFormatsSupplier,uno::UNO_QUERY); + rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM("NullDate")); + if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sNullDate) ) + m_aNullDate = xProp->getPropertyValue(sNullDate); + SvNumberFormatsSupplierObj* pSupplierObj = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); + if( pSupplierObj ) + m_pNumberFormatter = pSupplierObj->GetNumberFormatter(); + DBG_ASSERT(m_pNumberFormatter,"need a numberformatter"); +} + +NumberFormatterWrapper::~NumberFormatterWrapper() +{ +} + +SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const +{ + return m_pNumberFormatter; +} + +Date NumberFormatterWrapper::getNullDate() const +{ + USHORT nYear = 1899,nDay = 30,nMonth = 12; + Date aRet(nDay,nMonth,nYear); + + util::DateTime aUtilDate; + if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) ) + { + aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year); + } + else if( m_pNumberFormatter ) + { + Date* pDate = m_pNumberFormatter->GetNullDate(); + if( pDate ) + aRet = *pDate; + } + return aRet; +} + +rtl::OUString NumberFormatterWrapper::getFormattedString( + sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const +{ + String aText; + Color* pTextColor = NULL; + if( !m_pNumberFormatter ) + { + DBG_ERROR("Need a NumberFormatter"); + return aText; + } + // i99104 handle null date correctly + USHORT nYear = 1899,nDay = 30,nMonth = 12; + if ( m_aNullDate.hasValue() ) + { + Date* pDate = m_pNumberFormatter->GetNullDate(); + if ( pDate ) + { + nYear = pDate->GetYear(); + nMonth = pDate->GetMonth(); + nDay = pDate->GetDay(); + } // if ( pDate ) + util::DateTime aNewNullDate; + m_aNullDate >>= aNewNullDate; + m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year); + } + m_pNumberFormatter->GetOutputString( + fValue, nNumberFormatKey, aText, &pTextColor); + if ( m_aNullDate.hasValue() ) + { + m_pNumberFormatter->ChangeNullDate(nDay,nMonth,nYear); + } + rtl::OUString aRet( aText ); + + if(pTextColor) + { + rbColorChanged = true; + rLabelColor = pTextColor->GetColor(); + } + else + rbColorChanged = false; + + return aRet; +} + +// to get the language type use MsLangId::convertLocaleToLanguage( rNumberFormat.aLocale ) + +/* + uno::Reference< i18n::XNumberFormatCode > xNumberFormatCode( + m_xCC->getServiceManager()->createInstanceWithContext( C2U( + "com.sun.star.i18n.NumberFormatMapper" ), m_xCC ), uno::UNO_QUERY ); + + i18n::NumberFormatCode aNumberFormatCode = xNumberFormatCode->getDefault ( + i18n::KNumberFormatType::MEDIUM, + i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, + aLocale ); + + uno::Sequence< i18n::NumberFormatCode > aListOfNumberFormatCode = xNumberFormatCode->getAllFormatCode( + i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, + aLocale ); + + i18n::NumberFormatCode aNumberFormatCode0 = aListOfNumberFormatCode[0]; + i18n::NumberFormatCode aNumberFormatCode1 = aListOfNumberFormatCode[1]; +*/ + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk index fd92b894bfab..7554bd19cd38 100644 --- a/chart2/source/tools/makefile.mk +++ b/chart2/source/tools/makefile.mk @@ -70,6 +70,7 @@ SLOFILES= \ $(SLO)$/LinearRegressionCurveCalculator.obj \ $(SLO)$/LogarithmicRegressionCurveCalculator.obj \ $(SLO)$/MeanValueRegressionCurveCalculator.obj \ + $(SLO)$/NumberFormatterWrapper.obj \ $(SLO)$/OPropertySet.obj \ $(SLO)$/WrappedPropertySet.obj \ $(SLO)$/WrappedProperty.obj \ diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 23d1d7985b90..a4cca736fe18 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -36,7 +36,7 @@ #include "macros.hxx" #include "ViewDefines.hxx" #include "PropertyMapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "LabelPositionHelper.hxx" #include "TrueGuard.hxx" #include "BaseGFXHelper.hxx" diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index 0a10ee25e1c4..c23d6b95629d 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -33,7 +33,7 @@ #include "VPolarGrid.hxx" #include "ShapeFactory.hxx" #include "macros.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "PolarLabelPositionHelper.hxx" #include diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index dbafa59c0588..6b2f916b03ec 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -43,7 +43,7 @@ #include "ChartTypeHelper.hxx" #include "Clipping.hxx" #include "servicenames_charttypes.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ContainerHelper.hxx" #include "DataSeriesHelper.hxx" #include "RegressionCurveHelper.hxx" @@ -53,6 +53,7 @@ #include "Strings.hrc" #include "RelativePositionHelper.hxx" #include "DateHelper.hxx" +#include "DiagramHelper.hxx" //only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory #include "BarChart.hxx" @@ -395,7 +396,7 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries nNumberFormatKey = rDataSeries.getExplicitNumberFormat(nPointIndex,bAsPercentage); else if( bAsPercentage ) { - sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() ); + sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() ); if( nPercentFormat != -1 ) nNumberFormatKey = nPercentFormat; } diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index cff3ab3d1c14..4f39cac39c9d 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -31,7 +31,7 @@ #include "ChartView.hxx" #include "chartview/DrawModelWrapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" @@ -585,12 +585,14 @@ private: ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList; sal_Int32 m_nMaxAxisIndex; bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; + sal_Int32 m_nDefaultDateNumberFormat; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) + , m_nDefaultDateNumberFormat(0) { } @@ -628,6 +630,10 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( return; uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() + && DiagramHelper::isSupportingDateAxis( xDiagram ) ) + m_nDefaultDateNumberFormat=DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); if(!nDimensionCount) @@ -904,6 +910,11 @@ void SeriesPlotterContainer::setNumberFormatsFromAxes() { aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex ); } + else if( nDimensionIndex==0 ) + { + //provide a default date format for date axis with own data + aAxesNumberFormats.setFormat( m_nDefaultDateNumberFormat, nDimensionIndex, nAxisIndex ); + } } } catch( lang::IndexOutOfBoundsException& e ) @@ -1828,195 +1839,16 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } -sal_Int32 lcl_getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) -{ - sal_Int32 nRet=-1; - Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); - if( xNumberFormats.is() ) - { - sal_Bool bCreate = sal_True; - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, - rLocaleDataWrapper.getLocale(), bCreate ); - if( aKeySeq.getLength() ) - { - nRet = aKeySeq[0]; - } - } - return nRet; -} - -sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( - const Reference< chart2::XAxis >& xAxis - , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem - , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier - , bool bSearchForParallelAxisIfNothingIsFound ) -{ - sal_Int32 nNumberFormatKey(0); - Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) - { - bool bFormatSet = false; - //check wether we have a percent scale -> use percent format - if( xNumberFormatsSupplier.is() ) - { - ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); - if( aData.AxisType==AxisType::PERCENT ) - { - sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); - if( nPercentFormat != -1 ) - { - nNumberFormatKey = nPercentFormat; - bFormatSet = true; - } - } - else if( aData.AxisType==AxisType::DATE ) - { - if( aData.Categories.is() ) - { - Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); - if( xSeq.is() ) - nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); - else - nNumberFormatKey = lcl_getDateNumberFormat( xNumberFormatsSupplier ); - bFormatSet = true; - } - } - } - - if( !bFormatSet ) - { - typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; - tNumberformatFrequency aKeyMap; - - bool bNumberFormatKeyFoundViaAttachedData = false; - sal_Int32 nAxisIndex = 0; - sal_Int32 nDimensionIndex = 1; - - try - { - Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); - if( xCTCnt.is() ) - { - AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); - ::rtl::OUString aRoleToMatch; - if( nDimensionIndex == 0 ) - aRoleToMatch = C2U("values-x"); - Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx xDataSeries(aDataSeriesSeq[nSeriesIdx]); - Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); - - if( nDimensionIndex == 1 ) - { - //only take those series into accoutn that are attached to this axis - sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); - if( nAttachedAxisIndex != nAxisIndex ) - continue; - } - - Reference< data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); - - if( !xLabeledSeq.is() && nDimensionIndex==0 ) - { - ScaleData aData = xAxis->getScaleData(); - if( aData.AxisType==AxisType::REALNUMBER ) - xLabeledSeq = aData.Categories; - } - - if( xLabeledSeq.is() ) - { - Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); - if( xSeq.is() ) - { - sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); - // initialize the value - if( aKeyMap.find( nKey ) == aKeyMap.end()) - aKeyMap[ nKey ] = 0; - // increase frequency - aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); - } - } - } - } - } - } - catch( const uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - - if( ! aKeyMap.empty()) - { - sal_Int32 nMaxFreq = 0; - // find most frequent key - for( tNumberformatFrequency::const_iterator aIt = aKeyMap.begin(); - aIt != aKeyMap.end(); ++aIt ) - { - OSL_TRACE( "NumberFormatKey %d appears %d times", (*aIt).first, (*aIt).second ); - // all values must at least be 1 - if( (*aIt).second > nMaxFreq ) - { - nNumberFormatKey = (*aIt).first; - bNumberFormatKeyFoundViaAttachedData = true; - nMaxFreq = (*aIt).second; - } - } - } - - if( bSearchForParallelAxisIfNothingIsFound ) - { - //no format is set to this axis and no data is set to this axis - //--> try to obtain the format from the parallel y-axis - if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 ) - { - sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1; - Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) ); - nNumberFormatKey = lcl_getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false ); - } - } - } - } - return nNumberFormatKey; -} - //static sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) { - return lcl_getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier + return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier , true /*bSearchForParallelAxisIfNothingIsFound*/ ); } -//static -sal_Int32 ExplicitValueProvider::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) -{ - sal_Int32 nRet=-1; - Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); - if( xNumberFormats.is() ) - { - sal_Bool bCreate = sal_True; - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - Sequence aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT, - rLocaleDataWrapper.getLocale(), bCreate ); - if( aKeySeq.getLength() ) - { - nRet = aKeySeq[0]; - } - } - return nRet; -} - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const uno::Reference< XDataSeries >& xSeries, @@ -2069,7 +1901,7 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe return nFormat; if( !(xSeriesOrPointProp->getPropertyValue(C2U( "PercentageNumberFormat" )) >>= nFormat) ) { - nFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); + nFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier ); } if(nFormat<0) nFormat=0; diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx deleted file mode 100644 index de7dde79e789..000000000000 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ /dev/null @@ -1,188 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" -#include "chartview/NumberFormatterWrapper.hxx" -#include "macros.hxx" -#include -// header for class SvNumberFormatsSupplierObj -#include -// header for class SvNumberformat -#include -#include -#include -#include -#include - -//............................................................................. -namespace chart -{ -//............................................................................. -using namespace ::com::sun::star; - -FixedNumberFormatter::FixedNumberFormatter( - const uno::Reference< util::XNumberFormatsSupplier >& xSupplier - , sal_Int32 nNumberFormatKey ) - : m_aNumberFormatterWrapper(xSupplier) - , m_nNumberFormatKey( nNumberFormatKey ) -{ -} - -FixedNumberFormatter::~FixedNumberFormatter() -{ -} - -/* -sal_Int32 FixedNumberFormatter::getTextAndColor( double fUnscaledValueForText, rtl::OUString& rLabel ) const -{ - sal_Int32 nLabelColor = Color(COL_BLUE).GetColor(); //@todo get this from somewheres - rLabel = getFormattedString( fUnscaledValueForText, nLabelColor ); - return nLabelColor; -} -*/ - -rtl::OUString FixedNumberFormatter::getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const -{ - return m_aNumberFormatterWrapper.getFormattedString( - m_nNumberFormatKey, fValue, rLabelColor, rbColorChanged ); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -NumberFormatterWrapper::NumberFormatterWrapper( const uno::Reference< util::XNumberFormatsSupplier >& xSupplier ) - : m_xNumberFormatsSupplier(xSupplier) - , m_pNumberFormatter(NULL) - -{ - uno::Reference xProp(m_xNumberFormatsSupplier,uno::UNO_QUERY); - rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM("NullDate")); - if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sNullDate) ) - m_aNullDate = xProp->getPropertyValue(sNullDate); - SvNumberFormatsSupplierObj* pSupplierObj = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); - if( pSupplierObj ) - m_pNumberFormatter = pSupplierObj->GetNumberFormatter(); - DBG_ASSERT(m_pNumberFormatter,"need a numberformatter"); -} - -NumberFormatterWrapper::~NumberFormatterWrapper() -{ -} - -SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const -{ - return m_pNumberFormatter; -} - -Date NumberFormatterWrapper::getNullDate() const -{ - USHORT nYear = 1899,nDay = 30,nMonth = 12; - Date aRet(nDay,nMonth,nYear); - - util::DateTime aUtilDate; - if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) ) - { - aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year); - } - else if( m_pNumberFormatter ) - { - Date* pDate = m_pNumberFormatter->GetNullDate(); - if( pDate ) - aRet = *pDate; - } - return aRet; -} - -rtl::OUString NumberFormatterWrapper::getFormattedString( - sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const -{ - String aText; - Color* pTextColor = NULL; - if( !m_pNumberFormatter ) - { - DBG_ERROR("Need a NumberFormatter"); - return aText; - } - // i99104 handle null date correctly - USHORT nYear = 1899,nDay = 30,nMonth = 12; - if ( m_aNullDate.hasValue() ) - { - Date* pDate = m_pNumberFormatter->GetNullDate(); - if ( pDate ) - { - nYear = pDate->GetYear(); - nMonth = pDate->GetMonth(); - nDay = pDate->GetDay(); - } // if ( pDate ) - util::DateTime aNewNullDate; - m_aNullDate >>= aNewNullDate; - m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year); - } - m_pNumberFormatter->GetOutputString( - fValue, nNumberFormatKey, aText, &pTextColor); - if ( m_aNullDate.hasValue() ) - { - m_pNumberFormatter->ChangeNullDate(nDay,nMonth,nYear); - } - rtl::OUString aRet( aText ); - - if(pTextColor) - { - rbColorChanged = true; - rLabelColor = pTextColor->GetColor(); - } - else - rbColorChanged = false; - - return aRet; -} - -// to get the language type use MsLangId::convertLocaleToLanguage( rNumberFormat.aLocale ) - -/* - uno::Reference< i18n::XNumberFormatCode > xNumberFormatCode( - m_xCC->getServiceManager()->createInstanceWithContext( C2U( - "com.sun.star.i18n.NumberFormatMapper" ), m_xCC ), uno::UNO_QUERY ); - - i18n::NumberFormatCode aNumberFormatCode = xNumberFormatCode->getDefault ( - i18n::KNumberFormatType::MEDIUM, - i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, - aLocale ); - - uno::Sequence< i18n::NumberFormatCode > aListOfNumberFormatCode = xNumberFormatCode->getAllFormatCode( - i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, - aLocale ); - - i18n::NumberFormatCode aNumberFormatCode0 = aListOfNumberFormatCode[0]; - i18n::NumberFormatCode aNumberFormatCode1 = aListOfNumberFormatCode[1]; -*/ - -//............................................................................. -} //namespace chart -//............................................................................. diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk index ec9c99f2a898..8675930aa107 100644 --- a/chart2/source/view/main/makefile.mk +++ b/chart2/source/view/main/makefile.mk @@ -43,7 +43,6 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES = \ $(SLO)$/ChartItemPool.obj \ $(SLO)$/DrawModelWrapper.obj \ - $(SLO)$/NumberFormatterWrapper.obj \ $(SLO)$/PropertyMapper.obj \ $(SLO)$/Stripe.obj \ $(SLO)$/VLineProperties.obj \ -- cgit From df4eb12515da36973ad00eb2ae2b18ca303646c7 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Fri, 14 Jan 2011 18:59:53 +0100 Subject: chart46: #i116468# scale tab page - better fallback after wrong input --- chart2/source/controller/dialogs/tp_Scale.cxx | 38 ++++++++++++++++++++------- chart2/source/controller/dialogs/tp_Scale.hxx | 1 + 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index c12c5bdb3814..3cb2d2838e8c 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -98,6 +98,17 @@ void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) rAuto.SetPosPixel(aPos); } +long lcl_getLabelDistance( Control& rControl ) +{ + return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); +} + +void lcl_setValue( FormattedField& rFmtField, double fValue ) +{ + rFmtField.SetValue( fValue ); + rFmtField.SetDefaultValue( fValue ); +} + } ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : @@ -168,6 +179,18 @@ ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : m_aLB_TimeResolution.SetDropDownLineCount(3); m_aLB_MainTimeUnit.SetDropDownLineCount(3); m_aLB_HelpTimeUnit.SetDropDownLineCount(3); + + aFmtFldMin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldMax.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldStepMain.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldOrigin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); +} + +IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied ) +{ + if( pFmtFied ) + pFmtFied->SetDefaultValue( pFmtFied->GetValue() ); + return 0; } void ScaleTabPage::StateChanged( StateChangedType nType ) @@ -178,11 +201,6 @@ void ScaleTabPage::StateChanged( StateChangedType nType ) AdjustControlPositions(); } -long lcl_getLabelDistance( Control& rControl ) -{ - return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); -} - void ScaleTabPage::AdjustControlPositions() { //optimize position of the controls @@ -320,7 +338,7 @@ void ScaleTabPage::EnableControls() { //transport value from one to other control if( bWasDateAxis ) - aFmtFldStepMain.SetValue( m_aMt_MainDateStep.GetValue() ); + lcl_setValue( aFmtFldStepMain, m_aMt_MainDateStep.GetValue() ); else m_aMt_MainDateStep.SetValue( static_cast(aFmtFldStepMain.GetValue()) ); } @@ -483,7 +501,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldMin.SetValue( fMin ); + lcl_setValue( aFmtFldMin, fMin ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) @@ -492,7 +510,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) { fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldMax.SetValue( fMax ); + lcl_setValue( aFmtFldMax, fMax ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) @@ -501,7 +519,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldStepMain.SetValue( fStepMain ); + lcl_setValue( aFmtFldStepMain, fStepMain ); m_aMt_MainDateStep.SetValue( static_cast(fStepMain) ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) @@ -520,7 +538,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldOrigin.SetValue( fOrigin ); + lcl_setValue( aFmtFldOrigin, fOrigin ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 953187d1d9cf..ecfc42c2c513 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -121,6 +121,7 @@ private: DECL_LINK( SelectAxisTypeHdl, void* ); DECL_LINK( EnableValueHdl, CheckBox* ); + DECL_LINK( FmtFieldModifiedHdl, FormattedField* ); /** shows a warning window due to an invalid input. -- cgit From f718b312b7de8a48dc959b871c188768a6e067d5 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Mon, 17 Jan 2011 17:10:29 +0100 Subject: chart46: #i25706# compiler error after rebase --- chart2/source/inc/NumberFormatterWrapper.hxx | 2 +- chart2/source/tools/ExplicitCategoriesProvider.cxx | 1 - chart2/source/tools/InternalDataProvider.cxx | 3 +-- chart2/source/view/diagram/VDiagram.cxx | 3 --- 4 files changed, 2 insertions(+), 7 deletions(-) (limited to 'chart2') diff --git a/chart2/source/inc/NumberFormatterWrapper.hxx b/chart2/source/inc/NumberFormatterWrapper.hxx index 964fd3f79f06..e4ef4b8600db 100755 --- a/chart2/source/inc/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/NumberFormatterWrapper.hxx @@ -63,7 +63,7 @@ private: //private member }; -class FixedNumberFormatter +class OOO_DLLPUBLIC_CHARTTOOLS FixedNumberFormatter { public: FixedNumberFormatter( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 9e2987be1ee4..39a76b2bf119 100755 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -214,7 +214,6 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< rtl:: bool bColorChanged = false; NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); - SvNumberFormatter* pSvNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); for(sal_Int32 nN=0;nN > aNewCategories;//inner count is level { ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); - bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); @@ -385,7 +384,7 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum else if( nLength < nCatLength ) aDataSeq.realloc( nCatLength ); transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(), - aNewCategories.begin(), lcl_setStringAtLevel(nL) ); + aNewCategories.begin(), lcl_setAnyAtLevel(nL) ); } if( !nLevelCount ) { diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 1e5911b76358..0aad597d2475 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -49,11 +49,8 @@ #include // header for class SvxShape #include -// header for GetSdrObjectFromXShape -#include // header for class E3dScene #include -#include #include //............................................................................. -- cgit From 91bc4841ef639a0e48449fab1f2a07920f2e5eba Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 19 Jan 2011 15:12:20 +0100 Subject: chart46: add missing explicit dependency to offapi --- chart2/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/prj/build.lst b/chart2/prj/build.lst index 5526e2964680..ec6658d212c6 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 LIBXSLT:libxslt NULL +ch chart2 : offapi offuh 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 -- cgit From b86301a3311c67e4e322331295b04f6a1a9c765a Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 19 Jan 2011 15:46:50 +0100 Subject: chart46: #i25706# implement date axis - #i116467# change behaviour of own data table --- .../controller/dialogs/ObjectNameProvider.cxx | 9 +--- chart2/source/controller/dialogs/Strings.src | 5 -- chart2/source/inc/CommonFunctors.hxx | 13 +---- chart2/source/inc/Strings.hrc | 2 +- chart2/source/tools/AxisHelper.cxx | 58 +++++++++++++++++++--- 5 files changed, 55 insertions(+), 32 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 257ff045f116..483424d04497 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -191,14 +191,7 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal if( aX.getLength() == 0 ) { - rtl::OUString aCategory = ::rtl::OUString( String(SchResId(STR_TIP_CATEGORY_VALUE))); - - replaceParamterInString( aCategory - , C2U("%CATEGORYVALUE") - , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex ) - ); - - aRet = aCategory; + aRet = ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex ); } else { diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 4b4cec65426e..ca511f08dbfe 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -388,11 +388,6 @@ String STR_TIP_DATAPOINT_VALUES Text [ en-US ] = "Values: %POINTVALUES"; }; -String STR_TIP_CATEGORY_VALUE -{ - Text [ en-US ] = "'%CATEGORYVALUE'"; -}; - String STR_TIP_DATAPOINT { Text [ en-US ] = "Data Point %POINTNUMBER, data series %SERIESNUMBER, values: %POINTVALUES"; diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx index 13435741e63e..eec5b59dd582 100644 --- a/chart2/source/inc/CommonFunctors.hxx +++ b/chart2/source/inc/CommonFunctors.hxx @@ -67,18 +67,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public ::std::unary_function< ::co ::rtl::math::setNan( & fResult ); ::com::sun::star::uno::TypeClass eClass( rAny.getValueType().getTypeClass() ); - if( eClass == ::com::sun::star::uno::TypeClass_STRING ) - { - rtl_math_ConversionStatus eConversionStatus; - fResult = ::rtl::math::stringToDouble( - * reinterpret_cast< const ::rtl::OUString * >( rAny.getValue() ), - sal_Char( '.' ), sal_Char( ',' ), - & eConversionStatus, NULL ); - - if( eConversionStatus != rtl_math_ConversionStatus_Ok ) - ::rtl::math::setNan( & fResult ); - } - else if( eClass == ::com::sun::star::uno::TypeClass_DOUBLE ) + if( eClass == ::com::sun::star::uno::TypeClass_DOUBLE ) { fResult = * reinterpret_cast< const double * >( rAny.getValue() ); } diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index fa7917ff7c5a..a5df51f81378 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -31,6 +31,7 @@ #include //next free is 293 +//single free: 139 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -325,7 +326,6 @@ #define STR_TIP_DATAPOINT (RID_APP_START + 140) #define STR_TIP_DATAPOINT_INDEX (RID_APP_START + 141) #define STR_TIP_DATAPOINT_VALUES (RID_APP_START + 142) -#define STR_TIP_CATEGORY_VALUE (RID_APP_START + 139) //----------------------------------------------------------------------------- //warning and info boxes diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 3f1213e06155..4fd21e2c3b8b 100755 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -39,6 +39,7 @@ #include "DataSeriesHelper.hxx" #include "Scaling.hxx" #include "ChartModelHelper.hxx" +#include "DataSourceHelper.hxx" #include #include @@ -52,6 +53,8 @@ // header for class OUStringBuffer #include +#include + #include #include @@ -150,6 +153,12 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( , bool bSearchForParallelAxisIfNothingIsFound ) { sal_Int32 nNumberFormatKey(0); + bool bNumberFormatKeyFoundViaAttachedData = false; + sal_Int32 nAxisIndex = 0; + sal_Int32 nDimensionIndex = 1; + AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); + Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) { @@ -172,7 +181,6 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( if( aData.Categories.is() ) { Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); - Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); if( xSeq.is() && !( xChartDoc.is() && xChartDoc->hasInternalDataProvider()) ) nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); else @@ -180,6 +188,49 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( bFormatSet = true; } } + else if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() && nDimensionIndex == 0 ) //maybe date axis + { + Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram() ); + if( DiagramHelper::isSupportingDateAxis( xDiagram ) ) + { + nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); + } + else + { + Reference< data::XDataSource > xSource( DataSourceHelper::getUsedData( xChartDoc ) ); + if( xSource.is() ) + { + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aXValues( + DataSeriesHelper::getAllDataSequencesByRole( xSource->getDataSequences(), C2U("values-x"), true ) ); + if( aXValues.empty() ) + { + Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) ); + if( xCategories.is() ) + { + Reference< data::XDataSequence > xSeq( xCategories->getValues()); + if( xSeq.is() ) + { + bool bHasValidDoubles = false; + double fTest=0.0; + Sequence< uno::Any > aCats( xSeq->getData() ); + sal_Int32 nCount = aCats.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) + { + if( (aCats[i]>>=fTest) && !::rtl::math::isNan(fTest) ) + { + bHasValidDoubles=true; + break; + } + } + if( bHasValidDoubles ) + nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); + } + } + } + } + } + bFormatSet = true; + } } if( !bFormatSet ) @@ -187,16 +238,11 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; tNumberformatFrequency aKeyMap; - bool bNumberFormatKeyFoundViaAttachedData = false; - sal_Int32 nAxisIndex = 0; - sal_Int32 nDimensionIndex = 1; - try { Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); if( xCTCnt.is() ) { - AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); ::rtl::OUString aRoleToMatch; if( nDimensionIndex == 0 ) aRoleToMatch = C2U("values-x"); -- cgit From 796dfe2205b9a7735e7fb908b3b4fe7d74d76170 Mon Sep 17 00:00:00 2001 From: "Ingrid Halama [iha]" Date: Wed, 19 Jan 2011 17:50:04 +0100 Subject: chart46: #i25706# implement date axis - #i116467# change behaviour of own data table --- chart2/source/tools/DiagramHelper.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 58460c0749a5..d442797d8ce1 100755 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -42,6 +42,7 @@ #include "ChartModelHelper.hxx" #include "RelativePositionHelper.hxx" #include "ControllerLockGuard.hxx" +#include "NumberFormatterWrapper.hxx" #include #include @@ -64,7 +65,7 @@ #include #include - +#include // header for class Application #include @@ -1192,6 +1193,16 @@ sal_Int32 DiagramHelper::getDateNumberFormat( const Reference< util::XNumberForm nRet = aKeySeq[0]; } } + + //try to get a date format with full year display + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + SvNumberFormatter* pNumFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); + if( pNumFormatter ) + { + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nRet ); + if( pFormat ) + nRet = pNumFormatter->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, pFormat->GetLanguage() ); + } return nRet; } -- cgit From 30ebcbb6e0595a13c32f1294fb1918a2a9e808c0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 24 Jan 2011 14:55:49 +0100 Subject: removetooltypes01: #i112600# adjust rebase for windows --- chart2/source/view/axes/VCartesianAxis.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index c17e56ce6bc5..a7bfa6a50640 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -336,17 +336,17 @@ bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape ) SvxTextForwarder* pTextForwarder = pTextEditSource->GetTextForwarder(); if ( pTextForwarder ) { - USHORT nParaCount = pTextForwarder->GetParagraphCount(); - for ( USHORT nPara = 0; nPara < nParaCount; ++nPara ) + sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount(); + for ( sal_uInt16 nPara = 0; nPara < nParaCount; ++nPara ) { - USHORT nLineCount = pTextForwarder->GetLineCount( nPara ); - for ( USHORT nLine = 0; nLine < nLineCount; ++nLine ) + sal_uInt16 nLineCount = pTextForwarder->GetLineCount( nPara ); + for ( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine ) { - USHORT nLineStart = 0; - USHORT nLineEnd = 0; + sal_uInt16 nLineStart = 0; + sal_uInt16 nLineEnd = 0; pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine ); - USHORT nWordStart = 0; - USHORT nWordEnd = 0; + sal_uInt16 nWordStart = 0; + sal_uInt16 nWordEnd = 0; if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) && ( nWordStart != nLineStart ) ) { -- cgit From b8e3d5a9d56ef6dd49b8b52bc22f2529591e16ef Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Wed, 2 Feb 2011 10:16:51 +0100 Subject: #i10000# WAE: initialize variables --- chart2/source/tools/ExplicitCategoriesProvider.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2') diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 39a76b2bf119..a0376aa95d46 100755 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -221,7 +221,7 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< rtl:: uno::Any aAny = rInAnys[nN]; if( aAny.hasValue() ) { - double fDouble; + double fDouble = 0; if( aAny>>=fDouble ) { if( !::rtl::math::isNan(fDouble) ) @@ -478,7 +478,7 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS if( aAny.hasValue() ) { OUString aTest; - double fTest; + double fTest = 0; if( (aAny>>=aTest) && !aTest.getLength() ) //empty String bContainsEmptyString = true; else if( (aAny>>=fTest) && ::rtl::math::isNan(fTest) ) -- cgit From 0ceb085ea2b49234664765161095f2e5911e2b3b Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Wed, 2 Feb 2011 11:27:57 +0100 Subject: #i10000# WAE: initialize variables --- chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index 658a9af83ac5..64773ad062f9 100755 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -279,7 +279,7 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons } case SCALE_PROP_AXIS_TYPE: { - sal_Int32 nType; + sal_Int32 nType = 0; if( (rOuterValue >>= nType) ) { if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType ) -- cgit From 981b1b3d5a9bcdad2a267bedcc5da22266103a0b Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 7 Feb 2011 18:01:48 +0100 Subject: removetooltypes01: #i112600# adjust rebase in chart2, starmath, sc, sd --- chart2/source/controller/dialogs/tp_AxisLabel.cxx | 2 +- chart2/source/controller/dialogs/tp_Scale.cxx | 18 +++++++++--------- chart2/source/inc/NumberFormatterWrapper.hxx | 2 +- chart2/source/model/main/UndoManager.cxx | 2 +- chart2/source/tools/NumberFormatterWrapper.cxx | 4 ++-- chart2/source/view/axes/DateHelper.cxx | 6 +++--- chart2/source/view/axes/DateScaling.cxx | 6 +++--- chart2/source/view/main/ChartItemPool.cxx | 10 +++++----- 8 files changed, 25 insertions(+), 25 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 63014c1a6824..8d405af88dc8 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -259,7 +259,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) <<<<<<< local aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, sal_False, &pPoolItem ); ======= - aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, sal_False, &pPoolItem ); >>>>>>> other if( aState == SFX_ITEM_SET ) { diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 1ca3e8b358b8..62f2aee5e076 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -398,7 +398,7 @@ enum AxisTypeListBoxEntry IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG ) { - USHORT nPos = m_aLB_AxisType.GetSelectEntryPos(); + sal_uInt16 nPos = m_aLB_AxisType.GetSelectEntryPos(); if( nPos==TYPE_DATE ) m_nAxisType = chart2::AxisType::DATE; else @@ -458,17 +458,17 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) return; const SfxPoolItem *pPoolItem = NULL; - if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); m_nAxisType=chart2::AxisType::REALNUMBER; - if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, sal_True, &pPoolItem) == SFX_ITEM_SET) m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis ) m_nAxisType=chart2::AxisType::CATEGORY; if( m_bAllowDateAxis ) { bool bAutoDateAxis = false; - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); sal_uInt16 nPos = 0; @@ -495,7 +495,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) aCbxAutoOrigin.Check( true ); m_aCbx_AutoTimeResolution.Check( true ); - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,sal_True,&pPoolItem) == SFX_ITEM_SET) aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,sal_True, &pPoolItem) == SFX_ITEM_SET) @@ -541,20 +541,20 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) lcl_setValue( aFmtFldOrigin, fOrigin ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET) m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); - if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET) { m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue(); m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET) { m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit ); } - if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET) { m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit ); diff --git a/chart2/source/inc/NumberFormatterWrapper.hxx b/chart2/source/inc/NumberFormatterWrapper.hxx index e4ef4b8600db..77e2423a266f 100755 --- a/chart2/source/inc/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/NumberFormatterWrapper.hxx @@ -74,7 +74,7 @@ public: private: NumberFormatterWrapper m_aNumberFormatterWrapper; - ULONG m_nNumberFormatKey; + sal_uLong m_nNumberFormatKey; }; //............................................................................. diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx index 702dd2e5ab54..4efe57e17090 100755 --- a/chart2/source/model/main/UndoManager.cxx +++ b/chart2/source/model/main/UndoManager.cxx @@ -85,7 +85,7 @@ namespace chart ,m_aUndoManager() ,m_aUndoHelper( *this ) { - m_aUndoManager.SetMaxUndoActionCount( (USHORT)SvtUndoOptions().GetUndoCount() ); + m_aUndoManager.SetMaxUndoActionCount( (sal_uInt16)SvtUndoOptions().GetUndoCount() ); } virtual ~UndoManager_Impl() diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx index 829a64cc6617..c4711a4da8be 100755 --- a/chart2/source/tools/NumberFormatterWrapper.cxx +++ b/chart2/source/tools/NumberFormatterWrapper.cxx @@ -102,7 +102,7 @@ SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const Date NumberFormatterWrapper::getNullDate() const { - USHORT nYear = 1899,nDay = 30,nMonth = 12; + sal_uInt16 nYear = 1899,nDay = 30,nMonth = 12; Date aRet(nDay,nMonth,nYear); util::DateTime aUtilDate; @@ -130,7 +130,7 @@ rtl::OUString NumberFormatterWrapper::getFormattedString( return aText; } // i99104 handle null date correctly - USHORT nYear = 1899,nDay = 30,nMonth = 12; + sal_uInt16 nYear = 1899,nDay = 30,nMonth = 12; if ( m_aNullDate.hasValue() ) { Date* pDate = m_pNumberFormatter->GetNullDate(); diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx index 45f958ab2898..7159a733498f 100644 --- a/chart2/source/view/axes/DateHelper.cxx +++ b/chart2/source/view/axes/DateHelper.cxx @@ -72,8 +72,8 @@ Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) nNewYear--; if( nNewMonth <= 0 ) nNewMonth += 12; - aRet.SetMonth( USHORT(nNewMonth) ); - aRet.SetYear( USHORT(nNewYear) ); + aRet.SetMonth( sal_uInt16(nNewMonth) ); + aRet.SetYear( sal_uInt16(nNewYear) ); while(!aRet.IsValid()) aRet--; return aRet; @@ -82,7 +82,7 @@ Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) Date DateHelper::GetDateSomeYearsAway( const Date& rD, long nYearDistance ) { Date aRet(rD); - aRet.SetYear( static_cast(rD.GetYear()+nYearDistance) ); + aRet.SetYear( static_cast(rD.GetYear()+nYearDistance) ); while(!aRet.IsValid()) aRet--; return aRet; diff --git a/chart2/source/view/axes/DateScaling.cxx b/chart2/source/view/axes/DateScaling.cxx index 6802fba67bd2..8a69e83abbc8 100644 --- a/chart2/source/view/axes/DateScaling.cxx +++ b/chart2/source/view/axes/DateScaling.cxx @@ -177,13 +177,13 @@ double SAL_CALL InverseDateScaling::doScaling( double value ) fYear--; fMonth=12.0; } - aDate.SetYear( static_cast(fYear) ); - aDate.SetMonth( static_cast(fMonth) ); + aDate.SetYear( static_cast(fYear) ); + aDate.SetMonth( static_cast(fMonth) ); aDate.SetDay( 1 ); double fMonthCount = (fYear*lcl_fNumberOfMonths)+fMonth; double fDay = (value-fMonthCount)*aDate.GetDaysInMonth(); fDay += 1.0; - aDate.SetDay( static_cast(::rtl::math::round(fDay)) ); + aDate.SetDay( static_cast(::rtl::math::round(fDay)) ); fResult = aDate - m_aNullDate; break; } diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 6b728caa6003..60e880ab311e 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -73,7 +73,7 @@ ChartItemPool::ChartItemPool(): //text ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); - ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); + ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,sal_False); //statistic ppPoolDefaults[SCHATTR_STAT_AVERAGE - SCHATTR_START] = new SfxBoolItem (SCHATTR_STAT_AVERAGE); @@ -132,8 +132,8 @@ ChartItemPool::ChartItemPool(): //axis label ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); ppPoolDefaults[SCHATTR_AXIS_LABEL_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_AXIS_LABEL_ORDER); - ppPoolDefaults[SCHATTR_AXIS_LABEL_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_OVERLAP,FALSE); - ppPoolDefaults[SCHATTR_AXIS_LABEL_BREAK - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_BREAK, FALSE ); + ppPoolDefaults[SCHATTR_AXIS_LABEL_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_OVERLAP,sal_False); + ppPoolDefaults[SCHATTR_AXIS_LABEL_BREAK - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_BREAK, sal_False ); //-- ppPoolDefaults[SCHATTR_SYMBOL_BRUSH - SCHATTR_START] = new SvxBrushItem(SCHATTR_SYMBOL_BRUSH); @@ -149,13 +149,13 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_SPLINE_ORDER - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_ORDER, 3 ); ppPoolDefaults[SCHATTR_SPLINE_RESOLUTION - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, 20 ); ppPoolDefaults[SCHATTR_DIAGRAM_STYLE - SCHATTR_START] = new SvxChartStyleItem( CHSTYLE_2D_COLUMN, SCHATTR_DIAGRAM_STYLE ); - ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, FALSE); + ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, sal_False); ppPoolDefaults[SCHATTR_STARTING_ANGLE - SCHATTR_START] = new SfxInt32Item( SCHATTR_STARTING_ANGLE, 90 ); ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, sal_False ); ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0); ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp); - ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); + ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True); ppPoolDefaults[SCHATTR_AXIS_FOR_ALL_SERIES - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_FOR_ALL_SERIES, 0); -- cgit From 24684974fe50ca308a7af50a34c5f73d4b2d9d5f Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Tue, 8 Feb 2011 11:05:35 +0100 Subject: removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw --- chart2/source/controller/dialogs/tp_AxisLabel.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 8d405af88dc8..e04857adbca2 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -256,11 +256,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { -<<<<<<< local - aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, sal_False, &pPoolItem ); -======= aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, sal_False, &pPoolItem ); ->>>>>>> other if( aState == SFX_ITEM_SET ) { SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); -- cgit