LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdedtv.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 271 527 51.4 %
Date: 2012-08-25 Functions: 17 32 53.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 162 774 20.9 %

           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                 :            : 
      30                 :            : #include <vcl/metaact.hxx>
      31                 :            : #include <svx/svdedtv.hxx>
      32                 :            : #include <svx/svdundo.hxx>
      33                 :            : #include <svx/svdograf.hxx>  // for Possibilities
      34                 :            : #include <svx/svdopath.hxx>
      35                 :            : #include <svx/svdoole2.hxx>
      36                 :            : #include <svx/svdopage.hxx>
      37                 :            : #include <svx/svdoedge.hxx>
      38                 :            : #include <svx/svdlayer.hxx>
      39                 :            : #include <svx/svdpagv.hxx>
      40                 :            : #include <svx/svdpage.hxx>
      41                 :            : #include <svx/svdpoev.hxx>  // for the PolyPossiblities
      42                 :            : #include "svx/svdstr.hrc"   // names taken from the resource
      43                 :            : #include "svx/svdglob.hxx"  // StringCache
      44                 :            : #include <svx/e3dsceneupdater.hxx>
      45                 :            : #include <rtl/strbuf.hxx>
      46                 :            : 
      47                 :            : // #i13033#
      48                 :            : #include <clonelist.hxx>
      49                 :            : 
      50                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      51                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      52                 :            : // EditView
      53                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      54                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      55                 :            : 
      56                 :      14272 : void SdrEditView::ImpResetPossibilityFlags()
      57                 :            : {
      58                 :      14272 :     bReadOnly               =sal_False;
      59                 :            : 
      60                 :      14272 :     bGroupPossible          =sal_False;
      61                 :      14272 :     bUnGroupPossible        =sal_False;
      62                 :      14272 :     bGrpEnterPossible       =sal_False;
      63                 :      14272 :     bDeletePossible         =sal_False;
      64                 :      14272 :     bToTopPossible          =sal_False;
      65                 :      14272 :     bToBtmPossible          =sal_False;
      66                 :      14272 :     bReverseOrderPossible   =sal_False;
      67                 :            : 
      68                 :      14272 :     bImportMtfPossible      =sal_False;
      69                 :      14272 :     bCombinePossible        =sal_False;
      70                 :      14272 :     bDismantlePossible      =sal_False;
      71                 :      14272 :     bCombineNoPolyPolyPossible =sal_False;
      72                 :      14272 :     bDismantleMakeLinesPossible=sal_False;
      73                 :      14272 :     bOrthoDesiredOnMarked   =sal_False;
      74                 :            : 
      75                 :      14272 :     bMoreThanOneNotMovable  =sal_False;
      76                 :      14272 :     bOneOrMoreMovable       =sal_False;
      77                 :      14272 :     bMoreThanOneNoMovRot    =sal_False;
      78                 :      14272 :     bContortionPossible     =sal_False;
      79                 :      14272 :     bAllPolys               =sal_False;
      80                 :      14272 :     bOneOrMorePolys         =sal_False;
      81                 :      14272 :     bMoveAllowed            =sal_False;
      82                 :      14272 :     bResizeFreeAllowed      =sal_False;
      83                 :      14272 :     bResizePropAllowed      =sal_False;
      84                 :      14272 :     bRotateFreeAllowed      =sal_False;
      85                 :      14272 :     bRotate90Allowed        =sal_False;
      86                 :      14272 :     bMirrorFreeAllowed      =sal_False;
      87                 :      14272 :     bMirror45Allowed        =sal_False;
      88                 :      14272 :     bMirror90Allowed        =sal_False;
      89                 :      14272 :     bTransparenceAllowed    =sal_False;
      90                 :      14272 :     bGradientAllowed        =sal_False;
      91                 :      14272 :     bShearAllowed           =sal_False;
      92                 :      14272 :     bEdgeRadiusAllowed      =sal_False;
      93                 :      14272 :     bCanConvToPath          =sal_False;
      94                 :      14272 :     bCanConvToPoly          =sal_False;
      95                 :      14272 :     bCanConvToContour       =sal_False;
      96                 :      14272 :     bCanConvToPathLineToArea=sal_False;
      97                 :      14272 :     bCanConvToPolyLineToArea=sal_False;
      98                 :      14272 :     bMoveProtect            =sal_False;
      99                 :      14272 :     bResizeProtect          =sal_False;
     100                 :      14272 : }
     101                 :            : 
     102                 :       4699 : void SdrEditView::ImpClearVars()
     103                 :            : {
     104                 :       4699 :     ImpResetPossibilityFlags();
     105                 :       4699 :     bPossibilitiesDirty=sal_True;   // << Purify didn't like this
     106                 :       4699 :     bBundleVirtObj=sal_False;
     107                 :       4699 : }
     108                 :            : 
     109                 :       4699 : SdrEditView::SdrEditView(SdrModel* pModel1, OutputDevice* pOut):
     110                 :       4699 :     SdrMarkView(pModel1,pOut)
     111                 :            : {
     112                 :       4699 :     ImpClearVars();
     113                 :       4699 : }
     114                 :            : 
     115                 :       4508 : SdrEditView::~SdrEditView()
     116                 :            : {
     117         [ -  + ]:       4508 : }
     118                 :            : 
     119                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     120                 :            : 
     121                 :          0 : SdrLayer* SdrEditView::InsertNewLayer(const XubString& rName, sal_uInt16 nPos)
     122                 :            : {
     123                 :          0 :     SdrLayerAdmin& rLA=pMod->GetLayerAdmin();
     124                 :          0 :     sal_uInt16 nMax=rLA.GetLayerCount();
     125         [ #  # ]:          0 :     if (nPos>nMax) nPos=nMax;
     126                 :          0 :     SdrLayer* pNewLayer=rLA.NewLayer(rName,nPos);
     127                 :            : 
     128         [ #  # ]:          0 :     if( GetModel()->IsUndoEnabled() )
     129                 :          0 :         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA,*pMod));
     130                 :            : 
     131                 :          0 :     pMod->SetChanged();
     132                 :          0 :     return pNewLayer;
     133                 :            : }
     134                 :            : 
     135                 :            : #include <svx/svdogrp.hxx>
     136                 :            : #include <svx/scene3d.hxx>
     137                 :            : 
     138                 :          0 : sal_Bool SdrEditView::ImpDelLayerCheck(SdrObjList* pOL, SdrLayerID nDelID) const
     139                 :            : {
     140                 :          0 :     sal_Bool bDelAll(sal_True);
     141                 :          0 :     sal_uInt32 nObjAnz(pOL->GetObjCount());
     142                 :            : 
     143 [ #  # ][ #  # ]:          0 :     for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0 && bDelAll;)
                 [ #  # ]
     144                 :            :     {
     145                 :          0 :         nObjNum--;
     146                 :          0 :         SdrObject* pObj = pOL->GetObj(nObjNum);
     147                 :          0 :         SdrObjList* pSubOL = pObj->GetSubList();
     148                 :            : 
     149                 :            :         // explicitly test for group objects and 3d scenes
     150 [ #  # ][ #  # ]:          0 :         if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
         [ #  # ][ #  # ]
     151                 :            :         {
     152         [ #  # ]:          0 :             if(!ImpDelLayerCheck(pSubOL, nDelID))
     153                 :            :             {
     154                 :          0 :                 bDelAll = sal_False;
     155                 :            :             }
     156                 :            :         }
     157                 :            :         else
     158                 :            :         {
     159         [ #  # ]:          0 :             if(pObj->GetLayer() != nDelID)
     160                 :            :             {
     161                 :          0 :                 bDelAll = sal_False;
     162                 :            :             }
     163                 :            :         }
     164                 :            :     }
     165                 :            : 
     166                 :          0 :     return bDelAll;
     167                 :            : }
     168                 :            : 
     169                 :          0 : void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
     170                 :            : {
     171                 :          0 :     sal_uInt32 nObjAnz(pOL->GetObjCount());
     172                 :            :     // make sure OrdNums are correct
     173                 :          0 :     pOL->GetObj(0)->GetOrdNum();
     174                 :            : 
     175                 :          0 :     const bool bUndo = GetModel()->IsUndoEnabled();
     176                 :            : 
     177         [ #  # ]:          0 :     for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0;)
     178                 :            :     {
     179                 :          0 :         nObjNum--;
     180         [ #  # ]:          0 :         SdrObject* pObj = pOL->GetObj(nObjNum);
     181         [ #  # ]:          0 :         SdrObjList* pSubOL = pObj->GetSubList();
     182                 :            : 
     183                 :            : 
     184                 :            :         // explicitly test for group objects and 3d scenes
     185 [ #  # ][ #  # ]:          0 :         if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     186                 :            :         {
     187 [ #  # ][ #  # ]:          0 :             if(ImpDelLayerCheck(pSubOL, nDelID))
     188                 :            :             {
     189         [ #  # ]:          0 :                 if( bUndo )
     190 [ #  # ][ #  # ]:          0 :                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
                 [ #  # ]
     191         [ #  # ]:          0 :                 pOL->RemoveObject(nObjNum);
     192                 :            : 
     193         [ #  # ]:          0 :                 if( !bUndo )
     194         [ #  # ]:          0 :                     SdrObject::Free( pObj );
     195                 :            :             }
     196                 :            :             else
     197                 :            :             {
     198         [ #  # ]:          0 :                 ImpDelLayerDelObjs(pSubOL, nDelID);
     199                 :            :             }
     200                 :            :         }
     201                 :            :         else
     202                 :            :         {
     203 [ #  # ][ #  # ]:          0 :             if(pObj->GetLayer() == nDelID)
     204                 :            :             {
     205         [ #  # ]:          0 :                 if( bUndo )
     206 [ #  # ][ #  # ]:          0 :                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
                 [ #  # ]
     207         [ #  # ]:          0 :                 pOL->RemoveObject(nObjNum);
     208         [ #  # ]:          0 :                 if( !bUndo )
     209         [ #  # ]:          0 :                     SdrObject::Free( pObj );
     210                 :            :             }
     211                 :            :         }
     212                 :            :     }
     213                 :          0 : }
     214                 :            : 
     215                 :          2 : void SdrEditView::DeleteLayer(const XubString& rName)
     216                 :            : {
     217                 :          2 :     SdrLayerAdmin& rLA = pMod->GetLayerAdmin();
     218                 :          2 :     SdrLayer* pLayer = rLA.GetLayer(rName, sal_True);
     219                 :          2 :     sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer));
     220                 :            : 
     221         [ +  - ]:          2 :     if(SDRLAYER_NOTFOUND != nLayerNum)
     222                 :            :     {
     223                 :            : 
     224                 :          2 :         SdrLayerID nDelID = pLayer->GetID();
     225                 :            : 
     226                 :          2 :         const bool bUndo = IsUndoEnabled();
     227         [ +  - ]:          2 :         if( bUndo )
     228         [ +  - ]:          2 :             BegUndo(ImpGetResStr(STR_UndoDelLayer));
     229                 :            : 
     230                 :          2 :         sal_Bool bMaPg(sal_True);
     231                 :            : 
     232         [ +  + ]:          6 :         for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++)
     233                 :            :         {
     234                 :            :             // MasterPages and DrawPages
     235         [ +  + ]:          4 :             sal_uInt16 nPgAnz(bMaPg ? pMod->GetMasterPageCount() : pMod->GetPageCount());
     236                 :            : 
     237         [ +  + ]:         16 :             for(sal_uInt16 nPgNum(0); nPgNum < nPgAnz; nPgNum++)
     238                 :            :             {
     239                 :            :                 // over all pages
     240         [ +  + ]:         12 :                 SdrPage* pPage = (bMaPg) ? pMod->GetMasterPage(nPgNum) : pMod->GetPage(nPgNum);
     241                 :         12 :                 sal_uInt32 nObjAnz(pPage->GetObjCount());
     242                 :            : 
     243                 :            :                 // make sure OrdNums are correct
     244         [ +  + ]:         12 :                 if(nObjAnz)
     245                 :          4 :                     pPage->GetObj(0)->GetOrdNum();
     246                 :            : 
     247         [ +  + ]:         18 :                 for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0;)
     248                 :            :                 {
     249                 :          6 :                     nObjNum--;
     250         [ +  - ]:          6 :                     SdrObject* pObj = pPage->GetObj(nObjNum);
     251         [ +  - ]:          6 :                     SdrObjList* pSubOL = pObj->GetSubList();
     252                 :            : 
     253                 :            :                     // explicitly test for group objects and 3d scenes
     254 [ -  + ][ #  # ]:          6 :                     if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
     255                 :            :                     {
     256 [ #  # ][ #  # ]:          0 :                         if(ImpDelLayerCheck(pSubOL, nDelID))
     257                 :            :                         {
     258         [ #  # ]:          0 :                             if( bUndo )
     259 [ #  # ][ #  # ]:          0 :                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
                 [ #  # ]
     260         [ #  # ]:          0 :                             pPage->RemoveObject(nObjNum);
     261         [ #  # ]:          0 :                             if( !bUndo )
     262         [ #  # ]:          0 :                                 SdrObject::Free(pObj);
     263                 :            :                         }
     264                 :            :                         else
     265                 :            :                         {
     266         [ #  # ]:          0 :                             ImpDelLayerDelObjs(pSubOL, nDelID);
     267                 :            :                         }
     268                 :            :                     }
     269                 :            :                     else
     270                 :            :                     {
     271 [ +  - ][ +  + ]:          6 :                         if(pObj->GetLayer() == nDelID)
     272                 :            :                         {
     273         [ +  - ]:          2 :                             if( bUndo )
     274 [ +  - ][ +  - ]:          2 :                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
                 [ +  - ]
     275         [ +  - ]:          2 :                             pPage->RemoveObject(nObjNum);
     276         [ -  + ]:          2 :                             if( !bUndo )
     277         [ #  # ]:          6 :                                 SdrObject::Free(pObj);
     278                 :            :                         }
     279                 :            :                     }
     280                 :            :                 }
     281                 :            :             }
     282                 :          4 :             bMaPg = sal_False;
     283                 :            :         }
     284                 :            : 
     285         [ +  - ]:          2 :         if( bUndo )
     286                 :            :         {
     287                 :          2 :             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *pMod));
     288                 :          2 :             rLA.RemoveLayer(nLayerNum);
     289                 :          2 :             EndUndo();
     290                 :            :         }
     291                 :            :         else
     292                 :            :         {
     293         [ #  # ]:          0 :             delete rLA.RemoveLayer(nLayerNum);
     294                 :            :         }
     295                 :            : 
     296                 :          2 :         pMod->SetChanged();
     297                 :            :     }
     298                 :          2 : }
     299                 :            : 
     300                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     301                 :            : 
     302                 :         68 : void SdrEditView::EndUndo()
     303                 :            : {
     304                 :            :     // #i13033#
     305                 :            :     // Comparison changed to 1L since EndUndo() is called later now
     306                 :            :     // and EndUndo WILL change count to count-1
     307         [ +  + ]:         68 :     if(1L == pMod->GetUndoBracketLevel())
     308                 :            :     {
     309                 :         44 :         ImpBroadcastEdgesOfMarkedNodes();
     310                 :            :     }
     311                 :            : 
     312                 :            :     // #i13033#
     313                 :            :     // moved to bottom to still have access to UNDOs inside of
     314                 :            :     // ImpBroadcastEdgesOfMarkedNodes()
     315                 :         68 :     pMod->EndUndo();
     316                 :         68 : }
     317                 :            : 
     318                 :         44 : void SdrEditView::ImpBroadcastEdgesOfMarkedNodes()
     319                 :            : {
     320                 :         44 :     std::vector<SdrObject*>::const_iterator iterPos;
     321         [ +  - ]:         44 :     const std::vector<SdrObject*>& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects();
     322                 :            : 
     323                 :            :     // #i13033#
     324                 :            :     // New mechanism to search for necessary disconnections for
     325                 :            :     // changed connectors inside the transitive hull of all at
     326                 :            :     // the beginning of UNDO selected objects
     327         [ +  + ]:        241 :     for(sal_uInt32 a(0L); a < rAllMarkedObjects.size(); a++)
     328                 :            :     {
     329 [ +  - ][ +  - ]:        197 :         SdrEdgeObj* pEdge = PTR_CAST(SdrEdgeObj, rAllMarkedObjects[a]);
         [ +  - ][ -  + ]
     330                 :            : 
     331         [ -  + ]:        197 :         if(pEdge)
     332                 :            :         {
     333         [ #  # ]:          0 :             SdrObject* pObj1 = pEdge->GetConnectedNode(sal_False);
     334         [ #  # ]:          0 :             SdrObject* pObj2 = pEdge->GetConnectedNode(sal_True);
     335                 :            : 
     336 [ #  # ][ #  # ]:          0 :             if(pObj1 && !pEdge->CheckNodeConnection(sal_False))
         [ #  # ][ #  # ]
     337                 :            :             {
     338         [ #  # ]:          0 :                 iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj1);
     339                 :            : 
     340 [ #  # ][ #  # ]:          0 :                 if (iterPos == rAllMarkedObjects.end())
     341                 :            :                 {
     342 [ #  # ][ #  # ]:          0 :                     if( IsUndoEnabled() )
     343 [ #  # ][ #  # ]:          0 :                         AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
                 [ #  # ]
     344         [ #  # ]:          0 :                     pEdge->DisconnectFromNode(sal_False);
     345                 :            :                 }
     346                 :            :             }
     347                 :            : 
     348 [ #  # ][ #  # ]:          0 :             if(pObj2 && !pEdge->CheckNodeConnection(sal_True))
         [ #  # ][ #  # ]
     349                 :            :             {
     350         [ #  # ]:          0 :                 iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj2);
     351                 :            : 
     352 [ #  # ][ #  # ]:          0 :                 if (iterPos == rAllMarkedObjects.end())
     353                 :            :                 {
     354 [ #  # ][ #  # ]:          0 :                     if( IsUndoEnabled() )
     355 [ #  # ][ #  # ]:          0 :                         AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
                 [ #  # ]
     356         [ #  # ]:          0 :                     pEdge->DisconnectFromNode(sal_True);
     357                 :            :                 }
     358                 :            :             }
     359                 :            :         }
     360                 :            :     }
     361                 :            : 
     362         [ +  - ]:         44 :     sal_uIntPtr nMarkedEdgeAnz = GetMarkedEdgesOfMarkedNodes().GetMarkCount();
     363                 :            :     sal_uInt16 i;
     364                 :            : 
     365         [ -  + ]:         44 :     for (i=0; i<nMarkedEdgeAnz; i++) {
     366 [ #  # ][ #  # ]:          0 :         SdrMark* pEM = GetMarkedEdgesOfMarkedNodes().GetMark(i);
     367         [ #  # ]:          0 :         SdrObject* pEdgeTmp=pEM->GetMarkedSdrObj();
     368 [ #  # ][ #  # ]:          0 :         SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pEdgeTmp);
         [ #  # ][ #  # ]
     369         [ #  # ]:          0 :         if (pEdge!=NULL) {
     370                 :          0 :             pEdge->SetEdgeTrackDirty();
     371                 :            :         }
     372                 :            :     }
     373                 :         44 : }
     374                 :            : 
     375                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     376                 :            : // Possibilities
     377                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     378                 :            : 
     379                 :       3748 : void SdrEditView::MarkListHasChanged()
     380                 :            : {
     381                 :       3748 :     SdrMarkView::MarkListHasChanged();
     382                 :       3748 :     bPossibilitiesDirty=sal_True;
     383                 :       3748 : }
     384                 :            : 
     385                 :       4384 : void SdrEditView::ModelHasChanged()
     386                 :            : {
     387                 :       4384 :     SdrMarkView::ModelHasChanged();
     388                 :       4384 :     bPossibilitiesDirty=sal_True;
     389                 :       4384 : }
     390                 :            : 
     391                 :          1 : sal_Bool SdrEditView::IsResizeAllowed(sal_Bool bProp) const
     392                 :            : {
     393                 :          1 :     ForcePossibilities();
     394         [ -  + ]:          1 :     if (bResizeProtect) return sal_False;
     395         [ +  - ]:          1 :     if (bProp) return bResizePropAllowed;
     396                 :          1 :     return bResizeFreeAllowed;
     397                 :            : }
     398                 :            : 
     399                 :          0 : sal_Bool SdrEditView::IsRotateAllowed(sal_Bool b90Deg) const
     400                 :            : {
     401                 :          0 :     ForcePossibilities();
     402         [ #  # ]:          0 :     if (bMoveProtect) return sal_False;
     403         [ #  # ]:          0 :     if (b90Deg) return bRotate90Allowed;
     404                 :          0 :     return bRotateFreeAllowed;
     405                 :            : }
     406                 :            : 
     407                 :      12770 : sal_Bool SdrEditView::IsMirrorAllowed(sal_Bool b45Deg, sal_Bool b90Deg) const
     408                 :            : {
     409                 :      12770 :     ForcePossibilities();
     410         [ -  + ]:      12770 :     if (bMoveProtect) return sal_False;
     411         [ +  + ]:      12770 :     if (b90Deg) return bMirror90Allowed;
     412         [ -  + ]:       6385 :     if (b45Deg) return bMirror45Allowed;
     413 [ +  + ][ +  - ]:      12770 :     return bMirrorFreeAllowed && !bMoveProtect;
     414                 :            : }
     415                 :            : 
     416                 :       6385 : sal_Bool SdrEditView::IsTransparenceAllowed() const
     417                 :            : {
     418                 :       6385 :     ForcePossibilities();
     419                 :       6385 :     return bTransparenceAllowed;
     420                 :            : }
     421                 :            : 
     422                 :       6385 : sal_Bool SdrEditView::IsGradientAllowed() const
     423                 :            : {
     424                 :       6385 :     ForcePossibilities();
     425                 :       6385 :     return bGradientAllowed;
     426                 :            : }
     427                 :            : 
     428                 :          0 : sal_Bool SdrEditView::IsShearAllowed() const
     429                 :            : {
     430                 :          0 :     ForcePossibilities();
     431         [ #  # ]:          0 :     if (bResizeProtect) return sal_False;
     432                 :          0 :     return bShearAllowed;
     433                 :            : }
     434                 :            : 
     435                 :          0 : sal_Bool SdrEditView::IsEdgeRadiusAllowed() const
     436                 :            : {
     437                 :          0 :     ForcePossibilities();
     438                 :          0 :     return bEdgeRadiusAllowed;
     439                 :            : }
     440                 :            : 
     441                 :       6382 : sal_Bool SdrEditView::IsCrookAllowed(sal_Bool bNoContortion) const
     442                 :            : {
     443                 :            :     // CrookMode missing here (no rotations allowed when shearing ...)
     444                 :       6382 :     ForcePossibilities();
     445         [ -  + ]:       6382 :     if (bNoContortion) {
     446         [ #  # ]:          0 :         if (!bRotateFreeAllowed) return sal_False;
     447 [ #  # ][ #  # ]:          0 :         return !bMoveProtect && bMoveAllowed;
     448                 :            :     } else {
     449 [ +  - ][ -  + ]:       6382 :         return !bResizeProtect && bContortionPossible;
     450                 :            :     }
     451                 :            : }
     452                 :            : 
     453                 :          0 : sal_Bool SdrEditView::IsDistortAllowed(sal_Bool bNoContortion) const
     454                 :            : {
     455                 :          0 :     ForcePossibilities();
     456         [ #  # ]:          0 :     if (bNoContortion) {
     457                 :          0 :         return sal_False;
     458                 :            :     } else {
     459 [ #  # ][ #  # ]:          0 :         return !bResizeProtect && bContortionPossible;
     460                 :            :     }
     461                 :            : }
     462                 :            : 
     463                 :          0 : sal_Bool SdrEditView::IsCombinePossible(sal_Bool bNoPolyPoly) const
     464                 :            : {
     465                 :          0 :     ForcePossibilities();
     466         [ #  # ]:          0 :     if (bNoPolyPoly) return bCombineNoPolyPolyPossible;
     467                 :          0 :     else return bCombinePossible;
     468                 :            : }
     469                 :            : 
     470                 :          0 : sal_Bool SdrEditView::IsDismantlePossible(sal_Bool bMakeLines) const
     471                 :            : {
     472                 :          0 :     ForcePossibilities();
     473         [ #  # ]:          0 :     if (bMakeLines) return bDismantleMakeLinesPossible;
     474                 :          0 :     else return bDismantlePossible;
     475                 :            : }
     476                 :            : 
     477                 :       9573 : void SdrEditView::CheckPossibilities()
     478                 :            : {
     479         [ +  + ]:       9573 :     if (bSomeObjChgdFlag) bPossibilitiesDirty=sal_True;
     480                 :            : 
     481         [ +  + ]:       9573 :     if(bSomeObjChgdFlag)
     482                 :            :     {
     483                 :            :         // This call IS necessary to correct the MarkList, in which
     484                 :            :         // no longer to the model belonging objects still can reside.
     485                 :            :         // These ones need to be removed.
     486                 :       9269 :         CheckMarked();
     487                 :            :     }
     488                 :            : 
     489         [ +  - ]:       9573 :     if (bPossibilitiesDirty) {
     490                 :       9573 :         ImpResetPossibilityFlags();
     491                 :       9573 :         SortMarkedObjects();
     492                 :       9573 :         sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
     493         [ +  + ]:       9573 :         if (nMarkAnz!=0) {
     494                 :          2 :             bReverseOrderPossible=nMarkAnz>=2;
     495                 :            : 
     496                 :          2 :             sal_uIntPtr nMovableCount=0;
     497                 :          2 :             bGroupPossible=nMarkAnz>=2;
     498                 :          2 :             bCombinePossible=nMarkAnz>=2;
     499         [ +  - ]:          2 :             if (nMarkAnz==1) {
     500                 :            :                 // check bCombinePossible more thoroughly
     501                 :            :                 // still missing ...
     502                 :          2 :                 const SdrObject* pObj=GetMarkedObjectByIndex(0);
     503                 :            :                 //const SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj);
     504                 :          2 :                 sal_Bool bGroup=pObj->GetSubList()!=NULL;
     505                 :          2 :                 sal_Bool bHasText=pObj->GetOutlinerParaObject()!=NULL;
     506 [ -  + ][ +  - ]:          2 :                 if (bGroup || bHasText) {
     507                 :          0 :                     bCombinePossible=sal_True;
     508                 :            :                 }
     509                 :            :             }
     510                 :          2 :             bCombineNoPolyPolyPossible=bCombinePossible;
     511                 :          2 :             bDeletePossible=sal_True;
     512                 :            :             // accept transformations for now
     513                 :          2 :             bMoveAllowed      =sal_True;
     514                 :          2 :             bResizeFreeAllowed=sal_True;
     515                 :          2 :             bResizePropAllowed=sal_True;
     516                 :          2 :             bRotateFreeAllowed=sal_True;
     517                 :          2 :             bRotate90Allowed  =sal_True;
     518                 :          2 :             bMirrorFreeAllowed=sal_True;
     519                 :          2 :             bMirror45Allowed  =sal_True;
     520                 :          2 :             bMirror90Allowed  =sal_True;
     521                 :          2 :             bShearAllowed     =sal_True;
     522                 :          2 :             bEdgeRadiusAllowed=sal_False;
     523                 :          2 :             bContortionPossible=sal_True;
     524                 :          2 :             bCanConvToContour = sal_True;
     525                 :            : 
     526                 :            :             // these ones are only allowed when single object is selected
     527                 :          2 :             bTransparenceAllowed = (nMarkAnz == 1);
     528                 :          2 :             bGradientAllowed = (nMarkAnz == 1);
     529         [ +  - ]:          2 :             if(bGradientAllowed)
     530                 :            :             {
     531                 :            :                 // gradient depends on fill style
     532                 :          2 :                 const SdrMark* pM = GetSdrMarkByIndex(0);
     533                 :          2 :                 const SdrObject* pObj = pM->GetMarkedSdrObj();
     534                 :            : 
     535                 :            :                 // may be group object, so get merged ItemSet
     536                 :          2 :                 const SfxItemSet& rSet = pObj->GetMergedItemSet();
     537                 :          2 :                 SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, sal_False);
     538                 :            : 
     539         [ +  - ]:          2 :                 if(SFX_ITEM_DONTCARE != eState)
     540                 :            :                 {
     541                 :            :                     // If state is not DONTCARE, test the item
     542                 :          2 :                     XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
     543                 :            : 
     544         [ +  - ]:          2 :                     if(eFillStyle != XFILL_GRADIENT)
     545                 :            :                     {
     546                 :          2 :                         bGradientAllowed = sal_False;
     547                 :            :                     }
     548                 :            :                 }
     549                 :            :             }
     550                 :            : 
     551                 :          2 :             sal_Bool bNoMovRotFound=sal_False;
     552                 :          2 :             const SdrPageView* pPV0=NULL;
     553                 :            : 
     554         [ +  + ]:          4 :             for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++) {
     555         [ +  - ]:          2 :                 const SdrMark* pM=GetSdrMarkByIndex(nm);
     556         [ +  - ]:          2 :                 const SdrObject* pObj=pM->GetMarkedSdrObj();
     557                 :          2 :                 const SdrPageView* pPV=pM->GetPageView();
     558         [ +  - ]:          2 :                 if (pPV!=pPV0) {
     559 [ +  - ][ -  + ]:          2 :                     if (pPV->IsReadOnly()) bReadOnly=sal_True;
     560                 :          2 :                     pPV0=pPV;
     561                 :            :                 }
     562                 :            : 
     563         [ +  - ]:          2 :                 SdrObjTransformInfoRec aInfo;
     564         [ +  - ]:          2 :                 pObj->TakeObjInfo(aInfo);
     565         [ +  - ]:          2 :                 sal_Bool bMovPrt=pObj->IsMoveProtect();
     566         [ +  - ]:          2 :                 sal_Bool bSizPrt=pObj->IsResizeProtect();
     567 [ +  - ][ +  - ]:          2 :                 if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // count MovableObjs
     568         [ -  + ]:          2 :                 if (bMovPrt) bMoveProtect=sal_True;
     569         [ -  + ]:          2 :                 if (bSizPrt) bResizeProtect=sal_True;
     570                 :            : 
     571                 :            :                 // not allowed when not allowed at one object
     572         [ -  + ]:          2 :                 if(!aInfo.bTransparenceAllowed)
     573                 :          0 :                     bTransparenceAllowed = sal_False;
     574                 :            : 
     575                 :            :                 // If one of these can't do something, none can
     576         [ -  + ]:          2 :                 if (!aInfo.bMoveAllowed      ) bMoveAllowed      =sal_False;
     577         [ -  + ]:          2 :                 if (!aInfo.bResizeFreeAllowed) bResizeFreeAllowed=sal_False;
     578         [ -  + ]:          2 :                 if (!aInfo.bResizePropAllowed) bResizePropAllowed=sal_False;
     579         [ -  + ]:          2 :                 if (!aInfo.bRotateFreeAllowed) bRotateFreeAllowed=sal_False;
     580         [ -  + ]:          2 :                 if (!aInfo.bRotate90Allowed  ) bRotate90Allowed  =sal_False;
     581         [ -  + ]:          2 :                 if (!aInfo.bMirrorFreeAllowed) bMirrorFreeAllowed=sal_False;
     582         [ -  + ]:          2 :                 if (!aInfo.bMirror45Allowed  ) bMirror45Allowed  =sal_False;
     583         [ -  + ]:          2 :                 if (!aInfo.bMirror90Allowed  ) bMirror90Allowed  =sal_False;
     584         [ -  + ]:          2 :                 if (!aInfo.bShearAllowed     ) bShearAllowed     =sal_False;
     585         [ +  - ]:          2 :                 if (aInfo.bEdgeRadiusAllowed) bEdgeRadiusAllowed=sal_True;
     586         [ +  - ]:          2 :                 if (aInfo.bNoContortion      ) bContortionPossible=sal_False;
     587                 :            :                 // For Crook with Contortion: all objects have to be
     588                 :            :                 // Movable and Rotatable, except for a maximum of 1 of them
     589         [ +  - ]:          2 :                 if (!bMoreThanOneNoMovRot) {
     590 [ +  - ][ -  + ]:          2 :                     if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) {
     591                 :          0 :                         bMoreThanOneNoMovRot=bNoMovRotFound;
     592                 :          0 :                         bNoMovRotFound=sal_True;
     593                 :            :                     }
     594                 :            :                 }
     595                 :            : 
     596                 :            :                 // if one member cannot be converted, no conversion is possible
     597         [ -  + ]:          2 :                 if(!aInfo.bCanConvToContour)
     598                 :          0 :                     bCanConvToContour = sal_False;
     599                 :            : 
     600                 :            :                 // Ungroup
     601 [ +  - ][ +  - ]:          2 :                 if (!bUnGroupPossible) bUnGroupPossible=pObj->GetSubList()!=NULL;
     602                 :            :                 // ConvertToCurve: If at least one can be converted, that is fine.
     603         [ +  - ]:          2 :                 if (aInfo.bCanConvToPath          ) bCanConvToPath          =sal_True;
     604         [ +  - ]:          2 :                 if (aInfo.bCanConvToPoly          ) bCanConvToPoly          =sal_True;
     605         [ +  - ]:          2 :                 if (aInfo.bCanConvToPathLineToArea) bCanConvToPathLineToArea=sal_True;
     606         [ +  - ]:          2 :                 if (aInfo.bCanConvToPolyLineToArea) bCanConvToPolyLineToArea=sal_True;
     607                 :            : 
     608                 :            :                 // Combine/Dismantle
     609         [ -  + ]:          2 :                 if(bCombinePossible)
     610                 :            :                 {
     611         [ #  # ]:          0 :                     bCombinePossible = ImpCanConvertForCombine(pObj);
     612                 :          0 :                     bCombineNoPolyPolyPossible = bCombinePossible;
     613                 :            :                 }
     614                 :            : 
     615 [ +  - ][ +  - ]:          2 :                 if (!bDismantlePossible) bDismantlePossible = ImpCanDismantle(pObj, sal_False);
     616 [ +  - ][ +  - ]:          2 :                 if (!bDismantleMakeLinesPossible) bDismantleMakeLinesPossible = ImpCanDismantle(pObj, sal_True);
     617                 :            :                 // check OrthoDesiredOnMarked
     618 [ +  - ][ -  + ]:          2 :                 if (!bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) bOrthoDesiredOnMarked=sal_True;
     619                 :            :                 // check ImportMtf
     620                 :            : 
     621         [ +  - ]:          2 :                 if (!bImportMtfPossible) {
     622 [ +  - ][ +  - ]:          2 :                     sal_Bool bGraf=HAS_BASE(SdrGrafObj,pObj);
         [ +  - ][ -  + ]
     623 [ +  - ][ +  - ]:          2 :                     sal_Bool bOle2=HAS_BASE(SdrOle2Obj,pObj);
         [ +  - ][ -  + ]
     624                 :            : 
     625 [ -  + ][ #  # ]:          2 :                     if( bGraf &&
         [ #  # ][ -  + ]
     626         [ #  # ]:          0 :                         ((SdrGrafObj*)pObj)->HasGDIMetaFile() &&
     627 [ #  # ][ #  # ]:          0 :                         !( ((SdrGrafObj*)pObj)->IsEPS() || ((SdrGrafObj*)pObj)->IsRenderGraphic() ) )
                 [ #  # ]
     628                 :            :                     {
     629                 :          0 :                         bImportMtfPossible = sal_True;
     630                 :            :                     }
     631                 :            : 
     632         [ -  + ]:          2 :                     if (bOle2)
     633         [ #  # ]:          0 :                         bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is();
     634                 :            :                 }
     635                 :            :             }
     636                 :            : 
     637                 :          2 :             bMoreThanOneNotMovable=nMovableCount<nMarkAnz-1;
     638                 :          2 :             bOneOrMoreMovable=nMovableCount!=0;
     639                 :          2 :             bGrpEnterPossible=bUnGroupPossible;
     640                 :            :         }
     641                 :       9573 :         ImpCheckToTopBtmPossible();
     642                 :       9573 :         ((SdrPolyEditView*)this)->ImpCheckPolyPossibilities();
     643                 :       9573 :         bPossibilitiesDirty=sal_False;
     644                 :            : 
     645         [ -  + ]:       9573 :         if (bReadOnly) {
     646                 :          0 :             sal_Bool bMerker1=bGrpEnterPossible;
     647                 :          0 :             ImpResetPossibilityFlags();
     648                 :          0 :             bReadOnly=sal_True;
     649                 :          0 :             bGrpEnterPossible=bMerker1;
     650                 :            :         }
     651         [ +  + ]:       9573 :         if (bMoveAllowed) {
     652                 :            :             // Don't allow moving glued connectors.
     653                 :            :             // Currently only implemented for single selection.
     654         [ +  - ]:          2 :             if (nMarkAnz==1) {
     655                 :          2 :                 SdrObject* pObj=GetMarkedObjectByIndex(0);
     656 [ -  + ][ +  - ]:          2 :                 SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
     657         [ -  + ]:          2 :                 if (pEdge!=NULL) {
     658                 :          0 :                     SdrObject* pNode1=pEdge->GetConnectedNode(sal_True);
     659                 :          0 :                     SdrObject* pNode2=pEdge->GetConnectedNode(sal_False);
     660 [ #  # ][ #  # ]:          0 :                     if (pNode1!=NULL || pNode2!=NULL) bMoveAllowed=sal_False;
     661                 :            :                 }
     662                 :            :             }
     663                 :            :         }
     664                 :            :     }
     665                 :       9573 : }
     666                 :            : 
     667                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     668                 :            : 
     669                 :          0 : void SdrEditView::ForceMarkedObjToAnotherPage()
     670                 :            : {
     671                 :          0 :     sal_Bool bFlg=sal_False;
     672         [ #  # ]:          0 :     for (sal_uIntPtr nm=0; nm<GetMarkedObjectCount(); nm++) {
     673         [ #  # ]:          0 :         SdrMark* pM=GetSdrMarkByIndex(nm);
     674         [ #  # ]:          0 :         SdrObject* pObj=pM->GetMarkedSdrObj();
     675         [ #  # ]:          0 :         Rectangle aObjRect(pObj->GetCurrentBoundRect());
     676         [ #  # ]:          0 :         Rectangle aPgRect(pM->GetPageView()->GetPageRect());
     677 [ #  # ][ #  # ]:          0 :         if (!aObjRect.IsOver(aPgRect)) {
     678                 :          0 :             sal_Bool bFnd=sal_False;
     679                 :          0 :             SdrPageView* pPV = GetSdrPageView();
     680                 :            : 
     681         [ #  # ]:          0 :             if(pPV)
     682                 :            :             {
     683 [ #  # ][ #  # ]:          0 :                 bFnd = aObjRect.IsOver(pPV->GetPageRect());
     684                 :            :             }
     685                 :            : 
     686         [ #  # ]:          0 :             if(bFnd)
     687                 :            :             {
     688 [ #  # ][ #  # ]:          0 :                 pM->GetPageView()->GetObjList()->RemoveObject(pObj->GetOrdNum());
     689                 :          0 :                 SdrInsertReason aReason(SDRREASON_VIEWCALL);
     690         [ #  # ]:          0 :                 pPV->GetObjList()->InsertObject(pObj,CONTAINER_APPEND,&aReason);
     691                 :          0 :                 pM->SetPageView(pPV);
     692         [ #  # ]:          0 :                 InvalidateAllWin(aObjRect);
     693                 :          0 :                 bFlg=sal_True;
     694                 :            :             }
     695                 :            :         }
     696                 :            :     }
     697         [ #  # ]:          0 :     if (bFlg) {
     698                 :          0 :         MarkListHasChanged();
     699                 :            :     }
     700                 :          0 : }
     701                 :            : 
     702                 :         12 : void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark)
     703                 :            : {
     704         [ +  - ]:         12 :     if (rMark.GetMarkCount()!=0)
     705                 :            :     {
     706                 :         12 :         rMark.ForceSort();
     707                 :            : 
     708                 :         12 :         const bool bUndo = IsUndoEnabled();
     709         [ +  - ]:         12 :         if( bUndo )
     710                 :         12 :             BegUndo();
     711                 :         12 :         const sal_uInt32 nMarkAnz(rMark.GetMarkCount());
     712                 :            : 
     713         [ +  - ]:         12 :         if(nMarkAnz)
     714                 :            :         {
     715                 :         12 :             sal_uInt32 nm(0);
     716         [ +  - ]:         12 :             std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
     717                 :            : 
     718         [ +  - ]:         12 :             if( bUndo )
     719                 :            :             {
     720         [ +  + ]:         52 :                 for(nm = nMarkAnz; nm > 0;)
     721                 :            :                 {
     722                 :         40 :                     nm--;
     723         [ +  - ]:         40 :                     SdrMark* pM = rMark.GetMark(nm);
     724         [ +  - ]:         40 :                     SdrObject* pObj = pM->GetMarkedSdrObj();
     725                 :            : 
     726                 :            :                     // extra undo actions for changed connector which now may hold its layed out path (SJ)
     727         [ +  - ]:         40 :                     std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) );
     728         [ +  - ]:         40 :                     AddUndoActions( vConnectorUndoActions );
     729                 :            : 
     730 [ +  - ][ +  - ]:         40 :                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
                 [ +  - ]
     731                 :         40 :                 }
     732                 :            :             }
     733                 :            : 
     734                 :            :             // make sure, OrderNums are correct:
     735 [ +  - ][ +  - ]:         12 :             rMark.GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
                 [ +  - ]
     736                 :            : 
     737         [ +  - ]:         12 :             std::vector< SdrObject* > aRemoved3DObjects;
     738                 :            : 
     739         [ +  + ]:         52 :             for(nm = nMarkAnz; nm > 0;)
     740                 :            :             {
     741                 :         40 :                 nm--;
     742         [ +  - ]:         40 :                 SdrMark* pM = rMark.GetMark(nm);
     743         [ +  - ]:         40 :                 SdrObject* pObj = pM->GetMarkedSdrObj();
     744         [ +  - ]:         40 :                 SdrObjList*  pOL = pObj->GetObjList();
     745         [ +  - ]:         40 :                 const sal_uInt32 nOrdNum(pObj->GetOrdNumDirect());
     746                 :            : 
     747 [ +  - ][ -  + ]:         40 :                 bool bIs3D = dynamic_cast< E3dObject* >(pObj);
     748                 :            :                 // set up a scene updater if object is a 3d object
     749         [ -  + ]:         40 :                 if(bIs3D)
     750                 :            :                 {
     751 [ #  # ][ #  # ]:          0 :                     aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
                 [ #  # ]
     752                 :            :                 }
     753                 :            : 
     754         [ +  - ]:         40 :                 pOL->RemoveObject(nOrdNum);
     755                 :            : 
     756         [ -  + ]:         40 :                 if( !bUndo )
     757                 :            :                 {
     758         [ #  # ]:          0 :                     if( bIs3D )
     759         [ #  # ]:          0 :                         aRemoved3DObjects.push_back( pObj ); // may be needed later
     760                 :            :                     else
     761         [ #  # ]:         40 :                         SdrObject::Free(pObj);
     762                 :            :                 }
     763                 :            :             }
     764                 :            : 
     765                 :            :             // fire scene updaters
     766         [ -  + ]:         12 :             while(!aUpdaters.empty())
     767                 :            :             {
     768 [ #  # ][ #  # ]:          0 :                 delete aUpdaters.back();
                 [ #  # ]
     769         [ #  # ]:          0 :                 aUpdaters.pop_back();
     770                 :            :             }
     771                 :            : 
     772         [ -  + ]:         12 :             if( !bUndo )
     773                 :            :             {
     774                 :            :                 // now delete removed scene objects
     775         [ #  # ]:          0 :                 while(!aRemoved3DObjects.empty())
     776                 :            :                 {
     777 [ #  # ][ #  # ]:          0 :                     SdrObject::Free( aRemoved3DObjects.back() );
     778         [ #  # ]:          0 :                     aRemoved3DObjects.pop_back();
     779                 :            :                 }
     780                 :         12 :             }
     781                 :            :         }
     782                 :            : 
     783         [ +  - ]:         12 :         if( bUndo )
     784                 :         12 :             EndUndo();
     785                 :            :     }
     786                 :         12 : }
     787                 :            : 
     788                 :          0 : void SdrEditView::DeleteMarkedObj()
     789                 :            : {
     790                 :            :     // #i110981# return when nothing is to be done at all
     791         [ #  # ]:          0 :     if(!GetMarkedObjectCount())
     792                 :            :     {
     793                 :          0 :         return;
     794                 :            :     }
     795                 :            : 
     796                 :            :     // moved breaking action and undo start outside loop
     797                 :          0 :     BrkAction();
     798 [ #  # ][ #  # ]:          0 :     BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_DELETE);
                 [ #  # ]
     799                 :            : 
     800                 :            :     // remove as long as something is selected. This allows to schedule objects for
     801                 :            :     // removal for a next run as needed
     802         [ #  # ]:          0 :     while(GetMarkedObjectCount())
     803                 :            :     {
     804                 :            :         // vector to remember the parents which may be empty after object removal
     805         [ #  # ]:          0 :         std::vector< SdrObject* > aParents;
     806                 :            : 
     807                 :            :         {
     808                 :          0 :             const SdrMarkList& rMarkList = GetMarkedObjectList();
     809                 :          0 :             const sal_uInt32 nCount(rMarkList.GetMarkCount());
     810                 :          0 :             sal_uInt32 a(0);
     811                 :            : 
     812         [ #  # ]:          0 :             for(a = 0; a < nCount; a++)
     813                 :            :             {
     814                 :            :                 // in the first run, add all found parents, but only once
     815         [ #  # ]:          0 :                 SdrMark* pMark = rMarkList.GetMark(a);
     816         [ #  # ]:          0 :                 SdrObject* pObject = pMark->GetMarkedSdrObj();
     817         [ #  # ]:          0 :                 SdrObject* pParent = pObject->GetObjList()->GetOwnerObj();
     818                 :            : 
     819         [ #  # ]:          0 :                 if(pParent)
     820                 :            :                 {
     821         [ #  # ]:          0 :                     if(!aParents.empty())
     822                 :            :                     {
     823                 :            :                         std::vector< SdrObject* >::iterator aFindResult =
     824         [ #  # ]:          0 :                             std::find(aParents.begin(), aParents.end(), pParent);
     825                 :            : 
     826 [ #  # ][ #  # ]:          0 :                         if(aFindResult == aParents.end())
     827                 :            :                         {
     828         [ #  # ]:          0 :                             aParents.push_back(pParent);
     829                 :            :                         }
     830                 :            :                     }
     831                 :            :                     else
     832                 :            :                     {
     833         [ #  # ]:          0 :                         aParents.push_back(pParent);
     834                 :            :                     }
     835                 :            :                 }
     836                 :            :             }
     837                 :            : 
     838         [ #  # ]:          0 :             if(!aParents.empty())
     839                 :            :             {
     840                 :            :                 // in a 2nd run, remove all objects which may already be scheduled for
     841                 :            :                 // removal. I am not sure if this can happen, but theoretically
     842                 :            :                 // a to-be-removed object may already be the group/3DScene itself
     843         [ #  # ]:          0 :                 for(a = 0; a < nCount; a++)
     844                 :            :                 {
     845         [ #  # ]:          0 :                     SdrMark* pMark = rMarkList.GetMark(a);
     846         [ #  # ]:          0 :                     SdrObject* pObject = pMark->GetMarkedSdrObj();
     847                 :            : 
     848                 :            :                     std::vector< SdrObject* >::iterator aFindResult =
     849         [ #  # ]:          0 :                         std::find(aParents.begin(), aParents.end(), pObject);
     850                 :            : 
     851 [ #  # ][ #  # ]:          0 :                     if(aFindResult != aParents.end())
     852                 :            :                     {
     853         [ #  # ]:          0 :                         aParents.erase(aFindResult);
     854                 :            :                     }
     855                 :            :                 }
     856                 :            :             }
     857                 :            :         }
     858                 :            : 
     859                 :            :         // original stuff: remove selected objects. Handle clear will
     860                 :            :         // do something only once
     861         [ #  # ]:          0 :         DeleteMarkedList(GetMarkedObjectList());
     862         [ #  # ]:          0 :         GetMarkedObjectListWriteAccess().Clear();
     863         [ #  # ]:          0 :         aHdl.Clear();
     864                 :            : 
     865 [ #  # ][ #  # ]:          0 :         while(aParents.size() && !GetMarkedObjectCount())
                 [ #  # ]
     866                 :            :         {
     867                 :            :             // iterate over remembered parents
     868         [ #  # ]:          0 :             SdrObject* pParent = aParents.back();
     869         [ #  # ]:          0 :             aParents.pop_back();
     870                 :            : 
     871 [ #  # ][ #  # ]:          0 :             if(pParent->GetSubList() && 0 == pParent->GetSubList()->GetObjCount())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     872                 :            :             {
     873                 :            :                 // we detected an empty parent, a candidate to leave group/3DScene
     874                 :            :                 // if entered
     875   [ #  #  #  # ]:          0 :                 if(GetSdrPageView()->GetAktGroup()
                 [ #  # ]
     876                 :          0 :                     && GetSdrPageView()->GetAktGroup() == pParent)
     877                 :            :                 {
     878         [ #  # ]:          0 :                     GetSdrPageView()->LeaveOneGroup();
     879                 :            :                 }
     880                 :            : 
     881                 :            :                 // schedule empty parent for removal
     882                 :          0 :                 GetMarkedObjectListWriteAccess().InsertEntry(
     883   [ #  #  #  # ]:          0 :                     SdrMark(pParent, GetSdrPageView()));
                 [ #  # ]
     884                 :            :             }
     885                 :            :         }
     886                 :          0 :     }
     887                 :            : 
     888                 :            :     // end undo and change messaging moved at the end
     889                 :          0 :     EndUndo();
     890                 :          0 :     MarkListHasChanged();
     891                 :            : }
     892                 :            : 
     893                 :          0 : void SdrEditView::CopyMarkedObj()
     894                 :            : {
     895         [ #  # ]:          0 :     SortMarkedObjects();
     896                 :            : 
     897         [ #  # ]:          0 :     SdrMarkList aSourceObjectsForCopy(GetMarkedObjectList());
     898                 :            :     // The following loop is used instead of MarkList::Merge(), to be
     899                 :            :     // able to flag the MarkEntries.
     900         [ #  # ]:          0 :     sal_uIntPtr nEdgeAnz = GetEdgesOfMarkedNodes().GetMarkCount();
     901         [ #  # ]:          0 :     for (sal_uIntPtr nEdgeNum=0; nEdgeNum<nEdgeAnz; nEdgeNum++) {
     902 [ #  # ][ #  # ]:          0 :         SdrMark aM(*GetEdgesOfMarkedNodes().GetMark(nEdgeNum));
                 [ #  # ]
     903                 :          0 :         aM.SetUser(1);
     904         [ #  # ]:          0 :         aSourceObjectsForCopy.InsertEntry(aM);
     905         [ #  # ]:          0 :     }
     906         [ #  # ]:          0 :     aSourceObjectsForCopy.ForceSort();
     907                 :            : 
     908                 :            :     // #i13033#
     909                 :            :     // New mechanism to re-create the connections of cloned connectors
     910         [ #  # ]:          0 :     CloneList aCloneList;
     911                 :            : 
     912         [ #  # ]:          0 :     const bool bUndo = IsUndoEnabled();
     913                 :            : 
     914         [ #  # ]:          0 :     GetMarkedObjectListWriteAccess().Clear();
     915                 :          0 :     sal_uIntPtr nCloneErrCnt=0;
     916                 :          0 :     sal_uIntPtr nMarkAnz=aSourceObjectsForCopy.GetMarkCount();
     917                 :            :     sal_uIntPtr nm;
     918         [ #  # ]:          0 :     for (nm=0; nm<nMarkAnz; nm++) {
     919         [ #  # ]:          0 :         SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
     920 [ #  # ][ #  # ]:          0 :         SdrObject* pO=pM->GetMarkedSdrObj()->Clone();
     921         [ #  # ]:          0 :         if (pO!=NULL) {
     922                 :          0 :             SdrInsertReason aReason(SDRREASON_VIEWCALL);
     923         [ #  # ]:          0 :             pM->GetPageView()->GetObjList()->InsertObject(pO,CONTAINER_APPEND,&aReason);
     924                 :            : 
     925         [ #  # ]:          0 :             if( bUndo )
     926 [ #  # ][ #  # ]:          0 :                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO));
                 [ #  # ]
     927                 :            : 
     928         [ #  # ]:          0 :             SdrMark aME(*pM);
     929         [ #  # ]:          0 :             aME.SetMarkedSdrObj(pO);
     930 [ #  # ][ #  # ]:          0 :             aCloneList.AddPair(pM->GetMarkedSdrObj(), pO);
     931                 :            : 
     932         [ #  # ]:          0 :             if (pM->GetUser()==0)
     933                 :            :             {
     934                 :            :                 // otherwise it is only an Edge we have to copy as well
     935         [ #  # ]:          0 :                 GetMarkedObjectListWriteAccess().InsertEntry(aME);
     936         [ #  # ]:          0 :             }
     937                 :            :         } else {
     938                 :          0 :             nCloneErrCnt++;
     939                 :            :         }
     940                 :            :     }
     941                 :            : 
     942                 :            :     // #i13033#
     943                 :            :     // New mechanism to re-create the connections of cloned connectors
     944         [ #  # ]:          0 :     aCloneList.CopyConnections();
     945                 :            : 
     946                 :            :     if(0L != nCloneErrCnt)
     947                 :            :     {
     948                 :            : #ifdef DBG_UTIL
     949                 :            :         rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
     950                 :            :             "SdrEditView::CopyMarkedObj(): Error when cloning "));
     951                 :            : 
     952                 :            :         if(nCloneErrCnt == 1)
     953                 :            :         {
     954                 :            :             aStr.append(RTL_CONSTASCII_STRINGPARAM("a drawing object."));
     955                 :            :         }
     956                 :            :         else
     957                 :            :         {
     958                 :            :             aStr.append(static_cast<sal_Int32>(nCloneErrCnt));
     959                 :            :             aStr.append(RTL_CONSTASCII_STRINGPARAM(" drawing objects."));
     960                 :            :         }
     961                 :            : 
     962                 :            :         aStr.append(RTL_CONSTASCII_STRINGPARAM(
     963                 :            :             " This object's/These objects's connections will not be copied."));
     964                 :            :         OSL_FAIL(aStr.getStr());
     965                 :            : #endif
     966                 :            :     }
     967 [ #  # ][ #  # ]:          0 :     MarkListHasChanged();
     968                 :          0 : }
     969                 :            : 
     970                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     971                 :            : 
     972                 :          0 : sal_Bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, sal_uIntPtr nOptions)
     973                 :            : {
     974         [ #  # ]:          0 :     if ((nOptions & SDRINSERT_SETDEFLAYER)!=0) {
     975                 :          0 :         SdrLayerID nLayer=rPV.GetPage()->GetLayerAdmin().GetLayerID(aAktLayer,sal_True);
     976         [ #  # ]:          0 :         if (nLayer==SDRLAYER_NOTFOUND) nLayer=0;
     977 [ #  # ][ #  # ]:          0 :         if (rPV.GetLockedLayers().IsSet(nLayer) || !rPV.GetVisibleLayers().IsSet(nLayer)) {
                 [ #  # ]
     978                 :          0 :             SdrObject::Free( pObj ); // Layer locked or invisible
     979                 :          0 :             return sal_False;
     980                 :            :         }
     981                 :          0 :         pObj->NbcSetLayer(nLayer);
     982                 :            :     }
     983         [ #  # ]:          0 :     if ((nOptions & SDRINSERT_SETDEFATTR)!=0) {
     984         [ #  # ]:          0 :         if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
     985                 :          0 :         pObj->SetMergedItemSet(aDefaultAttr);
     986                 :            :     }
     987         [ #  # ]:          0 :     if (!pObj->IsInserted()) {
     988                 :          0 :         SdrInsertReason aReason(SDRREASON_VIEWCALL);
     989         [ #  # ]:          0 :         if ((nOptions & SDRINSERT_NOBROADCAST)!=0) {
     990         [ #  # ]:          0 :             rPV.GetObjList()->NbcInsertObject(pObj,CONTAINER_APPEND,&aReason);
     991                 :            :         } else {
     992         [ #  # ]:          0 :             rPV.GetObjList()->InsertObject(pObj,CONTAINER_APPEND,&aReason);
     993                 :            :         }
     994                 :            :     }
     995         [ #  # ]:          0 :     if( IsUndoEnabled() )
     996                 :          0 :         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
     997                 :            : 
     998         [ #  # ]:          0 :     if ((nOptions & SDRINSERT_DONTMARK)==0) {
     999         [ #  # ]:          0 :         if ((nOptions & SDRINSERT_ADDMARK)==0) UnmarkAllObj();
    1000                 :          0 :         MarkObj(pObj,&rPV);
    1001                 :            :     }
    1002                 :          0 :     return sal_True;
    1003                 :            : }
    1004                 :            : 
    1005                 :          0 : void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, sal_Bool bMark)
    1006                 :            : {
    1007                 :          0 :     SdrObjList* pOL=pOldObj->GetObjList();
    1008                 :          0 :     const bool bUndo = IsUndoEnabled();
    1009         [ #  # ]:          0 :     if( bUndo  )
    1010                 :          0 :         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj));
    1011                 :            : 
    1012         [ #  # ]:          0 :     if( IsObjMarked( pOldObj ) )
    1013                 :          0 :         MarkObj( pOldObj, &rPV, sal_True /*unmark!*/ );
    1014                 :            : 
    1015                 :          0 :     pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum());
    1016                 :            : 
    1017         [ #  # ]:          0 :     if( !bUndo )
    1018                 :          0 :         SdrObject::Free( pOldObj );
    1019                 :            : 
    1020         [ #  # ]:          0 :     if (bMark) MarkObj(pNewObj,&rPV);
    1021                 :          0 : }
    1022                 :            : 
    1023                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1024                 :            : 
    1025                 :        108 : bool SdrEditView::IsUndoEnabled() const
    1026                 :            : {
    1027                 :        108 :     return pMod->IsUndoEnabled();
    1028                 :            : }
    1029                 :            : 
    1030                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10