summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdpoev.cxx
blob: bcf9168a47cf2495b5faa1a9461d7be098ab0a53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#include <svx/svdpoev.hxx>
#include <math.h>
#include <svx/svdpagv.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdopath.hxx>
#include <svx/svdundo.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <svx/svdtrans.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <tools/debug.hxx>
#include <tools/helpers.hxx>

#include <svx/polypolygoneditor.hxx>

using namespace sdr;


void SdrPolyEditView::ImpResetPolyPossibilityFlags()
{
    eMarkedPointsSmooth=SdrPathSmoothKind::DontCare;
    eMarkedSegmentsKind=SdrPathSegmentKind::DontCare;
    bSetMarkedPointsSmoothPossible=false;
    bSetMarkedSegmentsKindPossible=false;
}

SdrPolyEditView::SdrPolyEditView(
    SdrModel& rSdrModel,
    OutputDevice* pOut)
:   SdrEditView(rSdrModel, pOut)
{
    ImpResetPolyPossibilityFlags();
}

SdrPolyEditView::~SdrPolyEditView()
{
}

void SdrPolyEditView::ImpCheckPolyPossibilities()
{
    ImpResetPolyPossibilityFlags();
    const size_t nMarkCount(GetMarkedObjectCount());

    if(!nMarkCount || ImpIsFrameHandles())
        return;

    bool b1stSmooth(true);
    bool b1stSegm(true);
    bool bCurve(false);
    bool bSmoothFuz(false);
    bool bSegmFuz(false);
    basegfx::B2VectorContinuity eSmooth = basegfx::B2VectorContinuity::NONE;

    for(size_t nMarkNum = 0; nMarkNum < nMarkCount; ++nMarkNum)
    {
        SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
        CheckPolyPossibilitiesHelper( pM, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
    }
}

void SdrPolyEditView::CheckPolyPossibilitiesHelper( SdrMark* pM, bool& b1stSmooth, bool& b1stSegm, bool& bCurve, bool& bSmoothFuz, bool& bSegmFuz, basegfx::B2VectorContinuity& eSmooth )
{
    SdrObject* pObj = pM->GetMarkedSdrObj();
    SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pObj );

    if (!pPath)
        return;

    SdrUShortCont& rPts = pM->GetMarkedPoints();
    if (rPts.empty())
        return;

    const bool bClosed(pPath->IsClosed());
    bSetMarkedPointsSmoothPossible = true;

    if (bClosed)
    {
        bSetMarkedSegmentsKindPossible = true;
    }

    for (const auto& rPt : rPts)
    {
        sal_uInt32 nNum(rPt);
        sal_uInt32 nPolyNum, nPntNum;

        if(PolyPolygonEditor::GetRelativePolyPoint(pPath->GetPathPoly(), nNum, nPolyNum, nPntNum))
        {
            const basegfx::B2DPolygon aLocalPolygon(pPath->GetPathPoly().getB2DPolygon(nPolyNum));
            bool bCanSegment(bClosed || nPntNum < aLocalPolygon.count() - 1);

            if(!bSetMarkedSegmentsKindPossible && bCanSegment)
            {
                bSetMarkedSegmentsKindPossible = true;
            }

            if(!bSmoothFuz)
            {
                if (b1stSmooth)
                {
                    b1stSmooth = false;
                    eSmooth = basegfx::utils::getContinuityInPoint(aLocalPolygon, nPntNum);
                }
                else
                {
                    bSmoothFuz = (eSmooth != basegfx::utils::getContinuityInPoint(aLocalPolygon, nPntNum));
                }
            }

            if(!bSegmFuz && bCanSegment)
            {
                bool bCrv(aLocalPolygon.isNextControlPointUsed(nPntNum));

                if(b1stSegm)
                {
                    b1stSegm = false;
                    bCurve = bCrv;
                }
                else
                {
                    bSegmFuz = (bCrv != bCurve);
                }
            }
        }
    }

    if(!b1stSmooth && !bSmoothFuz)
    {
        if(basegfx::B2VectorContinuity::NONE == eSmooth)
        {
            eMarkedPointsSmooth = SdrPathSmoothKind::Angular;
        }

        if(basegfx::B2VectorContinuity::C1 == eSmooth)
        {
            eMarkedPointsSmooth = SdrPathSmoothKind::Asymmetric;
        }

        if(basegfx::B2VectorContinuity::C2 == eSmooth)
        {
            eMarkedPointsSmooth = SdrPathSmoothKind::Symmetric;
        }
    }

    if(!b1stSegm && !bSegmFuz)
    {
        eMarkedSegmentsKind = bCurve ? SdrPathSegmentKind::Curve : SdrPathSegmentKind::Line;
    }
}

void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
{
    basegfx::B2VectorContinuity eFlags;

    if(SdrPathSmoothKind::Angular == eKind)
    {
        eFlags = basegfx::B2VectorContinuity::NONE;
    }
    else if(SdrPathSmoothKind::Asymmetric == eKind)
    {
        eFlags = basegfx::B2VectorContinuity::C1;
    }
    else if(SdrPathSmoothKind::Symmetric == eKind)
    {
        eFlags = basegfx::B2VectorContinuity::C2;
    }
    else
    {
        return;
    }

    if(!HasMarkedPoints())
        return;

    SortMarkedObjects();

    const bool bUndo = IsUndoEnabled();
    if( bUndo )
        BegUndo(SvxResId(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints());
    const size_t nMarkCount(GetMarkedObjectCount());

    for(size_t nMarkNum(nMarkCount); nMarkNum > 0;)
    {
        --nMarkNum;
        SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
        SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
        if (!pPath)
            continue;

        SdrUShortCont& rPts = pM->GetMarkedPoints();
        PolyPolygonEditor aEditor(pPath->GetPathPoly());
        if (aEditor.SetPointsSmooth(eFlags, rPts))
        {
            if( bUndo )
                AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
            pPath->SetPathPoly(aEditor.GetPolyPolygon());
        }
    }

    if( bUndo )
        EndUndo();
}

void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
{
    if(!HasMarkedPoints())
        return;

    SortMarkedObjects();

    const bool bUndo = IsUndoEnabled();
    if( bUndo )
        BegUndo(SvxResId(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints());
    const size_t nMarkCount(GetMarkedObjectCount());

    for(size_t nMarkNum=nMarkCount; nMarkNum > 0;)
    {
        --nMarkNum;
        SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
        SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
        if (!pPath)
            continue;
        SdrUShortCont& rPts = pM->GetMarkedPoints();
        PolyPolygonEditor aEditor( pPath->GetPathPoly());
        if (aEditor.SetSegmentsKind(eKind, rPts))
        {
            if( bUndo )
                AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
            pPath->SetPathPoly(aEditor.GetPolyPolygon());
        }
    }

    if( bUndo )
        EndUndo();
}

bool SdrPolyEditView::IsSetMarkedPointsSmoothPossible() const
{
    ForcePossibilities();
    return bSetMarkedPointsSmoothPossible;
}

SdrPathSmoothKind SdrPolyEditView::GetMarkedPointsSmooth() const
{
    ForcePossibilities();
    return eMarkedPointsSmooth;
}

bool SdrPolyEditView::IsSetMarkedSegmentsKindPossible() const
{
    ForcePossibilities();
    return bSetMarkedSegmentsKindPossible;
}

SdrPathSegmentKind SdrPolyEditView::GetMarkedSegmentsKind() const
{
    ForcePossibilities();
    return eMarkedSegmentsKind;
}

bool SdrPolyEditView::IsDeleteMarkedPointsPossible() const
{
    return HasMarkedPoints();
}

void SdrPolyEditView::DeleteMarkedPoints()
{
    if (!HasMarkedPoints())
        return;

    BrkAction();
    SortMarkedObjects();
    const size_t nMarkCount=GetMarkedObjectCount();

    const bool bUndo = IsUndoEnabled();
    if( bUndo )
    {
        // Description
        BegUndo(SvxResId(STR_EditDelete),GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Delete);
    }

    for (size_t nMarkNum=nMarkCount; nMarkNum>0;)
    {
        --nMarkNum;
        SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
        SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
        if (!pPath)
            continue;

        SdrUShortCont& rPts = pM->GetMarkedPoints();
        PolyPolygonEditor aEditor( pPath->GetPathPoly());
        if (aEditor.DeletePoints(rPts))
        {
            if( aEditor.GetPolyPolygon().count() )
            {
                if( bUndo )
                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath ));
                pPath->SetPathPoly( aEditor.GetPolyPolygon() );
            }
            else
            {
                if( bUndo )
                    AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) );
                pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum());
                if( !bUndo )
                {
                    SdrObject* pObj = pPath;
                    SdrObject::Free(pObj);
                }
            }
        }
    }

    if( bUndo )
        EndUndo();
    UnmarkAllPoints();
    MarkListHasChanged();
}

