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 : #include <svtools/ctrlbox.hxx>
30 :
31 : //////////////////////////////////////////////////////////////////////////////
32 :
33 : namespace drawinglayer
34 : {
35 : namespace primitive2d
36 : {
37 : /** BorderLinePrimitive2D class
38 :
39 : This is the basic primitive to build frames around objects, e.g. tables.
40 : It defines a single or double line from Start to nd using the LeftWidth,
41 : Distance and RightWidth definitions.
42 : The LineStart/End overlap is defined by the Extend(Inner|Outer)(Start|End)
43 : definitions.
44 : */
45 1084 : class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D
46 : {
47 : private:
48 : /// the line definition
49 : basegfx::B2DPoint maStart;
50 : basegfx::B2DPoint maEnd;
51 :
52 : /// the widths of single/double line
53 : double mfLeftWidth;
54 : double mfDistance;
55 : double mfRightWidth;
56 :
57 : /// edge overlap sizes
58 : double mfExtendLeftStart;
59 : double mfExtendLeftEnd;
60 : double mfExtendRightStart;
61 : double mfExtendRightEnd;
62 :
63 : /// the line colors
64 : basegfx::BColor maRGBColorRight;
65 : basegfx::BColor maRGBColorLeft;
66 : basegfx::BColor maRGBColorGap;
67 : bool mbHasGapColor;
68 :
69 : short mnStyle;
70 :
71 : /// local helpers
72 : double getWidth(
73 : const geometry::ViewInformation2D& rViewInformation) const;
74 :
75 472 : bool isSolidLine() const
76 : {
77 472 : return (mnStyle==STYLE_SOLID);
78 : }
79 :
80 614 : bool isInsideUsed() const
81 : {
82 614 : return !basegfx::fTools::equalZero(mfLeftWidth);
83 : }
84 :
85 546 : bool isOutsideUsed() const
86 : {
87 546 : return !basegfx::fTools::equalZero(mfRightWidth);
88 : }
89 :
90 : protected:
91 : virtual basegfx::B2DPolyPolygon getClipPolygon(
92 : const geometry::ViewInformation2D& rViewInformation) const;
93 :
94 : /// create local decomposition
95 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
96 :
97 : public:
98 : /// constructor
99 : BorderLinePrimitive2D(
100 : const basegfx::B2DPoint& rStart,
101 : const basegfx::B2DPoint& rEnd,
102 : double fLeftWidth,
103 : double fDistance,
104 : double fRightWidth,
105 : double fExtendLeftStart,
106 : double fExtendLeftEnd,
107 : double fExtendRightStart,
108 : double fExtendRightEnd,
109 : const basegfx::BColor& rRGBColorRight,
110 : const basegfx::BColor& rRGBColorLeft,
111 : const basegfx::BColor& rRGBColorGap,
112 : bool bHasGapColor,
113 : const short nStyle );
114 :
115 : /// data read access
116 10486 : const basegfx::B2DPoint& getStart() const { return maStart; }
117 10486 : const basegfx::B2DPoint& getEnd() const { return maEnd; }
118 480 : double getLeftWidth() const { return mfLeftWidth; }
119 0 : double getDistance() const { return mfDistance; }
120 6 : double getRightWidth() const { return mfRightWidth; }
121 574 : double getExtendLeftStart() const { return mfExtendLeftStart; }
122 574 : double getExtendLeftEnd() const { return mfExtendLeftEnd; }
123 576 : double getExtendRightStart() const { return mfExtendRightStart; }
124 576 : double getExtendRightEnd() const { return mfExtendRightEnd; }
125 74 : const basegfx::BColor& getRGBColorRight () const { return maRGBColorRight; }
126 540 : const basegfx::BColor& getRGBColorLeft () const { return maRGBColorLeft; }
127 0 : const basegfx::BColor& getRGBColorGap () const { return maRGBColorGap; }
128 68 : bool hasGapColor( ) const { return mbHasGapColor; }
129 96 : short getStyle () const { return mnStyle; }
130 :
131 : /// compare operator
132 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
133 :
134 : /// provide unique ID
135 : DeclPrimitrive2DIDBlock()
136 : };
137 : } // end of namespace primitive2d
138 : } // end of namespace drawinglayer
139 :
140 : //////////////////////////////////////////////////////////////////////////////
141 :
142 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|