/src/libreoffice/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | #include <sdr/primitive2d/sdrconnectorprimitive2d.hxx> |
21 | | #include <sdr/primitive2d/sdrdecompositiontools.hxx> |
22 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
23 | | #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> |
24 | | #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> |
25 | | #include <drawinglayer/primitive2d/groupprimitive2d.hxx> |
26 | | #include <basegfx/polygon/b2dpolypolygon.hxx> |
27 | | #include <utility> |
28 | | |
29 | | |
30 | | using namespace com::sun::star; |
31 | | |
32 | | |
33 | | namespace drawinglayer::primitive2d |
34 | | { |
35 | | Primitive2DReference SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const |
36 | 0 | { |
37 | 0 | Primitive2DContainer aRetval; |
38 | | |
39 | | // add line |
40 | 0 | if(getSdrLSTAttribute().getLine().isDefault()) |
41 | 0 | { |
42 | | // create invisible line for HitTest/BoundRect |
43 | 0 | aRetval.push_back( |
44 | 0 | createHiddenGeometryPrimitives2D( |
45 | 0 | basegfx::B2DPolyPolygon(getUnitPolygon()))); |
46 | 0 | } |
47 | 0 | else |
48 | 0 | { |
49 | 0 | aRetval.push_back( |
50 | 0 | createPolygonLinePrimitive( |
51 | 0 | getUnitPolygon(), |
52 | 0 | getSdrLSTAttribute().getLine(), |
53 | 0 | getSdrLSTAttribute().getLineStartEnd())); |
54 | 0 | } |
55 | | |
56 | | // add text |
57 | 0 | if(!getSdrLSTAttribute().getText().isDefault()) |
58 | 0 | { |
59 | 0 | aRetval.push_back( |
60 | 0 | createTextPrimitive( |
61 | 0 | basegfx::B2DPolyPolygon(getUnitPolygon()), |
62 | 0 | basegfx::B2DHomMatrix(), |
63 | 0 | getSdrLSTAttribute().getText(), |
64 | 0 | getSdrLSTAttribute().getLine(), |
65 | 0 | false, |
66 | 0 | false)); |
67 | 0 | } |
68 | | |
69 | | // add shadow |
70 | 0 | if(!getSdrLSTAttribute().getShadow().isDefault()) |
71 | 0 | { |
72 | 0 | aRetval = createEmbeddedShadowPrimitive( |
73 | 0 | std::move(aRetval), |
74 | 0 | getSdrLSTAttribute().getShadow()); |
75 | 0 | } |
76 | |
|
77 | 0 | return new GroupPrimitive2D(std::move(aRetval)); |
78 | 0 | } |
79 | | |
80 | | SdrConnectorPrimitive2D::SdrConnectorPrimitive2D( |
81 | | const attribute::SdrLineEffectsTextAttribute& rSdrLSTAttribute, |
82 | | ::basegfx::B2DPolygon aUnitPolygon) |
83 | 0 | : maSdrLSTAttribute(rSdrLSTAttribute), |
84 | 0 | maUnitPolygon(std::move(aUnitPolygon)) |
85 | 0 | { |
86 | 0 | } |
87 | | |
88 | | bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const |
89 | 0 | { |
90 | 0 | if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) |
91 | 0 | { |
92 | 0 | const SdrConnectorPrimitive2D& rCompare = static_cast<const SdrConnectorPrimitive2D&>(rPrimitive); |
93 | |
|
94 | 0 | return (getUnitPolygon() == rCompare.getUnitPolygon() |
95 | 0 | && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute()); |
96 | 0 | } |
97 | | |
98 | 0 | return false; |
99 | 0 | } |
100 | | |
101 | | // provide unique ID |
102 | | sal_uInt32 SdrConnectorPrimitive2D::getPrimitive2DID() const |
103 | 0 | { |
104 | 0 | return PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D; |
105 | 0 | } |
106 | | |
107 | | } // end of namespace |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |