update dev300-m58
[ooovba.git] / svx / source / sdr / contact / viewcontactofvirtobj.cxx
blobce6a755af712edc872ecf74150c2cde719bec5a1
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: viewcontactofvirtobj.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/contact/viewcontactofvirtobj.hxx>
34 #include <svx/svdovirt.hxx>
35 #include <svx/sdr/contact/displayinfo.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
38 #include <vcl/outdev.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 namespace sdr
44 namespace contact
46 SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const
48 return (SdrVirtObj&)mrObject;
51 ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj)
52 : ViewContactOfSdrObj(rObj)
56 ViewContactOfVirtObj::~ViewContactOfVirtObj()
60 // Access to possible sub-hierarchy
61 sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const
63 // Here, SdrVirtObj's need to return 0L to show that they have no
64 // sub-hierarchy, even when they are group objects. This is necessary
65 // to avoid that the same VOCs will be added to the draw hierarchy
66 // twice which leads to problems.
68 // This solution is only a first solution to get things running. Later
69 // this needs to be replaced with creating real VOCs for the objects
70 // referenced by virtual objects to avoid the 'trick' of setting the
71 // offset for painting at the destination OutputDevive.
73 // As can be seen, with primitives, the problem will be solved using
74 // a transformPrimitive, so this solution can stay with primitives.
75 return 0L;
78 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const
80 drawinglayer::primitive2d::Primitive2DSequence xRetval;
82 // use method from referenced object to get the Primitive2DSequence
83 const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual(GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence());
85 if(xSequenceVirtual.hasElements())
87 // create displacement transformation if we have content
88 ::basegfx::B2DHomMatrix aObjectMatrix;
89 Point aAnchor(GetVirtObj().GetAnchorPos());
91 if(aAnchor.X() || aAnchor.Y())
93 aObjectMatrix.set(0, 2, aAnchor.X());
94 aObjectMatrix.set(1, 2, aAnchor.Y());
97 // create transform primitive
98 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::TransformPrimitive2D(aObjectMatrix, xSequenceVirtual));
99 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
102 return xRetval;
104 } // end of namespace contact
105 } // end of namespace sdr
107 //////////////////////////////////////////////////////////////////////////////
108 // eof