bump product version to 6.4.0.3
[LibreOffice.git] / drawinglayer / source / primitive3d / polygonprimitive3d.cxx
blob29e2b97045693d6898fb659781d0f40e87d16c8c
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 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
21 #include <basegfx/polygon/b3dpolygontools.hxx>
22 #include <basegfx/utils/canvastools.hxx>
23 #include <basegfx/polygon/b3dpolypolygon.hxx>
24 #include <basegfx/polygon/b3dpolypolygontools.hxx>
25 #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
26 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
29 using namespace com::sun::star;
32 namespace drawinglayer
34 namespace primitive3d
36 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
37 const basegfx::B3DPolygon& rPolygon,
38 const basegfx::BColor& rBColor)
39 : BasePrimitive3D(),
40 maPolygon(rPolygon),
41 maBColor(rBColor)
45 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
47 if(BasePrimitive3D::operator==(rPrimitive))
49 const PolygonHairlinePrimitive3D& rCompare = static_cast<const PolygonHairlinePrimitive3D&>(rPrimitive);
51 return (getB3DPolygon() == rCompare.getB3DPolygon()
52 && getBColor() == rCompare.getBColor());
55 return false;
58 basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
60 return basegfx::utils::getRange(getB3DPolygon());
63 // provide unique ID
64 ImplPrimitive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
66 } // end of namespace primitive3d
67 } // end of namespace drawinglayer
70 namespace drawinglayer
72 namespace primitive3d
74 Primitive3DContainer PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
76 Primitive3DContainer aRetval;
78 if(getB3DPolygon().count())
80 basegfx::B3DPolyPolygon aHairLinePolyPolygon;
82 if(0.0 == getStrokeAttribute().getFullDotDashLen())
84 aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
86 else
88 // apply LineStyle
89 basegfx::utils::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, getStrokeAttribute().getFullDotDashLen());
92 // prepare result
93 aRetval.resize(aHairLinePolyPolygon.count());
95 if(getLineAttribute().getWidth())
97 // create fat line data
98 const double fRadius(getLineAttribute().getWidth() / 2.0);
99 const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
100 const css::drawing::LineCap aLineCap(getLineAttribute().getLineCap());
102 for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
104 // create tube primitives
105 const Primitive3DReference xRef(
106 new PolygonTubePrimitive3D(
107 aHairLinePolyPolygon.getB3DPolygon(a),
108 getLineAttribute().getColor(),
109 fRadius,
110 aLineJoin,
111 aLineCap));
112 aRetval[a] = xRef;
115 else
117 // create hair line data for all sub polygons
118 for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
120 const basegfx::B3DPolygon& aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
121 const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
122 aRetval[a] = xRef;
127 return aRetval;
130 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
131 const basegfx::B3DPolygon& rPolygon,
132 const attribute::LineAttribute& rLineAttribute,
133 const attribute::StrokeAttribute& rStrokeAttribute)
134 : BufferedDecompositionPrimitive3D(),
135 maPolygon(rPolygon),
136 maLineAttribute(rLineAttribute),
137 maStrokeAttribute(rStrokeAttribute)
141 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
143 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
145 const PolygonStrokePrimitive3D& rCompare = static_cast<const PolygonStrokePrimitive3D&>(rPrimitive);
147 return (getB3DPolygon() == rCompare.getB3DPolygon()
148 && getLineAttribute() == rCompare.getLineAttribute()
149 && getStrokeAttribute() == rCompare.getStrokeAttribute());
152 return false;
155 // provide unique ID
156 ImplPrimitive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
158 } // end of namespace primitive3d
159 } // end of namespace drawinglayer
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */