2004-07-13 13:28:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* $RCSfile: SlsViewOverlay.cxx,v $
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-03 13:45:26 +00:00
|
|
|
* $Revision: 1.15 $
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-03 13:45:26 +00:00
|
|
|
* last change: $Author: kz $ $Date: 2008-04-03 14:45:26 $
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* 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.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* 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.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2005-09-09 05:28:25 +00:00
|
|
|
* 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
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 18:11:43 +00:00
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-07-13 13:28:36 +00:00
|
|
|
#include "view/SlsViewOverlay.hxx"
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
#include "SlideSorter.hxx"
|
2004-07-13 13:28:36 +00:00
|
|
|
#include "model/SlideSorterModel.hxx"
|
|
|
|
#include "model/SlsPageDescriptor.hxx"
|
|
|
|
#include "model/SlsPageEnumeration.hxx"
|
|
|
|
#include "view/SlideSorterView.hxx"
|
|
|
|
#include "SlideSorterViewShell.hxx"
|
|
|
|
#include "view/SlsLayouter.hxx"
|
|
|
|
#include "view/SlsPageObject.hxx"
|
2004-09-20 12:35:48 +00:00
|
|
|
#include "view/SlsPageObjectViewObjectContact.hxx"
|
2008-04-03 13:45:26 +00:00
|
|
|
#include "ViewShell.hxx"
|
2005-03-30 08:26:35 +00:00
|
|
|
#include "ViewShellBase.hxx"
|
|
|
|
#include "UpdateLockManager.hxx"
|
2004-07-13 13:28:36 +00:00
|
|
|
|
|
|
|
#include "Window.hxx"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
#include <basegfx/range/b2drectangle.hxx>
|
|
|
|
#include <basegfx/range/b2drange.hxx>
|
|
|
|
#include <basegfx/matrix/b2dhommatrix.hxx>
|
|
|
|
#include <basegfx/polygon/b2dpolygon.hxx>
|
|
|
|
#include <basegfx/polygon/b2dpolygontools.hxx>
|
|
|
|
#include <basegfx/polygon/b2dpolypolygontools.hxx>
|
|
|
|
#include <svx/sdr/overlay/overlaymanager.hxx>
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
#include <svx/sdrpagewindow.hxx>
|
2006-11-14 13:37:02 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
using namespace ::sdr::overlay;
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
namespace {
|
|
|
|
const static sal_Int32 gnSubstitutionStripeLength (3);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace sd { namespace slidesorter { namespace view {
|
|
|
|
|
|
|
|
//===== ViewOverlay =========================================================
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
ViewOverlay::ViewOverlay (SlideSorter& rSlideSorter)
|
|
|
|
: mrSlideSorter(rSlideSorter),
|
2004-07-13 13:28:36 +00:00
|
|
|
maSelectionRectangleOverlay(*this),
|
2008-04-03 13:45:26 +00:00
|
|
|
maMouseOverIndicatorOverlay(*this),
|
|
|
|
maInsertionIndicatorOverlay(*this),
|
2008-02-12 15:29:19 +00:00
|
|
|
maSubstitutionOverlay(*this)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ViewOverlay::~ViewOverlay (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SelectionRectangleOverlay& ViewOverlay::GetSelectionRectangleOverlay (void)
|
|
|
|
{
|
|
|
|
return maSelectionRectangleOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:48 +00:00
|
|
|
MouseOverIndicatorOverlay& ViewOverlay::GetMouseOverIndicatorOverlay (void)
|
|
|
|
{
|
|
|
|
return maMouseOverIndicatorOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-13 13:28:36 +00:00
|
|
|
InsertionIndicatorOverlay& ViewOverlay::GetInsertionIndicatorOverlay (void)
|
|
|
|
{
|
|
|
|
return maInsertionIndicatorOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubstitutionOverlay& ViewOverlay::GetSubstitutionOverlay (void)
|
|
|
|
{
|
|
|
|
return maSubstitutionOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
SlideSorter& ViewOverlay::GetSlideSorter (void) const
|
|
|
|
{
|
|
|
|
return mrSlideSorter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
OverlayManager* ViewOverlay::GetOverlayManager (void) const
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
OverlayManager* pOverlayManager = NULL;
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
SlideSorterView& rView (mrSlideSorter.GetView());
|
2008-02-12 15:29:19 +00:00
|
|
|
SdrPageView* pPageView = rView.GetSdrPageView();
|
|
|
|
if (pPageView != NULL && pPageView->PageWindowCount()>0)
|
2004-11-26 14:13:08 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0);
|
|
|
|
if (pPageWindow != NULL)
|
|
|
|
pOverlayManager = pPageWindow->GetOverlayManager();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
return pOverlayManager;
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== OverlayBase =========================================================
|
|
|
|
|
|
|
|
OverlayBase::OverlayBase (ViewOverlay& rViewOverlay)
|
2008-02-12 15:29:19 +00:00
|
|
|
: OverlayObject(Color(0,0,0)),
|
|
|
|
mrViewOverlay(rViewOverlay)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
setVisible(false);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OverlayBase::~OverlayBase (void)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
OverlayManager* pOverlayManager = getOverlayManager();
|
|
|
|
if (pOverlayManager != NULL)
|
|
|
|
pOverlayManager->remove(*this);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OverlayBase::Paint (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool OverlayBase::IsShowing (void)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
return isVisible();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OverlayBase::Toggle (void)
|
|
|
|
{
|
|
|
|
if (IsShowing())
|
|
|
|
Hide();
|
|
|
|
else
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OverlayBase::Show (void)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
setVisible(true);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OverlayBase::Hide (void)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
setVisible(false);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-02-17 08:45:04 +00:00
|
|
|
ViewOverlay& OverlayBase::GetViewOverlay (void)
|
|
|
|
{
|
|
|
|
return mrViewOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void OverlayBase::transform (const basegfx::B2DHomMatrix& rMatrix)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
(void)rMatrix;
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void OverlayBase::EnsureRegistration (void)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
if (getOverlayManager() == NULL)
|
|
|
|
{
|
|
|
|
OverlayManager* pOverlayManager = mrViewOverlay.GetOverlayManager();
|
|
|
|
if (pOverlayManager != NULL)
|
|
|
|
pOverlayManager->add(*this);
|
|
|
|
}
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
//===== SubstitutionOverlay =================================================
|
|
|
|
|
|
|
|
SubstitutionOverlay::SubstitutionOverlay (ViewOverlay& rViewOverlay)
|
|
|
|
: OverlayBase(rViewOverlay),
|
|
|
|
maPosition(0,0),
|
|
|
|
maBoundingBox(),
|
|
|
|
maShapes()
|
2008-04-03 13:45:26 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
}
|
2004-07-13 13:28:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
|
|
|
|
SubstitutionOverlay::~SubstitutionOverlay (void)
|
|
|
|
{
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubstitutionOverlay::Create (
|
|
|
|
model::PageEnumeration& rSelection,
|
|
|
|
const Point& rPosition)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
EnsureRegistration();
|
|
|
|
|
2004-07-13 13:28:36 +00:00
|
|
|
maPosition = rPosition;
|
|
|
|
|
|
|
|
maShapes.clear();
|
|
|
|
while (rSelection.HasMoreElements())
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
const Rectangle aBox (rSelection.GetNextElement()->GetPageObject()->GetCurrentBoundRect());
|
|
|
|
basegfx::B2DRectangle aB2DBox(
|
|
|
|
aBox.Left(),
|
|
|
|
aBox.Top(),
|
|
|
|
aBox.Right(),
|
|
|
|
aBox.Bottom());
|
|
|
|
maShapes.append(basegfx::tools::createPolygonFromRect(aB2DBox), 4);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
2008-04-03 13:45:26 +00:00
|
|
|
maBoundingBox = basegfx::tools::getRange(maShapes);
|
2008-02-12 15:29:19 +00:00
|
|
|
|
|
|
|
setVisible(maShapes.count() > 0);
|
|
|
|
// The selection indicator may have been visible already so call
|
|
|
|
// objectChange() to enforce an update.
|
|
|
|
objectChange();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubstitutionOverlay::Clear (void)
|
|
|
|
{
|
|
|
|
maShapes.clear();
|
2008-02-12 15:29:19 +00:00
|
|
|
maBoundingBox = basegfx::B2DRange();
|
|
|
|
setVisible(false);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubstitutionOverlay::Move (const Point& rOffset)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
basegfx::B2DHomMatrix aTranslation;
|
|
|
|
aTranslation.translate(rOffset.X(), rOffset.Y());
|
|
|
|
maShapes.transform(aTranslation);
|
|
|
|
maBoundingBox.transform(aTranslation);
|
|
|
|
|
|
|
|
maPosition += rOffset;
|
|
|
|
|
|
|
|
objectChange();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubstitutionOverlay::SetPosition (const Point& rPosition)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
Move(rPosition - maPosition);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void SubstitutionOverlay::drawGeometry (OutputDevice& rOutputDevice)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
if (getOverlayManager() != NULL)
|
|
|
|
{
|
|
|
|
const sal_uInt32 nOldStripeLength (getOverlayManager()->getStripeLengthPixel());
|
|
|
|
getOverlayManager()->setStripeLengthPixel(gnSubstitutionStripeLength);
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
const sal_uInt32 nCount (maShapes.count());
|
|
|
|
for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
|
|
|
|
ImpDrawPolygonStriped(rOutputDevice, maShapes.getB2DPolygon(nIndex));
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
getOverlayManager()->setStripeLengthPixel(nOldStripeLength);
|
|
|
|
}
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void SubstitutionOverlay::createBaseRange (OutputDevice& rOutputDevice)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
(void)rOutputDevice;
|
|
|
|
|
|
|
|
maBaseRange = maBoundingBox;
|
2004-11-26 14:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
Point SubstitutionOverlay::GetPosition (void) const
|
2004-11-26 14:13:08 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
return maPosition;
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
//===== SelectionRectangleOverlay ===========================================
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
SelectionRectangleOverlay::SelectionRectangleOverlay (ViewOverlay& rViewOverlay)
|
2008-02-12 15:29:19 +00:00
|
|
|
: OverlayBase (rViewOverlay),
|
|
|
|
maAnchor(0,0),
|
|
|
|
maSecondCorner(0,0)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2004-11-26 14:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
|
2004-11-26 14:13:08 +00:00
|
|
|
Rectangle SelectionRectangleOverlay::GetSelectionRectangle (void)
|
|
|
|
{
|
|
|
|
return Rectangle(maAnchor, maSecondCorner);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectionRectangleOverlay::Start (const Point& rAnchor)
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
EnsureRegistration();
|
|
|
|
setVisible(false);
|
2004-11-26 14:13:08 +00:00
|
|
|
maAnchor = rAnchor;
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-26 14:13:08 +00:00
|
|
|
void SelectionRectangleOverlay::Update (const Point& rSecondCorner)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2004-11-26 14:13:08 +00:00
|
|
|
maSecondCorner = rSecondCorner;
|
2008-02-12 15:29:19 +00:00
|
|
|
setVisible(true);
|
|
|
|
// The selection rectangle may have been visible already so call
|
|
|
|
// objectChange() to enforce an update.
|
|
|
|
objectChange();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void SelectionRectangleOverlay::drawGeometry (OutputDevice& rOutputDevice)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
ImpDrawRangeStriped(
|
|
|
|
rOutputDevice,
|
|
|
|
basegfx::B2DRange(
|
|
|
|
maAnchor.X(),
|
|
|
|
maAnchor.Y(),
|
|
|
|
maSecondCorner.X(),
|
|
|
|
maSecondCorner.Y()));
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void SelectionRectangleOverlay::createBaseRange (OutputDevice& rOutputDevice)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
(void)rOutputDevice;
|
|
|
|
maBaseRange = basegfx::B2DRange(
|
|
|
|
maAnchor.X(),
|
|
|
|
maAnchor.Y(),
|
|
|
|
maSecondCorner.X(),
|
|
|
|
maSecondCorner.Y());
|
|
|
|
}
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== InsertionIndicatorOverlay ===========================================
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
InsertionIndicatorOverlay::InsertionIndicatorOverlay (ViewOverlay& rViewOverlay)
|
2008-02-12 15:29:19 +00:00
|
|
|
: OverlayBase (rViewOverlay),
|
|
|
|
mnInsertionIndex(-1),
|
|
|
|
maBoundingBox()
|
|
|
|
{
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void InsertionIndicatorOverlay::SetPositionAndSize (const Rectangle& aNewBoundingBox)
|
2004-07-13 13:28:36 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
EnsureRegistration();
|
|
|
|
maBoundingBox = aNewBoundingBox;
|
|
|
|
setVisible( ! maBoundingBox.IsEmpty());
|
|
|
|
// The insertion indicator may have been visible already so call
|
|
|
|
// objectChange() to enforce an update.
|
|
|
|
objectChange();
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsertionIndicatorOverlay::SetPosition (const Point& rPoint)
|
|
|
|
{
|
|
|
|
static const bool bAllowHorizontalInsertMarker = true;
|
2008-04-03 13:45:26 +00:00
|
|
|
Layouter& rLayouter (mrViewOverlay.GetSlideSorter().GetView().GetLayouter());
|
2004-07-13 13:28:36 +00:00
|
|
|
USHORT nPageCount
|
2008-04-03 13:45:26 +00:00
|
|
|
= (USHORT)mrViewOverlay.GetSlideSorter().GetModel().GetPageCount();
|
2004-07-13 13:28:36 +00:00
|
|
|
|
|
|
|
sal_Int32 nInsertionIndex = rLayouter.GetInsertionIndex (rPoint,
|
|
|
|
bAllowHorizontalInsertMarker);
|
|
|
|
if (nInsertionIndex >= nPageCount)
|
|
|
|
nInsertionIndex = nPageCount-1;
|
|
|
|
sal_Int32 nDrawIndex = nInsertionIndex;
|
|
|
|
|
|
|
|
bool bVertical = false;
|
|
|
|
bool bLeftOrTop = false;
|
|
|
|
if (nInsertionIndex >= 0)
|
|
|
|
{
|
|
|
|
// Now that we know where to insert, we still have to determine
|
|
|
|
// where to draw the marker. There are two decisions to make:
|
|
|
|
// 1. Draw a vertical or a horizontal insert marker.
|
|
|
|
// The horizontal one may only be chosen when there is only one
|
|
|
|
// column.
|
|
|
|
// 2. The vertical (standard) insert marker may be painted left to
|
|
|
|
// the insert page or right of the previous one. When both pages
|
|
|
|
// are in the same row this makes no difference. Otherwise the
|
|
|
|
// posiotions are at the left and right ends of two rows.
|
|
|
|
|
|
|
|
Point aPageCenter (rLayouter.GetPageObjectBox (
|
|
|
|
nInsertionIndex).Center());
|
|
|
|
|
|
|
|
if (bAllowHorizontalInsertMarker
|
|
|
|
&& rLayouter.GetColumnCount() == 1)
|
|
|
|
{
|
|
|
|
bVertical = false;
|
|
|
|
bLeftOrTop = (rPoint.Y() <= aPageCenter.Y());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bVertical = true;
|
|
|
|
bLeftOrTop = (rPoint.X() <= aPageCenter.X());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add one when the mark was painted below or to the right of the
|
|
|
|
// page object.
|
|
|
|
if ( ! bLeftOrTop)
|
|
|
|
nInsertionIndex += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mnInsertionIndex = nInsertionIndex;
|
|
|
|
|
|
|
|
Rectangle aBox;
|
|
|
|
if (mnInsertionIndex >= 0)
|
|
|
|
aBox = rLayouter.GetInsertionMarkerBox (
|
|
|
|
nDrawIndex,
|
|
|
|
bVertical,
|
|
|
|
bLeftOrTop);
|
|
|
|
SetPositionAndSize (aBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 InsertionIndicatorOverlay::GetInsertionPageIndex (void) const
|
|
|
|
{
|
|
|
|
return mnInsertionIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:48 +00:00
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void InsertionIndicatorOverlay::drawGeometry (OutputDevice& rOutputDevice)
|
|
|
|
{
|
|
|
|
const Color aFillColor (rOutputDevice.GetFillColor());
|
|
|
|
const Color aLineColor (rOutputDevice.GetLineColor());
|
|
|
|
|
|
|
|
if (isVisible())
|
|
|
|
{
|
|
|
|
const Color aColor (rOutputDevice.GetSettings().GetStyleSettings().GetFontColor());
|
|
|
|
rOutputDevice.SetLineColor(aColor);
|
|
|
|
rOutputDevice.SetFillColor(aColor);
|
|
|
|
rOutputDevice.DrawRect (maBoundingBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
rOutputDevice.SetFillColor(aFillColor);
|
|
|
|
rOutputDevice.SetLineColor(aLineColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsertionIndicatorOverlay::createBaseRange (OutputDevice& rOutputDevice)
|
|
|
|
{
|
|
|
|
(void)rOutputDevice;
|
|
|
|
const sal_Int32 nBorder (10);
|
|
|
|
maBaseRange = basegfx::B2DRange(
|
|
|
|
maBoundingBox.Left()-nBorder,
|
|
|
|
maBoundingBox.Top()-nBorder,
|
|
|
|
maBoundingBox.Right()-nBorder,
|
|
|
|
maBoundingBox.Bottom()-nBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:48 +00:00
|
|
|
//===== MouseOverIndicatorOverlay ===========================================
|
|
|
|
|
2008-04-03 13:45:26 +00:00
|
|
|
MouseOverIndicatorOverlay::MouseOverIndicatorOverlay (ViewOverlay& rViewOverlay)
|
2004-09-20 12:35:48 +00:00
|
|
|
: OverlayBase (rViewOverlay),
|
2006-04-06 15:28:14 +00:00
|
|
|
mpPageUnderMouse()
|
2004-09-20 12:35:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
MouseOverIndicatorOverlay::~MouseOverIndicatorOverlay (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:48 +00:00
|
|
|
void MouseOverIndicatorOverlay::SetSlideUnderMouse (
|
2006-04-06 15:28:14 +00:00
|
|
|
const model::SharedPageDescriptor& rpDescriptor)
|
2004-09-20 12:35:48 +00:00
|
|
|
{
|
2008-04-03 13:45:26 +00:00
|
|
|
ViewShellBase* pBase = mrViewOverlay.GetSlideSorter().GetViewShellBase();
|
|
|
|
if (pBase==NULL || ! pBase->GetUpdateLockManager()->IsLocked())
|
2006-04-06 15:28:14 +00:00
|
|
|
{
|
|
|
|
model::SharedPageDescriptor pDescriptor;
|
|
|
|
if ( ! mpPageUnderMouse.expired())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
pDescriptor = model::SharedPageDescriptor(mpPageUnderMouse);
|
|
|
|
}
|
|
|
|
catch (::boost::bad_weak_ptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDescriptor != rpDescriptor)
|
2005-03-30 08:26:35 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
// Switch to the new (possibly empty) descriptor.
|
2006-04-06 15:28:14 +00:00
|
|
|
mpPageUnderMouse = rpDescriptor;
|
2008-02-12 15:29:19 +00:00
|
|
|
|
|
|
|
EnsureRegistration();
|
|
|
|
|
|
|
|
// Show the indicator when a valid page descriptor is given.
|
|
|
|
setVisible( ! mpPageUnderMouse.expired());
|
|
|
|
// The mouse over indicator may have been visible already so call
|
|
|
|
// objectChange() to enforce an update.
|
|
|
|
objectChange();
|
2005-03-30 08:26:35 +00:00
|
|
|
}
|
2006-04-06 15:28:14 +00:00
|
|
|
}
|
2004-09-20 12:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
void MouseOverIndicatorOverlay::drawGeometry (OutputDevice& rOutputDevice)
|
2004-09-20 12:35:48 +00:00
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
const Color aFillColor (rOutputDevice.GetFillColor());
|
|
|
|
const Color aLineColor (rOutputDevice.GetLineColor());
|
2006-04-06 15:28:14 +00:00
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
view::PageObjectViewObjectContact* pContact = GetViewObjectContact();
|
|
|
|
if (pContact != NULL)
|
|
|
|
pContact->PaintMouseOverEffect(rOutputDevice, true);
|
|
|
|
|
|
|
|
rOutputDevice.SetFillColor(aFillColor);
|
|
|
|
rOutputDevice.SetLineColor(aLineColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MouseOverIndicatorOverlay::createBaseRange (OutputDevice& rOutputDevice)
|
|
|
|
{
|
|
|
|
(void)rOutputDevice;
|
|
|
|
view::PageObjectViewObjectContact* pContact = GetViewObjectContact();
|
|
|
|
if (pContact != NULL)
|
|
|
|
{
|
|
|
|
Rectangle aBox (pContact->GetBoundingBox(
|
|
|
|
rOutputDevice,
|
|
|
|
view::PageObjectViewObjectContact::MouseOverIndicatorBoundingBox,
|
|
|
|
view::PageObjectViewObjectContact::ModelCoordinateSystem));
|
|
|
|
maBaseRange = basegfx::B2DRange(aBox.Left(),aBox.Top(),aBox.Right(),aBox.Bottom());
|
2004-09-20 12:35:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:19 +00:00
|
|
|
view::PageObjectViewObjectContact* MouseOverIndicatorOverlay::GetViewObjectContact (void) const
|
|
|
|
{
|
|
|
|
if ( ! mpPageUnderMouse.expired())
|
|
|
|
{
|
|
|
|
model::SharedPageDescriptor pDescriptor (mpPageUnderMouse);
|
|
|
|
return pDescriptor->GetViewObjectContact();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:48 +00:00
|
|
|
|
2004-07-13 13:28:36 +00:00
|
|
|
} } } // end of namespace ::sd::slidesorter::view
|
2008-02-12 15:29:19 +00:00
|
|
|
|