Update ooo320-m1
[ooovba.git] / sc / source / ui / view / drawview.cxx
blob07d9ba6edde0a4bb9f087e064365045a763626f6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawview.cxx,v $
10 * $Revision: 1.50.126.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include <com/sun/star/embed/EmbedStates.hpp>
38 #include <svx/svditer.hxx>
39 #include <svx/svdograf.hxx>
40 #include <svx/svdomedia.hxx>
41 #include <svx/svdogrp.hxx>
42 #include <svx/svdoole2.hxx>
43 #include <svx/svdouno.hxx>
44 #include <svx/svdpage.hxx>
45 #include <svx/svdundo.hxx>
46 #include <svx/svdocapt.hxx>
47 #include <svx/outlobj.hxx>
48 #include <svx/writingmodeitem.hxx>
49 #include <svx/sdrpaintwindow.hxx>
50 #include <sfx2/bindings.hxx>
51 #include <sfx2/viewfrm.hxx>
53 #include "drawview.hxx"
54 #include "global.hxx"
55 #include "viewdata.hxx"
56 #include "document.hxx"
57 #include "drawutil.hxx"
58 #include "futext.hxx"
59 #include "globstr.hrc"
60 #include "tabvwsh.hxx"
61 #include "client.hxx"
62 #include "scmod.hxx"
63 #include "drwlayer.hxx"
64 #include "docsh.hxx"
65 #include "viewuno.hxx"
66 #include "userdat.hxx"
67 #include "postit.hxx"
68 #include "undocell.hxx"
70 #include "sc.hrc"
72 using namespace com::sun::star;
74 // -----------------------------------------------------------------------
76 #define SC_HANDLESIZE_BIG 9
77 #define SC_HANDLESIZE_SMALL 7
79 // -----------------------------------------------------------------------
81 #ifdef _MSC_VER
82 #pragma optimize ( "", off )
83 #endif
86 void ScDrawView::Construct()
88 EnableExtendedKeyInputDispatcher(FALSE);
89 EnableExtendedMouseEventDispatcher(FALSE);
90 EnableExtendedCommandEventDispatcher(FALSE);
92 SetFrameDragSingles(TRUE);
93 // SetSolidMarkHdl(TRUE); // einstellbar -> UpdateUserViewOptions
95 SetMinMoveDistancePixel( 2 );
96 SetHitTolerancePixel( 2 );
98 if (pViewData)
100 SCTAB nViewTab = pViewData->GetTabNo();
101 ShowSdrPage(GetModel()->GetPage(nViewTab));
103 BOOL bEx = pViewData->GetViewShell()->IsDrawSelMode();
104 BOOL bProt = pDoc->IsTabProtected( nViewTab ) ||
105 pViewData->GetSfxDocShell()->IsReadOnly();
107 SdrLayer* pLayer;
108 SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin();
109 pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
110 if (pLayer)
111 SetLayerLocked( pLayer->GetName(), bProt || !bEx );
112 pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
113 if (pLayer)
114 SetLayerLocked( pLayer->GetName(), TRUE );
115 pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
116 if (pLayer)
118 SetLayerLocked( pLayer->GetName(), bProt );
119 SetActiveLayer( pLayer->GetName() ); // FRONT als aktiven Layer setzen
121 pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
122 if (pLayer)
123 SetLayerLocked( pLayer->GetName(), bProt );
124 pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
125 if (pLayer)
127 SetLayerLocked( pLayer->GetName(), bProt );
128 SetLayerVisible( pLayer->GetName(), sal_False);
131 SetSwapAsynchron(TRUE);
133 else
135 ShowSdrPage(GetModel()->GetPage(nTab));
138 UpdateUserViewOptions();
139 RecalcScale();
140 UpdateWorkArea();
142 bInConstruct = FALSE;
145 void ScDrawView::ImplClearCalcDropMarker()
147 if(pDropMarker)
149 delete pDropMarker;
150 pDropMarker = 0L;
154 __EXPORT ScDrawView::~ScDrawView()
156 ImplClearCalcDropMarker();
159 void ScDrawView::AddCustomHdl()
161 BOOL bNegativePage = pDoc->IsNegativePage( nTab );
163 const SdrMarkList &rMrkList = GetMarkedObjectList();
164 UINT32 nCount = rMrkList.GetMarkCount();
165 for(UINT32 nPos=0; nPos<nCount; nPos++ )
167 const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
168 if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
170 const INT32 nDelta = 1;
172 Rectangle aBoundRect = pObj->GetCurrentBoundRect();
173 Point aPos;
174 if (bNegativePage)
176 aPos = aBoundRect.TopRight();
177 aPos.X() = -aPos.X(); // so the loop below is the same
179 else
180 aPos = aBoundRect.TopLeft();
181 long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
182 long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
184 SCCOL nCol;
185 INT32 nWidth = 0;
187 for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
188 nWidth += pDoc->GetColWidth(nCol,nTab);
190 if(nCol > 0)
191 --nCol;
193 SCROW nRow = nPosY <= 0 ? 0 : pDoc->FastGetRowForHeight( nTab,
194 (ULONG) nPosY);
195 if(nRow > 0)
196 --nRow;
198 ScTabView* pView = pViewData->GetView();
199 ScAddress aScAddress(nCol, nRow, nTab);
200 pView->CreateAnchorHandles(aHdl, aScAddress);
205 void ScDrawView::InvalidateAttribs()
207 if (!pViewData) return;
208 SfxBindings& rBindings = pViewData->GetBindings();
210 // echte Statuswerte:
211 rBindings.InvalidateAll( TRUE );
214 void ScDrawView::InvalidateDrawTextAttrs()
216 if (!pViewData) return;
217 SfxBindings& rBindings = pViewData->GetBindings();
219 // cjk/ctl font items have no configured slots,
220 // need no invalidate
222 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
223 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
224 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
225 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
226 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
227 rBindings.Invalidate( SID_ULINE_VAL_NONE );
228 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
229 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
230 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
231 rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
232 rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
233 rBindings.Invalidate( SID_ALIGNLEFT );
234 rBindings.Invalidate( SID_ALIGNCENTERHOR );
235 rBindings.Invalidate( SID_ALIGNRIGHT );
236 rBindings.Invalidate( SID_ALIGNBLOCK );
237 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
238 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
239 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
240 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
241 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
242 rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
243 rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
244 rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
245 rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
246 // pseudo slots for Format menu
247 rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
248 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
249 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
250 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
253 //void ScDrawView::DrawMarks( OutputDevice* pOut ) const
255 // DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)");
256 // SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
258 // if(pPaintWindow)
259 // {
260 // if(pPaintWindow->isXorVisible())
261 // {
262 // ToggleShownXor(pOut, 0L);
263 // }
264 // }
267 void ScDrawView::SetMarkedToLayer( BYTE nLayerNo )
269 if (AreObjectsMarked())
271 // #i11702# use SdrUndoObjectLayerChange for undo
272 // STR_UNDO_SELATTR is "Attributes" - should use a different text later
273 BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
275 const SdrMarkList& rMark = GetMarkedObjectList();
276 ULONG nCount = rMark.GetMarkCount();
277 for (ULONG i=0; i<nCount; i++)
279 SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
280 if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
282 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
283 pObj->SetLayer( nLayerNo );
287 EndUndo();
289 // repaint is done in SetLayer
291 pViewData->GetDocShell()->SetDrawModified();
293 // #84073# check mark list now instead of later in a timer
294 CheckMarked();
295 MarkListHasChanged();
299 bool ScDrawView::HasMarkedControl() const
301 SdrObjListIter aIter( GetMarkedObjectList() );
302 for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
303 if( pObj->ISA( SdrUnoObj ) )
304 return true;
305 return false;
308 bool ScDrawView::HasMarkedInternal() const
310 // internal objects should not be inside a group, but who knows...
311 SdrObjListIter aIter( GetMarkedObjectList() );
312 for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
313 if( pObj->GetLayer() == SC_LAYER_INTERN )
314 return true;
315 return false;
318 void ScDrawView::UpdateWorkArea()
320 SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
321 if (pPage)
323 Point aPos;
324 Size aPageSize( pPage->GetSize() );
325 Rectangle aNewArea( aPos, aPageSize );
326 if ( aPageSize.Width() < 0 )
328 // RTL: from max.negative (left) to zero (right)
329 aNewArea.Right() = 0;
330 aNewArea.Left() = aPageSize.Width() + 1;
332 SetWorkArea( aNewArea );
334 else
336 DBG_ERROR("Page nicht gefunden");
340 void ScDrawView::DoCut()
342 DoCopy();
343 BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
344 DeleteMarked(); // auf dieser View - von der 505f Umstellung nicht betroffen
345 EndUndo();
348 void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
350 rFractX = aScaleX;
351 rFractY = aScaleY;
354 void ScDrawView::RecalcScale()
356 double nPPTX;
357 double nPPTY;
358 Fraction aZoomX(1,1);
359 Fraction aZoomY(1,1);
361 if (pViewData)
363 nTab = pViewData->GetTabNo();
364 nPPTX = pViewData->GetPPTX();
365 nPPTY = pViewData->GetPPTY();
366 aZoomX = pViewData->GetZoomX();
367 aZoomY = pViewData->GetZoomY();
369 else
371 Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
372 nPPTX = aLogic.X() / 1000.0;
373 nPPTY = aLogic.Y() / 1000.0;
374 //! Zoom uebergeben ???
377 SCCOL nEndCol = 0;
378 SCROW nEndRow = 0;
379 pDoc->GetTableArea( nTab, nEndCol, nEndRow );
380 if (nEndCol<20)
381 nEndCol = 20;
382 if (nEndRow<20)
383 nEndRow = 20;
385 ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
386 aScaleX,aScaleY );
389 void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
391 if ( pViewData )
392 pViewData->GetViewShell()->ConnectObject( pOleObj );
395 void ScDrawView::MarkListHasChanged()
397 FmFormView::MarkListHasChanged();
399 UpdateBrowser();
401 ScTabViewShell* pViewSh = pViewData->GetViewShell();
403 if (!bInConstruct) // nicht wenn die View gerade angelegt wird
405 pViewSh->Unmark(); // Selektion auff'm Doc entfernen
407 // #65379# end cell edit mode if drawing objects are selected
408 if ( GetMarkedObjectList().GetMarkCount() )
409 SC_MOD()->InputEnterHandler();
412 // IP deaktivieren
414 ScModule* pScMod = SC_MOD();
415 bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
417 ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
418 if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
420 // #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
421 //HMHbDisableHdl = TRUE;
422 pClient->DeactivateObject();
423 //HMHbDisableHdl = FALSE;
424 // Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
427 // Ole-Objekt selektiert?
429 SdrOle2Obj* pOle2Obj = NULL;
430 SdrGrafObj* pGrafObj = NULL;
431 SdrMediaObj* pMediaObj = NULL;
433 const SdrMarkList& rMarkList = GetMarkedObjectList();
434 ULONG nMarkCount = rMarkList.GetMarkCount();
436 if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
438 // relock layers that may have been unlocked before
439 LockBackgroundLayer();
440 LockInternalLayer();
443 BOOL bSubShellSet = FALSE;
444 if (nMarkCount == 1)
446 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
447 if (pObj->GetObjIdentifier() == OBJ_OLE2)
449 pOle2Obj = (SdrOle2Obj*) pObj;
450 if (!pDoc->IsChart(pObj) )
451 pViewSh->SetOleObjectShell(TRUE);
452 else
453 pViewSh->SetChartShell(TRUE);
454 bSubShellSet = TRUE;
456 else if (pObj->GetObjIdentifier() == OBJ_GRAF)
458 pGrafObj = (SdrGrafObj*) pObj;
459 pViewSh->SetGraphicShell(TRUE);
460 bSubShellSet = TRUE;
462 else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
464 pMediaObj = (SdrMediaObj*) pObj;
465 pViewSh->SetMediaShell(TRUE);
466 bSubShellSet = TRUE;
468 else if (pObj->GetObjIdentifier() != OBJ_TEXT // Verhindern, das beim Anlegen
469 || !pViewSh->IsDrawTextShell()) // eines TextObjekts auf die
470 { // DrawShell umgeschaltet wird.
471 pViewSh->SetDrawShell(TRUE); //@#70206#
475 if ( nMarkCount && !bSubShellSet )
477 BOOL bOnlyControls = TRUE;
478 BOOL bOnlyGraf = TRUE;
479 for (ULONG i=0; i<nMarkCount; i++)
481 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
482 if ( pObj->ISA( SdrObjGroup ) )
484 const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
485 ULONG nListCount = pLst->GetObjCount();
486 if ( nListCount == 0 )
488 // #104156# An empty group (may occur during Undo) is no control or graphics object.
489 // Creating the form shell during undo would lead to problems with the undo manager.
490 bOnlyControls = FALSE;
491 bOnlyGraf = FALSE;
493 for ( USHORT j = 0; j < nListCount; ++j )
495 SdrObject *pSubObj = pLst->GetObj( j );
497 if (!pSubObj->ISA(SdrUnoObj))
498 bOnlyControls = FALSE;
499 if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
500 bOnlyGraf = FALSE;
502 if ( !bOnlyControls && !bOnlyGraf ) break;
505 else
507 if (!pObj->ISA(SdrUnoObj))
508 bOnlyControls = FALSE;
509 if (pObj->GetObjIdentifier() != OBJ_GRAF)
510 bOnlyGraf = FALSE;
513 if ( !bOnlyControls && !bOnlyGraf ) break;
516 if(bOnlyControls)
518 pViewSh->SetDrawFormShell(TRUE); // jetzt UNO-Controls
520 else if(bOnlyGraf)
522 pViewSh->SetGraphicShell(TRUE);
524 else if(nMarkCount>1)
526 pViewSh->SetDrawShell(TRUE);
532 // Verben anpassen
534 SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
535 BOOL bOle = pViewSh->GetViewFrame()->GetFrame()->IsInPlace();
536 if ( pOle2Obj && !bOle )
538 uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
539 if (xObj.is())
540 pViewSh->SetVerbs( xObj->getSupportedVerbs() );
541 else
543 DBG_ERROR("SdrOle2Obj ohne ObjRef");
544 pViewSh->SetVerbs( 0 );
547 else
548 pViewSh->SetVerbs( 0 );
550 // Image-Map Editor
552 if ( pOle2Obj )
553 UpdateIMap( pOle2Obj );
554 else if ( pGrafObj )
555 UpdateIMap( pGrafObj );
557 InvalidateAttribs(); // nach dem IMap-Editor Update
558 InvalidateDrawTextAttrs();
560 for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
562 SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
563 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
565 if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
567 ((Window&)rOutDev).Update();
571 // uno object for view returns drawing objects as selection,
572 // so it must notify its SelectionChangeListeners
574 if (pViewFrame)
576 SfxFrame* pFrame = pViewFrame->GetFrame();
577 if (pFrame)
579 uno::Reference<frame::XController> xController = pFrame->GetController();
580 if (xController.is())
582 ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
583 if (pImp)
584 pImp->SelectionChanged();
589 // update selection transfer object
591 pViewSh->CheckSelectionTransfer();
595 void __EXPORT ScDrawView::ModelHasChanged()
597 SdrObject* pEditObj = GetTextEditObject();
598 if ( pEditObj && !pEditObj->IsInserted() && pViewData )
600 // #111700# SdrObjEditView::ModelHasChanged will end text edit in this case,
601 // so make sure the EditEngine's undo manager is no longer used.
602 pViewData->GetViewShell()->SetDrawTextUndo(NULL);
603 SetCreateMode(); // don't leave FuText in a funny state
606 FmFormView::ModelHasChanged();
609 void __EXPORT ScDrawView::UpdateUserViewOptions()
611 if (pViewData)
613 const ScViewOptions& rOpt = pViewData->GetOptions();
614 const ScGridOptions& rGrid = rOpt.GetGridOptions();
616 BOOL bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
618 SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
619 SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
620 SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
622 SetGridVisible( rGrid.GetGridVisible() );
623 SetSnapEnabled( rGrid.GetUseGridSnap() );
624 SetGridSnap( rGrid.GetUseGridSnap() );
626 // Snap from grid options is no longer used
627 // SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) );
629 Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
630 Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
631 SetSnapGridWidth( aFractX, aFractY );
633 SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
634 SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
635 rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
639 #ifdef _MSC_VER
640 #pragma optimize ( "", on )
641 #endif
643 BOOL ScDrawView::SelectObject( const String& rName )
645 UnmarkAll();
647 SCTAB nObjectTab = 0;
648 SdrObject* pFound = NULL;
650 SfxObjectShell* pShell = pDoc->GetDocumentShell();
651 if (pShell)
653 SdrModel* pDrawLayer = GetModel();
654 SCTAB nTabCount = pDoc->GetTableCount();
655 for (SCTAB i=0; i<nTabCount && !pFound; i++)
657 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
658 DBG_ASSERT(pPage,"Page ?");
659 if (pPage)
661 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
662 SdrObject* pObject = aIter.Next();
663 while (pObject && !pFound)
665 if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
667 pFound = pObject;
668 nObjectTab = i;
670 pObject = aIter.Next();
676 if ( pFound )
678 ScTabView* pView = pViewData->GetView();
679 if ( nObjectTab != nTab ) // Tabelle umschalten
680 pView->SetTabNo( nObjectTab );
682 DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
684 pView->ScrollToObject( pFound );
686 /* #61585# To select an object on the background layer, the layer has to
687 be unlocked even if exclusive drawing selection mode is not active
688 (this is reversed in MarkListHasChanged when nothing is selected) */
689 if ( pFound->GetLayer() == SC_LAYER_BACK &&
690 !pViewData->GetViewShell()->IsDrawSelMode() &&
691 !pDoc->IsTabProtected( nTab ) &&
692 !pViewData->GetSfxDocShell()->IsReadOnly() )
694 UnlockBackgroundLayer();
697 SdrPageView* pPV = GetSdrPageView();
698 MarkObj( pFound, pPV );
701 return ( pFound != NULL );
704 //UNUSED2008-05 String ScDrawView::GetSelectedChartName() const
705 //UNUSED2008-05 {
706 //UNUSED2008-05 // used for modifying a chart's data area - PersistName must always be used
707 //UNUSED2008-05 // (as in ScDocument::FindChartData and UpdateChartArea)
708 //UNUSED2008-05
709 //UNUSED2008-05 const SdrMarkList& rMarkList = GetMarkedObjectList();
710 //UNUSED2008-05 if (rMarkList.GetMarkCount() == 1)
711 //UNUSED2008-05 {
712 //UNUSED2008-05 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
713 //UNUSED2008-05 if (pObj->GetObjIdentifier() == OBJ_OLE2)
714 //UNUSED2008-05 if ( pDoc->IsChart(pObj) )
715 //UNUSED2008-05 return static_cast<SdrOle2Obj*>(pObj)->GetPersistName();
716 //UNUSED2008-05 }
717 //UNUSED2008-05
718 //UNUSED2008-05 return EMPTY_STRING; // nichts gefunden
719 //UNUSED2008-05 }
721 FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions)
723 // Markierung nicht aendern, wenn Ole-Objekt aktiv
724 // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
726 if (pViewData)
728 SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
729 if ( pClient && pClient->IsObjectInPlaceActive() )
730 nOptions |= SDRINSERT_DONTMARK;
733 return InsertObjectAtView( pObj, rPV, nOptions );
736 SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
738 const SdrMarkList& rMarkList = GetMarkedObjectList();
739 if( pViewData && (rMarkList.GetMarkCount() == 1) )
741 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
742 if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
744 if( ppCaptData ) *ppCaptData = pCaptData;
745 return pObj;
748 return 0;
751 void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
753 SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
754 if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
755 SetLayerLocked( pLockLayer->GetName(), bLock );
758 void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
760 //! rWin richtig auswerten
761 //! ggf Zoom aendern
763 if ( pViewData && pViewData->GetActiveWin() == &rWin )
764 pViewData->GetView()->MakeVisible( rRect );
767 void ScDrawView::DeleteMarked()
769 // try to delete a note caption object with its cell note in the Calc document
770 ScDrawObjData* pCaptData = 0;
771 if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
773 (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
774 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
775 ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
776 SfxUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
777 bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
779 // remove the cell note from document, we are its owner now
780 ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
781 DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
782 if( pNote )
784 // rescue note data for undo (with pointer to caption object)
785 ScNoteData aNoteData = pNote->GetNoteData();
786 DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
787 // collect the drawing undo action created while deleting the note
788 if( bUndo )
789 pDrawLayer->BeginCalcUndo();
790 // delete the note (already removed from document above)
791 delete pNote;
792 // add the undo action for the note
793 if( bUndo )
794 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
795 // repaint the cell to get rid of the note marker
796 if( pDocShell )
797 pDocShell->PostPaintCell( pCaptData->maStart );
798 // done, return now to skip call of FmFormView::DeleteMarked()
799 return;
803 FmFormView::DeleteMarked();
806 SdrEndTextEditKind ScDrawView::ScEndTextEdit()
808 BOOL bIsTextEdit = IsTextEdit();
809 SdrEndTextEditKind eKind = SdrEndTextEdit();
811 if ( bIsTextEdit && pViewData )
812 pViewData->GetViewShell()->SetDrawTextUndo(NULL); // "normaler" Undo-Manager
814 return eKind;
817 void ScDrawView::MarkDropObj( SdrObject* pObj )
819 if ( pDropMarkObj != pObj )
821 pDropMarkObj = pObj;
822 ImplClearCalcDropMarker();
824 if(pDropMarkObj)
826 pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
831 //UNUSED2009-05 void ScDrawView::CaptionTextDirection( USHORT nSlot )
832 //UNUSED2009-05 {
833 //UNUSED2009-05 if(nSlot != SID_TEXTDIRECTION_LEFT_TO_RIGHT && nSlot != SID_TEXTDIRECTION_TOP_TO_BOTTOM)
834 //UNUSED2009-05 return;
835 //UNUSED2009-05
836 //UNUSED2009-05 SdrObject* pObject = GetTextEditObject();
837 //UNUSED2009-05 if ( ScDrawLayer::IsNoteCaption( pObject ) )
838 //UNUSED2009-05 {
839 //UNUSED2009-05 if( SdrCaptionObj* pCaption = dynamic_cast< SdrCaptionObj* >( pObject ) )
840 //UNUSED2009-05 {
841 //UNUSED2009-05 SfxItemSet aAttr(pCaption->GetMergedItemSet());
842 //UNUSED2009-05 aAttr.Put( SvxWritingModeItem(
843 //UNUSED2009-05 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
844 //UNUSED2009-05 com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
845 //UNUSED2009-05 SDRATTR_TEXTDIRECTION ) );
846 //UNUSED2009-05 pCaption->SetMergedItemSet(aAttr);
847 //UNUSED2009-05 FuPoor* pPoor = pViewData->GetView()->GetDrawFuncPtr();
848 //UNUSED2009-05 if ( pPoor )
849 //UNUSED2009-05 {
850 //UNUSED2009-05 FuText* pText = static_cast<FuText*>(pPoor);
851 //UNUSED2009-05 pText->StopEditMode(TRUE);
852 //UNUSED2009-05 }
853 //UNUSED2009-05 }
854 //UNUSED2009-05 }
855 //UNUSED2009-05 }