Update ooo320-m1
[ooovba.git] / svx / source / sdr / contact / viewcontactofsdrmeasureobj.cxx
blobcf5dfd3d72f4ecca9366121c55704a7e2ac4d0cf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewcontactofsdrmeasureobj.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
36 #include <svx/svdomeas.hxx>
37 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38 #include <svx/sdr/attribute/sdrallattribute.hxx>
39 #include <svtools/itemset.hxx>
40 #include <svx/sxmbritm.hxx>
41 #include <svx/sxmlhitm.hxx>
42 #include <svx/sxmtritm.hxx>
43 #include <svx/sxmtaitm.hxx>
44 #include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
45 #include <svx/sxmtpitm.hxx>
47 //////////////////////////////////////////////////////////////////////////////
49 namespace sdr
51 namespace contact
53 ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
54 : ViewContactOfTextObj(rMeasureObj)
58 ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
62 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
64 drawinglayer::primitive2d::Primitive2DSequence xRetval;
65 const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
66 SdrText* pSdrText = GetMeasureObj().getText(0);
68 if(pSdrText)
70 drawinglayer::attribute::SdrLineShadowTextAttribute* pAttribute = drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(rItemSet, *pSdrText);
72 if(pAttribute)
74 if(pAttribute->isVisible())
76 // take properties which are the model data.
77 const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
78 const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
79 const double fDistance(((SdrMeasureLineDistItem&)rItemSet.Get(SDRATTR_MEASURELINEDIST)).GetValue());
80 const double fUpperDistance(((SdrMeasureHelplineOverhangItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue());
81 const double fLowerDistance(((SdrMeasureHelplineDistItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST)).GetValue());
82 const double fLeftDelta(((SdrMeasureHelpline1LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN)).GetValue());
83 const double fRightDelta(((SdrMeasureHelpline2LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN)).GetValue());
84 const bool bBelow(((SdrMeasureBelowRefEdgeItem&)rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE)).GetValue());
85 const bool bTextRotation(((SdrMeasureTextRota90Item&)rItemSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue());
86 const bool bTextAutoAngle(((SdrMeasureTextAutoAngleItem&)rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE)).GetValue());
87 drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
88 drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
90 switch(((SdrMeasureTextHPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTHPOS)).GetValue())
92 case SDRMEASURE_TEXTLEFTOUTSIDE :
94 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
95 break;
97 case SDRMEASURE_TEXTINSIDE :
99 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
100 break;
102 case SDRMEASURE_TEXTRIGHTOUTSIDE :
104 aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
105 break;
107 default : // SDRMEASURE_TEXTHAUTO
109 break;
113 switch(((SdrMeasureTextVPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTVPOS)).GetValue())
115 case SDRMEASURE_ABOVE :
117 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
118 break;
120 case SDRMEASURETEXT_BREAKEDLINE :
121 case SDRMEASURETEXT_VERTICALCENTERED :
123 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
124 break;
126 case SDRMEASURE_BELOW :
128 aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
129 break;
131 default : // SDRMEASURE_TEXTVAUTO
133 break;
137 // create primitive with the model data
138 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::SdrMeasurePrimitive2D(*pAttribute,
139 aStart, aEnd, aMTPHor, aMTPVer, fDistance, fUpperDistance, fLowerDistance, fLeftDelta, fRightDelta,
140 bBelow, bTextRotation, bTextAutoAngle));
141 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
144 delete pAttribute;
148 return xRetval;
150 } // end of namespace contact
151 } // end of namespace sdr
153 //////////////////////////////////////////////////////////////////////////////
154 // eof