LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - drawview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 400 0.2 %
Date: 2012-12-27 Functions: 2 29 6.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10