1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 #include <svx/sdr/contact/viewcontactofvirtobj.hxx> 31 #include <svx/svdovirt.hxx> 32 #include <svx/sdr/contact/displayinfo.hxx> 33 #include <basegfx/matrix/b2dhommatrix.hxx> 34 #include <drawinglayer/primitive2d/transformprimitive2d.hxx> 35 #include <vcl/outdev.hxx> 36 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 37 38 ////////////////////////////////////////////////////////////////////////////// 39 40 namespace sdr 41 { 42 namespace contact 43 { 44 SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const 45 { 46 return (SdrVirtObj&)mrObject; 47 } 48 49 ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj) 50 : ViewContactOfSdrObj(rObj) 51 { 52 } 53 54 ViewContactOfVirtObj::~ViewContactOfVirtObj() 55 { 56 } 57 58 // Access to possible sub-hierarchy 59 sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const 60 { 61 // Here, SdrVirtObj's need to return 0L to show that they have no 62 // sub-hierarchy, even when they are group objects. This is necessary 63 // to avoid that the same VOCs will be added to the draw hierarchy 64 // twice which leads to problems. 65 // 66 // This solution is only a first solution to get things running. Later 67 // this needs to be replaced with creating real VOCs for the objects 68 // referenced by virtual objects to avoid the 'trick' of setting the 69 // offset for painting at the destination OutputDevive. 70 // 71 // As can be seen, with primitives, the problem will be solved using 72 // a transformPrimitive, so this solution can stay with primitives. 73 return 0L; 74 } 75 76 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const 77 { 78 // create displacement transformation if we have content 79 basegfx::B2DHomMatrix aObjectMatrix; 80 Point aAnchor(GetVirtObj().GetAnchorPos()); 81 82 if(aAnchor.X() || aAnchor.Y()) 83 { 84 aObjectMatrix.set(0, 2, aAnchor.X()); 85 aObjectMatrix.set(1, 2, aAnchor.Y()); 86 } 87 88 // use method from referenced object to get the Primitive2DSequence 89 const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual( 90 GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence()); 91 92 if(xSequenceVirtual.hasElements()) 93 { 94 // create transform primitive 95 const drawinglayer::primitive2d::Primitive2DReference xReference( 96 new drawinglayer::primitive2d::TransformPrimitive2D( 97 aObjectMatrix, 98 xSequenceVirtual)); 99 100 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 101 } 102 else 103 { 104 // always append an invisible outline for the cases where no visible content exists 105 const drawinglayer::primitive2d::Primitive2DReference xReference( 106 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( 107 false, aObjectMatrix)); 108 109 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 110 } 111 } 112 } // end of namespace contact 113 } // end of namespace sdr 114 115 ////////////////////////////////////////////////////////////////////////////// 116 // eof 117