/src/libreoffice/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
Line | Count | Source |
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/sdrpathprimitive2d.hxx> |
21 | | #include <sdr/primitive2d/sdrdecompositiontools.hxx> |
22 | | #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> |
23 | | #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> |
24 | | #include <drawinglayer/primitive2d/groupprimitive2d.hxx> |
25 | | #include <utility> |
26 | | |
27 | | |
28 | | using namespace com::sun::star; |
29 | | |
30 | | |
31 | | namespace drawinglayer::primitive2d |
32 | | { |
33 | | Primitive2DReference SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const |
34 | 338 | { |
35 | 338 | Primitive2DContainer aRetval; |
36 | | |
37 | | // add fill |
38 | 338 | if(!getSdrLFSTAttribute().getFill().isDefault() |
39 | 259 | && getUnitPolyPolygon().isClosed()) |
40 | 0 | { |
41 | | // #i108255# no need to use correctOrientations here; target is |
42 | | // straight visualisation |
43 | 0 | basegfx::B2DPolyPolygon aTransformed(getUnitPolyPolygon()); |
44 | 0 | aTransformed.transform(getTransform()); |
45 | | |
46 | | // OperationSmiley: Check if a UnitDefinitionPolyPolygon is set |
47 | 0 | if(getUnitDefinitionPolyPolygon().count() |
48 | 0 | && getUnitDefinitionPolyPolygon() != getUnitPolyPolygon()) |
49 | 0 | { |
50 | | // if yes, use the B2DRange of it's transformed form |
51 | 0 | basegfx::B2DPolyPolygon aTransformedDefinition(getUnitDefinitionPolyPolygon()); |
52 | 0 | aTransformedDefinition.transform(getTransform()); |
53 | |
|
54 | 0 | aRetval.push_back( |
55 | 0 | createPolyPolygonFillPrimitive( |
56 | 0 | aTransformed, |
57 | 0 | aTransformedDefinition.getB2DRange(), |
58 | 0 | getSdrLFSTAttribute().getFill(), |
59 | 0 | getSdrLFSTAttribute().getFillFloatTransGradient())); |
60 | 0 | } |
61 | 0 | else |
62 | 0 | { |
63 | 0 | aRetval.push_back( |
64 | 0 | createPolyPolygonFillPrimitive( |
65 | 0 | aTransformed, |
66 | 0 | getSdrLFSTAttribute().getFill(), |
67 | 0 | getSdrLFSTAttribute().getFillFloatTransGradient())); |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | | // add line |
72 | 338 | if(getSdrLFSTAttribute().getLine().isDefault()) |
73 | 0 | { |
74 | | // if initially no line is defined, create one for HitTest and BoundRect |
75 | 0 | aRetval.push_back( |
76 | 0 | createHiddenGeometryPrimitives2D( |
77 | 0 | false, |
78 | 0 | getUnitPolyPolygon(), |
79 | 0 | getTransform())); |
80 | 0 | } |
81 | 338 | else |
82 | 338 | { |
83 | 338 | Primitive2DContainer aTemp(getUnitPolyPolygon().count()); |
84 | | |
85 | 676 | for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++) |
86 | 338 | { |
87 | 338 | basegfx::B2DPolygon aTransformed(getUnitPolyPolygon().getB2DPolygon(a)); |
88 | | |
89 | 338 | aTransformed.transform(getTransform()); |
90 | 338 | aTemp[a] = createPolygonLinePrimitive( |
91 | 338 | aTransformed, |
92 | 338 | getSdrLFSTAttribute().getLine(), |
93 | 338 | getSdrLFSTAttribute().getLineStartEnd()); |
94 | 338 | } |
95 | | |
96 | 338 | aRetval.append(aTemp); |
97 | 338 | } |
98 | | |
99 | | // add text |
100 | 338 | if(!getSdrLFSTAttribute().getText().isDefault()) |
101 | 1 | { |
102 | 1 | aRetval.push_back( |
103 | 1 | createTextPrimitive( |
104 | 1 | getUnitPolyPolygon(), |
105 | 1 | getTransform(), |
106 | 1 | getSdrLFSTAttribute().getText(), |
107 | 1 | getSdrLFSTAttribute().getLine(), |
108 | 1 | false, |
109 | 1 | false)); |
110 | 1 | } |
111 | | |
112 | | // add shadow |
113 | 338 | if(!getSdrLFSTAttribute().getShadow().isDefault()) |
114 | 0 | { |
115 | 0 | aRetval = createEmbeddedShadowPrimitive( |
116 | 0 | std::move(aRetval), |
117 | 0 | getSdrLFSTAttribute().getShadow()); |
118 | 0 | } |
119 | | |
120 | 338 | return new GroupPrimitive2D(std::move(aRetval)); |
121 | 338 | } |
122 | | |
123 | | SdrPathPrimitive2D::SdrPathPrimitive2D( |
124 | | basegfx::B2DHomMatrix aTransform, |
125 | | const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute, |
126 | | basegfx::B2DPolyPolygon aUnitPolyPolygon, |
127 | | basegfx::B2DPolyPolygon aUnitDefinitionPolyPolygon) |
128 | 408 | : maTransform(std::move(aTransform)), |
129 | 408 | maSdrLFSTAttribute(rSdrLFSTAttribute), |
130 | 408 | maUnitPolyPolygon(std::move(aUnitPolyPolygon)), |
131 | 408 | maUnitDefinitionPolyPolygon(std::move(aUnitDefinitionPolyPolygon)) |
132 | 408 | { |
133 | 408 | } |
134 | | |
135 | | bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const |
136 | 140 | { |
137 | 140 | if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) |
138 | 140 | { |
139 | 140 | const SdrPathPrimitive2D& rCompare = static_cast<const SdrPathPrimitive2D&>(rPrimitive); |
140 | | |
141 | 140 | return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon() |
142 | 140 | && getUnitDefinitionPolyPolygon() == rCompare.getUnitDefinitionPolyPolygon() |
143 | 140 | && getTransform() == rCompare.getTransform() |
144 | 140 | && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()); |
145 | 140 | } |
146 | | |
147 | 0 | return false; |
148 | 140 | } |
149 | | |
150 | | // provide unique ID |
151 | | sal_uInt32 SdrPathPrimitive2D::getPrimitive2DID() const |
152 | 618 | { |
153 | 618 | return PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D; |
154 | 618 | } |
155 | | |
156 | | } // end of namespace |
157 | | |
158 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |