Branch libreoffice-6-3
[LibreOffice.git] / include / drawinglayer / primitive2d / borderlineprimitive2d.hxx
blobc801f36dc1a01251cb5005d0ce51dd9b95da9b3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <drawinglayer/attribute/lineattribute.hxx>
27 #include <drawinglayer/attribute/strokeattribute.hxx>
29 enum class SvxBorderLineStyle : sal_Int16;
31 namespace drawinglayer
33 namespace primitive2d
35 /** BorderLine class
36 Helper class holding the style definition for a single part of a full BorderLine definition.
37 Line extends are for start/end and for Left/Right, seen in vector direction. If
38 Left != Right that means the line has a diagonal start/end.
39 Think about it similar to a trapezoid, but not aligned to X-Axis and using the
40 perpendicular vector to the given one in a right-handed coordinate system.
42 class DRAWINGLAYER_DLLPUBLIC BorderLine
44 private:
45 // line attribute containing Width, Color and others
46 drawinglayer::attribute::LineAttribute maLineAttribute;
48 // line extends
49 double mfStartLeft;
50 double mfStartRight;
51 double mfEndLeft;
52 double mfEndRight;
54 // if this is a gap, this is set to true
55 bool mbIsGap;
57 public:
58 // Constructor for visible BorderLine segments
59 BorderLine(
60 const drawinglayer::attribute::LineAttribute& rLineAttribute,
61 double fStartLeft = 0.0,
62 double fStartRight = 0.0,
63 double fEndLeft = 0.0,
64 double fEndRight = 0.0);
66 // Constructor for gap BorderLine segments
67 BorderLine(double fWidth);
69 ~BorderLine();
71 const drawinglayer::attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; }
72 double getStartLeft() const { return mfStartLeft; }
73 double getStartRight() const { return mfStartRight; }
74 double getEndLeft() const { return mfEndLeft; }
75 double getEndRight() const { return mfEndRight; }
76 bool isGap() const { return mbIsGap; }
78 /// compare operator
79 bool operator==(const BorderLine& rBorderLine) const;
82 /// helper to try to merge two instances of BorderLinePrimitive2D. If it was possible,
83 /// a merged version is in the returned Primitive2DReference. Lots of preconditions
84 /// have to be met to allow that, see implementation (and maybe even expand)
85 Primitive2DReference DRAWINGLAYER_DLLPUBLIC tryMergeBorderLinePrimitive2D(
86 const Primitive2DReference& rCandidateA,
87 const Primitive2DReference& rCandidateB);
89 /** BorderLinePrimitive2D class
91 This is the basic primitive to build frames around objects, e.g. tables.
92 It defines a single or double line from Start to End using the LeftWidth,
93 Distance and RightWidth definitions.
94 The LineStart/End overlap is defined in the BorderLines definitions (see
95 class BorderLine above).
97 class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D
99 private:
100 /// the line definition
101 basegfx::B2DPoint maStart;
102 basegfx::B2DPoint maEnd;
104 /// the single BorderLine style definition(s), one or three mostly used
105 std::vector< BorderLine > maBorderLines;
107 /// common style definitions
108 const drawinglayer::attribute::StrokeAttribute maStrokeAttribute;
110 /// create local decomposition
111 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
113 /// helper to get the full width from maBorderLines
114 double getFullWidth() const;
116 public:
117 /// simplified constructor for BorderLine with single edge
118 BorderLinePrimitive2D(
119 const basegfx::B2DPoint& rStart,
120 const basegfx::B2DPoint& rEnd,
121 const std::vector< BorderLine >& rBorderLines,
122 const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute);
124 /// data read access
125 const basegfx::B2DPoint& getStart() const { return maStart; }
126 const basegfx::B2DPoint& getEnd() const { return maEnd; }
127 const std::vector< BorderLine >& getBorderLines() const { return maBorderLines; }
128 const drawinglayer::attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
130 /// helper to decide if AntiAliasing should be used
131 bool isHorizontalOrVertical(const geometry::ViewInformation2D& rViewInformation) const;
133 /// compare operator
134 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
136 /// provide unique ID
137 DeclPrimitive2DIDBlock()
139 } // end of namespace primitive2d
140 } // end of namespace drawinglayer
143 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */