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