1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9f62ea84SAndrew Rist * distributed with this work for additional information
6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10*9f62ea84SAndrew Rist *
11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist *
13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
17*9f62ea84SAndrew Rist * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist * under the License.
19*9f62ea84SAndrew Rist *
20*9f62ea84SAndrew Rist *************************************************************/
21*9f62ea84SAndrew Rist
22*9f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir #include <tools/vcompat.hxx>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <vcl/graphictools.hxx>
29cdf0e10cSrcweir
polyToString(const Polygon & rPoly)30cdf0e10cSrcweir static ::rtl::OString polyToString( const Polygon& rPoly )
31cdf0e10cSrcweir {
32cdf0e10cSrcweir ::rtl::OString aStr;
33cdf0e10cSrcweir sal_uInt16 nVertex;
34cdf0e10cSrcweir for(nVertex=0; nVertex<rPoly.GetSize(); ++nVertex)
35cdf0e10cSrcweir {
36cdf0e10cSrcweir aStr += "(";
37cdf0e10cSrcweir switch( rPoly.GetFlags(nVertex) )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir case POLY_NORMAL:
40cdf0e10cSrcweir case POLY_SMOOTH:
41cdf0e10cSrcweir case POLY_SYMMTR:
42cdf0e10cSrcweir aStr += "n: ";
43cdf0e10cSrcweir break;
44cdf0e10cSrcweir
45cdf0e10cSrcweir case POLY_CONTROL:
46cdf0e10cSrcweir aStr += "c: ";
47cdf0e10cSrcweir break;
48cdf0e10cSrcweir
49cdf0e10cSrcweir default:
50cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::polyToString invalid flag");
51cdf0e10cSrcweir break;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< double >( rPoly[nVertex].getX() ) );
54cdf0e10cSrcweir aStr += ",";
55cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< double >( rPoly[nVertex].getY() ) );
56cdf0e10cSrcweir aStr += ") ";
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
59cdf0e10cSrcweir return aStr;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
polyPolyToString(const PolyPolygon & rPolyPoly)62cdf0e10cSrcweir static ::rtl::OString polyPolyToString( const PolyPolygon& rPolyPoly )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir ::rtl::OString aStr;
65cdf0e10cSrcweir sal_uInt16 nPoly;
66cdf0e10cSrcweir for(nPoly=0; nPoly<rPolyPoly.Count(); ++nPoly)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir const Polygon& rPoly = rPolyPoly[nPoly];
69cdf0e10cSrcweir
70cdf0e10cSrcweir aStr += "{ ";
71cdf0e10cSrcweir aStr += polyToString( rPoly );
72cdf0e10cSrcweir aStr += "} ";
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir return aStr;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
dashToString(const SvtGraphicStroke::DashArray & rDashArray)78cdf0e10cSrcweir static ::rtl::OString dashToString( const SvtGraphicStroke::DashArray& rDashArray )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir ::rtl::OString aStr;
81cdf0e10cSrcweir
82cdf0e10cSrcweir aStr += "dash: [ ";
83cdf0e10cSrcweir
84cdf0e10cSrcweir int i, nDashes( rDashArray.size() );
85cdf0e10cSrcweir for(i=0; i<nDashes; ++i)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( rDashArray[i] );
88cdf0e10cSrcweir aStr += " ";
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir aStr += "] ";
92cdf0e10cSrcweir
93cdf0e10cSrcweir return aStr;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
colorToString(Color aColor)96cdf0e10cSrcweir static ::rtl::OString colorToString( Color aColor )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir ::rtl::OString aStr;
99cdf0e10cSrcweir
100cdf0e10cSrcweir aStr += "color: [ ";
101cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( aColor.GetRed() );
102cdf0e10cSrcweir aStr += " ";
103cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( aColor.GetGreen() );
104cdf0e10cSrcweir aStr += " ";
105cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( aColor.GetBlue() );
106cdf0e10cSrcweir aStr += " ] ";
107cdf0e10cSrcweir
108cdf0e10cSrcweir return aStr;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////
112cdf0e10cSrcweir
Transform()113cdf0e10cSrcweir SvtGraphicFill::Transform::Transform()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir matrix[0] = 1.0; matrix[1] = 0.0; matrix[2] = 0.0;
116cdf0e10cSrcweir matrix[3] = 0.0; matrix[4] = 1.0; matrix[5] = 0.0;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////
120cdf0e10cSrcweir
SvtGraphicStroke()121cdf0e10cSrcweir SvtGraphicStroke::SvtGraphicStroke() :
122cdf0e10cSrcweir maPath(),
123cdf0e10cSrcweir maStartArrow(),
124cdf0e10cSrcweir maEndArrow(),
125cdf0e10cSrcweir mfTransparency(),
126cdf0e10cSrcweir mfStrokeWidth(),
127cdf0e10cSrcweir maCapType(),
128cdf0e10cSrcweir maJoinType(),
129cdf0e10cSrcweir mfMiterLimit( 3.0 ),
130cdf0e10cSrcweir maDashArray()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
SvtGraphicStroke(const Polygon & rPath,const PolyPolygon & rStartArrow,const PolyPolygon & rEndArrow,double fTransparency,double fStrokeWidth,CapType aCap,JoinType aJoin,double fMiterLimit,const DashArray & rDashArray)134cdf0e10cSrcweir SvtGraphicStroke::SvtGraphicStroke( const Polygon& rPath,
135cdf0e10cSrcweir const PolyPolygon& rStartArrow,
136cdf0e10cSrcweir const PolyPolygon& rEndArrow,
137cdf0e10cSrcweir double fTransparency,
138cdf0e10cSrcweir double fStrokeWidth,
139cdf0e10cSrcweir CapType aCap,
140cdf0e10cSrcweir JoinType aJoin,
141cdf0e10cSrcweir double fMiterLimit,
142cdf0e10cSrcweir const DashArray& rDashArray ) :
143cdf0e10cSrcweir maPath( rPath ),
144cdf0e10cSrcweir maStartArrow( rStartArrow ),
145cdf0e10cSrcweir maEndArrow( rEndArrow ),
146cdf0e10cSrcweir mfTransparency( fTransparency ),
147cdf0e10cSrcweir mfStrokeWidth( fStrokeWidth ),
148cdf0e10cSrcweir maCapType( aCap ),
149cdf0e10cSrcweir maJoinType( aJoin ),
150cdf0e10cSrcweir mfMiterLimit( fMiterLimit ),
151cdf0e10cSrcweir maDashArray( rDashArray )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
getPath(Polygon & rPath) const155cdf0e10cSrcweir void SvtGraphicStroke::getPath( Polygon& rPath ) const
156cdf0e10cSrcweir {
157cdf0e10cSrcweir rPath = maPath;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
getStartArrow(PolyPolygon & rPath) const160cdf0e10cSrcweir void SvtGraphicStroke::getStartArrow( PolyPolygon& rPath ) const
161cdf0e10cSrcweir {
162cdf0e10cSrcweir rPath = maStartArrow;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
getEndArrow(PolyPolygon & rPath) const165cdf0e10cSrcweir void SvtGraphicStroke::getEndArrow( PolyPolygon& rPath ) const
166cdf0e10cSrcweir {
167cdf0e10cSrcweir rPath = maEndArrow;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
getTransparency() const170cdf0e10cSrcweir double SvtGraphicStroke::getTransparency() const
171cdf0e10cSrcweir {
172cdf0e10cSrcweir return mfTransparency;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
getStrokeWidth() const175cdf0e10cSrcweir double SvtGraphicStroke::getStrokeWidth() const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir return mfStrokeWidth;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
getCapType() const180cdf0e10cSrcweir SvtGraphicStroke::CapType SvtGraphicStroke::getCapType() const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir return maCapType;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
getJoinType() const185cdf0e10cSrcweir SvtGraphicStroke::JoinType SvtGraphicStroke::getJoinType() const
186cdf0e10cSrcweir {
187cdf0e10cSrcweir return maJoinType;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
getMiterLimit() const190cdf0e10cSrcweir double SvtGraphicStroke::getMiterLimit() const
191cdf0e10cSrcweir {
192cdf0e10cSrcweir return mfMiterLimit;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
getDashArray(DashArray & rDashArray) const195cdf0e10cSrcweir void SvtGraphicStroke::getDashArray( DashArray& rDashArray ) const
196cdf0e10cSrcweir {
197cdf0e10cSrcweir rDashArray = maDashArray;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
toString() const200cdf0e10cSrcweir ::rtl::OString SvtGraphicStroke::toString() const
201cdf0e10cSrcweir {
202cdf0e10cSrcweir ::rtl::OString aStr;
203cdf0e10cSrcweir
204cdf0e10cSrcweir aStr += polyToString( maPath );
205cdf0e10cSrcweir aStr += "trans: ";
206cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< double >(getTransparency()) );
207cdf0e10cSrcweir aStr += " width: ";
208cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< double >(getStrokeWidth()) );
209cdf0e10cSrcweir aStr += " cap: ";
210cdf0e10cSrcweir switch( getCapType() )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir case capButt:
213cdf0e10cSrcweir aStr += "butt";
214cdf0e10cSrcweir break;
215cdf0e10cSrcweir
216cdf0e10cSrcweir case capRound:
217cdf0e10cSrcweir aStr += "round";
218cdf0e10cSrcweir break;
219cdf0e10cSrcweir
220cdf0e10cSrcweir case capSquare:
221cdf0e10cSrcweir aStr += "square";
222cdf0e10cSrcweir break;
223cdf0e10cSrcweir
224cdf0e10cSrcweir default:
225cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing cap type");
226cdf0e10cSrcweir break;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir aStr += " join: ";
229cdf0e10cSrcweir switch( getJoinType() )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir case joinMiter:
232cdf0e10cSrcweir aStr += "miter";
233cdf0e10cSrcweir break;
234cdf0e10cSrcweir
235cdf0e10cSrcweir case joinRound:
236cdf0e10cSrcweir aStr += "round";
237cdf0e10cSrcweir break;
238cdf0e10cSrcweir
239cdf0e10cSrcweir case joinBevel:
240cdf0e10cSrcweir aStr += "bevel";
241cdf0e10cSrcweir break;
242cdf0e10cSrcweir
243cdf0e10cSrcweir case joinNone:
244cdf0e10cSrcweir aStr += "none";
245cdf0e10cSrcweir break;
246cdf0e10cSrcweir
247cdf0e10cSrcweir default:
248cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing join type");
249cdf0e10cSrcweir break;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir aStr += " ";
252cdf0e10cSrcweir
253cdf0e10cSrcweir if( maStartArrow.Count() )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir aStr += "start: ";
256cdf0e10cSrcweir aStr += polyPolyToString( maStartArrow );
257cdf0e10cSrcweir aStr += " ";
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir if( maEndArrow.Count() )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir aStr += "end: ";
263cdf0e10cSrcweir aStr += polyPolyToString( maEndArrow );
264cdf0e10cSrcweir aStr += " ";
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir aStr += dashToString( maDashArray );
268cdf0e10cSrcweir
269cdf0e10cSrcweir return aStr;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
setPath(const Polygon & rPoly)272cdf0e10cSrcweir void SvtGraphicStroke::setPath( const Polygon& rPoly )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir maPath = rPoly;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
setStartArrow(const PolyPolygon & rPoly)277cdf0e10cSrcweir void SvtGraphicStroke::setStartArrow( const PolyPolygon& rPoly )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir maStartArrow = rPoly;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
setEndArrow(const PolyPolygon & rPoly)282cdf0e10cSrcweir void SvtGraphicStroke::setEndArrow( const PolyPolygon& rPoly )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir maEndArrow = rPoly;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
setTransparency(double fTrans)287cdf0e10cSrcweir void SvtGraphicStroke::setTransparency( double fTrans )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir mfTransparency = fTrans;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
setStrokeWidth(double fWidth)292cdf0e10cSrcweir void SvtGraphicStroke::setStrokeWidth( double fWidth )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir mfStrokeWidth = fWidth;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
setCapType(CapType eType)297cdf0e10cSrcweir void SvtGraphicStroke::setCapType( CapType eType )
298cdf0e10cSrcweir {
299cdf0e10cSrcweir maCapType = eType;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
setJoinType(JoinType eType)302cdf0e10cSrcweir void SvtGraphicStroke::setJoinType( JoinType eType )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir maJoinType = eType;
305cdf0e10cSrcweir }
306cdf0e10cSrcweir
setMiterLimit(double fMiterLimit)307cdf0e10cSrcweir void SvtGraphicStroke::setMiterLimit( double fMiterLimit )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir mfMiterLimit = fMiterLimit;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
setDashArray(const DashArray & rDashArray)312cdf0e10cSrcweir void SvtGraphicStroke::setDashArray( const DashArray& rDashArray )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir maDashArray = rDashArray;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
operator <<(SvStream & rOStm,const SvtGraphicStroke & rClass)317cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const SvtGraphicStroke& rClass )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
320cdf0e10cSrcweir
321cdf0e10cSrcweir rClass.maPath.Write( rOStm );
322cdf0e10cSrcweir rClass.maStartArrow.Write( rOStm );
323cdf0e10cSrcweir rClass.maEndArrow.Write( rOStm );
324cdf0e10cSrcweir rOStm << rClass.mfTransparency;
325cdf0e10cSrcweir rOStm << rClass.mfStrokeWidth;
326cdf0e10cSrcweir sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maCapType );
327cdf0e10cSrcweir rOStm << nTmp;
328cdf0e10cSrcweir nTmp = sal::static_int_cast<sal_uInt16>( rClass.maJoinType );
329cdf0e10cSrcweir rOStm << nTmp;
330cdf0e10cSrcweir rOStm << rClass.mfMiterLimit;
331cdf0e10cSrcweir
332cdf0e10cSrcweir rOStm << static_cast<sal_uInt32>(rClass.maDashArray.size());
333cdf0e10cSrcweir size_t i;
334cdf0e10cSrcweir for(i=0; i<rClass.maDashArray.size(); ++i)
335cdf0e10cSrcweir rOStm << rClass.maDashArray[i];
336cdf0e10cSrcweir
337cdf0e10cSrcweir return rOStm;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
operator >>(SvStream & rIStm,SvtGraphicStroke & rClass)340cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, SvtGraphicStroke& rClass )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir VersionCompat aCompat( rIStm, STREAM_READ );
343cdf0e10cSrcweir
344cdf0e10cSrcweir rClass.maPath.Read( rIStm );
345cdf0e10cSrcweir rClass.maStartArrow.Read( rIStm );
346cdf0e10cSrcweir rClass.maEndArrow.Read( rIStm );
347cdf0e10cSrcweir rIStm >> rClass.mfTransparency;
348cdf0e10cSrcweir rIStm >> rClass.mfStrokeWidth;
349cdf0e10cSrcweir sal_uInt16 nTmp;
350cdf0e10cSrcweir rIStm >> nTmp;
351cdf0e10cSrcweir rClass.maCapType = SvtGraphicStroke::CapType(nTmp);
352cdf0e10cSrcweir rIStm >> nTmp;
353cdf0e10cSrcweir rClass.maJoinType = SvtGraphicStroke::JoinType(nTmp);
354cdf0e10cSrcweir rIStm >> rClass.mfMiterLimit;
355cdf0e10cSrcweir
356cdf0e10cSrcweir sal_uInt32 nSize;
357cdf0e10cSrcweir rIStm >> nSize;
358cdf0e10cSrcweir rClass.maDashArray.resize(nSize);
359cdf0e10cSrcweir size_t i;
360cdf0e10cSrcweir for(i=0; i<rClass.maDashArray.size(); ++i)
361cdf0e10cSrcweir rIStm >> rClass.maDashArray[i];
362cdf0e10cSrcweir
363cdf0e10cSrcweir return rIStm;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir
367cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
368cdf0e10cSrcweir
SvtGraphicFill()369cdf0e10cSrcweir SvtGraphicFill::SvtGraphicFill() :
370cdf0e10cSrcweir maPath(),
371cdf0e10cSrcweir maFillColor( COL_BLACK ),
372cdf0e10cSrcweir mfTransparency(),
373cdf0e10cSrcweir maFillRule(),
374cdf0e10cSrcweir maFillType(),
375cdf0e10cSrcweir maFillTransform(),
376cdf0e10cSrcweir maHatchType(),
377cdf0e10cSrcweir maHatchColor( COL_BLACK ),
378cdf0e10cSrcweir maGradientType(),
379cdf0e10cSrcweir maGradient1stColor( COL_BLACK ),
380cdf0e10cSrcweir maGradient2ndColor( COL_BLACK ),
381cdf0e10cSrcweir maGradientStepCount( gradientStepsInfinite ),
382cdf0e10cSrcweir maFillGraphic()
383cdf0e10cSrcweir {
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
SvtGraphicFill(const PolyPolygon & rPath,Color aFillColor,double fTransparency,FillRule aFillRule,FillType aFillType,const Transform & aFillTransform,bool bTiling,HatchType aHatchType,Color aHatchColor,GradientType aGradientType,Color aGradient1stColor,Color aGradient2ndColor,int aGradientStepCount,const Graphic & aFillGraphic)386cdf0e10cSrcweir SvtGraphicFill::SvtGraphicFill( const PolyPolygon& rPath,
387cdf0e10cSrcweir Color aFillColor,
388cdf0e10cSrcweir double fTransparency,
389cdf0e10cSrcweir FillRule aFillRule,
390cdf0e10cSrcweir FillType aFillType,
391cdf0e10cSrcweir const Transform& aFillTransform,
392cdf0e10cSrcweir bool bTiling,
393cdf0e10cSrcweir HatchType aHatchType,
394cdf0e10cSrcweir Color aHatchColor,
395cdf0e10cSrcweir GradientType aGradientType,
396cdf0e10cSrcweir Color aGradient1stColor,
397cdf0e10cSrcweir Color aGradient2ndColor,
398cdf0e10cSrcweir int aGradientStepCount,
399cdf0e10cSrcweir const Graphic& aFillGraphic ) :
400cdf0e10cSrcweir maPath( rPath ),
401cdf0e10cSrcweir maFillColor( aFillColor ),
402cdf0e10cSrcweir mfTransparency( fTransparency ),
403cdf0e10cSrcweir maFillRule( aFillRule ),
404cdf0e10cSrcweir maFillType( aFillType ),
405cdf0e10cSrcweir maFillTransform( aFillTransform ),
406cdf0e10cSrcweir mbTiling( bTiling ),
407cdf0e10cSrcweir maHatchType( aHatchType ),
408cdf0e10cSrcweir maHatchColor( aHatchColor ),
409cdf0e10cSrcweir maGradientType( aGradientType ),
410cdf0e10cSrcweir maGradient1stColor( aGradient1stColor ),
411cdf0e10cSrcweir maGradient2ndColor( aGradient2ndColor ),
412cdf0e10cSrcweir maGradientStepCount( aGradientStepCount ),
413cdf0e10cSrcweir maFillGraphic( aFillGraphic )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
getPath(PolyPolygon & rPath) const417cdf0e10cSrcweir void SvtGraphicFill::getPath( PolyPolygon& rPath ) const
418cdf0e10cSrcweir {
419cdf0e10cSrcweir rPath = maPath;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
getFillColor() const422cdf0e10cSrcweir Color SvtGraphicFill::getFillColor() const
423cdf0e10cSrcweir {
424cdf0e10cSrcweir return maFillColor;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
getTransparency() const427cdf0e10cSrcweir double SvtGraphicFill::getTransparency() const
428cdf0e10cSrcweir {
429cdf0e10cSrcweir return mfTransparency;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
getFillRule() const432cdf0e10cSrcweir SvtGraphicFill::FillRule SvtGraphicFill::getFillRule() const
433cdf0e10cSrcweir {
434cdf0e10cSrcweir return maFillRule;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
getFillType() const437cdf0e10cSrcweir SvtGraphicFill::FillType SvtGraphicFill::getFillType() const
438cdf0e10cSrcweir {
439cdf0e10cSrcweir return maFillType;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
getTransform(Transform & rTrans) const442cdf0e10cSrcweir void SvtGraphicFill::getTransform( Transform& rTrans ) const
443cdf0e10cSrcweir {
444cdf0e10cSrcweir rTrans = maFillTransform;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
IsTiling() const447cdf0e10cSrcweir bool SvtGraphicFill::IsTiling() const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir return mbTiling;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
isTiling() const452cdf0e10cSrcweir bool SvtGraphicFill::isTiling() const
453cdf0e10cSrcweir {
454cdf0e10cSrcweir return mbTiling;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
getHatchType() const457cdf0e10cSrcweir SvtGraphicFill::HatchType SvtGraphicFill::getHatchType() const
458cdf0e10cSrcweir {
459cdf0e10cSrcweir return maHatchType;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
getHatchColor() const462cdf0e10cSrcweir Color SvtGraphicFill::getHatchColor() const
463cdf0e10cSrcweir {
464cdf0e10cSrcweir return maHatchColor;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
getGradientType() const467cdf0e10cSrcweir SvtGraphicFill::GradientType SvtGraphicFill::getGradientType() const
468cdf0e10cSrcweir {
469cdf0e10cSrcweir return maGradientType;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir
getGradient1stColor() const472cdf0e10cSrcweir Color SvtGraphicFill::getGradient1stColor() const
473cdf0e10cSrcweir {
474cdf0e10cSrcweir return maGradient1stColor;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
getGradient2ndColor() const477cdf0e10cSrcweir Color SvtGraphicFill::getGradient2ndColor() const
478cdf0e10cSrcweir {
479cdf0e10cSrcweir return maGradient2ndColor;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
getGradientStepCount() const482cdf0e10cSrcweir int SvtGraphicFill::getGradientStepCount() const
483cdf0e10cSrcweir {
484cdf0e10cSrcweir return maGradientStepCount;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
getGraphic(Graphic & rGraphic) const487cdf0e10cSrcweir void SvtGraphicFill::getGraphic( Graphic& rGraphic ) const
488cdf0e10cSrcweir {
489cdf0e10cSrcweir rGraphic = maFillGraphic;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
toString() const492cdf0e10cSrcweir ::rtl::OString SvtGraphicFill::toString() const
493cdf0e10cSrcweir {
494cdf0e10cSrcweir ::rtl::OString aStr;
495cdf0e10cSrcweir
496cdf0e10cSrcweir aStr += polyPolyToString( maPath );
497cdf0e10cSrcweir aStr += "fill";
498cdf0e10cSrcweir aStr += colorToString( getFillColor() );
499cdf0e10cSrcweir aStr += " trans: ";
500cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< double >(getTransparency()) );
501cdf0e10cSrcweir aStr += " rule: ";
502cdf0e10cSrcweir switch( getFillRule() )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir case fillNonZero:
505cdf0e10cSrcweir aStr += "nonzero";
506cdf0e10cSrcweir break;
507cdf0e10cSrcweir
508cdf0e10cSrcweir case fillEvenOdd:
509cdf0e10cSrcweir aStr += "evenodd";
510cdf0e10cSrcweir break;
511cdf0e10cSrcweir
512cdf0e10cSrcweir default:
513cdf0e10cSrcweir DBG_ERROR( "SvtGraphicFill::toString missing fill rule");
514cdf0e10cSrcweir break;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir aStr += " type: ";
517cdf0e10cSrcweir switch( getFillType() )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir case fillSolid:
520cdf0e10cSrcweir aStr += "solid";
521cdf0e10cSrcweir break;
522cdf0e10cSrcweir
523cdf0e10cSrcweir case fillGradient:
524cdf0e10cSrcweir aStr += "gradient";
525cdf0e10cSrcweir break;
526cdf0e10cSrcweir
527cdf0e10cSrcweir case fillHatch:
528cdf0e10cSrcweir aStr += "hatch";
529cdf0e10cSrcweir break;
530cdf0e10cSrcweir
531cdf0e10cSrcweir case fillTexture:
532cdf0e10cSrcweir aStr += "bitmap";
533cdf0e10cSrcweir break;
534cdf0e10cSrcweir
535cdf0e10cSrcweir default:
536cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing fill type");
537cdf0e10cSrcweir break;
538cdf0e10cSrcweir }
539cdf0e10cSrcweir
540cdf0e10cSrcweir aStr += " transform: [ ";
541cdf0e10cSrcweir int i;
542cdf0e10cSrcweir for(i=0; i<Transform::MatrixSize; ++i)
543cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( maFillTransform.matrix[i] );
544cdf0e10cSrcweir aStr += " ] ";
545cdf0e10cSrcweir
546cdf0e10cSrcweir aStr += " hatch: ";
547cdf0e10cSrcweir switch( getHatchType() )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir case hatchSingle:
550cdf0e10cSrcweir aStr += "single";
551cdf0e10cSrcweir break;
552cdf0e10cSrcweir
553cdf0e10cSrcweir case hatchDouble:
554cdf0e10cSrcweir aStr += "double";
555cdf0e10cSrcweir break;
556cdf0e10cSrcweir
557cdf0e10cSrcweir case hatchTriple:
558cdf0e10cSrcweir aStr += "triple";
559cdf0e10cSrcweir break;
560cdf0e10cSrcweir
561cdf0e10cSrcweir default:
562cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing hatch type");
563cdf0e10cSrcweir break;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir
566cdf0e10cSrcweir aStr += " hatch";
567cdf0e10cSrcweir aStr += colorToString( getHatchColor() );
568cdf0e10cSrcweir
569cdf0e10cSrcweir aStr += " gradient: ";
570cdf0e10cSrcweir switch( getGradientType() )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir case gradientLinear:
573cdf0e10cSrcweir aStr += "linear";
574cdf0e10cSrcweir break;
575cdf0e10cSrcweir
576cdf0e10cSrcweir case gradientRadial:
577cdf0e10cSrcweir aStr += "radial";
578cdf0e10cSrcweir break;
579cdf0e10cSrcweir
580cdf0e10cSrcweir case gradientRectangular:
581cdf0e10cSrcweir aStr += "rectangular";
582cdf0e10cSrcweir break;
583cdf0e10cSrcweir
584cdf0e10cSrcweir default:
585cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing gradient type");
586cdf0e10cSrcweir break;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir
589cdf0e10cSrcweir aStr += " grad1st";
590cdf0e10cSrcweir aStr += colorToString( getGradient1stColor() );
591cdf0e10cSrcweir
592cdf0e10cSrcweir aStr += " grad2nd";
593cdf0e10cSrcweir aStr += colorToString( getGradient2ndColor() );
594cdf0e10cSrcweir
595cdf0e10cSrcweir aStr += " gradstep";
596cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( (sal_Int32)getGradientStepCount() );
597cdf0e10cSrcweir
598cdf0e10cSrcweir if( maFillGraphic.GetType() != GRAPHIC_NONE )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir aStr += " fillgraphic: ";
601cdf0e10cSrcweir switch( maFillGraphic.GetType() )
602cdf0e10cSrcweir {
603cdf0e10cSrcweir case GRAPHIC_BITMAP:
604cdf0e10cSrcweir aStr += "bitmap";
605cdf0e10cSrcweir break;
606cdf0e10cSrcweir
607cdf0e10cSrcweir case GRAPHIC_GDIMETAFILE:
608cdf0e10cSrcweir aStr += "metafile";
609cdf0e10cSrcweir break;
610cdf0e10cSrcweir
611cdf0e10cSrcweir case GRAPHIC_DEFAULT:
612cdf0e10cSrcweir aStr += "default";
613cdf0e10cSrcweir break;
614cdf0e10cSrcweir
615cdf0e10cSrcweir default:
616cdf0e10cSrcweir DBG_ERROR( "SvtGraphicStroke::toString missing graphic type");
617cdf0e10cSrcweir break;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir
620cdf0e10cSrcweir aStr += " of ";
621cdf0e10cSrcweir aStr += ::rtl::OString::valueOf( static_cast< sal_Int32 >(maFillGraphic.GetSizeBytes()) );
622cdf0e10cSrcweir aStr += " bytes";
623cdf0e10cSrcweir }
624cdf0e10cSrcweir
625cdf0e10cSrcweir return aStr;
626cdf0e10cSrcweir }
627cdf0e10cSrcweir
setPath(const PolyPolygon & rPath)628cdf0e10cSrcweir void SvtGraphicFill::setPath( const PolyPolygon& rPath )
629cdf0e10cSrcweir {
630cdf0e10cSrcweir maPath = rPath;
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
setFillColor(Color aFillColor)633cdf0e10cSrcweir void SvtGraphicFill::setFillColor( Color aFillColor )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir maFillColor = aFillColor;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
setTransparency(double fTransparency)638cdf0e10cSrcweir void SvtGraphicFill::setTransparency( double fTransparency )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir mfTransparency = fTransparency;
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
setFillRule(FillRule aFillRule)643cdf0e10cSrcweir void SvtGraphicFill::setFillRule( FillRule aFillRule )
644cdf0e10cSrcweir {
645cdf0e10cSrcweir maFillRule = aFillRule;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir
setFillType(FillType aFillType)648cdf0e10cSrcweir void SvtGraphicFill::setFillType( FillType aFillType )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir maFillType = aFillType;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
setTransform(const Transform & rTransform)653cdf0e10cSrcweir void SvtGraphicFill::setTransform( const Transform& rTransform )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir maFillTransform = rTransform;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
setTiling(bool bTiling)658cdf0e10cSrcweir void SvtGraphicFill::setTiling( bool bTiling )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir mbTiling = bTiling;
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
setHatchType(HatchType aHatchType)663cdf0e10cSrcweir void SvtGraphicFill::setHatchType( HatchType aHatchType )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir maHatchType = aHatchType;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
setHatchColor(Color aHatchColor)668cdf0e10cSrcweir void SvtGraphicFill::setHatchColor( Color aHatchColor )
669cdf0e10cSrcweir {
670cdf0e10cSrcweir maHatchColor = aHatchColor;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir
setGradientType(GradientType aGradType)673cdf0e10cSrcweir void SvtGraphicFill::setGradientType( GradientType aGradType )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir maGradientType = aGradType;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
setGradient1stColor(Color aColor)678cdf0e10cSrcweir void SvtGraphicFill::setGradient1stColor( Color aColor )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir maGradient1stColor = aColor;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir
setGradient2ndColor(Color aColor)683cdf0e10cSrcweir void SvtGraphicFill::setGradient2ndColor( Color aColor )
684cdf0e10cSrcweir {
685cdf0e10cSrcweir maGradient2ndColor = aColor;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
setGradientStepCount(int aCount)688cdf0e10cSrcweir void SvtGraphicFill::setGradientStepCount( int aCount )
689cdf0e10cSrcweir {
690cdf0e10cSrcweir maGradientStepCount = aCount;
691cdf0e10cSrcweir }
692cdf0e10cSrcweir
setGraphic(const Graphic & rGraphic)693cdf0e10cSrcweir void SvtGraphicFill::setGraphic( const Graphic& rGraphic )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir maFillGraphic = rGraphic;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
operator <<(SvStream & rOStm,const SvtGraphicFill & rClass)698cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const SvtGraphicFill& rClass )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
701cdf0e10cSrcweir
702cdf0e10cSrcweir rClass.maPath.Write( rOStm );
703cdf0e10cSrcweir rOStm << rClass.maFillColor;
704cdf0e10cSrcweir rOStm << rClass.mfTransparency;
705cdf0e10cSrcweir sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
706cdf0e10cSrcweir rOStm << nTmp;
707cdf0e10cSrcweir nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillType );
708cdf0e10cSrcweir rOStm << nTmp;
709cdf0e10cSrcweir int i;
710cdf0e10cSrcweir for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
711cdf0e10cSrcweir rOStm << rClass.maFillTransform.matrix[i];
712cdf0e10cSrcweir nTmp = rClass.mbTiling;
713cdf0e10cSrcweir rOStm << nTmp;
714cdf0e10cSrcweir nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
715cdf0e10cSrcweir rOStm << nTmp;
716cdf0e10cSrcweir rOStm << rClass.maHatchColor;
717cdf0e10cSrcweir nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
718cdf0e10cSrcweir rOStm << nTmp;
719cdf0e10cSrcweir rOStm << rClass.maGradient1stColor;
720cdf0e10cSrcweir rOStm << rClass.maGradient2ndColor;
721cdf0e10cSrcweir rOStm << rClass.maGradientStepCount;
722cdf0e10cSrcweir rOStm << rClass.maFillGraphic;
723cdf0e10cSrcweir
724cdf0e10cSrcweir return rOStm;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir
operator >>(SvStream & rIStm,SvtGraphicFill & rClass)727cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, SvtGraphicFill& rClass )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir VersionCompat aCompat( rIStm, STREAM_READ );
730cdf0e10cSrcweir
731cdf0e10cSrcweir rClass.maPath.Read( rIStm );
732cdf0e10cSrcweir rIStm >> rClass.maFillColor;
733cdf0e10cSrcweir rIStm >> rClass.mfTransparency;
734cdf0e10cSrcweir sal_uInt16 nTmp;
735cdf0e10cSrcweir rIStm >> nTmp;
736cdf0e10cSrcweir rClass.maFillRule = SvtGraphicFill::FillRule( nTmp );
737cdf0e10cSrcweir rIStm >> nTmp;
738cdf0e10cSrcweir rClass.maFillType = SvtGraphicFill::FillType( nTmp );
739cdf0e10cSrcweir int i;
740cdf0e10cSrcweir for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
741cdf0e10cSrcweir rIStm >> rClass.maFillTransform.matrix[i];
742cdf0e10cSrcweir rIStm >> nTmp;
743cdf0e10cSrcweir rClass.mbTiling = nTmp;
744cdf0e10cSrcweir rIStm >> nTmp;
745cdf0e10cSrcweir rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
746cdf0e10cSrcweir rIStm >> rClass.maHatchColor;
747cdf0e10cSrcweir rIStm >> nTmp;
748cdf0e10cSrcweir rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
749cdf0e10cSrcweir rIStm >> rClass.maGradient1stColor;
750cdf0e10cSrcweir rIStm >> rClass.maGradient2ndColor;
751cdf0e10cSrcweir rIStm >> rClass.maGradientStepCount;
752cdf0e10cSrcweir rIStm >> rClass.maFillGraphic;
753cdf0e10cSrcweir
754cdf0e10cSrcweir return rIStm;
755cdf0e10cSrcweir }
756