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 :
21 : #include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
22 : #include <svx/svdomeas.hxx>
23 : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
24 : #include <svl/itemset.hxx>
25 : #include <svx/sxmbritm.hxx>
26 : #include <svx/sxmlhitm.hxx>
27 : #include <svx/sxmtritm.hxx>
28 : #include <svx/sxmtaitm.hxx>
29 : #include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
30 : #include <svx/sxmtpitm.hxx>
31 :
32 :
33 :
34 : namespace sdr
35 : {
36 : namespace contact
37 : {
38 0 : ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
39 0 : : ViewContactOfTextObj(rMeasureObj)
40 : {
41 0 : }
42 :
43 0 : ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
44 : {
45 0 : }
46 :
47 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
48 : {
49 0 : const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
50 : const drawinglayer::attribute::SdrLineShadowTextAttribute aAttribute(
51 : drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
52 : rItemSet,
53 0 : GetMeasureObj().getText(0)));
54 :
55 : // take properties which are the model data.
56 0 : const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
57 0 : const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
58 0 : const double fDistance(((SdrMeasureLineDistItem&)rItemSet.Get(SDRATTR_MEASURELINEDIST)).GetValue());
59 0 : const double fUpperDistance(((SdrMeasureHelplineOverhangItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue());
60 0 : const double fLowerDistance(((SdrMeasureHelplineDistItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST)).GetValue());
61 0 : const double fLeftDelta(((SdrMeasureHelpline1LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN)).GetValue());
62 0 : const double fRightDelta(((SdrMeasureHelpline2LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN)).GetValue());
63 0 : const bool bBelow(((SdrMeasureBelowRefEdgeItem&)rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE)).GetValue());
64 0 : const bool bTextRotation(((SdrMeasureTextRota90Item&)rItemSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue());
65 0 : const bool bTextAutoAngle(((SdrMeasureTextAutoAngleItem&)rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE)).GetValue());
66 0 : drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
67 0 : drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
68 :
69 0 : switch(((SdrMeasureTextHPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTHPOS)).GetValue())
70 : {
71 : case SDRMEASURE_TEXTLEFTOUTSIDE :
72 : {
73 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
74 0 : break;
75 : }
76 : case SDRMEASURE_TEXTINSIDE :
77 : {
78 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
79 0 : break;
80 : }
81 : case SDRMEASURE_TEXTRIGHTOUTSIDE :
82 : {
83 0 : aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
84 0 : break;
85 : }
86 : default : // SDRMEASURE_TEXTHAUTO
87 : {
88 0 : break;
89 : }
90 : }
91 :
92 0 : switch(((SdrMeasureTextVPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTVPOS)).GetValue())
93 : {
94 : case SDRMEASURE_ABOVE :
95 : {
96 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
97 0 : break;
98 : }
99 : case SDRMEASURETEXT_BREAKEDLINE :
100 : case SDRMEASURETEXT_VERTICALCENTERED :
101 : {
102 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
103 0 : break;
104 : }
105 : case SDRMEASURE_BELOW :
106 : {
107 0 : aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
108 0 : break;
109 : }
110 : default : // SDRMEASURE_TEXTVAUTO
111 : {
112 0 : break;
113 : }
114 : }
115 :
116 : // create primitive with the model data. Always create primitives to allow the
117 : // decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
118 : // and/or BoundRect
119 : const drawinglayer::primitive2d::Primitive2DReference xReference(
120 : new drawinglayer::primitive2d::SdrMeasurePrimitive2D(
121 : aAttribute, aStart, aEnd,
122 : aMTPHor, aMTPVer, fDistance,
123 : fUpperDistance, fLowerDistance,
124 : fLeftDelta, fRightDelta, bBelow,
125 0 : bTextRotation, bTextAutoAngle));
126 :
127 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
128 : }
129 : } // end of namespace contact
130 : } // end of namespace sdr
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|