Line data Source code
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 : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
22 :
23 : #include <drawinglayer/drawinglayerdllapi.h>
24 :
25 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 : #include <basegfx/color/bcolor.hxx>
27 : #include <basegfx/matrix/b2dhommatrix.hxx>
28 : #include <basegfx/polygon/b2dpolypolygon.hxx>
29 :
30 : #include <com/sun/star/table/BorderLineStyle.hpp>
31 :
32 :
33 :
34 : namespace drawinglayer
35 : {
36 : namespace primitive2d
37 : {
38 : /** BorderLinePrimitive2D class
39 :
40 : This is the basic primitive to build frames around objects, e.g. tables.
41 : It defines a single or double line from Start to End using the LeftWidth,
42 : Distance and RightWidth definitions.
43 : The LineStart/End overlap is defined by the Extend(Left|Right)(Start|End)
44 : definitions.
45 : */
46 25274 : class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D
47 : {
48 : private:
49 : /// the line definition
50 : basegfx::B2DPoint maStart;
51 : basegfx::B2DPoint maEnd;
52 :
53 : /// the widths of single/double line
54 : double mfLeftWidth;
55 : double mfDistance;
56 : double mfRightWidth;
57 :
58 : /// edge overlap sizes
59 : double mfExtendLeftStart;
60 : double mfExtendLeftEnd;
61 : double mfExtendRightStart;
62 : double mfExtendRightEnd;
63 :
64 : /// the line colors
65 : basegfx::BColor maRGBColorRight;
66 : basegfx::BColor maRGBColorLeft;
67 : basegfx::BColor maRGBColorGap;
68 : bool mbHasGapColor;
69 :
70 : short mnStyle;
71 :
72 : double mfPatternScale;
73 :
74 : /// local helpers
75 : double getWidth(
76 : const geometry::ViewInformation2D& rViewInformation) const;
77 :
78 102 : bool isSolidLine() const
79 : {
80 102 : return mnStyle == com::sun::star::table::BorderLineStyle::SOLID;
81 : }
82 :
83 246 : bool isInsideUsed() const
84 : {
85 246 : return !basegfx::fTools::equalZero(mfLeftWidth);
86 : }
87 :
88 174 : bool isOutsideUsed() const
89 : {
90 174 : return !basegfx::fTools::equalZero(mfRightWidth);
91 : }
92 :
93 : protected:
94 : virtual basegfx::B2DPolyPolygon getClipPolygon(
95 : const geometry::ViewInformation2D& rViewInformation) const;
96 :
97 : /// create local decomposition
98 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
99 :
100 : public:
101 : /// constructor
102 : BorderLinePrimitive2D(
103 : const basegfx::B2DPoint& rStart,
104 : const basegfx::B2DPoint& rEnd,
105 : double fLeftWidth,
106 : double fDistance,
107 : double fRightWidth,
108 : double fExtendLeftStart,
109 : double fExtendLeftEnd,
110 : double fExtendRightStart,
111 : double fExtendRightEnd,
112 : const basegfx::BColor& rRGBColorRight,
113 : const basegfx::BColor& rRGBColorLeft,
114 : const basegfx::BColor& rRGBColorGap,
115 : bool bHasGapColor,
116 : const short nStyle,
117 : double fPatternScale = 1.0 );
118 :
119 : /// data read access
120 21897 : const basegfx::B2DPoint& getStart() const { return maStart; }
121 21095 : const basegfx::B2DPoint& getEnd() const { return maEnd; }
122 13788 : double getLeftWidth() const { return mfLeftWidth; }
123 927 : double getDistance() const { return mfDistance; }
124 919 : double getRightWidth() const { return mfRightWidth; }
125 211 : double getExtendLeftStart() const { return mfExtendLeftStart; }
126 211 : double getExtendLeftEnd() const { return mfExtendLeftEnd; }
127 211 : double getExtendRightStart() const { return mfExtendRightStart; }
128 211 : double getExtendRightEnd() const { return mfExtendRightEnd; }
129 911 : const basegfx::BColor& getRGBColorRight () const { return maRGBColorRight; }
130 13402 : const basegfx::BColor& getRGBColorLeft () const { return maRGBColorLeft; }
131 37 : const basegfx::BColor& getRGBColorGap () const { return maRGBColorGap; }
132 1240 : bool hasGapColor( ) const { return mbHasGapColor; }
133 25724 : short getStyle () const { return mnStyle; }
134 97 : double getPatternScale() const { return mfPatternScale; }
135 :
136 : /// compare operator
137 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
138 :
139 : /// provide unique ID
140 : DeclPrimitive2DIDBlock()
141 : };
142 : } // end of namespace primitive2d
143 : } // end of namespace drawinglayer
144 :
145 :
146 :
147 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|