diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2011-01-18 17:50:24 +0100 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2011-01-18 17:50:24 +0100 |
commit | f7db44253583f706eaec60b47364f5966d1294e1 (patch) | |
tree | 1442da66bc2a9dd2ed07637808a3880df2855574 | |
parent | a7417580c63270351601a7aef27c11247a831206 (diff) | |
parent | cdbb1cee28d40dab1e471f1381f4587dc100f31b (diff) |
CWS-TOOLING: integrate CWS chartextensibility
21 files changed, 533 insertions, 41 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 062dcc1a129d..7a0907b05a28 100644..100755 --- 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 ) 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 <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartType.hpp> @@ -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 8ec895fbd452..c17e56ce6bc5 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -48,6 +48,8 @@ #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <editeng/unoprnms.hxx> +#include <svx/unoshape.hxx> +#include <svx/unoshtxt.hxx> #include <algorithm> #include <memory> @@ -110,7 +112,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 +261,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 +284,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 @@ -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 @@ -714,10 +757,23 @@ 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; + removeTextShapesFromTicks(); + return false; + } + //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 +1342,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 +1363,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 +1405,23 @@ 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.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 +1491,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 +1508,12 @@ void SAL_CALL VCartesianAxis::updatePositions() static_cast<sal_Int32>(aTickScreenPos2D.getX()) ,static_cast<sal_Int32>(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 +1532,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 +1604,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<sal_Int32>(aLabelsDistance.getLength()); aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); nOffset += nCurrentLength; diff --git a/sc/inc/charthelper.hxx b/sc/inc/charthelper.hxx index 50b8586bdace..7966e07d00f8 100644 --- a/sc/inc/charthelper.hxx +++ b/sc/inc/charthelper.hxx @@ -31,10 +31,15 @@ #include <tools/solar.h> #include "address.hxx" #include "global.hxx" +#include "rangelst.hxx" #include <com/sun/star/chart2/XChartDocument.hpp> class SdrObject; +class SdrPage; +class ScModelObj; + +typedef ::std::vector< ScRangeList > ScRangeListVector; /** Use this to handle charts in a calc document */ @@ -49,6 +54,12 @@ public: ::com::sun::star::uno::Sequence< rtl::OUString >& rRanges ); static void SetChartRanges( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, const ::com::sun::star::uno::Sequence< rtl::OUString >& rRanges ); + + static void AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrObject* pObject ); + static void FillProtectedChartRangesVector( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrPage* pPage ); + static void GetChartNames( ::std::vector< ::rtl::OUString >& rChartNames, SdrPage* pPage ); + static void CreateProtectedChartListenersAndNotify( ScDocument* pDoc, SdrPage* pPage, ScModelObj* pModelObj, SCTAB nTab, + const ScRangeListVector& rRangesVector, const ::std::vector< ::rtl::OUString >& rExcludedChartNames, bool bSameDoc = true ); }; #endif diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx index 78b5474229d1..ce2d4ef30f46 100644 --- a/sc/inc/clipparam.hxx +++ b/sc/inc/clipparam.hxx @@ -30,6 +30,7 @@ #include "rangelst.hxx" #include "rangenam.hxx" +#include "charthelper.hxx" #include <vector> @@ -41,9 +42,11 @@ struct ScClipParam { enum Direction { Unspecified, Column, Row }; - ScRangeList maRanges; - Direction meDirection; - bool mbCutMode; + ScRangeList maRanges; + Direction meDirection; + bool mbCutMode; + sal_uInt32 mnSourceDocID; + ScRangeListVector maProtectedChartRangesVector; ScClipParam(); ScClipParam(const ScRange& rRange, bool bCutMode); @@ -70,6 +73,9 @@ struct ScClipParam ScRange getWholeRange() const; void transpose(); + + sal_uInt32 getSourceDocID() const { return mnSourceDocID; } + void setSourceDocID( sal_uInt32 nVal ) { mnSourceDocID = nVal; } }; // ============================================================================ diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 19cceb210b65..a9c08c2884fd 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -528,6 +528,7 @@ #define SC_UNO_ZOOMTYPE "ZoomType" #define SC_UNO_ZOOMVALUE "ZoomValue" #define SC_UNO_UPDTEMPL "UpdateFromTemplate" +#define SC_UNO_VISAREASCREEN "VisibleAreaOnScreen" /*Stampit enable/disable print cancel */ #define SC_UNO_ALLOWPRINTJOBCANCEL "AllowPrintJobCancel" diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx index 9ab5995ca26c..352c599e54bb 100644 --- a/sc/source/core/data/clipparam.cxx +++ b/sc/source/core/data/clipparam.cxx @@ -36,13 +36,15 @@ using ::std::vector; ScClipParam::ScClipParam() : meDirection(Unspecified), - mbCutMode(false) + mbCutMode(false), + mnSourceDocID(0) { } ScClipParam::ScClipParam(const ScRange& rRange, bool bCutMode) : meDirection(Unspecified), - mbCutMode(bCutMode) + mbCutMode(bCutMode), + mnSourceDocID(0) { maRanges.Append(rRange); } @@ -50,7 +52,9 @@ ScClipParam::ScClipParam(const ScRange& rRange, bool bCutMode) : ScClipParam::ScClipParam(const ScClipParam& r) : maRanges(r.maRanges), meDirection(r.meDirection), - mbCutMode(r.mbCutMode) + mbCutMode(r.mbCutMode), + mnSourceDocID(r.mnSourceDocID), + maProtectedChartRangesVector(r.maProtectedChartRangesVector) { } diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx index d86d174ab414..303dbd2ccae3 100644 --- a/sc/source/core/data/documen5.cxx +++ b/sc/source/core/data/documen5.cxx @@ -469,9 +469,12 @@ void ScDocument::UpdateChart( const String& rChartName ) } // After the update, chart keeps track of its own data source ranges, - // the listener doesn't need to listen anymore. - if(pChartListenerCollection) + // the listener doesn't need to listen anymore, except the chart has + // an internal data provider. + if ( !( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) && pChartListenerCollection ) + { pChartListenerCollection->ChangeListening( rChartName, new ScRangeList ); + } } void ScDocument::RestoreChartListener( const String& rName ) @@ -579,9 +582,28 @@ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode, svt::EmbeddedObjectRef::TryRunningState( xIPObj ); // After the change, chart keeps track of its own data source ranges, - // the listener doesn't need to listen anymore. - - pChartListener->ChangeListening( new ScRangeList, bDataChanged ); + // the listener doesn't need to listen anymore, except the chart has + // an internal data provider. + bool bInternalDataProvider = false; + if ( xIPObj.is() ) + { + try + { + uno::Reference< chart2::XChartDocument > xChartDoc( xIPObj->getComponent(), uno::UNO_QUERY_THROW ); + bInternalDataProvider = xChartDoc->hasInternalDataProvider(); + } + catch ( uno::Exception& ) + { + } + } + if ( bInternalDataProvider ) + { + pChartListener->ChangeListening( aNewRLR, bDataChanged ); + } + else + { + pChartListener->ChangeListening( new ScRangeList, bDataChanged ); + } } } } diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx index 1b2cde3d4a6d..6c091250c80d 100644 --- a/sc/source/core/tool/charthelper.cxx +++ b/sc/source/core/tool/charthelper.cxx @@ -33,6 +33,7 @@ #include "drwlayer.hxx" #include "rangelst.hxx" #include "chartlis.hxx" +#include "docuno.hxx" //#include <vcl/svapp.hxx> #include <svx/svditer.hxx> @@ -296,3 +297,155 @@ void ScChartHelper::SetChartRanges( const uno::Reference< chart2::XChartDocument if( xModel.is() ) xModel->unlockControllers(); } + +void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrObject* pObject ) +{ + if ( pDocument && pObject && ( pObject->GetObjIdentifier() == OBJ_OLE2 ) ) + { + SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject ); + if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() ) + { + uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = pSdrOle2Obj->GetObjRef(); + if ( xEmbeddedObj.is() ) + { + bool bDisableDataTableDialog = false; + svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj ); + uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY ); + if ( xProps.is() && + ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) && + bDisableDataTableDialog ) + { + ::rtl::OUString aChartName = pSdrOle2Obj->GetPersistName(); + ScRange aEmptyRange; + ScChartListener aSearcher( aChartName, pDocument, aEmptyRange ); + USHORT nIndex = 0; + ScChartListenerCollection* pCollection = pDocument->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) + { + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) + { + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + rRangesVector.push_back( *rRangeList ); + } + } + } + } + } + } + } +} + +void ScChartHelper::FillProtectedChartRangesVector( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrPage* pPage ) +{ + if ( pDocument && pPage ) + { + SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); + SdrObject* pObject = aIter.Next(); + while ( pObject ) + { + AddRangesIfProtectedChart( rRangesVector, pDocument, pObject ); + pObject = aIter.Next(); + } + } +} + +void ScChartHelper::GetChartNames( ::std::vector< ::rtl::OUString >& rChartNames, SdrPage* pPage ) +{ + if ( pPage ) + { + SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); + SdrObject* pObject = aIter.Next(); + while ( pObject ) + { + if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) + { + SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject ); + if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() ) + { + rChartNames.push_back( pSdrOle2Obj->GetPersistName() ); + } + } + pObject = aIter.Next(); + } + } +} + +void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, SdrPage* pPage, ScModelObj* pModelObj, SCTAB nTab, + const ScRangeListVector& rRangesVector, const ::std::vector< ::rtl::OUString >& rExcludedChartNames, bool bSameDoc ) +{ + if ( pDoc && pPage && pModelObj ) + { + size_t nRangeListCount = rRangesVector.size(); + size_t nRangeList = 0; + SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); + SdrObject* pObject = aIter.Next(); + while ( pObject ) + { + if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) + { + SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject ); + if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() ) + { + ::rtl::OUString aChartName = pSdrOle2Obj->GetPersistName(); + ::std::vector< ::rtl::OUString >::const_iterator aEnd = rExcludedChartNames.end(); + ::std::vector< ::rtl::OUString >::const_iterator aFound = ::std::find( rExcludedChartNames.begin(), aEnd, aChartName ); + if ( aFound == aEnd ) + { + uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = pSdrOle2Obj->GetObjRef(); + if ( xEmbeddedObj.is() && ( nRangeList < nRangeListCount ) ) + { + bool bDisableDataTableDialog = false; + svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj ); + uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY ); + if ( xProps.is() && + ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) && + bDisableDataTableDialog ) + { + if ( bSameDoc ) + { + ScRange aEmptyRange; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + USHORT nIndex = 0; + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && !pCollection->Search( &aSearcher, nIndex ) ) + { + ScRangeList aRangeList( rRangesVector[ nRangeList++ ] ); + ScRangeListRef rRangeList( new ScRangeList( aRangeList ) ); + ScChartListener* pChartListener = new ScChartListener( aChartName, pDoc, rRangeList ); + pCollection->Insert( pChartListener ); + pChartListener->StartListeningTo(); + } + } + else + { + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ), + uno::makeAny( sal_False ) ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ), + uno::makeAny( sal_False ) ); + } + } + } + + if ( pModelObj && pModelObj->HasChangesListeners() ) + { + Rectangle aRectangle = pSdrOle2Obj->GetSnapRect(); + ScRange aRange( pDoc->GetRange( nTab, aRectangle ) ); + ScRangeList aChangeRanges; + aChangeRanges.Append( aRange ); + + uno::Sequence< beans::PropertyValue > aProperties( 1 ); + aProperties[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ); + aProperties[ 0 ].Value <<= aChartName; + + pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-chart" ) ), aChangeRanges, aProperties ); + } + } + } + } + pObject = aIter.Next(); + } + } +} diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index b256233d7394..22153ff5ae6c 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -68,6 +68,9 @@ #include "drawview.hxx" #include "viewdata.hxx" #include "scmod.hxx" +#include "chartlis.hxx" +#include "rangeutl.hxx" +#include "formula/grammar.hxx" // #108584# #include "scitems.hxx" @@ -79,6 +82,7 @@ #include <editeng/fhgtitem.hxx> #include <vcl/svapp.hxx> + using namespace com::sun::star; // ----------------------------------------------------------------------- @@ -235,9 +239,15 @@ ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContain // if ( pContainerShell ) { - const ScDocument* pDoc = pContainerShell->GetDocument(); + ScDocument* pDoc = pContainerShell->GetDocument(); if ( pDoc ) + { nSourceDocID = pDoc->GetDocumentID(); + if ( pPage ) + { + ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector, pDoc, pPage ); + } + } } } diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx index 4a456522003c..6e174a186b84 100644 --- a/sc/source/ui/drawfunc/fusel.cxx +++ b/sc/source/ui/drawfunc/fusel.cxx @@ -56,6 +56,9 @@ #include "drwlayer.hxx" #include "userdat.hxx" #include "scmod.hxx" +#include "charthelper.hxx" +#include "docuno.hxx" +#include "docsh.hxx" // ----------------------------------------------------------------------- @@ -399,6 +402,14 @@ BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt) Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + bool bCopy = false; + ScViewData* pViewData = ( pViewShell ? pViewShell->GetViewData() : NULL ); + ScDocument* pDocument = ( pViewData ? pViewData->GetDocument() : NULL ); + SdrPageView* pPageView = ( pView ? pView->GetSdrPageView() : NULL ); + SdrPage* pPage = ( pPageView ? pPageView->GetPage() : NULL ); + ::std::vector< ::rtl::OUString > aExcludedChartNames; + ScRangeListVector aProtectedChartRangesVector; + if ( rMEvt.IsLeft() ) { if ( pView->IsDragObj() ) @@ -406,6 +417,29 @@ BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt) /****************************************************************** * Objekt wurde verschoben ******************************************************************/ + if ( rMEvt.IsMod1() ) + { + if ( pPage ) + { + ScChartHelper::GetChartNames( aExcludedChartNames, pPage ); + } + if ( pView && pDocument ) + { + const SdrMarkList& rSdrMarkList = pView->GetMarkedObjectList(); + ULONG nMarkCount = rSdrMarkList.GetMarkCount(); + for ( ULONG i = 0; i < nMarkCount; ++i ) + { + SdrMark* pMark = rSdrMarkList.GetMark( i ); + SdrObject* pObj = ( pMark ? pMark->GetMarkedSdrObj() : NULL ); + if ( pObj ) + { + ScChartHelper::AddRangesIfProtectedChart( aProtectedChartRangesVector, pDocument, pObj ); + } + } + } + bCopy = true; + } + pView->EndDragObj( rMEvt.IsMod1() ); pView->ForceMarkedToAnotherPage(); @@ -566,6 +600,18 @@ BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt) pViewShell->GetViewData()->GetDispatcher(). Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + if ( bCopy && pViewData && pDocument && pPage ) + { + ScDocShell* pDocShell = pViewData->GetDocShell(); + ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL ); + if ( pModelObj ) + { + SCTAB nTab = pViewData->GetTabNo(); + ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pPage, pModelObj, nTab, + aProtectedChartRangesVector, aExcludedChartNames ); + } + } + return (bReturn); } diff --git a/sc/source/ui/drawfunc/makefile.mk b/sc/source/ui/drawfunc/makefile.mk index a50c450ab373..f82008e4cdeb 100644 --- a/sc/source/ui/drawfunc/makefile.mk +++ b/sc/source/ui/drawfunc/makefile.mk @@ -75,6 +75,7 @@ SLOFILES = \ $(SLO)$/mediash.obj EXCEPTIONSFILES= \ + $(SLO)$/fusel.obj \ $(SLO)$/fuins2.obj \ $(SLO)$/graphsh.obj \ $(SLO)$/mediash.obj diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx index 9a1175d3310d..cb04b6114efe 100644 --- a/sc/source/ui/inc/drwtrans.hxx +++ b/sc/source/ui/inc/drwtrans.hxx @@ -34,6 +34,8 @@ #include <sfx2/objsh.hxx> #include "global.hxx" +#include "charthelper.hxx" +#include "rangelst.hxx" class SdrModel; @@ -69,6 +71,8 @@ private: sal_uInt32 nSourceDocID; + ScRangeListVector m_aProtectedChartRangesVector; + void InitDocShell(); //REMOVE SvInPlaceObjectRef GetSingleObject(); @@ -104,6 +108,8 @@ public: static ScDrawTransferObj* GetOwnClipboard( Window* pUIWin ); 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(); + + const ScRangeListVector& GetProtectedChartRangesVector() const { return m_aProtectedChartRangesVector; } }; #endif diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 86f59d66a7a4..168202548a30 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -232,7 +232,8 @@ void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName, // Rechteck anpassen //! Fehler/Exception, wenn leer/ungueltig ??? Point aRectPos( aRect.X, aRect.Y ); - if (aRectPos.X() < 0) aRectPos.X() = 0; + bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); + if ( ( aRectPos.X() < 0 && !bLayoutRTL ) || ( aRectPos.X() > 0 && bLayoutRTL ) ) aRectPos.X() = 0; if (aRectPos.Y() < 0) aRectPos.Y() = 0; Size aRectSize( aRect.Width, aRect.Height ); if (aRectSize.Width() <= 0) aRectSize.Width() = 5000; // Default-Groesse @@ -298,7 +299,7 @@ void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName, xObj->setVisualAreaSize( nAspect, aSz ); pPage->InsertObject( pObj ); - pModel->AddUndo( new SdrUndoInsertObj( *pObj ) ); //! Undo-Kommentar? + pModel->AddUndo( new SdrUndoNewObj( *pObj ) ); // Dies veranlaesst Chart zum sofortigen Update //SvData aEmpty; @@ -318,7 +319,7 @@ void SAL_CALL ScChartsObj::removeByName( const rtl::OUString& aName ) ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0 SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); // ist nicht 0 - pModel->AddUndo( new SdrUndoRemoveObj( *pObj ) ); //! Undo-Kommentar? + pModel->AddUndo( new SdrUndoDelObj( *pObj ) ); pPage->RemoveObject( pObj->GetOrdNum() ); //! Notify etc.??? diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index c7bf89671161..342f12ee1205 100755..100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1394,6 +1394,23 @@ void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { Refreshed_Impl(); } + else if ( rHint.ISA( ScUpdateRefHint ) ) + { + ScRange aRange( 0, 0, nTab ); + ScRangeList aRanges; + aRanges.Append( aRange ); + const ScUpdateRefHint& rRef = static_cast< const ScUpdateRefHint& >( rHint ); + if ( aRanges.UpdateReference( rRef.GetMode(), GetDocShell()->GetDocument(), rRef.GetRange(), + rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) && + aRanges.Count() == 1 ) + { + const ScRange* pRange = aRanges.GetObject( 0 ); + if ( pRange ) + { + nTab = pRange->aStart.Tab(); + } + } + } ScDataPilotDescriptorBase::Notify( rBC, rHint ); } diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 7646e52c030f..71ed56a93dad 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -51,6 +51,7 @@ #include <sfx2/viewfrm.hxx> #include <rtl/uuid.h> #include <toolkit/helper/convert.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include "drawsh.hxx" #include "drtxtob.hxx" @@ -114,6 +115,7 @@ const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_VISAREA), 0, &getCppuType((awt::Rectangle*)0), 0, 0}, {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0}, {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE), 0, &getCppuType((sal_Int16*)0), 0, 0}, + {MAP_CHAR_LEN(SC_UNO_VISAREASCREEN),0, &getCppuType((awt::Rectangle*)0), 0, 0}, {0,0,0,0,0,0} }; return aViewOptPropertyMap_Impl; @@ -418,10 +420,15 @@ awt::Rectangle ScViewPaneBase::GetVisArea() const ScAddress aCell(pViewShell->GetViewData()->GetPosX(eWhichH), pViewShell->GetViewData()->GetPosY(eWhichV), pViewShell->GetViewData()->GetTabNo()); - Rectangle aVisRect(pDoc->GetMMRect(aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab())); - - aVisRect.SetSize(pWindow->PixelToLogic(pWindow->GetSizePixel(), pWindow->GetDrawMapMode(sal_True))); - + Rectangle aCellRect( pDoc->GetMMRect( aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) ); + Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), pWindow->GetDrawMapMode( sal_True ) ) ); + Point aVisPos( aCellRect.TopLeft() ); + if ( pDoc->IsLayoutRTL( aCell.Tab() ) ) + { + aVisPos = aCellRect.TopRight(); + aVisPos.X() -= aVisSize.Width(); + } + Rectangle aVisRect( aVisPos, aVisSize ); aVisArea = AWTRectangle(aVisRect); } } @@ -2038,6 +2045,16 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aProperty else if ( aString.EqualsAscii( SC_UNO_VISAREA ) ) aRet <<= GetVisArea(); else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) aRet <<= GetZoomType(); else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) aRet <<= GetZoom(); + else if ( aString.EqualsAscii( SC_UNO_VISAREASCREEN ) ) + { + ScViewData* pViewData = pViewSh->GetViewData(); + Window* pActiveWin = ( pViewData ? pViewData->GetActiveWin() : NULL ); + if ( pActiveWin ) + { + Rectangle aRect = pActiveWin->GetWindowExtentsRelative( NULL ); + aRet <<= AWTRectangle( aRect ); + } + } } return aRet; diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 3104b7ed8b8f..f7a126c2dac8 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -164,6 +164,9 @@ #include "scitems.hxx" #include <svx/dbexch.hrc> #include <svx/svdetc.hxx> +#include <svx/svditer.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdpage.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfile.hxx> #include <svl/stritem.hxx> @@ -206,6 +209,10 @@ #include "drwtrans.hxx" #include "docuno.hxx" #include "clipparam.hxx" +#include "drawview.hxx" +#include "chartlis.hxx" +#include "charthelper.hxx" + using namespace com::sun::star; @@ -337,7 +344,28 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI } ScClipParam aClipParam(aRange, bCut); + aClipParam.setSourceDocID( pDoc->GetDocumentID() ); pDoc->CopyToClip(aClipParam, pClipDoc, &rMark, false, false, bIncludeObjects); + + if ( pDoc && pClipDoc ) + { + ScDrawLayer* pDrawLayer = pClipDoc->GetDrawLayer(); + if ( pDrawLayer ) + { + ScClipParam& rClipParam = pClipDoc->GetClipParam(); + ScRangeListVector& rRangesVector = rClipParam.maProtectedChartRangesVector; + SCTAB nTabCount = pClipDoc->GetTableCount(); + for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab ) + { + SdrPage* pPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) ); + if ( pPage ) + { + ScChartHelper::FillProtectedChartRangesVector( rRangesVector, pDoc, pPage ); + } + } + } + } + if (bSysClip) { ScDrawLayer::SetGlobalDrawPersist(NULL); @@ -1350,8 +1378,19 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc, AdjustBlockHeight(); // update row heights before pasting objects + ::std::vector< ::rtl::OUString > aExcludedChartNames; + SdrPage* pPage = NULL; + if ( nFlags & IDF_OBJECTS ) { + ScDrawView* pScDrawView = GetScDrawView(); + SdrModel* pModel = ( pScDrawView ? pScDrawView->GetModel() : NULL ); + pPage = ( pModel ? pModel->GetPage( static_cast< sal_uInt16 >( nStartTab ) ) : NULL ); + if ( pPage ) + { + ScChartHelper::GetChartNames( aExcludedChartNames, pPage ); + } + // Paste the drawing objects after the row heights have been updated. pDoc->CopyFromClip( aUserRange, aFilteredMark, IDF_OBJECTS, pRefUndoDoc, pClipDoc, @@ -1450,6 +1489,19 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc, aModificator.SetDocumentModified(); PostPasteFromClip(aUserRange, rMark); + + if ( nFlags & IDF_OBJECTS ) + { + ScModelObj* pModelObj = ( pDocSh ? ScModelObj::getImplementation( pDocSh->GetModel() ) : NULL ); + if ( pDoc && pPage && pModelObj ) + { + bool bSameDoc = ( rClipParam.getSourceDocID() == pDoc->GetDocumentID() ); + const ScRangeListVector& rProtectedChartRangesVector( rClipParam.maProtectedChartRangesVector ); + ScChartHelper::CreateProtectedChartListenersAndNotify( pDoc, pPage, pModelObj, nStartTab, + rProtectedChartRangesVector, aExcludedChartNames, bSameDoc ); + } + } + return TRUE; } diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index afa06ddfee3e..bdc0ac895b8e 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -56,6 +56,10 @@ #include "drwlayer.hxx" #include "drwtrans.hxx" #include "globstr.hrc" +#include "chartlis.hxx" +#include "docuno.hxx" +#include "docsh.hxx" +#include "convuno.hxx" extern Point aDragStartDiff; @@ -149,9 +153,16 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, else { SdrModel* pDrawModel = pDragEditView->GetModel(); - SdrPage* pDestPage = pDrawModel->GetPage( static_cast<sal_uInt16>(GetViewData()->GetTabNo()) ); + SCTAB nTab = GetViewData()->GetTabNo(); + SdrPage* pDestPage = pDrawModel->GetPage( static_cast< sal_uInt16 >( nTab ) ); DBG_ASSERT(pDestPage,"nanu, Page?"); + ::std::vector< ::rtl::OUString > aExcludedChartNames; + if ( pDestPage ) + { + ScChartHelper::GetChartNames( aExcludedChartNames, pDestPage ); + } + SdrMarkList aMark = pDragEditView->GetMarkedObjectList(); aMark.ForceSort(); ULONG nMarkAnz=aMark.GetMarkCount(); @@ -184,6 +195,16 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, if (bPasteIsMove) pDragEditView->DeleteMarked(); + + ScDocument* pDocument = GetViewData()->GetDocument(); + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL ); + if ( pDocument && pDestPage && pModelObj && pDrawTrans ) + { + const ScRangeListVector& rProtectedChartRangesVector( pDrawTrans->GetProtectedChartRangesVector() ); + ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pDestPage, pModelObj, nTab, + rProtectedChartRangesVector, aExcludedChartNames, bSameDoc ); + } } } else @@ -204,6 +225,15 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, if ( pClient && pClient->IsObjectInPlaceActive() ) nOptions |= SDRINSERT_DONTMARK; + ::std::vector< ::rtl::OUString > aExcludedChartNames; + SCTAB nTab = GetViewData()->GetTabNo(); + SdrPage* pPage = pScDrawView->GetModel()->GetPage( static_cast< sal_uInt16 >( nTab ) ); + DBG_ASSERT( pPage, "Page?" ); + if ( pPage ) + { + ScChartHelper::GetChartNames( aExcludedChartNames, pPage ); + } + // #89247# Set flag for ScDocument::UpdateChartListeners() which is // called during paste. if ( !bSameDocClipboard ) @@ -216,10 +246,6 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, // #68991# Paste puts all objects on the active (front) layer // controls must be on SC_LAYER_CONTROLS - - SCTAB nTab = GetViewData()->GetTabNo(); - SdrPage* pPage = pScDrawView->GetModel()->GetPage(static_cast<sal_uInt16>(nTab)); - DBG_ASSERT(pPage,"Page?"); if (pPage) { SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); @@ -234,6 +260,18 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, // #75299# all graphics objects must have names GetViewData()->GetDocument()->EnsureGraphicNames(); + + ScDocument* pDocument = GetViewData()->GetDocument(); + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL ); + ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard( NULL ); + if ( pDocument && pPage && pModelObj && ( pTransferObj || pDrawTrans ) ) + { + const ScRangeListVector& rProtectedChartRangesVector( + pTransferObj ? pTransferObj->GetProtectedChartRangesVector() : pDrawTrans->GetProtectedChartRangesVector() ); + ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pPage, pModelObj, nTab, + rProtectedChartRangesVector, aExcludedChartNames, bSameDocClipboard ); + } } if (bGroup) |