summaryrefslogtreecommitdiff
path: root/svx/source/inc/svdoimp.hxx
blob: eeef7d0ddba8eb104f8c27365c5e5ffdc22975e3 (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
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: svdoimp.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 23:26:35 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _SVX_SVDOIMP_HXX
#define _SVX_SVDOIMP_HXX

#include <memory>
#include <vector>

#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif

#ifndef _MAPMOD_HXX //autogen
#include <vcl/mapmod.hxx>
#endif

#ifndef _SFXLSTNER_HXX //autogen
#include <svtools/lstner.hxx>
#endif

#ifndef _SV_TIMER_HXX
#include <vcl/timer.hxx>
#endif

#ifndef _SVDSOB_HXX //autogen
#include "svdsob.hxx"
#endif

#ifndef _SVDTYPES_HXX
#include "svdtypes.hxx" // fuer SdrLayerID
#endif

#ifndef _SVDGLUE_HXX
#include "svdglue.hxx" // Klebepunkte
#endif

#ifndef _SVX_XDASH_HXX
#include "xdash.hxx"
#endif

#ifndef _XPOLY_HXX
#include "xpoly.hxx"
#endif

#ifndef _POLY3D_HXX
#include "poly3d.hxx"
#endif

#ifndef _XENUM_HXX
#include "xenum.hxx"
#endif

#ifndef _BGFX_VECTOR_B2DVECTOR_HXX
#include <basegfx/vector/b2dvector.hxx>
#endif

#ifndef _SVX_RECTENUM_HXX
#include "rectenum.hxx"
#endif

#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
#include <basegfx/polygon/b2dpolygon.hxx>
#endif

class SdrObject;
class XOutputDevice;
class XFillAttrSetItem;
class XLineAttrSetItem;
class SfxItemSet;

///////////////////////////////////////////////////////////////////////////////

// #100127# Bracket filled shapes with a comment, if recording a Mtf
class ImpGraphicFill
{
public:
    ImpGraphicFill( const SdrObject& rObj, const XOutputDevice& rXOut, const SfxItemSet& rFillItemSet, bool bIsShadow=false );
    ~ImpGraphicFill();

private:
    const SdrObject&        mrObj;
    const XOutputDevice&    mrXOut;
    bool                    mbCommentWritten;
};

///////////////////////////////////////////////////////////////////////////////

// #104609# Extracted from XOutputDevice::ImpCalcBmpFillStartValues

/** Calc offset and size for bitmap fill

    This method calculates the size and the offset from the left, top
    position of a shape in logical coordinates

    @param rStartOffset
    The offset from the left, top position of the output rectangle is returned

    @param rBmpOutputSize
    The output size of the bitmap is returned herein

    @param rOutputRect
    Specifies the output rectangle into which the bitmap should be tiled into

    @param rOutputMapMode
    Specifies the logical coordinate system the output rectangle is in

    @param rFillBitmap
    Specifies the bitmap to fill with

    @param rBmpSize
    The desired destination bitmap size. If null, size is taken from the bitmap

    @param rBmpPerCent
    Percentage of bitmap size, relative to the output rectangle

    @param rBmpOffPerCent
    Offset for bitmap tiling, in percentage relative to bitmap output size

    @param bBmpLogSize
    True when using the preferred bitmap size, False when using the percentage value

    @param bBmpTile
    True for tiling. False only paints one instance of the bitmap

    @param bBmpStretch
    True if bitmap should be stretched to output rect dimension

    @param eBmpRectPoint
    Position of the start point relative to the bitmap

 */
void ImpCalcBmpFillSizes( Size&            rStartOffset,
                          Size&            rBmpOutputSize,
                          const Rectangle& rOutputRect,
                          const MapMode&   rOutputMapMode,
                          const Bitmap&    rFillBitmap,
                          const Size&      rBmpSize,
                          const Size&      rBmpPerCent,
                          const Size&      rBmpOffPerCent,
                          BOOL             bBmpLogSize,
                          BOOL             bBmpTile,
                          BOOL             bBmpStretch,
                          RECT_POINT       eBmpRectPoint );


///////////////////////////////////////////////////////////////////////////////
// ImpCreateDotDashArray takes a XDash and translates it into an array of doubles
// which describe the lengths of the dashes, dots and empty passages. It returns
// the complete length of a full DashDot sequence and fills the given vetor of
// doubles accordingly (also resizing it).

double ImpCreateDotDashArray(::std::vector< double >& rDotDashArray, const XDash& mrDash, sal_Int32 nLineWidth);

///////////////////////////////////////////////////////////////////////////////

class ImpLineStyleParameterPack
{
    XLineJoint                      meLineJoint;
    ::basegfx::B2DPolygon           maStartPolygon;
    ::basegfx::B2DPolygon           maEndPolygon;

    sal_Int32                       mnLineWidth;
    sal_Int32                       mnStartWidth;
    sal_Int32                       mnEndWidth;

    ::std::vector<double>           maDotDashArray;
    double                          mfFullDashDotLen;
    double                          mfDegreeStepWidth;

    // bitfield
    unsigned                        mbStartCentered : 1;
    unsigned                        mbEndCentered : 1;
    unsigned                        mbForceNoArrowsLeft : 1;
    unsigned                        mbForceNoArrowsRight : 1;
    unsigned                        mbForceHair : 1;

    // flag for LineStyle. True is XLINE_SOLID, false is XLINE_DASH
    unsigned                        mbLineStyleSolid : 1;

public:
    ImpLineStyleParameterPack(const SfxItemSet& rSet, bool bForceHair);
    ~ImpLineStyleParameterPack();

    sal_Int32 GetLineWidth() const { return mnLineWidth; }
    sal_Int32 GetDisplayLineWidth() const { return mbForceHair ? 0L : mnLineWidth; }
    bool IsLineStyleSolid() const { return mbLineStyleSolid; }

    sal_Int32 GetStartWidth() const { return mnStartWidth; }
    sal_Int32 GetEndWidth() const { return mnEndWidth; }

    const ::basegfx::B2DPolygon& GetStartPolygon() const { return maStartPolygon; }
    const ::basegfx::B2DPolygon& GetEndPolygon() const { return maEndPolygon; }

    double GetDegreeStepWidth() const { return mfDegreeStepWidth; }

    XLineJoint GetLineJoint() const { return meLineJoint; }
    double GetLinejointMiterMinimumAngle() const { return 15.0; }

    double GetFullDashDotLen() const { return mfFullDashDotLen; }
    const ::std::vector< double >& GetDotDash() const { return maDotDashArray; }

    bool IsStartCentered() const { return mbStartCentered; }
    bool IsEndCentered() const { return mbEndCentered; }

    bool IsStartActive() const { return (!mbForceNoArrowsLeft && maStartPolygon.count() && GetStartWidth()); }
    bool IsEndActive() const { return (!mbForceNoArrowsRight && maEndPolygon.count() && GetEndWidth()); }

    void ForceNoArrowsLeft(bool bNew) { mbForceNoArrowsLeft = bNew; }
    void ForceNoArrowsRight(bool bNew) { mbForceNoArrowsRight = bNew; }
};

////////////////////////////////////////////////////////////////////////////////////////////////////

class ImpLineGeometryCreator
{
    const ImpLineStyleParameterPack&        mrLineAttr;
    ::basegfx::B2DPolyPolygon&              maAreaPolyPolygon;
    ::basegfx::B2DPolyPolygon&              maLinePolyPolygon;

    // bitfield
    unsigned                                mbLineDraft : 1;

    // private support functions
    // help functions for line geometry creation
    void ImpCreateLineGeometry(
        const ::basegfx::B2DPolygon& rSourcePoly);

public:
    ImpLineGeometryCreator(
        const ImpLineStyleParameterPack& rAttr,
        ::basegfx::B2DPolyPolygon& rPoPo,
        ::basegfx::B2DPolyPolygon& rPoLi,
        bool bIsLineDraft = false)
    :   mrLineAttr(rAttr),
        maAreaPolyPolygon(rPoPo),
        maLinePolyPolygon(rPoLi),
        mbLineDraft(bIsLineDraft)
    {
    }

    void AddPolygon(const ::basegfx::B2DPolygon& rPoly) { ImpCreateLineGeometry(rPoly); }
    const ::basegfx::B2DPolyPolygon& GetAreaPolyPolygon() const { return maAreaPolyPolygon; }
    const ::basegfx::B2DPolyPolygon& GetLinePolyPolygon() const { return maLinePolyPolygon; }
};

////////////////////////////////////////////////////////////////////////////////////////////////////

class SdrLineGeometry
{
    ::basegfx::B2DPolyPolygon               maAreaPolyPolygon;
    ::basegfx::B2DPolyPolygon               maLinePolyPolygon;
    ImpLineStyleParameterPack               maLineAttr;

    // bitfield
    unsigned                                mbForceOnePixel : 1;
    unsigned                                mbForceTwoPixel : 1;

public:
    SdrLineGeometry(
        const ::basegfx::B2DPolyPolygon& rAreaPolyPolygon,
        const ::basegfx::B2DPolyPolygon& rLinePolyPolygon,
        const ImpLineStyleParameterPack& rLineAttr,
        bool bForceOnePixel,
        bool bForceTwoPixel)
    :   maAreaPolyPolygon(rAreaPolyPolygon),
        maLinePolyPolygon(rLinePolyPolygon),
        maLineAttr(rLineAttr),
        mbForceOnePixel(bForceOnePixel),
        mbForceTwoPixel(bForceTwoPixel)
    {}

    const ::basegfx::B2DPolyPolygon& GetAreaPolyPolygon() { return maAreaPolyPolygon; }
    const ::basegfx::B2DPolyPolygon& GetLinePolyPolygon() { return maLinePolyPolygon; }
    const ImpLineStyleParameterPack& GetLineAttr() { return maLineAttr; }
    bool DoForceOnePixel() const { return mbForceOnePixel; }
    bool DoForceTwoPixel() const { return mbForceTwoPixel; }
};

#endif // _SVX_SVDOIMP_HXX

// eof