void SdrPolyEditView::RipUpAtMarkedPoints()
{
    if(!HasMarkedPoints())
        return;

    SortMarkedObjects();
    const size_t nMarkCount(GetMarkedObjectCount());

    const bool bUndo = IsUndoEnabled();
    if( bUndo )
        BegUndo(SvxResId(STR_EditRipUp), GetDescriptionOfMarkedPoints());

    for(size_t nMarkNum = nMarkCount; nMarkNum > 0;)
    {
        --nMarkNum;
        SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
        SdrPathObj* pObj = dynamic_cast<SdrPathObj*>( pM->GetMarkedSdrObj() );
        if (!pObj)
            continue;

        SdrUShortCont& rPts = pM->GetMarkedPoints();

        if( bUndo )
            AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
        bool bCorrectionFlag(false);
        sal_uInt32 nMax(pObj->GetHdlCount());

        for(SdrUShortCont::const_reverse_iterator it = rPts.rbegin(); it != rPts.rend(); ++it)
        {
            sal_uInt32 nNewPt0Idx(0);
            SdrObject* pNewObj = pObj->RipPoint(*it, nNewPt0Idx);

            if(pNewObj)
            {
                pM->GetPageView()->GetObjList()->InsertObject(pNewObj, pObj->GetOrdNum() + 1);
                if( bUndo )
                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
                MarkObj(pNewObj, pM->GetPageView(), false, true);
            }

            if(nNewPt0Idx)
            {
                // correction necessary?
                DBG_ASSERT(!bCorrectionFlag,"Multiple index corrections at SdrPolyEditView::RipUp().");
                if(!bCorrectionFlag)
                {
                    bCorrectionFlag = true;

                    SdrUShortCont aReplaceSet;
                    for(const auto& rPt : rPts)
                    {
                        sal_uInt32 nPntNum(rPt);
                        nPntNum += nNewPt0Idx;

                        if(nPntNum >= nMax)
                        {
                            nPntNum -= nMax;
                        }

                        aReplaceSet.insert( static_cast<sal_uInt16>(nPntNum) );
                    }
                    rPts.swap(aReplaceSet);

                    it = rPts.rbegin();
                }
            }
        }
    }

    UnmarkAllPoints();
    if( bUndo )
        EndUndo();
    MarkListHasChanged();
}

bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const
{
    bool bRetval(false);
    const size_t nMarkCount(GetMarkedObjectCount());

    for(size_t a = 0; a < nMarkCount; ++a)
    {
        const SdrMark* pMark = GetSdrMarkByIndex(a);
        const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());

        if (!pMarkedPathObject)
            continue;

        const SdrUShortCont& rSelectedPoints = pMark->GetMarkedPoints();
        if (rSelectedPoints.empty())
            continue;

        const basegfx::B2DPolyPolygon& rPathPolyPolygon = pMarkedPathObject->GetPathPoly();

        if(1 == rPathPolyPolygon.count())
        {
            // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
            // are different and methods need to be changed thoroughly with interaction rework
            const tools::Polygon aPathPolygon(rPathPolyPolygon.getB2DPolygon(0));
            const sal_uInt16 nPointCount(aPathPolygon.GetSize());

            if(nPointCount >= 3)
            {
                bRetval = pMarkedPathObject->IsClosedObj() // #i76617#
                    || std::any_of(rSelectedPoints.begin(), rSelectedPoints.end(),
                        [nPointCount](const sal_uInt16 nMarkedPointNum) {
                            return nMarkedPointNum > 0 && nMarkedPointNum < nPointCount - 1;
                        });
            }
        }
    }

    return bRetval;
}

bool SdrPolyEditView::IsOpenCloseMarkedObjectsPossible() const
{
    bool bRetval(false);
    const size_t nMarkCount(GetMarkedObjectCount());

    for(size_t a = 0; a < nMarkCount; ++a)
    {
        const SdrMark* pMark = GetSdrMarkByIndex(a);
        const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());

        if(pMarkedPathObject)
        {
            // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
            // are different and methods need to be changed thoroughly with interaction rework
            const tools::PolyPolygon aPathPolyPolygon(pMarkedPathObject->GetPathPoly());
            const sal_uInt16 nPolygonCount(aPathPolyPolygon.Count());

            for(sal_uInt16 b(0); !bRetval && b < nPolygonCount; b++)
            {
                const tools::Polygon& rPathPolygon = aPathPolyPolygon[b];
                const sal_uInt16 nPointCount(rPathPolygon.GetSize());

                bRetval = (nPointCount >= 3);
            }
        }
    }

    return bRetval;
}

SdrObjClosedKind SdrPolyEditView::GetMarkedObjectsClosedState() const
{
    bool bOpen(false);
    bool bClosed(false);
    const size_t nMarkCount(GetMarkedObjectCount());

    for(size_t a = 0; !(bOpen && bClosed) && a < nMarkCount; ++a)
    {
        const SdrMark* pMark = GetSdrMarkByIndex(a);
        const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());

        if(pMarkedPathObject)
        {
            if(pMarkedPathObject->IsClosedObj())
            {
                bClosed = true;
            }
            else
            {
                bOpen = true;
            }
        }
    }

    if(bOpen && bClosed)
    {
        return SdrObjClosedKind::DontCare;
    }
    else if(bOpen)
    {
        return SdrObjClosedKind::Open;
    }
    else
    {
        return SdrObjClosedKind::Closed;
    }
}

void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4)
{
    const bool bUndo = IsUndoEnabled();

    const size_t nMarkCount=GetMarkedObjectCount();
    for (size_t nm=0; nm<nMarkCount; ++nm)
    {
        SdrMark* pM=GetSdrMarkByIndex(nm);
        SdrObject* pObj=pM->GetMarkedSdrObj();
        SdrPathObj* pPath=dynamic_cast<SdrPathObj*>( pObj );
        if (!pPath)
            continue;

        const SdrUShortCont& rPts = pM->GetMarkedPoints();
        if (rPts.empty())
            continue;

        if( bUndo )
            AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));

        basegfx::B2DPolyPolygon aXPP(pPath->GetPathPoly());

        for (const auto& rPt : rPts)
        {
            sal_uInt32 nPt = rPt;
            sal_uInt32 nPolyNum, nPointNum;

            if(PolyPolygonEditor::GetRelativePolyPoint(aXPP, nPt, nPolyNum, nPointNum))
            {
                //#i83671# used nLocalPointNum (which was the polygon point count)
                // instead of the point index (nPointNum). This of course led
                // to a wrong point access to the B2DPolygon.
                basegfx::B2DPolygon aNewXP(aXPP.getB2DPolygon(nPolyNum));
                Point aPos, aC1, aC2;
                bool bC1(false);
                bool bC2(false);

                const basegfx::B2DPoint aB2DPos(aNewXP.getB2DPoint(nPointNum));
                aPos = Point(FRound(aB2DPos.getX()), FRound(aB2DPos.getY()));

                if(aNewXP.isPrevControlPointUsed(nPointNum))
                {
                    const basegfx::B2DPoint aB2DC1(aNewXP.getPrevControlPoint(nPointNum));
                    aC1 = Point(FRound(aB2DC1.getX()), FRound(aB2DC1.getY()));
                    bC1 = true;
                }

                if(aNewXP.isNextControlPointUsed(nPointNum))
                {
                    const basegfx::B2DPoint aB2DC2(aNewXP.getNextControlPoint(nPointNum));
                    aC2 = Point(FRound(aB2DC2.getX()), FRound(aB2DC2.getY()));
                    bC2 = true;
                }

                (*pTrFunc)(aPos,&aC1,&aC2,p1,p2,p3,p4);
                aNewXP.setB2DPoint(nPointNum, basegfx::B2DPoint(aPos.X(), aPos.Y()));

                if (bC1)
                {
                    aNewXP.setPrevControlPoint(nPointNum, basegfx::B2DPoint(aC1.X(), aC1.Y()));
                }

                if (bC2)
                {
                    aNewXP.setNextControlPoint(nPointNum, basegfx::B2DPoint(aC2.X(), aC2.Y()));
                }

                aXPP.setB2DPolygon(nPolyNum, aNewXP);
            }
        }

        pPath->SetPathPoly(aXPP);
    }
}


static void ImpMove(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* /*p3*/, const void* /*p4*/)
{
    rPt.Move(*static_cast<const Size*>(p1));
    if (pC1!=nullptr) pC1->Move(*static_cast<const Size*>(p1));
    if (pC2!=nullptr) pC2->Move(*static_cast<const Size*>(p1));
}

void SdrPolyEditView::MoveMarkedPoints(const Size& rSiz)
{
    ForceUndirtyMrkPnt();
    OUString aStr(SvxResId(STR_EditMove));
    BegUndo(aStr,GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Move);
    ImpTransformMarkedPoints(ImpMove,&rSiz);
    EndUndo();
    AdjustMarkHdl();
}

static void ImpResize(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* p2, const void* p3, const void* /*p4*/)
{
    ResizePoint(rPt,*static_cast<const Point*>(p1),*static_cast<const Fraction*>(p2),*static_cast<const Fraction*>(p3));
    if (pC1!=nullptr) ResizePoint(*pC1,*static_cast<const Point*>(p1),*static_cast<const Fraction*>(p2),*static_cast<const Fraction*>(p3));
    if (pC2!=nullptr) ResizePoint(*pC2,*static_cast<const Point*>(p1),*static_cast<const Fraction*>(p2),*static_cast<const Fraction*>(p3));
}

void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
    ForceUndirtyMrkPnt();
    OUString aStr(SvxResId(STR_EditResize));
    BegUndo(aStr,GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Resize);
    ImpTransformMarkedPoints(ImpResize,&rRef,&xFact,&yFact);
    EndUndo();
    AdjustMarkHdl();
}

static void ImpRotate(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* p3, const void* p4)
{
    RotatePoint(rPt,*static_cast<const Point*>(p1),*static_cast<const double*>(p3),*static_cast<const double*>(p4));
    if (pC1!=nullptr) RotatePoint(*pC1,*static_cast<const Point*>(p1),*static_cast<const double*>(p3),*static_cast<const double*>(p4));
    if (pC2!=nullptr) RotatePoint(*pC2,*static_cast<const Point*>(p1),*static_cast<const double*>(p3),*static_cast<const double*>(p4));
}

void SdrPolyEditView::RotateMarkedPoints(const Point& rRef, Degree100 nAngle)
{
    ForceUndirtyMrkPnt();
    OUString aStr(SvxResId(STR_EditResize));
    BegUndo(aStr,GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Rotate);
    double nSin = sin(toRadians(nAngle));
    double nCos = cos(toRadians(nAngle));
    ImpTransformMarkedPoints(ImpRotate,&rRef,&nAngle,&nSin,&nCos);
    EndUndo();
    AdjustMarkHdl();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */