1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
25 #include <drawinglayer/attribute/lineattribute.hxx>
26 #include <drawinglayer/attribute/strokeattribute.hxx>
28 enum class SvxBorderLineStyle
: sal_Int16
;
30 namespace drawinglayer::primitive2d
33 Helper class holding the style definition for a single part of a full BorderLine definition.
34 Line extends are for start/end and for Left/Right, seen in vector direction. If
35 Left != Right that means the line has a diagonal start/end.
36 Think about it similar to a trapezoid, but not aligned to X-Axis and using the
37 perpendicular vector to the given one in a right-handed coordinate system.
39 class DRAWINGLAYER_DLLPUBLIC BorderLine
42 // line attribute containing Width, Color and others
43 drawinglayer::attribute::LineAttribute maLineAttribute
;
51 // if this is a gap, this is set to true
55 // Constructor for visible BorderLine segments
56 BorderLine(const drawinglayer::attribute::LineAttribute
& rLineAttribute
,
57 double fStartLeft
= 0.0, double fStartRight
= 0.0, double fEndLeft
= 0.0,
58 double fEndRight
= 0.0);
60 // Constructor for gap BorderLine segments
61 BorderLine(double fWidth
);
65 BorderLine(BorderLine
const&) = default;
66 BorderLine(BorderLine
&&) = default;
67 BorderLine
& operator=(BorderLine
const&) = default;
68 BorderLine
& operator=(BorderLine
&&) = default;
70 const drawinglayer::attribute::LineAttribute
& getLineAttribute() const
72 return maLineAttribute
;
74 double getStartLeft() const { return mfStartLeft
; }
75 double getStartRight() const { return mfStartRight
; }
76 double getEndLeft() const { return mfEndLeft
; }
77 double getEndRight() const { return mfEndRight
; }
78 bool isGap() const { return mbIsGap
; }
81 bool operator==(const BorderLine
& rBorderLine
) const;
84 /** BorderLinePrimitive2D class
86 This is the basic primitive to build frames around objects, e.g. tables.
87 It defines a single or double line from Start to End using the LeftWidth,
88 Distance and RightWidth definitions.
89 The LineStart/End overlap is defined in the BorderLines definitions (see
90 class BorderLine above).
92 class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D final
: public BufferedDecompositionPrimitive2D
95 /// the line definition
96 basegfx::B2DPoint maStart
;
97 basegfx::B2DPoint maEnd
;
99 /// the single BorderLine style definition(s), one or three mostly used
100 std::vector
<BorderLine
> maBorderLines
;
102 /// common style definitions
103 const drawinglayer::attribute::StrokeAttribute maStrokeAttribute
;
105 /// create local decomposition
107 create2DDecomposition(Primitive2DContainer
& rContainer
,
108 const geometry::ViewInformation2D
& rViewInformation
) const override
;
110 /// helper to get the full width from maBorderLines
111 double getFullWidth() const;
114 /// simplified constructor for BorderLine with single edge
115 BorderLinePrimitive2D(const basegfx::B2DPoint
& rStart
, const basegfx::B2DPoint
& rEnd
,
116 std::vector
<BorderLine
>&& rBorderLines
,
117 drawinglayer::attribute::StrokeAttribute aStrokeAttribute
);
120 const basegfx::B2DPoint
& getStart() const { return maStart
; }
121 const basegfx::B2DPoint
& getEnd() const { return maEnd
; }
122 const std::vector
<BorderLine
>& getBorderLines() const { return maBorderLines
; }
123 const drawinglayer::attribute::StrokeAttribute
& getStrokeAttribute() const
125 return maStrokeAttribute
;
128 /// helper to decide if AntiAliasing should be used
129 bool isHorizontalOrVertical(const geometry::ViewInformation2D
& rViewInformation
) const;
132 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
134 /// provide unique ID
135 virtual sal_uInt32
getPrimitive2DID() const override
;
138 /// helper to try to merge two instances of BorderLinePrimitive2D. If it was possible,
139 /// a merged version is in the returned Primitive2DReference. Lots of preconditions
140 /// have to be met to allow that, see implementation (and maybe even expand)
141 Primitive2DReference DRAWINGLAYER_DLLPUBLIC
tryMergeBorderLinePrimitive2D(
142 const BorderLinePrimitive2D
* pCandidateA
, const BorderLinePrimitive2D
* pCandidateB
);
144 } // end of namespace drawinglayer::primitive2d
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */