summaryrefslogtreecommitdiff
path: root/svx/source/sdr/overlay/overlaymanager.cxx
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2006-11-14 12:34:01 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2006-11-14 12:34:01 +0000
commit97054951597fa657a5ed46241320ee5d2c96e485 (patch)
treee954ec73b1c4771cf3260b7d653ff141133deb3c /svx/source/sdr/overlay/overlaymanager.cxx
parent64daa8b7f03450d0f1672a4bc7cbca9ebc848c4e (diff)
INTEGRATION: CWS aw024 (1.1.4); FILE ADDED
2006/10/27 12:14:05 aw 1.1.4.5: #i39528# ::basegfx -> basegfx adaption 2006/07/27 15:34:34 aw 1.1.4.4: #114408# adaptions for SC 2006/07/07 16:03:14 aw 1.1.4.3: adaptions after resync SRC680m171->SRC680m174 2005/09/22 12:11:42 aw 1.1.4.2: #i39529# removed SISSL from headers 2005/05/19 12:26:47 aw 1.1.4.1: #i39529#
Diffstat (limited to 'svx/source/sdr/overlay/overlaymanager.cxx')
-rw-r--r--svx/source/sdr/overlay/overlaymanager.cxx303
1 files changed, 303 insertions, 0 deletions
diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx
new file mode 100644
index 000000000000..c2419480a63f
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaymanager.cxx
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: overlaymanager.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: ihi $ $Date: 2006-11-14 13:34:01 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef _SDR_OVERLAY_OVERLAYMANAGER_HXX
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#endif
+
+#ifndef _BGFX_POINT_B2DPOINT_HXX
+#include <basegfx/point/b2dpoint.hxx>
+#endif
+
+#ifndef _BGFX_RANGE_B2DRANGE_HXX
+#include <basegfx/range/b2drange.hxx>
+#endif
+
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+
+#ifndef _SV_SALBTYPE_HXX
+#include <vcl/salbtype.hxx>
+#endif
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+#ifndef _SV_WINDOW_HXX
+#include <vcl/window.hxx>
+#endif
+
+#ifndef _SDR_OVERLAY_OVERLAYOBJECT_HXX
+#include <svx/sdr/overlay/overlayobject.hxx>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ void OverlayManager::ImpDrawMembers(const basegfx::B2DRange& rRange, OutputDevice& rDestinationDevice) const
+ {
+ ::sdr::overlay::OverlayObject* pCurrent = mpOverlayObjectStart;
+
+ while(pCurrent)
+ {
+ if(pCurrent->isVisible())
+ {
+ if(rRange.overlaps(pCurrent->getBaseRange()))
+ {
+ pCurrent->drawGeometry(rDestinationDevice);
+ }
+ }
+
+ pCurrent = pCurrent->mpNext;
+ }
+ }
+
+ void OverlayManager::ImpCheckMapModeChange() const
+ {
+ sal_Bool bZoomHasChanged(sal_False);
+ MapMode aOutputDeviceMapMode(getOutputDevice().GetMapMode());
+ ::sdr::overlay::OverlayObject* pCurrent = mpOverlayObjectStart;
+
+ if(maMapMode != aOutputDeviceMapMode)
+ {
+ bZoomHasChanged = (
+ maMapMode.GetScaleX() != aOutputDeviceMapMode.GetScaleX()
+ || maMapMode.GetScaleY() != aOutputDeviceMapMode.GetScaleY());
+
+ // remember MapMode
+ ((OverlayManager*)this)->maMapMode = aOutputDeviceMapMode;
+ }
+
+ if(bZoomHasChanged && pCurrent)
+ {
+ while(pCurrent)
+ {
+ pCurrent->zoomHasChanged();
+ pCurrent = pCurrent->mpNext;
+ }
+ }
+ }
+
+ void OverlayManager::ImpStripeDefinitionChanged()
+ {
+ ::sdr::overlay::OverlayObject* pCurrent = mpOverlayObjectStart;
+
+ while(pCurrent)
+ {
+ pCurrent->stripeDefinitionHasChanged();
+ pCurrent = pCurrent->mpNext;
+ }
+ }
+
+ OverlayManager::OverlayManager(OutputDevice& rOutputDevice)
+ : Scheduler(),
+ rmOutputDevice(rOutputDevice),
+ mpOverlayObjectStart(0L),
+ mpOverlayObjectEnd(0L),
+ maStripeColorA(Color(COL_BLACK)),
+ maStripeColorB(Color(COL_WHITE)),
+ mnStripeLengthPixel(5L)
+ {
+ }
+
+ OverlayManager::~OverlayManager()
+ {
+ // the OverlayManager is not the owner of the OverlayObjects
+ // and thus will not delete them, but remove them.
+ while(mpOverlayObjectStart)
+ {
+ remove(*mpOverlayObjectStart);
+ }
+ }
+
+ void OverlayManager::completeRedraw(const Region& rRegion, OutputDevice* pPreRenderDevice) const
+ {
+ if(!rRegion.IsEmpty() && mpOverlayObjectStart)
+ {
+ // check for changed MapModes. That may influence the
+ // logical size of pixel based OverlayObjects (like BitmapHandles)
+ ImpCheckMapModeChange();
+
+ // paint members
+ const Rectangle aRegionBoundRect(rRegion.GetBoundRect());
+ const basegfx::B2DRange aRegionRange(
+ aRegionBoundRect.Left(), aRegionBoundRect.Top(),
+ aRegionBoundRect.Right(), aRegionBoundRect.Bottom());
+
+ OutputDevice& rTarget = (pPreRenderDevice) ? *pPreRenderDevice : getOutputDevice();
+ ImpDrawMembers(aRegionRange, rTarget);
+ }
+ }
+
+ void OverlayManager::flush()
+ {
+ // default has nothing to do
+ }
+
+ void OverlayManager::restoreBackground(const Region& /*rRegion*/) const
+ {
+ // unbuffered versions do nothing here
+ }
+
+ void OverlayManager::add(OverlayObject& rOverlayObject)
+ {
+ // add to the end of chain to preserve display order in paint
+ DBG_ASSERT(0L == rOverlayObject.mpOverlayManager,
+ "OverlayManager::add: OverlayObject is added to an OverlayManager (!)");
+
+ if(mpOverlayObjectEnd)
+ {
+ // new element, add to end
+ rOverlayObject.mpNext = mpOverlayObjectEnd->mpNext;
+ rOverlayObject.mpPrevious = mpOverlayObjectEnd;
+ mpOverlayObjectEnd->mpNext = &rOverlayObject;
+ mpOverlayObjectEnd = &rOverlayObject;
+ }
+ else
+ {
+ // first element
+ rOverlayObject.mpNext = rOverlayObject.mpPrevious = 0L;
+ mpOverlayObjectEnd = mpOverlayObjectStart = &rOverlayObject;
+ }
+
+ // set manager
+ rOverlayObject.mpOverlayManager = this;
+
+ // make visible
+ invalidateRange(rOverlayObject.getBaseRange());
+
+ // handle evtl. animation
+ if(rOverlayObject.allowsAnimation())
+ {
+ InsertEvent(&rOverlayObject);
+ Execute();
+ }
+ }
+
+ void OverlayManager::remove(OverlayObject& rOverlayObject)
+ {
+ // handle evtl. animation
+ if(rOverlayObject.allowsAnimation())
+ {
+ // remove from event chain
+ RemoveEvent(&rOverlayObject);
+ }
+
+ // Remove from chain
+ DBG_ASSERT(rOverlayObject.mpOverlayManager == this,
+ "OverlayManager::remove: OverlayObject is removed from wrong OverlayManager (!)");
+
+ if(rOverlayObject.mpPrevious)
+ {
+ rOverlayObject.mpPrevious->mpNext = rOverlayObject.mpNext;
+ }
+
+ if(rOverlayObject.mpNext)
+ {
+ rOverlayObject.mpNext->mpPrevious = rOverlayObject.mpPrevious;
+ }
+
+ if(&rOverlayObject == mpOverlayObjectStart)
+ {
+ mpOverlayObjectStart = rOverlayObject.mpNext;
+ }
+
+ if(&rOverlayObject == mpOverlayObjectEnd)
+ {
+ mpOverlayObjectEnd = rOverlayObject.mpPrevious;
+ }
+
+ // make invisible
+ invalidateRange(rOverlayObject.getBaseRange());
+
+ // clear manager
+ rOverlayObject.mpOverlayManager = 0L;
+ }
+
+ void OverlayManager::invalidateRange(const basegfx::B2DRange& rRange)
+ {
+ if(OUTDEV_WINDOW == getOutputDevice().GetOutDevType())
+ {
+ // transform to rectangle
+ const basegfx::B2DPoint aMinimum(rRange.getMinimum());
+ const basegfx::B2DPoint aMaximum(rRange.getMaximum());
+ const Rectangle aInvalidateRectangle(
+ FRound(aMinimum.getX()), FRound(aMinimum.getY()),
+ FRound(aMaximum.getX()), FRound(aMaximum.getY()));
+
+ // simply invalidate
+ ((Window&)getOutputDevice()).Invalidate(aInvalidateRectangle, INVALIDATE_NOERASE);
+ }
+ }
+
+ // stripe support ColA
+ void OverlayManager::setStripeColorA(Color aNew)
+ {
+ if(aNew != maStripeColorA)
+ {
+ maStripeColorA = aNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+
+ // stripe support ColB
+ void OverlayManager::setStripeColorB(Color aNew)
+ {
+ if(aNew != maStripeColorB)
+ {
+ maStripeColorB = aNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+
+ // stripe support StripeLengthPixel
+ void OverlayManager::setStripeLengthPixel(sal_uInt32 nNew)
+ {
+ if(nNew != mnStripeLengthPixel)
+ {
+ mnStripeLengthPixel = nNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof