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 0 : Primitive2DSequence SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
39 : {
40 0 : Primitive2DSequence aRetval;
41 :
42 : // add line
43 0 : 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 0 : getUnitPolygon(),
56 0 : getSdrLSTAttribute().getLine(),
57 0 : getSdrLSTAttribute().getLineStartEnd()));
58 : }
59 :
60 : // add text
61 0 : if(!getSdrLSTAttribute().getText().isDefault())
62 : {
63 : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
64 : createTextPrimitive(
65 0 : basegfx::B2DPolyPolygon(getUnitPolygon()),
66 : basegfx::B2DHomMatrix(),
67 0 : getSdrLSTAttribute().getText(),
68 0 : getSdrLSTAttribute().getLine(),
69 : false,
70 : false,
71 0 : false));
72 : }
73 :
74 : // add shadow
75 0 : if(!getSdrLSTAttribute().getShadow().isDefault())
76 : {
77 0 : aRetval = createEmbeddedShadowPrimitive(
78 : aRetval,
79 0 : getSdrLSTAttribute().getShadow());
80 : }
81 :
82 0 : return aRetval;
83 : }
84 :
85 0 : SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
86 : const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
87 : const ::basegfx::B2DPolygon& rUnitPolygon)
88 : : BufferedDecompositionPrimitive2D(),
89 : maSdrLSTAttribute(rSdrLSTAttribute),
90 0 : maUnitPolygon(rUnitPolygon)
91 : {
92 0 : }
93 :
94 0 : bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
95 : {
96 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
97 : {
98 0 : const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive;
99 :
100 0 : return (getUnitPolygon() == rCompare.getUnitPolygon()
101 0 : && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
102 : }
103 :
104 0 : return false;
105 : }
106 :
107 : // provide unique ID
108 0 : ImplPrimitive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D)
109 :
110 : } // end of namespace primitive2d
111 : } // end of namespace drawinglayer
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|