1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 // INCLUDE --------------------------------------------------------------- 32 33 #include <com/sun/star/embed/EmbedStates.hpp> 34 35 #include <svx/svditer.hxx> 36 #include <svx/svdograf.hxx> 37 #include <svx/svdomedia.hxx> 38 #include <svx/svdogrp.hxx> 39 #include <svx/svdoole2.hxx> 40 #include <svx/svdouno.hxx> 41 #include <svx/svdpage.hxx> 42 #include <svx/svdundo.hxx> 43 #include <svx/svdocapt.hxx> 44 #include <editeng/outlobj.hxx> 45 #include <editeng/writingmodeitem.hxx> 46 #include <svx/sdrpaintwindow.hxx> 47 #include <sfx2/bindings.hxx> 48 #include <sfx2/viewfrm.hxx> 49 50 #include "drawview.hxx" 51 #include "global.hxx" 52 #include "viewdata.hxx" 53 #include "document.hxx" 54 #include "drawutil.hxx" 55 #include "futext.hxx" 56 #include "globstr.hrc" 57 #include "tabvwsh.hxx" 58 #include "client.hxx" 59 #include "scmod.hxx" 60 #include "drwlayer.hxx" 61 #include "docsh.hxx" 62 #include "viewuno.hxx" 63 #include "userdat.hxx" 64 #include "postit.hxx" 65 #include "undocell.hxx" 66 67 #include "sc.hrc" 68 69 using namespace com::sun::star; 70 71 // ----------------------------------------------------------------------- 72 73 #define SC_HANDLESIZE_BIG 9 74 #define SC_HANDLESIZE_SMALL 7 75 76 // ----------------------------------------------------------------------- 77 78 #ifdef _MSC_VER 79 #pragma optimize ( "", off ) 80 #endif 81 82 83 void ScDrawView::Construct() 84 { 85 EnableExtendedKeyInputDispatcher(sal_False); 86 EnableExtendedMouseEventDispatcher(sal_False); 87 EnableExtendedCommandEventDispatcher(sal_False); 88 89 SetFrameDragSingles(sal_True); 90 // SetSolidMarkHdl(sal_True); // einstellbar -> UpdateUserViewOptions 91 92 SetMinMoveDistancePixel( 2 ); 93 SetHitTolerancePixel( 2 ); 94 95 if (pViewData) 96 { 97 SCTAB nViewTab = pViewData->GetTabNo(); 98 ShowSdrPage(GetModel()->GetPage(nViewTab)); 99 100 sal_Bool bEx = pViewData->GetViewShell()->IsDrawSelMode(); 101 sal_Bool bProt = pDoc->IsTabProtected( nViewTab ) || 102 pViewData->GetSfxDocShell()->IsReadOnly(); 103 104 SdrLayer* pLayer; 105 SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin(); 106 pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); 107 if (pLayer) 108 SetLayerLocked( pLayer->GetName(), bProt || !bEx ); 109 pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); 110 if (pLayer) 111 SetLayerLocked( pLayer->GetName(), sal_True ); 112 pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); 113 if (pLayer) 114 { 115 SetLayerLocked( pLayer->GetName(), bProt ); 116 SetActiveLayer( pLayer->GetName() ); // FRONT als aktiven Layer setzen 117 } 118 pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); 119 if (pLayer) 120 SetLayerLocked( pLayer->GetName(), bProt ); 121 pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN); 122 if (pLayer) 123 { 124 SetLayerLocked( pLayer->GetName(), bProt ); 125 SetLayerVisible( pLayer->GetName(), sal_False); 126 } 127 128 SetSwapAsynchron(sal_True); 129 } 130 else 131 { 132 ShowSdrPage(GetModel()->GetPage(nTab)); 133 } 134 135 UpdateUserViewOptions(); 136 RecalcScale(); 137 UpdateWorkArea(); 138 139 bInConstruct = sal_False; 140 } 141 142 void ScDrawView::ImplClearCalcDropMarker() 143 { 144 if(pDropMarker) 145 { 146 delete pDropMarker; 147 pDropMarker = 0L; 148 } 149 } 150 151 __EXPORT ScDrawView::~ScDrawView() 152 { 153 ImplClearCalcDropMarker(); 154 } 155 156 void ScDrawView::AddCustomHdl() 157 { 158 sal_Bool bNegativePage = pDoc->IsNegativePage( nTab ); 159 160 const SdrMarkList &rMrkList = GetMarkedObjectList(); 161 sal_uInt32 nCount = rMrkList.GetMarkCount(); 162 for(sal_uInt32 nPos=0; nPos<nCount; nPos++ ) 163 { 164 const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj(); 165 if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL) 166 { 167 const sal_Int32 nDelta = 1; 168 169 Rectangle aBoundRect = pObj->GetCurrentBoundRect(); 170 Point aPos; 171 if (bNegativePage) 172 { 173 aPos = aBoundRect.TopRight(); 174 aPos.X() = -aPos.X(); // so the loop below is the same 175 } 176 else 177 aPos = aBoundRect.TopLeft(); 178 long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta; 179 long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta; 180 181 SCCOL nCol; 182 sal_Int32 nWidth = 0; 183 184 for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++) 185 nWidth += pDoc->GetColWidth(nCol,nTab); 186 187 if(nCol > 0) 188 --nCol; 189 190 SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab, 191 (sal_uLong) nPosY); 192 if(nRow > 0) 193 --nRow; 194 195 ScTabView* pView = pViewData->GetView(); 196 ScAddress aScAddress(nCol, nRow, nTab); 197 pView->CreateAnchorHandles(aHdl, aScAddress); 198 } 199 } 200 } 201 202 void ScDrawView::InvalidateAttribs() 203 { 204 if (!pViewData) return; 205 SfxBindings& rBindings = pViewData->GetBindings(); 206 207 // echte Statuswerte: 208 rBindings.InvalidateAll( sal_True ); 209 } 210 211 void ScDrawView::InvalidateDrawTextAttrs() 212 { 213 if (!pViewData) return; 214 SfxBindings& rBindings = pViewData->GetBindings(); 215 216 // cjk/ctl font items have no configured slots, 217 // need no invalidate 218 219 rBindings.Invalidate( SID_ATTR_CHAR_FONT ); 220 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 221 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); 222 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); 223 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); 224 rBindings.Invalidate( SID_ULINE_VAL_NONE ); 225 rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); 226 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); 227 rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); 228 rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE ); 229 rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); 230 rBindings.Invalidate( SID_ALIGNLEFT ); 231 rBindings.Invalidate( SID_ALIGNCENTERHOR ); 232 rBindings.Invalidate( SID_ALIGNRIGHT ); 233 rBindings.Invalidate( SID_ALIGNBLOCK ); 234 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 ); 235 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 ); 236 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 ); 237 rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); 238 rBindings.Invalidate( SID_SET_SUB_SCRIPT ); 239 rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT ); 240 rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM ); 241 rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT ); 242 rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT ); 243 // pseudo slots for Format menu 244 rBindings.Invalidate( SID_ALIGN_ANY_LEFT ); 245 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER ); 246 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT ); 247 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED ); 248 } 249 250 //void ScDrawView::DrawMarks( OutputDevice* pOut ) const 251 //{ 252 // DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)"); 253 // SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut); 254 // 255 // if(pPaintWindow) 256 // { 257 // if(pPaintWindow->isXorVisible()) 258 // { 259 // ToggleShownXor(pOut, 0L); 260 // } 261 // } 262 //} 263 264 void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo ) 265 { 266 if (AreObjectsMarked()) 267 { 268 // #i11702# use SdrUndoObjectLayerChange for undo 269 // STR_UNDO_SELATTR is "Attributes" - should use a different text later 270 BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) ); 271 272 const SdrMarkList& rMark = GetMarkedObjectList(); 273 sal_uLong nCount = rMark.GetMarkCount(); 274 for (sal_uLong i=0; i<nCount; i++) 275 { 276 SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); 277 if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) ) 278 { 279 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) ); 280 pObj->SetLayer( nLayerNo ); 281 } 282 } 283 284 EndUndo(); 285 286 // repaint is done in SetLayer 287 288 pViewData->GetDocShell()->SetDrawModified(); 289 290 // #84073# check mark list now instead of later in a timer 291 CheckMarked(); 292 MarkListHasChanged(); 293 } 294 } 295 296 bool ScDrawView::HasMarkedControl() const 297 { 298 SdrObjListIter aIter( GetMarkedObjectList() ); 299 for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() ) 300 if( pObj->ISA( SdrUnoObj ) ) 301 return true; 302 return false; 303 } 304 305 bool ScDrawView::HasMarkedInternal() const 306 { 307 // internal objects should not be inside a group, but who knows... 308 SdrObjListIter aIter( GetMarkedObjectList() ); 309 for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() ) 310 if( pObj->GetLayer() == SC_LAYER_INTERN ) 311 return true; 312 return false; 313 } 314 315 void ScDrawView::UpdateWorkArea() 316 { 317 SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab)); 318 if (pPage) 319 { 320 Point aPos; 321 Size aPageSize( pPage->GetSize() ); 322 Rectangle aNewArea( aPos, aPageSize ); 323 if ( aPageSize.Width() < 0 ) 324 { 325 // RTL: from max.negative (left) to zero (right) 326 aNewArea.Right() = 0; 327 aNewArea.Left() = aPageSize.Width() + 1; 328 } 329 SetWorkArea( aNewArea ); 330 } 331 else 332 { 333 DBG_ERROR("Page nicht gefunden"); 334 } 335 } 336 337 void ScDrawView::DoCut() 338 { 339 DoCopy(); 340 BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) ); 341 DeleteMarked(); // auf dieser View - von der 505f Umstellung nicht betroffen 342 EndUndo(); 343 } 344 345 void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const 346 { 347 rFractX = aScaleX; 348 rFractY = aScaleY; 349 } 350 351 void ScDrawView::RecalcScale() 352 { 353 double nPPTX; 354 double nPPTY; 355 Fraction aZoomX(1,1); 356 Fraction aZoomY(1,1); 357 358 if (pViewData) 359 { 360 nTab = pViewData->GetTabNo(); 361 nPPTX = pViewData->GetPPTX(); 362 nPPTY = pViewData->GetPPTY(); 363 aZoomX = pViewData->GetZoomX(); 364 aZoomY = pViewData->GetZoomY(); 365 } 366 else 367 { 368 Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); 369 nPPTX = aLogic.X() / 1000.0; 370 nPPTY = aLogic.Y() / 1000.0; 371 //! Zoom uebergeben ??? 372 } 373 374 SCCOL nEndCol = 0; 375 SCROW nEndRow = 0; 376 pDoc->GetTableArea( nTab, nEndCol, nEndRow ); 377 if (nEndCol<20) 378 nEndCol = 20; 379 if (nEndRow<20) 380 nEndRow = 20; // #i116848# instead of a large row number for an empty sheet, heights are multiplied in CalcScale 381 382 ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY, 383 aScaleX,aScaleY ); 384 } 385 386 void ScDrawView::DoConnect(SdrOle2Obj* pOleObj) 387 { 388 if ( pViewData ) 389 pViewData->GetViewShell()->ConnectObject( pOleObj ); 390 } 391 392 void ScDrawView::MarkListHasChanged() 393 { 394 FmFormView::MarkListHasChanged(); 395 396 UpdateBrowser(); 397 398 ScTabViewShell* pViewSh = pViewData->GetViewShell(); 399 400 // #i110829# remove the cell selection only if drawing objects are selected 401 if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() ) 402 { 403 pViewSh->Unmark(); // remove cell selection 404 405 // #65379# end cell edit mode if drawing objects are selected 406 SC_MOD()->InputEnterHandler(); 407 } 408 409 // IP deaktivieren 410 411 ScModule* pScMod = SC_MOD(); 412 bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF; 413 414 ScClient* pClient = (ScClient*) pViewSh->GetIPClient(); 415 if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog ) 416 { 417 // #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen 418 //HMHbDisableHdl = sal_True; 419 pClient->DeactivateObject(); 420 //HMHbDisableHdl = sal_False; 421 // Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate 422 } 423 424 // Ole-Objekt selektiert? 425 426 SdrOle2Obj* pOle2Obj = NULL; 427 SdrGrafObj* pGrafObj = NULL; 428 SdrMediaObj* pMediaObj = NULL; 429 430 const SdrMarkList& rMarkList = GetMarkedObjectList(); 431 sal_uLong nMarkCount = rMarkList.GetMarkCount(); 432 433 if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct ) 434 { 435 // relock layers that may have been unlocked before 436 LockBackgroundLayer(); 437 LockInternalLayer(); 438 } 439 440 sal_Bool bSubShellSet = sal_False; 441 if (nMarkCount == 1) 442 { 443 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 444 if (pObj->GetObjIdentifier() == OBJ_OLE2) 445 { 446 pOle2Obj = (SdrOle2Obj*) pObj; 447 if (!pDoc->IsChart(pObj) ) 448 pViewSh->SetOleObjectShell(sal_True); 449 else 450 pViewSh->SetChartShell(sal_True); 451 bSubShellSet = sal_True; 452 } 453 else if (pObj->GetObjIdentifier() == OBJ_GRAF) 454 { 455 pGrafObj = (SdrGrafObj*) pObj; 456 pViewSh->SetGraphicShell(sal_True); 457 bSubShellSet = sal_True; 458 } 459 else if (pObj->GetObjIdentifier() == OBJ_MEDIA) 460 { 461 pMediaObj = (SdrMediaObj*) pObj; 462 pViewSh->SetMediaShell(sal_True); 463 bSubShellSet = sal_True; 464 } 465 else if (pObj->GetObjIdentifier() != OBJ_TEXT // Verhindern, das beim Anlegen 466 || !pViewSh->IsDrawTextShell()) // eines TextObjekts auf die 467 { // DrawShell umgeschaltet wird. 468 pViewSh->SetDrawShell(sal_True); //@#70206# 469 } 470 } 471 472 if ( nMarkCount && !bSubShellSet ) 473 { 474 sal_Bool bOnlyControls = sal_True; 475 sal_Bool bOnlyGraf = sal_True; 476 for (sal_uLong i=0; i<nMarkCount; i++) 477 { 478 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); 479 if ( pObj->ISA( SdrObjGroup ) ) 480 { 481 const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList(); 482 sal_uLong nListCount = pLst->GetObjCount(); 483 if ( nListCount == 0 ) 484 { 485 // #104156# An empty group (may occur during Undo) is no control or graphics object. 486 // Creating the form shell during undo would lead to problems with the undo manager. 487 bOnlyControls = sal_False; 488 bOnlyGraf = sal_False; 489 } 490 for ( sal_uInt16 j = 0; j < nListCount; ++j ) 491 { 492 SdrObject *pSubObj = pLst->GetObj( j ); 493 494 if (!pSubObj->ISA(SdrUnoObj)) 495 bOnlyControls = sal_False; 496 if (pSubObj->GetObjIdentifier() != OBJ_GRAF) 497 bOnlyGraf = sal_False; 498 499 if ( !bOnlyControls && !bOnlyGraf ) break; 500 } 501 } 502 else 503 { 504 if (!pObj->ISA(SdrUnoObj)) 505 bOnlyControls = sal_False; 506 if (pObj->GetObjIdentifier() != OBJ_GRAF) 507 bOnlyGraf = sal_False; 508 } 509 510 if ( !bOnlyControls && !bOnlyGraf ) break; 511 } 512 513 if(bOnlyControls) 514 { 515 pViewSh->SetDrawFormShell(sal_True); // jetzt UNO-Controls 516 } 517 else if(bOnlyGraf) 518 { 519 pViewSh->SetGraphicShell(sal_True); 520 } 521 else if(nMarkCount>1) 522 { 523 pViewSh->SetDrawShell(sal_True); 524 } 525 } 526 527 528 529 // Verben anpassen 530 531 SfxViewFrame* pViewFrame = pViewSh->GetViewFrame(); 532 sal_Bool bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace(); 533 uno::Sequence< embed::VerbDescriptor > aVerbs; 534 if ( pOle2Obj && !bOle ) 535 { 536 uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef(); 537 DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" ); 538 if (xObj.is()) 539 aVerbs = xObj->getSupportedVerbs(); 540 } 541 pViewSh->SetVerbs( aVerbs ); 542 543 // Image-Map Editor 544 545 if ( pOle2Obj ) 546 UpdateIMap( pOle2Obj ); 547 else if ( pGrafObj ) 548 UpdateIMap( pGrafObj ); 549 550 InvalidateAttribs(); // nach dem IMap-Editor Update 551 InvalidateDrawTextAttrs(); 552 553 for(sal_uInt32 a(0L); a < PaintWindowCount(); a++) 554 { 555 SdrPaintWindow* pPaintWindow = GetPaintWindow(a); 556 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 557 558 if(OUTDEV_WINDOW == rOutDev.GetOutDevType()) 559 { 560 ((Window&)rOutDev).Update(); 561 } 562 } 563 564 // uno object for view returns drawing objects as selection, 565 // so it must notify its SelectionChangeListeners 566 567 if (pViewFrame) 568 { 569 SfxFrame& rFrame = pViewFrame->GetFrame(); 570 uno::Reference<frame::XController> xController = rFrame.GetController(); 571 if (xController.is()) 572 { 573 ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController ); 574 if (pImp) 575 pImp->SelectionChanged(); 576 } 577 } 578 579 // update selection transfer object 580 581 pViewSh->CheckSelectionTransfer(); 582 583 } 584 585 void __EXPORT ScDrawView::ModelHasChanged() 586 { 587 SdrObject* pEditObj = GetTextEditObject(); 588 if ( pEditObj && !pEditObj->IsInserted() && pViewData ) 589 { 590 // #111700# SdrObjEditView::ModelHasChanged will end text edit in this case, 591 // so make sure the EditEngine's undo manager is no longer used. 592 pViewData->GetViewShell()->SetDrawTextUndo(NULL); 593 SetCreateMode(); // don't leave FuText in a funny state 594 } 595 596 FmFormView::ModelHasChanged(); 597 } 598 599 void __EXPORT ScDrawView::UpdateUserViewOptions() 600 { 601 if (pViewData) 602 { 603 const ScViewOptions& rOpt = pViewData->GetOptions(); 604 const ScGridOptions& rGrid = rOpt.GetGridOptions(); 605 606 sal_Bool bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES ); 607 608 SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) ); 609 SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) ); 610 SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL ); 611 612 SetGridVisible( rGrid.GetGridVisible() ); 613 SetSnapEnabled( rGrid.GetUseGridSnap() ); 614 SetGridSnap( rGrid.GetUseGridSnap() ); 615 616 // Snap from grid options is no longer used 617 // SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) ); 618 619 Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 ); 620 Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 ); 621 SetSnapGridWidth( aFractX, aFractY ); 622 623 SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) ); 624 SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1), 625 rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) ); 626 } 627 } 628 629 #ifdef _MSC_VER 630 #pragma optimize ( "", on ) 631 #endif 632 633 sal_Bool ScDrawView::SelectObject( const String& rName ) 634 { 635 UnmarkAll(); 636 637 SCTAB nObjectTab = 0; 638 SdrObject* pFound = NULL; 639 640 SfxObjectShell* pShell = pDoc->GetDocumentShell(); 641 if (pShell) 642 { 643 SdrModel* pDrawLayer = GetModel(); 644 SCTAB nTabCount = pDoc->GetTableCount(); 645 for (SCTAB i=0; i<nTabCount && !pFound; i++) 646 { 647 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i)); 648 DBG_ASSERT(pPage,"Page ?"); 649 if (pPage) 650 { 651 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 652 SdrObject* pObject = aIter.Next(); 653 while (pObject && !pFound) 654 { 655 if ( ScDrawLayer::GetVisibleName( pObject ) == rName ) 656 { 657 pFound = pObject; 658 nObjectTab = i; 659 } 660 pObject = aIter.Next(); 661 } 662 } 663 } 664 } 665 666 if ( pFound ) 667 { 668 ScTabView* pView = pViewData->GetView(); 669 if ( nObjectTab != nTab ) // Tabelle umschalten 670 pView->SetTabNo( nObjectTab ); 671 672 DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" ); 673 674 pView->ScrollToObject( pFound ); 675 676 /* #61585# To select an object on the background layer, the layer has to 677 be unlocked even if exclusive drawing selection mode is not active 678 (this is reversed in MarkListHasChanged when nothing is selected) */ 679 if ( pFound->GetLayer() == SC_LAYER_BACK && 680 !pViewData->GetViewShell()->IsDrawSelMode() && 681 !pDoc->IsTabProtected( nTab ) && 682 !pViewData->GetSfxDocShell()->IsReadOnly() ) 683 { 684 UnlockBackgroundLayer(); 685 } 686 687 SdrPageView* pPV = GetSdrPageView(); 688 MarkObj( pFound, pPV ); 689 } 690 691 return ( pFound != NULL ); 692 } 693 694 //UNUSED2008-05 String ScDrawView::GetSelectedChartName() const 695 //UNUSED2008-05 { 696 //UNUSED2008-05 // used for modifying a chart's data area - PersistName must always be used 697 //UNUSED2008-05 // (as in ScDocument::FindChartData and UpdateChartArea) 698 //UNUSED2008-05 699 //UNUSED2008-05 const SdrMarkList& rMarkList = GetMarkedObjectList(); 700 //UNUSED2008-05 if (rMarkList.GetMarkCount() == 1) 701 //UNUSED2008-05 { 702 //UNUSED2008-05 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 703 //UNUSED2008-05 if (pObj->GetObjIdentifier() == OBJ_OLE2) 704 //UNUSED2008-05 if ( pDoc->IsChart(pObj) ) 705 //UNUSED2008-05 return static_cast<SdrOle2Obj*>(pObj)->GetPersistName(); 706 //UNUSED2008-05 } 707 //UNUSED2008-05 708 //UNUSED2008-05 return EMPTY_STRING; // nichts gefunden 709 //UNUSED2008-05 } 710 711 FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, sal_uLong nOptions) 712 { 713 // Markierung nicht aendern, wenn Ole-Objekt aktiv 714 // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!) 715 716 if (pViewData) 717 { 718 SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient(); 719 if ( pClient && pClient->IsObjectInPlaceActive() ) 720 nOptions |= SDRINSERT_DONTMARK; 721 } 722 723 return InsertObjectAtView( pObj, rPV, nOptions ); 724 } 725 726 SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData ) 727 { 728 const SdrMarkList& rMarkList = GetMarkedObjectList(); 729 if( pViewData && (rMarkList.GetMarkCount() == 1) ) 730 { 731 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 732 if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) ) 733 { 734 if( ppCaptData ) *ppCaptData = pCaptData; 735 return pObj; 736 } 737 } 738 return 0; 739 } 740 741 void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock ) 742 { 743 SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer ); 744 if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) ) 745 SetLayerLocked( pLockLayer->GetName(), bLock ); 746 } 747 748 void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin ) 749 { 750 //! rWin richtig auswerten 751 //! ggf Zoom aendern 752 753 if ( pViewData && pViewData->GetActiveWin() == &rWin ) 754 pViewData->GetView()->MakeVisible( rRect ); 755 } 756 757 void ScDrawView::DeleteMarked() 758 { 759 // try to delete a note caption object with its cell note in the Calc document 760 ScDrawObjData* pCaptData = 0; 761 if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) ) 762 { 763 (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds 764 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 765 ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0; 766 ::svl::IUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0; 767 bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled(); 768 769 // remove the cell note from document, we are its owner now 770 ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart ); 771 DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" ); 772 if( pNote ) 773 { 774 // rescue note data for undo (with pointer to caption object) 775 ScNoteData aNoteData = pNote->GetNoteData(); 776 DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" ); 777 // collect the drawing undo action created while deleting the note 778 if( bUndo ) 779 pDrawLayer->BeginCalcUndo(); 780 // delete the note (already removed from document above) 781 delete pNote; 782 // add the undo action for the note 783 if( bUndo ) 784 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) ); 785 // repaint the cell to get rid of the note marker 786 if( pDocShell ) 787 pDocShell->PostPaintCell( pCaptData->maStart ); 788 // done, return now to skip call of FmFormView::DeleteMarked() 789 return; 790 } 791 } 792 793 FmFormView::DeleteMarked(); 794 } 795 796 SdrEndTextEditKind ScDrawView::ScEndTextEdit() 797 { 798 sal_Bool bIsTextEdit = IsTextEdit(); 799 SdrEndTextEditKind eKind = SdrEndTextEdit(); 800 801 if ( bIsTextEdit && pViewData ) 802 pViewData->GetViewShell()->SetDrawTextUndo(NULL); // "normaler" Undo-Manager 803 804 return eKind; 805 } 806 807 void ScDrawView::MarkDropObj( SdrObject* pObj ) 808 { 809 if ( pDropMarkObj != pObj ) 810 { 811 pDropMarkObj = pObj; 812 ImplClearCalcDropMarker(); 813 814 if(pDropMarkObj) 815 { 816 pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj); 817 } 818 } 819 } 820 821 //UNUSED2009-05 void ScDrawView::CaptionTextDirection( sal_uInt16 nSlot ) 822 //UNUSED2009-05 { 823 //UNUSED2009-05 if(nSlot != SID_TEXTDIRECTION_LEFT_TO_RIGHT && nSlot != SID_TEXTDIRECTION_TOP_TO_BOTTOM) 824 //UNUSED2009-05 return; 825 //UNUSED2009-05 826 //UNUSED2009-05 SdrObject* pObject = GetTextEditObject(); 827 //UNUSED2009-05 if ( ScDrawLayer::IsNoteCaption( pObject ) ) 828 //UNUSED2009-05 { 829 //UNUSED2009-05 if( SdrCaptionObj* pCaption = dynamic_cast< SdrCaptionObj* >( pObject ) ) 830 //UNUSED2009-05 { 831 //UNUSED2009-05 SfxItemSet aAttr(pCaption->GetMergedItemSet()); 832 //UNUSED2009-05 aAttr.Put( SvxWritingModeItem( 833 //UNUSED2009-05 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? 834 //UNUSED2009-05 com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL, 835 //UNUSED2009-05 SDRATTR_TEXTDIRECTION ) ); 836 //UNUSED2009-05 pCaption->SetMergedItemSet(aAttr); 837 //UNUSED2009-05 FuPoor* pPoor = pViewData->GetView()->GetDrawFuncPtr(); 838 //UNUSED2009-05 if ( pPoor ) 839 //UNUSED2009-05 { 840 //UNUSED2009-05 FuText* pText = static_cast<FuText*>(pPoor); 841 //UNUSED2009-05 pText->StopEditMode(sal_True); 842 //UNUSED2009-05 } 843 //UNUSED2009-05 } 844 //UNUSED2009-05 } 845 //UNUSED2009-05 } 846