diff options
author | Ingrid Halama <iha@openoffice.org> | 2010-05-10 16:30:45 +0200 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2010-05-10 16:30:45 +0200 |
commit | e0a1128c4b13e2f32a76e0b5f55839b705798da0 (patch) | |
tree | ca6335b03a2d84a244617577612bdb1e15db84ed /chart2/source | |
parent | 0581e072a69d06abd1bdcc8b5cc14771b110e6f9 (diff) |
chartpositioning: #i100778# switch to manual positioning if shapes are added via user interface
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/controller/main/ChartController.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Tools.cxx | 15 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 1 | ||||
-rw-r--r-- | chart2/source/inc/DiagramHelper.hxx | 5 | ||||
-rw-r--r-- | chart2/source/tools/DiagramHelper.cxx | 35 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 26 |
6 files changed, 59 insertions, 25 deletions
diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index 8deffe47396f..81f4ba5a549e 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -725,6 +725,8 @@ private: void impl_SetMousePointer( const MouseEvent & rEvent ); void impl_ClearSelection(); + + void impl_switchDiagramPositioningToExcludingPositioning(); }; //............................................................................. diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index be9bc092ba4c..11fa5e74054e 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -50,6 +50,7 @@ #include "RegressionCurveHelper.hxx" #include "ShapeController.hxx" #include "DiagramHelper.hxx" +#include "ObjectNameProvider.hxx" #include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/beans/XPropertyState.hpp> @@ -469,6 +470,8 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) m_aSelection.applySelection( m_pDrawViewWrapper ); m_pDrawViewWrapper->EndUndo(); + + impl_switchDiagramPositioningToExcludingPositioning(); } } } @@ -515,6 +518,8 @@ void ChartController::impl_PasteStringAsTextShape( const OUString& rString, cons m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) ); m_pDrawViewWrapper->EndUndo(); + + impl_switchDiagramPositioningToExcludingPositioning(); } } catch ( const uno::Exception& ex ) @@ -903,4 +908,14 @@ void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const } } +void ChartController::impl_switchDiagramPositioningToExcludingPositioning() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::POS_SIZE, + ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), + m_xUndoManager, m_aModel->getModel() ); + if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) + aUndoGuard.commitAction(); +} + } // namespace chart diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 176d38aa5fc3..91531683f7c5 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -796,6 +796,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() ) { pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND ); + impl_switchDiagramPositioningToExcludingPositioning(); if ( pDrawViewWrapper->AreObjectsMarked() ) { if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 1886609d8600..c7cda6189680 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -333,6 +333,11 @@ public: static ::com::sun::star::awt::Rectangle getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel + , bool bResetModifiedState //set model back to unchanged if it was unchanged before + , bool bConvertAlsoFromAutoPositioning ); + private: // not implemented DiagramHelper(); diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index a71daa4139eb..4ce623ae460c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -44,6 +44,8 @@ #include "ControllerLockGuard.hxx" #include <com/sun/star/chart/MissingValueTreatment.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart/XDiagramPositioning.hpp> #include <com/sun/star/chart2/XTitled.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XChartTypeTemplate.hpp> @@ -54,10 +56,12 @@ #include <com/sun/star/chart2/DataPointGeometry3D.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/drawing/ShadeMode.hpp> +#include <unotools/saveopt.hxx> #include <rtl/math.hxx> +#include <com/sun/star/util/XModifiable.hpp> + using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using namespace ::std; @@ -1521,4 +1525,33 @@ awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference return aRet; } +//static +bool DiagramHelper::switchDiagramPositioningToExcludingPositioning( + const uno::Reference< frame::XModel >& xChartModel + , bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning ) +{ + //return true if something was changed + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution + { + uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( xChartModel, uno::UNO_QUERY ) ; + if( xOldDoc.is() ) + { + uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY ); + if( xDiagramPositioning.is() && ( bConvertAlsoFromAutoPositioning || !xDiagramPositioning->isAutomaticDiagramPositioning() ) + && !xDiagramPositioning->isExcludingDiagramPositioning() ) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + uno::Reference< util::XModifiable > xModifiable( xChartModel, uno::UNO_QUERY ); + bool bModelWasModified = xModifiable.is() && xModifiable->isModified(); + xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() ); + if(bResetModifiedState && !bModelWasModified && xModifiable.is() ) + xModifiable->setModified(sal_False); + return true; + } + } + } + return false; +} + } // namespace chart diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 534c24cae1ad..886bab7ced29 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -72,15 +72,12 @@ #include <vcl/svapp.hxx> #include <vos/mutex.hxx> #include <svx/unofill.hxx> -#include <unotools/saveopt.hxx> #include <time.h> #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> -#include <com/sun/star/chart/XChartDocument.hpp> -#include <com/sun/star/chart/XDiagramPositioning.hpp> #include <com/sun/star/chart2/ExplicitSubIncrement.hpp> #include <com/sun/star/chart2/StackingDirection.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -2989,27 +2986,8 @@ void SAL_CALL ChartView::update() throw (uno::RuntimeException) //When a view update is requested (what happens for creating the metafile or displaying //the chart in edit mode or printing) it is most likely that all necessary informations are available - like the underlying spreadsheet data for example. //Those data is important for the correct axis lable sizes which are needed during conversion. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); - if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution - { - uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( m_xChartModel, uno::UNO_QUERY ) ; - if( xOldDoc.is() ) - { - uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY ); - if( xDiagramPositioning.is() && !xDiagramPositioning->isAutomaticDiagramPositioning() && !xDiagramPositioning->isExcludingDiagramPositioning() ) - { - { - ControllerLockGuard aCtrlLockGuard( m_xChartModel ); - uno::Reference< util::XModifiable > xModifiable( m_xChartModel, uno::UNO_QUERY ); - bool bModelWasModified = xModifiable.is() && xModifiable->isModified(); - xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() ); - if(!bModelWasModified && xModifiable.is() ) - xModifiable->setModified(sal_False); - } - impl_updateView(); - } - } - } + if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_xChartModel, true, false ) ) + impl_updateView(); } // ____ XPropertySet ____ |