LCOV - code coverage report
Current view: top level - sc/source/ui/view - drawview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 180 369 48.8 %
Date: 2012-08-25 Functions: 14 26 53.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 78 496 15.7 %

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

Generated by: LCOV version 1.10