tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / include / drawinglayer / primitive2d / borderlineprimitive2d.hxx
blob5d58feded56737015d2a9692523e30debaee9e57
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 #pragma once
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
32 /** BorderLine class
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
41 private:
42 // line attribute containing Width, Color and others
43 drawinglayer::attribute::LineAttribute maLineAttribute;
45 // line extends
46 double mfStartLeft;
47 double mfStartRight;
48 double mfEndLeft;
49 double mfEndRight;
51 // if this is a gap, this is set to true
52 bool mbIsGap;
54 public:
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);
63 ~BorderLine();
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; }
80 /// compare operator
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
94 private:
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
106 virtual void
107 create2DDecomposition(Primitive2DContainer& rContainer,
108 const geometry::ViewInformation2D& rViewInformation) const override;
110 /// helper to get the full width from maBorderLines
111 double getFullWidth() const;
113 public:
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);
119 /// data read access
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;
131 /// compare operator
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: */