diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/clipparam.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/documen5.cxx | 32 | ||||
-rw-r--r-- | sc/source/core/tool/charthelper.cxx | 153 | ||||
-rw-r--r-- | sc/source/ui/app/drwtrans.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/docshell/arealink.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/tablink.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fusel.cxx | 46 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/makefile.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/drwtrans.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chartuno.cxx | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | sc/source/ui/unoobj/dapiuno.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/unoobj/viewuno.cxx | 25 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 52 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun7.cxx | 48 |
15 files changed, 394 insertions, 25 deletions
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/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index d819785c843b..1cd4c4700894 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -270,9 +270,9 @@ BOOL ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter, SfxMedium* pMed = new SfxMedium(aNewUrl, STREAM_STD_READ, FALSE, pFilter); + // aRef->DoClose() will be closed explicitly, but it is still more safe to use SfxObjectShellLock here ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL); -//REMOVE SvEmbeddedObjectRef aRef = pSrcShell; - SfxObjectShellRef aRef = pSrcShell; + SfxObjectShellLock aRef = pSrcShell; pSrcShell->DoLoad(pMed); ScDocument* pSrcDoc = pSrcShell->GetDocument(); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 78287257c080..5de8b17b0598 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -781,8 +781,9 @@ void ScDocShell::Execute( SfxRequest& rReq ) { SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() ); + // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here ScDocShell* pOtherDocSh = new ScDocShell; - SfxObjectShellRef aDocShTablesRef = pOtherDocSh; + SfxObjectShellLock aDocShTablesRef = pOtherDocSh; pOtherDocSh->DoLoad( pMed ); ULONG nErr = pOtherDocSh->GetErrorCode(); if (nErr) diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx index 697b39052b9f..5414e19c1ca4 100644 --- a/sc/source/ui/docshell/tablink.cxx +++ b/sc/source/ui/docshell/tablink.cxx @@ -219,8 +219,9 @@ BOOL ScTableLink::Refresh(const String& rNewFile, const String& rNewFilter, if ( bInEdit ) // only if using the edit dialog, pMed->UseInteractionHandler( TRUE ); // enable the filter options dialog + // aRef->DoClose() will be called explicitly, but it is still more safe to use SfxObjectShellLock here ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL); - SfxObjectShellRef aRef = pSrcShell; + SfxObjectShellLock aRef = pSrcShell; pSrcShell->DoLoad(pMed); // Optionen koennten gesetzt worden sein 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) |