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

Generated by: LCOV version 1.10