LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdpoev.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 371 5.4 %
Date: 2012-08-25 Functions: 5 27 18.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 586 0.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 <svx/svdpoev.hxx>
      31                 :            : #include <math.h>
      32                 :            : #include <svx/svdpagv.hxx>
      33                 :            : #include <svx/svdpage.hxx>
      34                 :            : #include <svx/svdopath.hxx>
      35                 :            : #include <svx/svdundo.hxx>
      36                 :            : #include "svx/svdstr.hrc"   // names taken from the resource
      37                 :            : #include "svx/svdglob.hxx"  // StringCache
      38                 :            : #include <svx/svdtrans.hxx>
      39                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      40                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      41                 :            : #include <tools/helpers.hxx>
      42                 :            : 
      43                 :            : #include <svx/polypolygoneditor.hxx>
      44                 :            : 
      45                 :            : using namespace sdr;
      46                 :            : 
      47                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      48                 :            : 
      49                 :      14272 : void SdrPolyEditView::ImpResetPolyPossibilityFlags()
      50                 :            : {
      51                 :      14272 :     eMarkedPointsSmooth=SDRPATHSMOOTH_DONTCARE;
      52                 :      14272 :     eMarkedSegmentsKind=SDRPATHSEGMENT_DONTCARE;
      53                 :      14272 :     bSetMarkedPointsSmoothPossible=sal_False;
      54                 :      14272 :     bSetMarkedSegmentsKindPossible=sal_False;
      55                 :      14272 : }
      56                 :            : 
      57                 :       4699 : void SdrPolyEditView::ImpClearVars()
      58                 :            : {
      59                 :       4699 :     ImpResetPolyPossibilityFlags();
      60                 :       4699 : }
      61                 :            : 
      62                 :       4699 : SdrPolyEditView::SdrPolyEditView(SdrModel* pModel1, OutputDevice* pOut):
      63                 :       4699 :     SdrEditView(pModel1,pOut)
      64                 :            : {
      65                 :       4699 :     ImpClearVars();
      66                 :       4699 : }
      67                 :            : 
      68                 :       4508 : SdrPolyEditView::~SdrPolyEditView()
      69                 :            : {
      70         [ -  + ]:       4508 : }
      71                 :            : 
      72                 :       9573 : void SdrPolyEditView::ImpCheckPolyPossibilities()
      73                 :            : {
      74                 :       9573 :     ImpResetPolyPossibilityFlags();
      75                 :       9573 :     const sal_uIntPtr nMarkAnz(GetMarkedObjectCount());
      76                 :            : 
      77 [ -  + ][ -  + ]:       9573 :     if(nMarkAnz && !ImpIsFrameHandles())
                 [ +  + ]
      78                 :            :     {
      79                 :          0 :         bool b1stSmooth(true);
      80                 :          0 :         bool b1stSegm(true);
      81                 :          0 :         bool bCurve(false);
      82                 :          0 :         bool bSmoothFuz(false);
      83                 :          0 :         bool bSegmFuz(false);
      84                 :          0 :         basegfx::B2VectorContinuity eSmooth = basegfx::CONTINUITY_NONE;
      85                 :            : 
      86         [ #  # ]:          0 :         for(sal_uIntPtr nMarkNum(0L); nMarkNum < nMarkAnz; nMarkNum++)
      87                 :            :         {
      88         [ #  # ]:          0 :             SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
      89         [ #  # ]:          0 :             CheckPolyPossibilitiesHelper( pM, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
      90                 :            :         }
      91                 :            :     }
      92                 :       9573 : }
      93                 :            : 
      94                 :          0 : void SdrPolyEditView::CheckPolyPossibilitiesHelper( SdrMark* pM, bool& b1stSmooth, bool& b1stSegm, bool& bCurve, bool& bSmoothFuz, bool& bSegmFuz, basegfx::B2VectorContinuity& eSmooth )
      95                 :            : {
      96                 :          0 :     SdrObject* pObj = pM->GetMarkedSdrObj();
      97                 :          0 :     SdrUShortCont* pPts = pM->GetMarkedPoints();
      98 [ #  # ][ #  # ]:          0 :     SdrPathObj* pPath = PTR_CAST(SdrPathObj,pObj);
      99                 :            : 
     100 [ #  # ][ #  # ]:          0 :     if(pPath && pPts)
     101                 :            :     {
     102                 :          0 :         const sal_uInt32 nMarkedPntAnz(pPts->size());
     103                 :            : 
     104         [ #  # ]:          0 :         if(nMarkedPntAnz)
     105                 :            :         {
     106                 :          0 :             bool bClosed(pPath->IsClosed());
     107                 :          0 :             bSetMarkedPointsSmoothPossible = true;
     108                 :            : 
     109         [ #  # ]:          0 :             if(bClosed)
     110                 :            :             {
     111                 :          0 :                 bSetMarkedSegmentsKindPossible = true;
     112                 :            :             }
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :             for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
                 [ #  # ]
     115                 :            :             {
     116         [ #  # ]:          0 :                 sal_uInt32 nNum(*it);
     117                 :            :                 sal_uInt32 nPolyNum, nPntNum;
     118                 :            : 
     119 [ #  # ][ #  # ]:          0 :                 if(PolyPolygonEditor::GetRelativePolyPoint(pPath->GetPathPoly(), nNum, nPolyNum, nPntNum))
     120                 :            :                 {
     121         [ #  # ]:          0 :                     const basegfx::B2DPolygon aLocalPolygon(pPath->GetPathPoly().getB2DPolygon(nPolyNum));
     122 [ #  # ][ #  # ]:          0 :                     bool bCanSegment(bClosed || nPntNum < aLocalPolygon.count() - 1L);
                 [ #  # ]
     123                 :            : 
     124 [ #  # ][ #  # ]:          0 :                     if(!bSetMarkedSegmentsKindPossible && bCanSegment)
     125                 :            :                     {
     126                 :          0 :                         bSetMarkedSegmentsKindPossible = true;
     127                 :            :                     }
     128                 :            : 
     129         [ #  # ]:          0 :                     if(!bSmoothFuz)
     130                 :            :                     {
     131         [ #  # ]:          0 :                         if (b1stSmooth)
     132                 :            :                         {
     133                 :          0 :                             b1stSmooth = false;
     134         [ #  # ]:          0 :                             eSmooth = basegfx::tools::getContinuityInPoint(aLocalPolygon, nPntNum);
     135                 :            :                         }
     136                 :            :                         else
     137                 :            :                         {
     138         [ #  # ]:          0 :                             bSmoothFuz = (eSmooth != basegfx::tools::getContinuityInPoint(aLocalPolygon, nPntNum));
     139                 :            :                         }
     140                 :            :                     }
     141                 :            : 
     142         [ #  # ]:          0 :                     if(!bSegmFuz)
     143                 :            :                     {
     144         [ #  # ]:          0 :                         if(bCanSegment)
     145                 :            :                         {
     146         [ #  # ]:          0 :                             bool bCrv(aLocalPolygon.isNextControlPointUsed(nPntNum));
     147                 :            : 
     148         [ #  # ]:          0 :                             if(b1stSegm)
     149                 :            :                             {
     150                 :          0 :                                 b1stSegm = false;
     151                 :          0 :                                 bCurve = bCrv;
     152                 :            :                             }
     153                 :            :                             else
     154                 :            :                             {
     155                 :          0 :                                 bSegmFuz = (bCrv != bCurve);
     156                 :            :                             }
     157                 :            :                         }
     158         [ #  # ]:          0 :                     }
     159                 :            :                 }
     160                 :            :             }
     161                 :            : 
     162 [ #  # ][ #  # ]:          0 :             if(!b1stSmooth && !bSmoothFuz)
     163                 :            :             {
     164         [ #  # ]:          0 :                 if(basegfx::CONTINUITY_NONE == eSmooth)
     165                 :            :                 {
     166                 :          0 :                     eMarkedPointsSmooth = SDRPATHSMOOTH_ANGULAR;
     167                 :            :                 }
     168                 :            : 
     169         [ #  # ]:          0 :                 if(basegfx::CONTINUITY_C1 == eSmooth)
     170                 :            :                 {
     171                 :          0 :                     eMarkedPointsSmooth = SDRPATHSMOOTH_ASYMMETRIC;
     172                 :            :                 }
     173                 :            : 
     174         [ #  # ]:          0 :                 if(basegfx::CONTINUITY_C2 == eSmooth)
     175                 :            :                 {
     176                 :          0 :                     eMarkedPointsSmooth = SDRPATHSMOOTH_SYMMETRIC;
     177                 :            :                 }
     178                 :            :             }
     179                 :            : 
     180 [ #  # ][ #  # ]:          0 :             if(!b1stSegm && !bSegmFuz)
     181                 :            :             {
     182         [ #  # ]:          0 :                 eMarkedSegmentsKind = (bCurve) ? SDRPATHSEGMENT_CURVE : SDRPATHSEGMENT_LINE;
     183                 :            :             }
     184                 :            :         }
     185                 :            :     }
     186                 :          0 : }
     187                 :            : 
     188                 :          0 : void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
     189                 :            : {
     190                 :            :     basegfx::B2VectorContinuity eFlags;
     191                 :            : 
     192         [ #  # ]:          0 :     if(SDRPATHSMOOTH_ANGULAR == eKind)
     193                 :            :     {
     194                 :          0 :         eFlags = basegfx::CONTINUITY_NONE;
     195                 :            :     }
     196         [ #  # ]:          0 :     else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
     197                 :            :     {
     198                 :          0 :         eFlags = basegfx::CONTINUITY_C1;
     199                 :            :     }
     200         [ #  # ]:          0 :     else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
     201                 :            :     {
     202                 :          0 :         eFlags = basegfx::CONTINUITY_C2;
     203                 :            :     }
     204                 :            :     else
     205                 :            :     {
     206                 :          0 :         return;
     207                 :            :     }
     208                 :            : 
     209         [ #  # ]:          0 :     if(HasMarkedPoints())
     210                 :            :     {
     211                 :          0 :         SortMarkedObjects();
     212                 :            : 
     213                 :          0 :         const bool bUndo = IsUndoEnabled();
     214         [ #  # ]:          0 :         if( bUndo )
     215 [ #  # ][ #  # ]:          0 :             BegUndo(ImpGetResStr(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints());
                 [ #  # ]
     216                 :          0 :         sal_uIntPtr nMarkAnz(GetMarkedObjectCount());
     217                 :            : 
     218         [ #  # ]:          0 :         for(sal_uIntPtr nMarkNum(nMarkAnz); nMarkNum > 0L;)
     219                 :            :         {
     220                 :          0 :             nMarkNum--;
     221                 :          0 :             SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
     222                 :          0 :             SdrUShortCont* pPts = pM->GetMarkedPoints();
     223         [ #  # ]:          0 :             SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
     224                 :            : 
     225 [ #  # ][ #  # ]:          0 :             if(pPts && pPath)
     226                 :            :             {
     227         [ #  # ]:          0 :                 PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
     228 [ #  # ][ #  # ]:          0 :                 if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
     229                 :            :                 {
     230         [ #  # ]:          0 :                     if( bUndo )
     231 [ #  # ][ #  # ]:          0 :                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
                 [ #  # ]
     232         [ #  # ]:          0 :                     pPath->SetPathPoly(aEditor.GetPolyPolygon());
     233         [ #  # ]:          0 :                 }
     234                 :            :             }
     235                 :            :         }
     236                 :            : 
     237         [ #  # ]:          0 :         if( bUndo )
     238                 :          0 :             EndUndo();
     239                 :            :     }
     240                 :            : }
     241                 :            : 
     242                 :          0 : void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
     243                 :            : {
     244         [ #  # ]:          0 :     if(HasMarkedPoints())
     245                 :            :     {
     246                 :          0 :         SortMarkedObjects();
     247                 :            : 
     248                 :          0 :         const bool bUndo = IsUndoEnabled();
     249         [ #  # ]:          0 :         if( bUndo )
     250 [ #  # ][ #  # ]:          0 :             BegUndo(ImpGetResStr(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints());
                 [ #  # ]
     251                 :          0 :         sal_uIntPtr nMarkAnz(GetMarkedObjectCount());
     252                 :            : 
     253         [ #  # ]:          0 :         for(sal_uIntPtr nMarkNum(nMarkAnz); nMarkNum > 0L;)
     254                 :            :         {
     255                 :          0 :             nMarkNum--;
     256                 :          0 :             SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
     257                 :          0 :             SdrUShortCont* pPts = pM->GetMarkedPoints();
     258         [ #  # ]:          0 :             SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
     259                 :            : 
     260 [ #  # ][ #  # ]:          0 :             if(pPts && pPath)
     261                 :            :             {
     262         [ #  # ]:          0 :                 PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
     263 [ #  # ][ #  # ]:          0 :                 if(aEditor.SetSegmentsKind( eKind, *pPts ) )
     264                 :            :                 {
     265         [ #  # ]:          0 :                     if( bUndo )
     266 [ #  # ][ #  # ]:          0 :                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
                 [ #  # ]
     267         [ #  # ]:          0 :                     pPath->SetPathPoly(aEditor.GetPolyPolygon());
     268         [ #  # ]:          0 :                 }
     269                 :            :             }
     270                 :            :         }
     271                 :            : 
     272         [ #  # ]:          0 :         if( bUndo )
     273                 :          0 :             EndUndo();
     274                 :            :     }
     275                 :          0 : }
     276                 :            : 
     277                 :          0 : sal_Bool SdrPolyEditView::IsSetMarkedPointsSmoothPossible() const
     278                 :            : {
     279                 :          0 :     ForcePossibilities();
     280                 :          0 :     return bSetMarkedPointsSmoothPossible;
     281                 :            : }
     282                 :            : 
     283                 :          0 : SdrPathSmoothKind SdrPolyEditView::GetMarkedPointsSmooth() const
     284                 :            : {
     285                 :          0 :     ForcePossibilities();
     286                 :          0 :     return eMarkedPointsSmooth;
     287                 :            : }
     288                 :            : 
     289                 :          0 : sal_Bool SdrPolyEditView::IsSetMarkedSegmentsKindPossible() const
     290                 :            : {
     291                 :          0 :     ForcePossibilities();
     292                 :          0 :     return bSetMarkedSegmentsKindPossible;
     293                 :            : }
     294                 :            : 
     295                 :          0 : SdrPathSegmentKind SdrPolyEditView::GetMarkedSegmentsKind() const
     296                 :            : {
     297                 :          0 :     ForcePossibilities();
     298                 :          0 :     return eMarkedSegmentsKind;
     299                 :            : }
     300                 :            : 
     301                 :          0 : sal_Bool SdrPolyEditView::IsDeleteMarkedPointsPossible() const
     302                 :            : {
     303                 :          0 :     return HasMarkedPoints();
     304                 :            : }
     305                 :            : 
     306                 :          0 : void SdrPolyEditView::DeleteMarkedPoints()
     307                 :            : {
     308         [ #  # ]:          0 :     if (HasMarkedPoints())
     309                 :            :     {
     310                 :          0 :         BrkAction();
     311                 :          0 :         SortMarkedObjects();
     312                 :          0 :         sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
     313                 :            : 
     314                 :          0 :         const bool bUndo = IsUndoEnabled();
     315         [ #  # ]:          0 :         if( bUndo )
     316                 :            :         {
     317                 :            :             // Description
     318 [ #  # ][ #  # ]:          0 :             BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_DELETE);
                 [ #  # ]
     319                 :            :         }
     320                 :            : 
     321         [ #  # ]:          0 :         for (sal_uIntPtr nMarkNum=nMarkAnz; nMarkNum>0;)
     322                 :            :         {
     323                 :          0 :             nMarkNum--;
     324                 :          0 :             SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
     325                 :          0 :             SdrUShortCont* pPts=pM->GetMarkedPoints();
     326         [ #  # ]:          0 :             SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
     327                 :            : 
     328 [ #  # ][ #  # ]:          0 :             if( pPath && pPts )
     329                 :            :             {
     330         [ #  # ]:          0 :                 PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
     331 [ #  # ][ #  # ]:          0 :                 if( aEditor.DeletePoints( *pPts ) )
     332                 :            :                 {
     333 [ #  # ][ #  # ]:          0 :                     if( aEditor.GetPolyPolygon().count() )
     334                 :            :                     {
     335         [ #  # ]:          0 :                         if( bUndo )
     336 [ #  # ][ #  # ]:          0 :                             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath ));
                 [ #  # ]
     337         [ #  # ]:          0 :                         pPath->SetPathPoly( aEditor.GetPolyPolygon() );
     338                 :            :                     }
     339                 :            :                     else
     340                 :            :                     {
     341         [ #  # ]:          0 :                         if( bUndo )
     342 [ #  # ][ #  # ]:          0 :                             AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) );
                 [ #  # ]
     343 [ #  # ][ #  # ]:          0 :                         pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum());
     344         [ #  # ]:          0 :                         if( !bUndo )
     345                 :            :                         {
     346                 :          0 :                             SdrObject* pObj = pPath;
     347         [ #  # ]:          0 :                             SdrObject::Free(pObj);
     348                 :            :                         }
     349                 :            :                     }
     350         [ #  # ]:          0 :                 }
     351                 :            :             }
     352                 :            :         }
     353                 :            : 
     354         [ #  # ]:          0 :         if( bUndo )
     355                 :          0 :             EndUndo();
     356                 :          0 :         UnmarkAllPoints();
     357                 :          0 :         MarkListHasChanged();
     358                 :            :     }
     359                 :          0 : }
     360                 :            : 
     361                 :          0 : void SdrPolyEditView::RipUpAtMarkedPoints()
     362                 :            : {
     363         [ #  # ]:          0 :     if(HasMarkedPoints())
     364                 :            :     {
     365                 :          0 :         SortMarkedObjects();
     366                 :          0 :         sal_uInt32 nMarkAnz(GetMarkedObjectCount());
     367                 :            : 
     368                 :          0 :         const bool bUndo = IsUndoEnabled();
     369         [ #  # ]:          0 :         if( bUndo )
     370 [ #  # ][ #  # ]:          0 :             BegUndo(ImpGetResStr(STR_EditRipUp), GetDescriptionOfMarkedPoints());
                 [ #  # ]
     371                 :            : 
     372         [ #  # ]:          0 :         for(sal_uInt32 nMarkNum(nMarkAnz); nMarkNum > 0L;)
     373                 :            :         {
     374                 :          0 :             nMarkNum--;
     375                 :          0 :             SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
     376                 :          0 :             SdrUShortCont* pPts = pM->GetMarkedPoints();
     377 [ #  # ][ #  # ]:          0 :             SdrPathObj* pObj = PTR_CAST(SdrPathObj, pM->GetMarkedSdrObj());
     378                 :            : 
     379 [ #  # ][ #  # ]:          0 :             if(pPts && pObj)
     380                 :            :             {
     381         [ #  # ]:          0 :                 if( bUndo )
     382                 :          0 :                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
     383                 :          0 :                 sal_Bool bKorregFlag(sal_False);
     384                 :          0 :                 sal_uInt32 nMax(pObj->GetHdlCount());
     385                 :            : 
     386 [ #  # ][ #  # ]:          0 :                 for(SdrUShortCont::const_reverse_iterator it = pPts->rbegin(); it != pPts->rend(); ++it)
                 [ #  # ]
     387                 :            :                 {
     388                 :          0 :                     sal_uInt32 nNewPt0Idx(0L);
     389 [ #  # ][ #  # ]:          0 :                     SdrObject* pNeuObj = pObj->RipPoint(*it, nNewPt0Idx);
     390                 :            : 
     391         [ #  # ]:          0 :                     if(pNeuObj)
     392                 :            :                     {
     393                 :          0 :                         SdrInsertReason aReason(SDRREASON_VIEWCALL, pObj);
     394 [ #  # ][ #  # ]:          0 :                         pM->GetPageView()->GetObjList()->InsertObject(pNeuObj, pObj->GetOrdNum() + 1, &aReason);
     395         [ #  # ]:          0 :                         if( bUndo )
     396 [ #  # ][ #  # ]:          0 :                             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj));
                 [ #  # ]
     397         [ #  # ]:          0 :                         MarkObj(pNeuObj, pM->GetPageView(), sal_False, sal_True);
     398                 :            :                     }
     399                 :            : 
     400         [ #  # ]:          0 :                     if(nNewPt0Idx)
     401                 :            :                     {
     402                 :            :                         // correction necessary?
     403                 :            :                         DBG_ASSERT(bKorregFlag==sal_False,"Multiple index corrections at SdrPolyEditView::RipUp().");
     404         [ #  # ]:          0 :                         if(!bKorregFlag)
     405                 :            :                         {
     406                 :          0 :                             bKorregFlag = sal_True;
     407                 :            : 
     408         [ #  # ]:          0 :                             SdrUShortCont aReplaceSet;
     409 [ #  # ][ #  # ]:          0 :                             for(SdrUShortCont::const_iterator it2 = pPts->begin(); it2 != pPts->end(); ++it2)
                 [ #  # ]
     410                 :            :                             {
     411         [ #  # ]:          0 :                                 sal_uInt32 nPntNum(*it2);
     412                 :          0 :                                 nPntNum += nNewPt0Idx;
     413                 :            : 
     414         [ #  # ]:          0 :                                 if(nPntNum >= nMax)
     415                 :            :                                 {
     416                 :          0 :                                     nPntNum -= nMax;
     417                 :            :                                 }
     418                 :            : 
     419         [ #  # ]:          0 :                                 aReplaceSet.insert( (sal_uInt16)nPntNum );
     420                 :            :                             }
     421         [ #  # ]:          0 :                             pPts->swap(aReplaceSet);
     422                 :            : 
     423                 :          0 :                             it = pPts->rbegin();
     424                 :            :                         }
     425                 :            :                     }
     426                 :            :                 }
     427                 :            :             }
     428                 :            :         }
     429                 :            : 
     430                 :          0 :         UnmarkAllPoints();
     431         [ #  # ]:          0 :         if( bUndo )
     432                 :          0 :             EndUndo();
     433                 :          0 :         MarkListHasChanged();
     434                 :            :     }
     435                 :          0 : }
     436                 :            : 
     437                 :          0 : bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const
     438                 :            : {
     439                 :          0 :     bool bRetval(false);
     440                 :          0 :     const sal_uInt32 nMarkCount(GetMarkedObjectCount());
     441                 :            : 
     442         [ #  # ]:          0 :     for(sal_uInt32 a(0); a < nMarkCount; a++)
     443                 :            :     {
     444                 :          0 :         const SdrMark* pMark = GetSdrMarkByIndex(a);
     445         [ #  # ]:          0 :         const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
     446                 :            : 
     447         [ #  # ]:          0 :         if(pMarkedPathObject)
     448                 :            :         {
     449                 :          0 :             const SdrUShortCont* pSelectedPoints = pMark->GetMarkedPoints();
     450                 :            : 
     451 [ #  # ][ #  # ]:          0 :             if(pSelectedPoints && !pSelectedPoints->empty())
                 [ #  # ]
     452                 :            :             {
     453                 :          0 :                 const basegfx::B2DPolyPolygon& rPathPolyPolygon = pMarkedPathObject->GetPathPoly();
     454                 :            : 
     455         [ #  # ]:          0 :                 if(1 == rPathPolyPolygon.count())
     456                 :            :                 {
     457                 :            :                     // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
     458                 :            :                     // are different and methods need to be changed thoroughly with interaction rework
     459 [ #  # ][ #  # ]:          0 :                     const Polygon aPathPolygon(rPathPolyPolygon.getB2DPolygon(0));
                 [ #  # ]
     460         [ #  # ]:          0 :                     const sal_uInt16 nPointCount(aPathPolygon.GetSize());
     461                 :            : 
     462         [ #  # ]:          0 :                     if(nPointCount >= 3)
     463                 :            :                     {
     464         [ #  # ]:          0 :                         bRetval = pMarkedPathObject->IsClosedObj(); // #i76617#
     465                 :            : 
     466 [ #  # ][ #  # ]:          0 :                         for(SdrUShortCont::const_iterator it = pSelectedPoints->begin();
         [ #  # ][ #  # ]
     467 [ #  # ][ #  # ]:          0 :                             !bRetval && it != pSelectedPoints->end(); ++it)
                 [ #  # ]
     468                 :            :                         {
     469         [ #  # ]:          0 :                             const sal_uInt16 nMarkedPointNum(*it);
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :                             bRetval = (nMarkedPointNum > 0 && nMarkedPointNum < nPointCount - 1);
     472                 :            :                         }
     473         [ #  # ]:          0 :                     }
     474                 :            :                 }
     475                 :            :             }
     476                 :            :         }
     477                 :            :     }
     478                 :            : 
     479                 :          0 :     return bRetval;
     480                 :            : }
     481                 :            : 
     482                 :          0 : bool SdrPolyEditView::IsOpenCloseMarkedObjectsPossible() const
     483                 :            : {
     484                 :          0 :     bool bRetval(false);
     485                 :          0 :     const sal_uInt32 nMarkCount(GetMarkedObjectCount());
     486                 :            : 
     487         [ #  # ]:          0 :     for(sal_uInt32 a(0); a < nMarkCount; a++)
     488                 :            :     {
     489                 :          0 :         const SdrMark* pMark = GetSdrMarkByIndex(a);
     490         [ #  # ]:          0 :         const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
     491                 :            : 
     492         [ #  # ]:          0 :         if(pMarkedPathObject)
     493                 :            :         {
     494                 :            :             // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
     495                 :            :             // are different and methods need to be changed thoroughly with interaction rework
     496         [ #  # ]:          0 :             const PolyPolygon aPathPolyPolygon(pMarkedPathObject->GetPathPoly());
     497         [ #  # ]:          0 :             const sal_uInt16 nPolygonCount(aPathPolyPolygon.Count());
     498                 :            : 
     499 [ #  # ][ #  # ]:          0 :             for(sal_uInt16 b(0); !bRetval && b < nPolygonCount; b++)
                 [ #  # ]
     500                 :            :             {
     501         [ #  # ]:          0 :                 const Polygon& rPathPolygon = aPathPolyPolygon[b];
     502         [ #  # ]:          0 :                 const sal_uInt16 nPointCount(rPathPolygon.GetSize());
     503                 :            : 
     504                 :          0 :                 bRetval = (nPointCount >= 3);
     505         [ #  # ]:          0 :             }
     506                 :            :         }
     507                 :            :     }
     508                 :            : 
     509                 :          0 :     return bRetval;
     510                 :            : }
     511                 :            : 
     512                 :          0 : SdrObjClosedKind SdrPolyEditView::GetMarkedObjectsClosedState() const
     513                 :            : {
     514                 :          0 :     bool bOpen(false);
     515                 :          0 :     bool bClosed(false);
     516                 :          0 :     const sal_uInt32 nMarkCount(GetMarkedObjectCount());
     517                 :            : 
     518 [ #  # ][ #  # ]:          0 :     for(sal_uInt32 a(0); !(bOpen && bClosed) && a < nMarkCount; a++)
         [ #  # ][ #  # ]
     519                 :            :     {
     520                 :          0 :         const SdrMark* pMark = GetSdrMarkByIndex(a);
     521         [ #  # ]:          0 :         const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
     522                 :            : 
     523         [ #  # ]:          0 :         if(pMarkedPathObject)
     524                 :            :         {
     525         [ #  # ]:          0 :             if(pMarkedPathObject->IsClosedObj())
     526                 :            :             {
     527                 :          0 :                 bClosed = true;
     528                 :            :             }
     529                 :            :             else
     530                 :            :             {
     531                 :          0 :                 bOpen = true;
     532                 :            :             }
     533                 :            :         }
     534                 :            :     }
     535                 :            : 
     536 [ #  # ][ #  # ]:          0 :     if(bOpen && bClosed)
     537                 :            :     {
     538                 :          0 :         return SDROBJCLOSED_DONTCARE;
     539                 :            :     }
     540         [ #  # ]:          0 :     else if(bOpen)
     541                 :            :     {
     542                 :          0 :         return SDROBJCLOSED_OPEN;
     543                 :            :     }
     544                 :            :     else
     545                 :            :     {
     546                 :          0 :         return SDROBJCLOSED_CLOSED;
     547                 :            :     }
     548                 :            : }
     549                 :            : 
     550                 :          0 : void SdrPolyEditView::CloseMarkedObjects(sal_Bool bToggle, sal_Bool bOpen)
     551                 :            : {
     552         [ #  # ]:          0 :     if (AreObjectsMarked())
     553                 :            :     {
     554                 :          0 :         const bool bUndo = IsUndoEnabled();
     555         [ #  # ]:          0 :         if( bUndo )
     556 [ #  # ][ #  # ]:          0 :             BegUndo(ImpGetResStr(STR_EditShut),GetDescriptionOfMarkedPoints());
                 [ #  # ]
     557                 :            : 
     558                 :          0 :         bool bChg=false;
     559                 :          0 :         sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
     560         [ #  # ]:          0 :         for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
     561                 :            :         {
     562                 :          0 :             SdrMark* pM=GetSdrMarkByIndex(nm);
     563                 :          0 :             SdrObject* pO=pM->GetMarkedSdrObj();
     564                 :          0 :             sal_Bool bClosed=pO->IsClosedObj();
     565 [ #  # ][ #  # ]:          0 :             if ((pO->IsPolyObj() && (bClosed==bOpen)) || bToggle)
         [ #  # ][ #  # ]
     566                 :            :             {
     567         [ #  # ]:          0 :                 if( bUndo )
     568                 :          0 :                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
     569                 :            : 
     570         [ #  # ]:          0 :                 SdrPathObj* pPathObj = dynamic_cast< SdrPathObj* >( pO );
     571         [ #  # ]:          0 :                 if(pPathObj)
     572                 :          0 :                     pPathObj->ToggleClosed();
     573                 :          0 :                 bChg=true;
     574                 :            :             }
     575                 :            :         }
     576                 :            : 
     577         [ #  # ]:          0 :         if( bUndo )
     578                 :          0 :             EndUndo();
     579                 :            : 
     580         [ #  # ]:          0 :         if (bChg)
     581                 :            :         {
     582                 :          0 :             UnmarkAllPoints();
     583                 :          0 :             MarkListHasChanged();
     584                 :            :         }
     585                 :            :     }
     586                 :          0 : }
     587                 :            : 
     588                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     589                 :            : 
     590                 :          0 : void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
     591                 :            : {
     592                 :          0 :     const bool bUndo = IsUndoEnabled();
     593                 :            : 
     594                 :          0 :     sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
     595         [ #  # ]:          0 :     for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
     596                 :            :     {
     597                 :          0 :         SdrMark* pM=GetSdrMarkByIndex(nm);
     598                 :          0 :         SdrObject* pObj=pM->GetMarkedSdrObj();
     599                 :          0 :         const SdrUShortCont* pPts=pM->GetMarkedPoints();
     600         [ #  # ]:          0 :         sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
     601 [ #  # ][ #  # ]:          0 :         SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj);
     602 [ #  # ][ #  # ]:          0 :         if (nPtAnz!=0 && pPath!=NULL)
     603                 :            :         {
     604         [ #  # ]:          0 :             if( bUndo )
     605 [ #  # ][ #  # ]:          0 :                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
                 [ #  # ]
     606                 :            : 
     607         [ #  # ]:          0 :             basegfx::B2DPolyPolygon aXPP(pPath->GetPathPoly());
     608                 :            : 
     609 [ #  # ][ #  # ]:          0 :             for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
                 [ #  # ]
     610                 :            :             {
     611         [ #  # ]:          0 :                 sal_uInt32 nPt = *it;
     612                 :            :                 sal_uInt32 nPolyNum, nPointNum;
     613                 :            : 
     614 [ #  # ][ #  # ]:          0 :                 if(PolyPolygonEditor::GetRelativePolyPoint(aXPP, nPt, nPolyNum, nPointNum))
     615                 :            :                 {
     616                 :            :                     //#i83671# used nLocalPointNum (which was the polygon point count)
     617                 :            :                     // instead of the point index (nPointNum). This of course leaded
     618                 :            :                     // to a wrong point access to the B2DPolygon.
     619         [ #  # ]:          0 :                     basegfx::B2DPolygon aNewXP(aXPP.getB2DPolygon(nPolyNum));
     620                 :          0 :                     Point aPos, aC1, aC2;
     621                 :          0 :                     bool bC1(false);
     622                 :          0 :                     bool bC2(false);
     623                 :            : 
     624         [ #  # ]:          0 :                     const basegfx::B2DPoint aB2DPos(aNewXP.getB2DPoint(nPointNum));
     625                 :          0 :                     aPos = Point(FRound(aB2DPos.getX()), FRound(aB2DPos.getY()));
     626                 :            : 
     627 [ #  # ][ #  # ]:          0 :                     if(aNewXP.isPrevControlPointUsed(nPointNum))
     628                 :            :                     {
     629         [ #  # ]:          0 :                         const basegfx::B2DPoint aB2DC1(aNewXP.getPrevControlPoint(nPointNum));
     630                 :          0 :                         aC1 = Point(FRound(aB2DC1.getX()), FRound(aB2DC1.getY()));
     631                 :          0 :                         bC1 = true;
     632                 :            :                     }
     633                 :            : 
     634 [ #  # ][ #  # ]:          0 :                     if(aNewXP.isNextControlPointUsed(nPointNum))
     635                 :            :                     {
     636         [ #  # ]:          0 :                         const basegfx::B2DPoint aB2DC2(aNewXP.getNextControlPoint(nPointNum));
     637                 :          0 :                         aC2 = Point(FRound(aB2DC2.getX()), FRound(aB2DC2.getY()));
     638                 :          0 :                         bC2 = true;
     639                 :            :                     }
     640                 :            : 
     641         [ #  # ]:          0 :                     (*pTrFunc)(aPos,&aC1,&aC2,p1,p2,p3,p4,p5);
     642         [ #  # ]:          0 :                     aNewXP.setB2DPoint(nPointNum, basegfx::B2DPoint(aPos.X(), aPos.Y()));
     643                 :            : 
     644         [ #  # ]:          0 :                     if (bC1)
     645                 :            :                     {
     646         [ #  # ]:          0 :                         aNewXP.setPrevControlPoint(nPointNum, basegfx::B2DPoint(aC1.X(), aC1.Y()));
     647                 :            :                     }
     648                 :            : 
     649         [ #  # ]:          0 :                     if (bC2)
     650                 :            :                     {
     651         [ #  # ]:          0 :                         aNewXP.setNextControlPoint(nPointNum, basegfx::B2DPoint(aC2.X(), aC2.Y()));
     652                 :            :                     }
     653                 :            : 
     654 [ #  # ][ #  # ]:          0 :                     aXPP.setB2DPolygon(nPolyNum, aNewXP);
     655                 :            :                 }
     656                 :            :             }
     657                 :            : 
     658 [ #  # ][ #  # ]:          0 :             pPath->SetPathPoly(aXPP);
     659                 :            :         }
     660                 :            :     }
     661                 :          0 : }
     662                 :            : 
     663                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     664                 :            : 
     665                 :          0 : static void ImpMove(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* /*p3*/, const void* /*p4*/, const void* /*p5*/)
     666                 :            : {
     667                 :          0 :     MovePoint(rPt,*(const Size*)p1);
     668         [ #  # ]:          0 :     if (pC1!=NULL) MovePoint(*pC1,*(const Size*)p1);
     669         [ #  # ]:          0 :     if (pC2!=NULL) MovePoint(*pC2,*(const Size*)p1);
     670                 :          0 : }
     671                 :            : 
     672                 :          0 : void SdrPolyEditView::MoveMarkedPoints(const Size& rSiz, bool bCopy)
     673                 :            : {
     674                 :          0 :     bCopy=sal_False; // TODO: not yet implemented
     675         [ #  # ]:          0 :     ForceUndirtyMrkPnt();
     676         [ #  # ]:          0 :     XubString aStr(ImpGetResStr(STR_EditMove));
     677 [ #  # ][ #  # ]:          0 :     if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
         [ #  # ][ #  # ]
     678 [ #  # ][ #  # ]:          0 :     BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_MOVE);
                 [ #  # ]
     679         [ #  # ]:          0 :     ImpTransformMarkedPoints(ImpMove,&rSiz);
     680         [ #  # ]:          0 :     EndUndo();
     681 [ #  # ][ #  # ]:          0 :     AdjustMarkHdl();
     682                 :          0 : }
     683                 :            : 
     684                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     685                 :            : 
     686                 :          0 : static void ImpResize(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/)
     687                 :            : {
     688 [ #  # ][ #  # ]:          0 :     ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
     689 [ #  # ][ #  # ]:          0 :     if (pC1!=NULL) ResizePoint(*pC1,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
                 [ #  # ]
     690 [ #  # ][ #  # ]:          0 :     if (pC2!=NULL) ResizePoint(*pC2,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
                 [ #  # ]
     691                 :          0 : }
     692                 :            : 
     693                 :          0 : void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
     694                 :            : {
     695                 :          0 :     bCopy=sal_False; // TODO: not yet implemented
     696         [ #  # ]:          0 :     ForceUndirtyMrkPnt();
     697         [ #  # ]:          0 :     XubString aStr(ImpGetResStr(STR_EditResize));
     698 [ #  # ][ #  # ]:          0 :     if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
         [ #  # ][ #  # ]
     699 [ #  # ][ #  # ]:          0 :     BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_RESIZE);
                 [ #  # ]
     700         [ #  # ]:          0 :     ImpTransformMarkedPoints(ImpResize,&rRef,&xFact,&yFact);
     701         [ #  # ]:          0 :     EndUndo();
     702 [ #  # ][ #  # ]:          0 :     AdjustMarkHdl();
     703                 :          0 : }
     704                 :            : 
     705                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     706                 :            : 
     707                 :          0 : static void ImpRotate(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* p3, const void* p4, const void* /*p5*/)
     708                 :            : {
     709                 :          0 :     RotatePoint(rPt,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
     710         [ #  # ]:          0 :     if (pC1!=NULL) RotatePoint(*pC1,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
     711         [ #  # ]:          0 :     if (pC2!=NULL) RotatePoint(*pC2,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
     712                 :          0 : }
     713                 :            : 
     714                 :          0 : void SdrPolyEditView::RotateMarkedPoints(const Point& rRef, long nWink, bool bCopy)
     715                 :            : {
     716                 :          0 :     bCopy=sal_False; // TODO: not yet implemented
     717         [ #  # ]:          0 :     ForceUndirtyMrkPnt();
     718         [ #  # ]:          0 :     XubString aStr(ImpGetResStr(STR_EditResize));
     719 [ #  # ][ #  # ]:          0 :     if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
         [ #  # ][ #  # ]
     720 [ #  # ][ #  # ]:          0 :     BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_ROTATE);
                 [ #  # ]
     721                 :          0 :     double nSin=sin(nWink*nPi180);
     722                 :          0 :     double nCos=cos(nWink*nPi180);
     723         [ #  # ]:          0 :     ImpTransformMarkedPoints(ImpRotate,&rRef,&nWink,&nSin,&nCos);
     724         [ #  # ]:          0 :     EndUndo();
     725 [ #  # ][ #  # ]:          0 :     AdjustMarkHdl();
     726                 :          0 : }
     727                 :            : 
     728                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10