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