diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-08-19 22:10:56 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-08-19 22:10:56 +0000 |
commit | 2f182a9afce4bece886f9d61398234224c34423a (patch) | |
tree | 5dcb2d949f091ea123ca60ffdb92ceeabdd2d9a3 /svx/source/sdr/contact/viewobjectcontactofgraphic.cxx | |
parent | 58ba15ca8cb7433dfb70b3694edc57d27c89453d (diff) |
INTEGRATION: CWS aw033 (1.1.2); FILE ADDED
2008/08/19 16:46:29 cl 1.1.2.9: fixed license files
2008/07/10 13:00:55 aw 1.1.2.8: #i39532# XOutputDevice removed, PrepareDelete removed
2008/05/27 14:49:58 aw 1.1.2.7: #i39532# changes DEV300 m12 resync corrections
2008/02/26 08:40:52 aw 1.1.2.6: removals, OLE, optimizations for primitives
2008/02/07 14:13:23 aw 1.1.2.5: stable version from working GIT repository for unxlngi6 build
2008/01/22 12:29:30 aw 1.1.2.4: adaptions and 1st stripping
2007/01/23 10:46:32 aw 1.1.2.3: changes after resync
2006/08/09 17:12:26 aw 1.1.2.2: #i39532#
2006/05/12 12:40:55 aw 1.1.2.1: code for primitive support
Diffstat (limited to 'svx/source/sdr/contact/viewobjectcontactofgraphic.cxx')
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofgraphic.cxx | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx new file mode 100644 index 000000000000..351a0dfec734 --- /dev/null +++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: viewobjectcontactofgraphic.cxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <svx/sdr/contact/viewobjectcontactofgraphic.hxx> +#include <svx/sdr/contact/viewcontactofgraphic.hxx> +#include <svx/sdr/event/eventhandler.hxx> +#include <svx/svdograf.hxx> +#include <svx/sdr/contact/objectcontact.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace sdr +{ + namespace event + { + class AsynchGraphicLoadingEvent : public BaseEvent + { + // the ViewContactOfGraphic to work with + sdr::contact::ViewObjectContactOfGraphic& mrVOCOfGraphic; + + public: + // basic constructor. + AsynchGraphicLoadingEvent(EventHandler& rEventHandler, sdr::contact::ViewObjectContactOfGraphic& rVOCOfGraphic); + + // destructor + virtual ~AsynchGraphicLoadingEvent(); + + // the called method if the event is triggered + virtual void ExecuteEvent(); + }; + + AsynchGraphicLoadingEvent::AsynchGraphicLoadingEvent( + EventHandler& rEventHandler, sdr::contact::ViewObjectContactOfGraphic& rVOCOfGraphic) + : BaseEvent(rEventHandler), + mrVOCOfGraphic(rVOCOfGraphic) + { + } + + AsynchGraphicLoadingEvent::~AsynchGraphicLoadingEvent() + { + mrVOCOfGraphic.forgetAsynchGraphicLoadingEvent(this); + } + + void AsynchGraphicLoadingEvent::ExecuteEvent() + { + mrVOCOfGraphic.doAsynchGraphicLoading(); + } + } // end of namespace event +} // end of namespace sdr + +////////////////////////////////////////////////////////////////////////////// + +namespace sdr +{ + namespace contact + { + // Test graphics state and eventually trigger a SwapIn event or an Asynchronous + // load event. Return value gives info if SwapIn was triggered or not + bool ViewObjectContactOfGraphic::impPrepareForPaint() + { + bool bRetval(false); + SdrGrafObj& rGrafObj = getSdrGrafObj(); + + if(rGrafObj.IsSwappedOut()) + { + if(rGrafObj.IsLinkedGraphic()) + { + // update graphic link + rGrafObj.ImpUpdateGraphicLink(); + } + else + { + // SwapIn needs to be done. Decide if it can be done asynchronious. + bool bSwapInAsynchronious(false); + ObjectContact& rObjectContact = GetObjectContact(); + + // only when allowed from configuration + if(rObjectContact.IsAsynchronGraphicsLoadingAllowed()) + { + // direct output or vdev output (PageView buffering) + if(rObjectContact.isOutputToWindow() || rObjectContact.isOutputToVirtualDevice()) + { + // only when no metafile recording + if(!rObjectContact.isOutputToRecordingMetaFile()) + { + // allow asynchronious loading + bSwapInAsynchronious = true; + } + } + } + + if(bSwapInAsynchronious) + { + // maybe it's on the way, then do nothing + if(!mpAsynchLoadEvent) + { + // Trigger asynchronious SwapIn. + sdr::event::TimerEventHandler& rEventHandler = rObjectContact.GetEventHandler(); + + mpAsynchLoadEvent = new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this); + } + } + else + { + if(rObjectContact.isOutputToPrinter()) + { + // #i76395# preview mechanism is only active if + // swapin is called from inside paint preparation, so mbInsidePaint + // has to be false to be able to print with high resolution + rGrafObj.ForceSwapIn(); + } + else + { + // SwapIn direct + rGrafObj.mbInsidePaint = sal_True; + rGrafObj.ForceSwapIn(); + rGrafObj.mbInsidePaint = sal_False; + } + + bRetval = true; + } + } + } + else + { + // it is not swapped out, somehow it was loaded. In that case, forget + // about an existing triggered event + if(mpAsynchLoadEvent) + { + // just delete it, this will remove it from the EventHandler and + // will trigger forgetAsynchGraphicLoadingEvent from the destructor + delete mpAsynchLoadEvent; + } + } + + return bRetval; + } + + // This is the call from the asynch graphic loading. This may only be called from + // AsynchGraphicLoadingEvent::ExecuteEvent(). Do load the graphics. The event will + // be deleted (consumed) and forgetAsynchGraphicLoadingEvent will be called. + void ViewObjectContactOfGraphic::doAsynchGraphicLoading() + { + DBG_ASSERT(mpAsynchLoadEvent, "ViewObjectContactOfGraphic::doAsynchGraphicLoading: I did not trigger a event, why am i called (?)"); + + // swap it in + SdrGrafObj& rGrafObj = getSdrGrafObj(); + rGrafObj.ForceSwapIn(); + + // Invalidate all paint areas and check existing animation (which may have changed). + GetViewContact().ActionChanged(); + } + + // This is the call from the destructor of the asynch graphic loading event. + // No one else has to call this. It is needed to let this object forget about + // the event. The parameter allows checking for the correct event. + void ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent(sdr::event::AsynchGraphicLoadingEvent* pEvent) + { + (void) pEvent; // suppress warning + DBG_ASSERT(mpAsynchLoadEvent, "ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent: I did not trigger a event, why am i called (?)"); + DBG_ASSERT(mpAsynchLoadEvent == pEvent, "ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent: Forced to forget another event then i have scheduled (?)"); + + // forget event + mpAsynchLoadEvent = 0; + } + + SdrGrafObj& ViewObjectContactOfGraphic::getSdrGrafObj() + { + return static_cast< ViewContactOfGraphic& >(GetViewContact()).GetGrafObject(); + } + + drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGraphic::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const + { + // prepare primitive generation with evtl. loading the graphic when it's swapped out + static bool bDoAsyncLoading(false); // ATM taken out + bool bSwapInDone(bDoAsyncLoading ? const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareForPaint() : false); + bool bSwapInExclusiveForPrinting(bSwapInDone && GetObjectContact().isOutputToPrinter()); + + // get return value by calling parent + drawinglayer::primitive2d::Primitive2DSequence xRetval = ViewObjectContactOfSdrObj::createPrimitive2DSequence(rDisplayInfo); + + // if swap in was forced only for printing, swap out again + if(bSwapInExclusiveForPrinting) + { + const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj().ForceSwapOut(); + } + + return xRetval; + } + + ViewObjectContactOfGraphic::ViewObjectContactOfGraphic(ObjectContact& rObjectContact, ViewContact& rViewContact) + : ViewObjectContactOfSdrObj(rObjectContact, rViewContact), + mpAsynchLoadEvent(0) + { + } + + ViewObjectContactOfGraphic::~ViewObjectContactOfGraphic() + { + // evtl. delete the asynch loading event + if(mpAsynchLoadEvent) + { + // just delete it, this will remove it from the EventHandler and + // will trigger forgetAsynchGraphicLoadingEvent from the destructor + delete mpAsynchLoadEvent; + } + } + } // end of namespace contact +} // end of namespace sdr + +////////////////////////////////////////////////////////////////////////////// +// eof |