Update ooo320-m1
[ooovba.git] / svx / source / sdr / contact / viewcontactofsdrole2obj.cxx
blob454b68cbfb6a6fd4fbb6f576029a9b7d61f2597e
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: viewcontactofsdrole2obj.cxx,v $
11 * $Revision: 1.2.18.1 $
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/viewcontactofsdrole2obj.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/sdr/attribute/sdrallattribute.hxx>
38 #include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
39 #include <basegfx/matrix/b2dhommatrix.hxx>
40 #include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
41 #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
42 #include <basegfx/polygon/b2dpolygontools.hxx>
43 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
44 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
45 #include <svtools/colorcfg.hxx>
46 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
47 #include <vcl/svapp.hxx>
48 #include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
50 //////////////////////////////////////////////////////////////////////////////
52 namespace sdr
54 namespace contact
56 // Create a Object-Specific ViewObjectContact, set ViewContact and
57 // ObjectContact. Always needs to return something.
58 ViewObjectContact& ViewContactOfSdrOle2Obj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
60 ViewObjectContact* pRetval = new ViewObjectContactOfSdrOle2Obj(rObjectContact, *this);
61 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
63 return *pRetval;
66 ViewContactOfSdrOle2Obj::ViewContactOfSdrOle2Obj(SdrOle2Obj& rOle2Obj)
67 : ViewContactOfSdrRectObj(rOle2Obj)
71 ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj()
75 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters(
76 bool bHighContrast) const
78 drawinglayer::primitive2d::Primitive2DSequence xRetval;
79 SdrText* pSdrText = GetOle2Obj().getText(0);
81 if(pSdrText)
83 // take unrotated snap rect (direct model data) for position and size
84 const Rectangle& rRectangle = GetOle2Obj().GetGeoRect();
85 const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
87 // create object matrix
88 const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
89 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
90 const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
91 basegfx::B2DHomMatrix aObjectMatrix;
93 aObjectMatrix.scale(aObjectRange.getWidth(), aObjectRange.getHeight());
94 aObjectMatrix.shearX(fShearX);
95 aObjectMatrix.rotate(fRotate);
96 aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY());
98 // Prepare attribute settings, will be used soon anyways
99 const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
100 drawinglayer::attribute::SdrLineFillShadowTextAttribute* pAttribute = drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(rItemSet, *pSdrText);
102 if(!pAttribute)
104 // force existence, even when not visible
105 pAttribute = new drawinglayer::attribute::SdrLineFillShadowTextAttribute(0, 0, 0, 0, 0, 0);
108 // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
109 // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
110 // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
111 // It will also take care of HighContrast and ScaleContent
112 const drawinglayer::primitive2d::Primitive2DReference xOleContent(
113 new drawinglayer::primitive2d::SdrOleContentPrimitive2D(
114 GetOle2Obj(),
115 aObjectMatrix,
116 bHighContrast));
118 // create primitive. Use Ole2 primitive here. Prepare attribute settings, will be used soon anyways.
119 const drawinglayer::primitive2d::Primitive2DSequence xOLEContent(&xOleContent, 1);
120 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::SdrOle2Primitive2D(
121 xOLEContent,
122 aObjectMatrix,
123 *pAttribute));
124 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
125 delete pAttribute;
128 return xRetval;
131 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createViewIndependentPrimitive2DSequence() const
133 // do as if no HC and call standard creator
134 return createPrimitive2DSequenceWithParameters(false);
136 } // end of namespace contact
137 } // end of namespace sdr
139 //////////////////////////////////////////////////////////////////////////////
140 // eof