1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx> 31*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx> 32*cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx> 33*cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 34*cdf0e10cSrcweir #include <vcl/region.hxx> 35*cdf0e10cSrcweir #include <svx/sdr/animation/objectanimator.hxx> 36*cdf0e10cSrcweir #include <svx/sdr/animation/animationstate.hxx> 37*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactredirector.hxx> 38*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 39*cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx> 40*cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> 41*cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 42*cdf0e10cSrcweir #include <drawinglayer/primitive2d/animatedprimitive2d.hxx> 43*cdf0e10cSrcweir #include <drawinglayer/processor2d/baseprocessor2d.hxx> 44*cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 45*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactredirector.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir using namespace com::sun::star; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir namespace 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir // animated extractor 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir // Necessary to filter a sequence of animated primitives from 58*cdf0e10cSrcweir // a sequence of primitives to find out if animated or not. The decision for 59*cdf0e10cSrcweir // what to decompose is hard-coded and only done for knowingly animated primitives 60*cdf0e10cSrcweir // to not decompose too deeply and unnecessarily. This implies that the list 61*cdf0e10cSrcweir // which is view-specific needs to be expanded by hand when new animated objects 62*cdf0e10cSrcweir // are added. This may eventually be changed to a dynamically configurable approach 63*cdf0e10cSrcweir // if necessary. 64*cdf0e10cSrcweir class AnimatedExtractingProcessor2D : public drawinglayer::processor2d::BaseProcessor2D 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir protected: 67*cdf0e10cSrcweir // the found animated primitives 68*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // bitfield 71*cdf0e10cSrcweir // text animation allowed? 72*cdf0e10cSrcweir unsigned mbTextAnimationAllowed : 1; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir // graphic animation allowed? 75*cdf0e10cSrcweir unsigned mbGraphicAnimationAllowed : 1; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir // as tooling, the process() implementation takes over API handling and calls this 78*cdf0e10cSrcweir // virtual render method when the primitive implementation is BasePrimitive2D-based. 79*cdf0e10cSrcweir virtual void processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir public: 82*cdf0e10cSrcweir AnimatedExtractingProcessor2D( 83*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rViewInformation, 84*cdf0e10cSrcweir bool bTextAnimationAllowed, 85*cdf0e10cSrcweir bool bGraphicAnimationAllowed); 86*cdf0e10cSrcweir virtual ~AnimatedExtractingProcessor2D(); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // data access 89*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; } 90*cdf0e10cSrcweir bool isTextAnimationAllowed() const { return mbTextAnimationAllowed; } 91*cdf0e10cSrcweir bool isGraphicAnimationAllowed() const { return mbGraphicAnimationAllowed; } 92*cdf0e10cSrcweir }; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir AnimatedExtractingProcessor2D::AnimatedExtractingProcessor2D( 95*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rViewInformation, 96*cdf0e10cSrcweir bool bTextAnimationAllowed, 97*cdf0e10cSrcweir bool bGraphicAnimationAllowed) 98*cdf0e10cSrcweir : drawinglayer::processor2d::BaseProcessor2D(rViewInformation), 99*cdf0e10cSrcweir maPrimitive2DSequence(), 100*cdf0e10cSrcweir mbTextAnimationAllowed(bTextAnimationAllowed), 101*cdf0e10cSrcweir mbGraphicAnimationAllowed(bGraphicAnimationAllowed) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir AnimatedExtractingProcessor2D::~AnimatedExtractingProcessor2D() 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir void AnimatedExtractingProcessor2D::processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir // known implementation, access directly 112*cdf0e10cSrcweir switch(rCandidate.getPrimitive2DID()) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir // add and accept animated primitives directly, no need to decompose 115*cdf0e10cSrcweir case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D : 116*cdf0e10cSrcweir case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D : 117*cdf0e10cSrcweir case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D : 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& rSwitchPrimitive = static_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& >(rCandidate); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if((rSwitchPrimitive.isTextAnimation() && isTextAnimationAllowed()) 122*cdf0e10cSrcweir || (rSwitchPrimitive.isGraphicAnimation() && isGraphicAnimationAllowed())) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReference(const_cast< drawinglayer::primitive2d::BasePrimitive2D* >(&rCandidate)); 125*cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xReference); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir break; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir // decompose animated gifs where SdrGrafPrimitive2D produces a GraphicPrimitive2D 131*cdf0e10cSrcweir // which then produces the animation infos (all when used/needed) 132*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D : 133*cdf0e10cSrcweir case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D : 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // decompose SdrObjects with evtl. animated text 136*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D : 137*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D : 138*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D : 139*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D : 140*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D : 141*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D : 142*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D : 143*cdf0e10cSrcweir case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D : 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // decompose evtl. animated text contained in MaskPrimitive2D 146*cdf0e10cSrcweir // or group rimitives 147*cdf0e10cSrcweir case PRIMITIVE2D_ID_MASKPRIMITIVE2D : 148*cdf0e10cSrcweir case PRIMITIVE2D_ID_GROUPPRIMITIVE2D : 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir default : 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir // nothing to do for the rest 157*cdf0e10cSrcweir break; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir } // end of anonymous namespace 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir namespace sdr 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir namespace contact 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir ViewObjectContact::ViewObjectContact(ObjectContact& rObjectContact, ViewContact& rViewContact) 170*cdf0e10cSrcweir : mrObjectContact(rObjectContact), 171*cdf0e10cSrcweir mrViewContact(rViewContact), 172*cdf0e10cSrcweir maObjectRange(), 173*cdf0e10cSrcweir mxPrimitive2DSequence(), 174*cdf0e10cSrcweir mpPrimitiveAnimation(0), 175*cdf0e10cSrcweir mbLazyInvalidate(false) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir // make the ViewContact remember me 178*cdf0e10cSrcweir mrViewContact.AddViewObjectContact(*this); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // make the ObjectContact remember me 181*cdf0e10cSrcweir mrObjectContact.AddViewObjectContact(*this); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir ViewObjectContact::~ViewObjectContact() 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir // invalidate in view 187*cdf0e10cSrcweir if(!maObjectRange.isEmpty()) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir GetObjectContact().InvalidatePartOfView(maObjectRange); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir // delete PrimitiveAnimation 193*cdf0e10cSrcweir if(mpPrimitiveAnimation) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir delete mpPrimitiveAnimation; 196*cdf0e10cSrcweir mpPrimitiveAnimation = 0; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // take care of remebered ObjectContact. Remove from 200*cdf0e10cSrcweir // OC first. The VC removal (below) CAN trigger a StopGettingViewed() 201*cdf0e10cSrcweir // which (depending of it's implementation) may destroy other OCs. This 202*cdf0e10cSrcweir // can trigger the deletion of the helper OC of a page visualising object 203*cdf0e10cSrcweir // which IS the OC of this object. Eventually StopGettingViewed() needs 204*cdf0e10cSrcweir // to get asynchron later 205*cdf0e10cSrcweir GetObjectContact().RemoveViewObjectContact(*this); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // take care of remebered ViewContact 208*cdf0e10cSrcweir GetViewContact().RemoveViewObjectContact(*this); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir const basegfx::B2DRange& ViewObjectContact::getObjectRange() const 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir if(maObjectRange.isEmpty()) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir // if range is not computed (new or LazyInvalidate objects), force it 216*cdf0e10cSrcweir const DisplayInfo aDisplayInfo; 217*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence xSequence(getPrimitive2DSequence(aDisplayInfo)); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir if(xSequence.hasElements()) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); 222*cdf0e10cSrcweir const_cast< ViewObjectContact* >(this)->maObjectRange = 223*cdf0e10cSrcweir drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSequence, rViewInformation2D); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir return maObjectRange; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void ViewObjectContact::ActionChanged() 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if(!mbLazyInvalidate) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir // set local flag 235*cdf0e10cSrcweir mbLazyInvalidate = true; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir // force ObjectRange 238*cdf0e10cSrcweir getObjectRange(); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir if(!maObjectRange.isEmpty()) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir // invalidate current valid range 243*cdf0e10cSrcweir GetObjectContact().InvalidatePartOfView(maObjectRange); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // reset ObjectRange, it needs to be recalculated 246*cdf0e10cSrcweir maObjectRange.reset(); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // register at OC for lazy invalidate 250*cdf0e10cSrcweir GetObjectContact().setLazyInvalidate(*this); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir void ViewObjectContact::triggerLazyInvalidate() 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir if(mbLazyInvalidate) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir // reset flag 259*cdf0e10cSrcweir mbLazyInvalidate = false; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir // force ObjectRange 262*cdf0e10cSrcweir getObjectRange(); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir if(!maObjectRange.isEmpty()) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // invalidate current valid range 267*cdf0e10cSrcweir GetObjectContact().InvalidatePartOfView(maObjectRange); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // Take some action when new objects are inserted 273*cdf0e10cSrcweir void ViewObjectContact::ActionChildInserted(ViewContact& rChild) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir // force creation of the new VOC and trigger it's refresh, so it 276*cdf0e10cSrcweir // will take part in LazyInvalidate immediately 277*cdf0e10cSrcweir rChild.GetViewObjectContact(GetObjectContact()).ActionChanged(); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir // forward action to ObjectContact 280*cdf0e10cSrcweir // const ViewObjectContact& rChildVOC = rChild.GetViewObjectContact(GetObjectContact()); 281*cdf0e10cSrcweir // GetObjectContact().InvalidatePartOfView(rChildVOC.getObjectRange()); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir void ViewObjectContact::checkForPrimitive2DAnimations() 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir // remove old one 287*cdf0e10cSrcweir if(mpPrimitiveAnimation) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir delete mpPrimitiveAnimation; 290*cdf0e10cSrcweir mpPrimitiveAnimation = 0; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir // check for animated primitives 294*cdf0e10cSrcweir if(mxPrimitive2DSequence.hasElements()) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir const bool bTextAnimationAllowed(GetObjectContact().IsTextAnimationAllowed()); 297*cdf0e10cSrcweir const bool bGraphicAnimationAllowed(GetObjectContact().IsGraphicAnimationAllowed()); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir if(bTextAnimationAllowed || bGraphicAnimationAllowed) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir AnimatedExtractingProcessor2D aAnimatedExtractor(GetObjectContact().getViewInformation2D(), 302*cdf0e10cSrcweir bTextAnimationAllowed, bGraphicAnimationAllowed); 303*cdf0e10cSrcweir aAnimatedExtractor.process(mxPrimitive2DSequence); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir if(aAnimatedExtractor.getPrimitive2DSequence().hasElements()) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir // dervied primitiveList is animated, setup new PrimitiveAnimation 308*cdf0e10cSrcweir mpPrimitiveAnimation = new sdr::animation::PrimitiveAnimation(*this, aAnimatedExtractor.getPrimitive2DSequence()); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir // get the view-independent Primitive from the viewContact 317*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval(GetViewContact().getViewIndependentPrimitive2DSequence()); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if(xRetval.hasElements()) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir // handle GluePoint 322*cdf0e10cSrcweir if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible()) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence()); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir if(xGlue.hasElements()) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir // handle ghosted 333*cdf0e10cSrcweir if(isPrimitiveGhosted(rDisplayInfo)) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir const basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); 336*cdf0e10cSrcweir const basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, basegfx::BCOLORMODIFYMODE_INTERPOLATE); 337*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier)); 338*cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir return xRetval; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xNewPrimitiveSequence; 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir // take care of redirectors and create new list 350*cdf0e10cSrcweir ViewObjectContactRedirector* pRedirector = GetObjectContact().GetViewObjectContactRedirector(); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir if(pRedirector) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir xNewPrimitiveSequence = pRedirector->createRedirectedPrimitive2DSequence(*this, rDisplayInfo); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir else 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir xNewPrimitiveSequence = createPrimitive2DSequence(rDisplayInfo); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir // local up-to-date checks. New list different from local one? 362*cdf0e10cSrcweir if(!drawinglayer::primitive2d::arePrimitive2DSequencesEqual(mxPrimitive2DSequence, xNewPrimitiveSequence)) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir // has changed, copy content 365*cdf0e10cSrcweir const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = xNewPrimitiveSequence; 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir // check for animated stuff 368*cdf0e10cSrcweir const_cast< ViewObjectContact* >(this)->checkForPrimitive2DAnimations(); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir // always update object range when PrimitiveSequence changes 371*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); 372*cdf0e10cSrcweir const_cast< ViewObjectContact* >(this)->maObjectRange = 373*cdf0e10cSrcweir drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(mxPrimitive2DSequence, rViewInformation2D); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir // return current Primitive2DSequence 377*cdf0e10cSrcweir return mxPrimitive2DSequence; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir bool ViewObjectContact::isPrimitiveVisible(const DisplayInfo& /*rDisplayInfo*/) const 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir // default: always visible 383*cdf0e10cSrcweir return true; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir bool ViewObjectContact::isPrimitiveGhosted(const DisplayInfo& rDisplayInfo) const 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir // default: standard check 389*cdf0e10cSrcweir return (GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive()); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir // check model-view visibility 397*cdf0e10cSrcweir if(isPrimitiveVisible(rDisplayInfo)) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir xRetval = getPrimitive2DSequence(rDisplayInfo); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if(xRetval.hasElements()) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir // get ranges 404*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); 405*cdf0e10cSrcweir const basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D)); 406*cdf0e10cSrcweir const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport()); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // check geometrical visibility 409*cdf0e10cSrcweir if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange)) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir // not visible, release 412*cdf0e10cSrcweir xRetval.realloc(0); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir return xRetval; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceSubHierarchy(DisplayInfo& rDisplayInfo) const 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount()); 423*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xSeqRetval; 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir for(sal_uInt32 a(0); a < nSubHierarchyCount; a++) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir const ViewObjectContact& rCandidate(GetViewContact().GetViewContact(a).GetViewObjectContact(GetObjectContact())); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xSeqRetval, rCandidate.getPrimitive2DSequenceHierarchy(rDisplayInfo)); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir return xSeqRetval; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir } // end of namespace contact 435*cdf0e10cSrcweir } // end of namespace sdr 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 438*cdf0e10cSrcweir // eof 439