xref: /trunk/main/vcl/inc/vcl/lineinfo.hxx (revision 5aaf853b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_LINEINFO_HXX
25 #define _SV_LINEINFO_HXX
26 
27 #include <vcl/dllapi.h>
28 #include <tools/gen.hxx>
29 #include <vcl/vclenum.hxx>
30 #include <basegfx/vector/b2enums.hxx>
31 #include <com/sun/star/drawing/LineCap.hpp>
32 
33 // ----------------
34 // - ImplLineInfo -
35 // ----------------
36 
37 class SvStream;
38 namespace basegfx { class B2DPolyPolygon; }
39 
40 struct ImplLineInfo
41 {
42     sal_uLong				    mnRefCount;
43 	LineStyle			    meStyle;
44     long				    mnWidth;
45 	sal_uInt16				    mnDashCount;
46 	long				    mnDashLen;
47 	sal_uInt16				    mnDotCount;
48 	long				    mnDotLen;
49 	long				    mnDistance;
50 
51     basegfx::B2DLineJoin    meLineJoin;
52     com::sun::star::drawing::LineCap meLineCap;
53 
54 						ImplLineInfo();
55 						ImplLineInfo( const ImplLineInfo& rImplLineInfo );
56 
57     bool operator==( const ImplLineInfo& ) const;
58 
59     friend SvStream&	operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo );
60     friend SvStream&	operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo );
61 };
62 
63 // ------------
64 // - LineInfo -
65 // ------------
66 
67 class VCL_DLLPUBLIC LineInfo
68 {
69 private:
70 
71 	ImplLineInfo*	mpImplLineInfo;
72 	long			n1;
73 	long			n2;
74 	long			n3;
75 
76 	SAL_DLLPRIVATE void ImplMakeUnique();
77 
78 public:
79 
80 					LineInfo( LineStyle eLineStyle = LINE_SOLID, long nWidth = 0L );
81                     LineInfo( const LineInfo& rLineInfo );
82                     ~LineInfo();
83 
84 	LineInfo&		operator=( const LineInfo& rLineInfo );
85     sal_Bool            operator==( const LineInfo& rLineInfo ) const;
operator !=(const LineInfo & rLineInfo) const86     sal_Bool            operator!=( const LineInfo& rLineInfo ) const { return !(LineInfo::operator==( rLineInfo ) ); }
IsSameInstance(const LineInfo & rLineInfo) const87     sal_Bool            IsSameInstance( const LineInfo& rLineInfo ) const { return( mpImplLineInfo == rLineInfo.mpImplLineInfo ); }
88 
89     void            SetStyle( LineStyle eStyle );
GetStyle() const90     LineStyle		GetStyle() const { return mpImplLineInfo->meStyle; }
91 
92     void            SetWidth( long nWidth );
GetWidth() const93     long			GetWidth() const { return mpImplLineInfo->mnWidth; }
94 
95 	void			SetDashCount( sal_uInt16 nDashCount );
GetDashCount() const96 	sal_uInt16			GetDashCount() const { return mpImplLineInfo->mnDashCount; }
97 
98 	void			SetDashLen( long nDashLen );
GetDashLen() const99 	long			GetDashLen() const { return mpImplLineInfo->mnDashLen; }
100 
101 	void			SetDotCount( sal_uInt16 nDotCount );
GetDotCount() const102 	sal_uInt16			GetDotCount() const { return mpImplLineInfo->mnDotCount; }
103 
104 	void			SetDotLen( long nDotLen );
GetDotLen() const105 	long			GetDotLen() const { return mpImplLineInfo->mnDotLen; }
106 
107 	void			SetDistance( long nDistance );
GetDistance() const108 	long			GetDistance() const { return mpImplLineInfo->mnDistance; }
109 
110     void SetLineJoin(basegfx::B2DLineJoin eLineJoin);
GetLineJoin() const111     basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; }
112 
113     void SetLineCap(com::sun::star::drawing::LineCap eLineCap);
GetLineCap() const114     com::sun::star::drawing::LineCap GetLineCap() const { return mpImplLineInfo->meLineCap; }
115 
116     sal_Bool			IsDefault() const;
117 
118     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo );
119     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo );
120 
121 	// helper to check if line width or DashDot is used
122 	bool isDashDotOrFatLineUsed() const;
123 
124 	// helper to get decomposed polygon data with the LineInfo applied. The source
125 	// hairline polygon is given in io_rLinePolyPolygon. Both given polygons may
126 	// contain results; e.g. when no fat line but DasDot is defined, the resut will
127 	// be in io_rLinePolyPolygon while o_rFillPolyPolygon will be empty. When fat line
128 	// is defined, it will be vice-versa. If none is defined, io_rLinePolyPolygon will
129 	// not be changed (but o_rFillPolyPolygon will be freed)
130 	void applyToB2DPolyPolygon(
131 		basegfx::B2DPolyPolygon& io_rLinePolyPolygon,
132 		basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const;
133 };
134 
135 #endif  // _SV_LINEINFO_HXX
136