Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdopath.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#pragma once
21
22
#include <svx/svdotext.hxx>
23
#include <svx/svxdllapi.h>
24
#include <memory>
25
26
class ImpPathForDragAndCreate;
27
28
// Helper class SdrPathObjGeoData
29
// used for undo/redo
30
31
class SdrPathObjGeoData final : public SdrTextObjGeoData
32
{
33
public:
34
    basegfx::B2DPolyPolygon maPathPolygon;
35
    SdrObjKind meKind;
36
37
    SdrPathObjGeoData();
38
    virtual ~SdrPathObjGeoData() override;
39
};
40
41
42
class SVXCORE_DLLPUBLIC SdrPathObj final : public SdrTextObj
43
{
44
private:
45
    friend class ImpPathForDragAndCreate;
46
47
    virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
48
49
    basegfx::B2DPolyPolygon maPathPolygon;
50
    SdrObjKind meKind;
51
    bool mbHandleScale = false;
52
53
    // for isolation of old Drag/Create code
54
    std::unique_ptr<ImpPathForDragAndCreate> mpDAC;
55
56
    // helper functions for GET, SET, INS etc. PNT
57
    void ImpSetClosed(bool bClose);
58
    void ImpForceKind();
59
    void ImpForceLineAngle();
60
    ImpPathForDragAndCreate& impGetDAC() const;
61
62
private:
63
    // protected destructor - due to final, make private
64
    virtual ~SdrPathObj() override;
65
66
public:
67
    SdrPathObj(
68
        SdrModel& rSdrModel,
69
        SdrObjKind eNewKind);
70
    // Copy constructor
71
    SdrPathObj(SdrModel& rSdrModel, SdrPathObj const & rSource);
72
    SdrPathObj(
73
        SdrModel& rSdrModel,
74
        SdrObjKind eNewKind,
75
        basegfx::B2DPolyPolygon aPathPoly);
76
77
    virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
78
    virtual SdrObjKind GetObjIdentifier() const override;
79
    virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
80
    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
81
82
    virtual OUString TakeObjNameSingul() const override;
83
    virtual OUString TakeObjNamePlural() const override;
84
    virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
85
    virtual void RecalcSnapRect() override;
86
    virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
87
    virtual sal_uInt32 GetHdlCount() const override;
88
    virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
89
    virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const override;
90
    virtual const tools::Rectangle& GetLogicRect() const override;
91
92
    // special drag methods
93
    virtual bool hasSpecialDrag() const override;
94
    virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
95
    virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
96
    virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
97
    virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const override;
98
99
    virtual bool BegCreate(SdrDragStat& rStat) override;
100
    virtual bool MovCreate(SdrDragStat& rStat) override;
101
    virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
102
    virtual bool BckCreate(SdrDragStat& rStat) override;
103
    virtual void BrkCreate(SdrDragStat& rStat) override;
104
    virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
105
    PointerStyle GetCreatePointer() const override;
106
107
    // during drag or create, allow accessing the so-far created/modified polyPolygon
108
    basegfx::B2DPolyPolygon getObjectPolyPolygon(const SdrDragStat& rDrag) const;
109
    basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const;
110
111
    virtual void NbcMove(const Size& aSize) override;
112
    virtual void NbcResize(const Point& rRefPnt, double aXFact, double aYFact) override;
113
    virtual void NbcRotate(const Point& rRefPnt, Degree100 nAngle, double fSin, double fCos) override;
114
    virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) override;
115
    virtual void NbcShear(const Point& rRefPnt, Degree100 nAngle, double fTan, bool bVShear) override;
116
117
    virtual sal_uInt32 GetSnapPointCount() const override;
118
    virtual Point GetSnapPoint(sal_uInt32 i) const override;
119
120
    virtual bool IsPolyObj() const override;
121
    virtual sal_uInt32 GetPointCount() const override;
122
    virtual Point GetPoint(sal_uInt32 nHdlNum) const override;
123
    virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) override;
124
125
    // insert point
126
    sal_uInt32 NbcInsPointOld(const Point& rPos, bool bNewObj);
127
    sal_uInt32 NbcInsPoint(const Point& rPos, bool bNewObj);
128
129
    // rip at given point
130
    rtl::Reference<SdrPathObj> RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
131
132
private:
133
    virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
134
    virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
135
    virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
136
137
public:
138
    virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
139
140
    // Bezier-polygon getter/setter
141
937k
    const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
142
    void SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
143
    void NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
144
145
    // special functions for Bezier-polygon handling
146
494k
    bool IsClosed() const { return meKind==SdrObjKind::Polygon || meKind==SdrObjKind::PathPoly || meKind==SdrObjKind::PathFill || meKind==SdrObjKind::FreehandFill; }
147
101k
    bool IsLine() const { return meKind==SdrObjKind::PolyLine || meKind==SdrObjKind::PathPolyLine || meKind==SdrObjKind::PathLine || meKind==SdrObjKind::FreehandLine || meKind==SdrObjKind::Line; }
148
0
    bool IsBezier() const { return meKind==SdrObjKind::PathLine || meKind==SdrObjKind::PathFill; }
149
150
    // close/open path
151
    // if opening, move end point by "nOpenDistance"
152
    void ToggleClosed(); // long nOpenDistance);
153
154
    // transformation interface for StarOfficeAPI. This implements support for
155
    // homogen 3x3 matrices containing the transformation of the SdrObject. At the
156
    // moment it contains a shearX, rotation and translation, but for setting all linear
157
    // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
158
    //
159
    // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
160
    // with the base geometry and returns TRUE. Otherwise it returns FALSE.
161
    virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
162
    // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
163
    // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
164
    // to use (0,0) as upper left and will be scaled to the given size in the matrix.
165
    virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
166
167
    /**
168
     * Scaling is ignored from the transform matrix by default, to not break compatibility. One can
169
     * opt in to handle scaling if matching ODF behavior is more important.
170
     */
171
    void SetHandleScale(bool bHandleScale);
172
};
173
174
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */