Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/view/inc/ShapeFactory.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
#pragma once
20
21
#include "PropertyMapper.hxx"
22
#include <basegfx/range/b2irectangle.hxx>
23
#include <com/sun/star/awt/Size.hpp>
24
#include <com/sun/star/awt/Point.hpp>
25
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
26
27
#include <rtl/ref.hxx>
28
#include <rtl/ustring.hxx>
29
#include <svx/unoshape.hxx>
30
#include <svx/unodraw/SvxTableShape.hxx>
31
#include <svx/unopage.hxx>
32
33
namespace chart { struct VLineProperties; }
34
namespace com::sun::star::beans { class XPropertySet; }
35
namespace com::sun::star::chart2 { class XFormattedString; }
36
namespace com::sun::star::drawing { class XShape; }
37
namespace com::sun::star::drawing { struct HomogenMatrix; }
38
namespace com::sun::star::drawing { struct PolyPolygonShape3D; }
39
namespace com::sun::star::drawing { struct Position3D; }
40
namespace com::sun::star::graphic { class XGraphic; }
41
namespace com::sun::star::drawing { struct Direction3D; }
42
43
namespace chart
44
{
45
class Stripe;
46
47
// Be careful here not to clash with the SYMBOL_FOO #defines in
48
// <vcl/vclenum.hxx>
49
enum SymbolEnum { Symbol_Square=0
50
                 , Symbol_Diamond
51
                 , Symbol_DownArrow
52
                 , Symbol_UpArrow
53
                 , Symbol_RightArrow
54
                 , Symbol_LeftArrow
55
                 , Symbol_Bowtie
56
                 , Symbol_Sandglass
57
                 , Symbol_Circle
58
                 , Symbol_Star
59
                 , Symbol_X
60
                 , Symbol_Plus
61
                 , Symbol_Asterisk
62
                 , Symbol_HorizontalBar
63
                 , Symbol_VerticalBar
64
                 , Symbol_COUNT
65
};
66
67
68
class ShapeFactory
69
{
70
public:
71
    enum class StackPosition { Top, Bottom };
72
73
    ShapeFactory() = delete;
74
75
    static rtl::Reference< SvxShapeGroup >
76
        createGroup2D(
77
            const rtl::Reference<SvxShapeGroupAnyD>& xTarget
78
          , const OUString& aName = OUString() );
79
80
    static rtl::Reference< SvxShapeGroup >
81
        createGroup2D(
82
            const rtl::Reference<SvxDrawPage>& xTarget
83
          , const OUString& aName = OUString() );
84
85
    static rtl::Reference<Svx3DSceneObject>
86
        createGroup3D(
87
            const rtl::Reference<SvxShapeGroupAnyD>& xTarget
88
          , const OUString& aName = OUString() );
89
90
    static rtl::Reference<Svx3DExtrudeObject>
91
            createCube(   const rtl::Reference<SvxShapeGroupAnyD>& xTarget
92
                        , const css::drawing::Position3D& rPosition
93
                        , const css::drawing::Direction3D& rSize
94
                        , sal_Int32 nRotateZAngleHundredthDegree
95
                        , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp
96
                        , const tPropertyNameMap& rPropertyNameMap
97
                        , bool bRounded = false);
98
99
    static rtl::Reference<Svx3DLatheObject>
100
        createCylinder(   const rtl::Reference<SvxShapeGroupAnyD>& xTarget
101
                        , const css::drawing::Position3D& rPosition
102
                        , const css::drawing::Direction3D& rSize
103
                        , sal_Int32 nRotateZAngleHundredthDegree );
104
105
    static rtl::Reference<Svx3DSceneObject>
106
        createPyramid(    const rtl::Reference<SvxShapeGroupAnyD>& xTarget
107
                        , const css::drawing::Position3D& rPosition
108
                        , const css::drawing::Direction3D& rSize
109
                        , double fTopHeight
110
                        , bool bRotateZ
111
                        , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp
112
                        , const tPropertyNameMap& rPropertyNameMap);
113
114
    static rtl::Reference<Svx3DLatheObject>
115
        createCone(       const rtl::Reference<SvxShapeGroupAnyD>& xTarget
116
                        , const css::drawing::Position3D& rPosition
117
                        , const css::drawing::Direction3D& rSize
118
                        , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree );
119
120
    static rtl::Reference<SvxShapePolyPolygon>
121
        createPieSegment2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
122
                    , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
123
                    , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
124
                    , const css::drawing::Direction3D& rOffset
125
                    , const css::drawing::HomogenMatrix& rUnitCircleToScene );
126
127
    static rtl::Reference<Svx3DExtrudeObject>
128
        createPieSegment( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
129
                    , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
130
                    , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
131
                    , const css::drawing::Direction3D& rOffset
132
                    , const css::drawing::HomogenMatrix& rUnitCircleToScene
133
                    , double fDepth );
134
135
    static rtl::Reference<Svx3DPolygonObject>
136
        createStripe( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
137
                    , const Stripe& rStripe
138
                    , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp
139
                    , const tPropertyNameMap& rPropertyNameMap
140
                    , bool bDoubleSided
141
                    , short nRotatedTexture = 0 //0 to 7 are the different possibilities
142
                    , bool bFlatNormals=true );
143
144
    static rtl::Reference<Svx3DExtrudeObject>
145
        createArea3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
146
                    , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
147
                    , double fDepth);
148
149
    static rtl::Reference<SvxShapePolyPolygon>
150
        createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
151
                    , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
152
                    , const std::vector<std::vector<css::drawing::Position3D>>* pClipPolyPolygon = nullptr);
153
154
    static rtl::Reference<SvxShapePolyPolygon>
155
        createSymbol2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
156
                    , const css::drawing::Position3D& rPos
157
                    , const css::drawing::Direction3D& rSize
158
                    , sal_Int32 nStandardSymbol
159
                    , sal_Int32 nBorderColor
160
                    , sal_Int32 nFillColor );
161
162
    static rtl::Reference<SvxGraphicObject>
163
        createGraphic2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
164
                    , const css::drawing::Position3D& rPos
165
                    , const css::drawing::Direction3D& rSize
166
                    , const css::uno::Reference< css::graphic::XGraphic >& xGraphic );
167
168
    static rtl::Reference<SvxShapePolyPolygon>
169
        createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
170
                    , const css::drawing::PointSequenceSequence& rPoints
171
                    , const VLineProperties* pLineProperties = nullptr );
172
    static rtl::Reference<SvxShapePolyPolygon>
173
        createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
174
                    , const std::vector<std::vector<css::drawing::Position3D>>& rPoints
175
                    , const VLineProperties* pLineProperties = nullptr );
176
177
    static rtl::Reference<SvxShapePolyPolygon>
178
        createLine ( const rtl::Reference<SvxShapeGroupAnyD>& xTarget,
179
                const css::awt::Size& rSize, const css::awt::Point& rPosition );
180
181
    static rtl::Reference<Svx3DPolygonObject>
182
        createLine3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
183
                    , const std::vector<std::vector<css::drawing::Position3D>>& rPoints
184
                    , const VLineProperties& rLineProperties );
185
186
    static rtl::Reference<SvxShapeCircle>
187
        createCircle2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
188
                    , const css::drawing::Position3D& rPos
189
                    , const css::drawing::Direction3D& rSize );
190
191
    static rtl::Reference<SvxShapeCircle>
192
        createCircle( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
193
                    , const css::awt::Size& rSize
194
                    , const css::awt::Point& rPosition );
195
196
    static rtl::Reference<SvxShapeText>
197
        createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget2D
198
                    , const OUString& rText
199
                    , const tNameSequence& rPropNames
200
                    , const tAnySequence& rPropValues
201
                    , const css::uno::Any& rATransformation
202
                     );
203
204
    static rtl::Reference<SvxShapeText>
205
        createText(const rtl::Reference<SvxShapeGroupAnyD>& xTarget
206
            , const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString
207
            , const tNameSequence& rPropNames
208
            , const tAnySequence& rPropValues
209
            , const css::uno::Any& rATransformation);
210
211
    static rtl::Reference<SvxShapeText>
212
        createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget2D,
213
                const css::awt::Size& rSize,
214
                const css::awt::Point& rPosition,
215
                css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString,
216
                const css::uno::Reference< css::beans::XPropertySet > & xTextProperties,
217
                double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth );
218
219
    static rtl::Reference<SvxTableShape> createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget, OUString const& rName = OUString());
220
221
    static rtl::Reference<SvxShapeRect>
222
        createInvisibleRectangle(
223
            const rtl::Reference<SvxShapeGroupAnyD>& xTarget
224
          , const css::awt::Size& rSize );
225
226
    static rtl::Reference<SvxShapeRect>
227
        createRectangle(
228
            const rtl::Reference<SvxShapeGroupAnyD>& xTarget,
229
            const css::awt::Size& rSize,
230
            const css::awt::Point& rPosition,
231
            const tNameSequence& rPropNames,
232
            const tAnySequence& rPropValues,
233
            StackPosition ePos = StackPosition::Top );
234
235
    static rtl::Reference<SvxShapeRect>
236
        createRectangle(
237
            const rtl::Reference<SvxShapeGroupAnyD>& xTarget );
238
239
    static rtl::Reference<SvxShapeGroupAnyD>
240
         getOrCreateChartRootShape( const rtl::Reference<SvxDrawPage>& xPage );
241
242
    static void setPageSize(const rtl::Reference<SvxShapeGroupAnyD>& xChartShapes,
243
                     const css::awt::Size& rSize);
244
245
    static rtl::Reference<SvxShapeGroupAnyD>
246
         getChartRootShape( const rtl::Reference<SvxDrawPage>& xPage );
247
248
    static void makeShapeInvisible( const rtl::Reference< SvxShape >& rShape );
249
250
    static void setShapeName( const rtl::Reference< SvxShape >& xShape
251
            , const OUString& rName );
252
253
    static OUString getShapeName( const css::uno::Reference< css::drawing::XShape >& xShape );
254
255
    static css::uno::Any makeTransformation( const css::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 );
256
257
    static OUString getStackedString( const OUString& rString, bool bStacked );
258
259
    static bool hasPolygonAnyLines( const std::vector<std::vector<css::drawing::Position3D>>& rPoly );
260
    static bool isPolygonEmptyOrSinglePoint( const css::drawing::PolyPolygonShape3D& rPoly );
261
    static bool isPolygonEmptyOrSinglePoint( const std::vector<std::vector<css::drawing::Position3D>>& rPoly );
262
    static void closePolygon( css::drawing::PolyPolygonShape3D& rPoly );
263
    static void closePolygon( std::vector<std::vector<css::drawing::Position3D>>& rPoly );
264
265
    static css::awt::Size calculateNewSizeRespectingAspectRatio(
266
            const css::awt::Size& rTargetSize
267
            , const css::awt::Size& rSourceSizeWithCorrectAspectRatio );
268
269
    static css::awt::Point calculateTopLeftPositionToCenterObject(
270
            const css::awt::Point& rTargetAreaPosition
271
            , const css::awt::Size& rTargetAreaSize
272
            , const css::awt::Size& rObjectSize );
273
274
    static ::basegfx::B2IRectangle getRectangleOfShape( SvxShape& rShape );
275
276
    static css::awt::Size getSizeAfterRotation(
277
            SvxShape& rShape, double fRotationAngleDegree );
278
279
    static void removeSubShapes( const rtl::Reference<SvxShapeGroupAnyD>& xShapes );
280
281
0
    static sal_Int32 getSymbolCount() { return Symbol_COUNT; }
282
283
private:
284
    static rtl::Reference<Svx3DExtrudeObject>
285
        impl_createCube( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
286
                    , const css::drawing::Position3D& rPosition
287
                    , const css::drawing::Direction3D& rSize, sal_Int32 nRotateZAngleHundredthDegree
288
                    , bool bRounded );
289
290
    static rtl::Reference<Svx3DLatheObject>
291
        impl_createConeOrCylinder( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
292
                    , const css::drawing::Position3D& rPosition
293
                    , const css::drawing::Direction3D& rSize
294
                    , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
295
                    , bool bCylinder);
296
};
297
298
} //namespace chart
299
300
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */