2004-07-13 13:28:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* $RCSfile: SlsViewOverlay.cxx,v $
|
|
|
|
* $Revision: 1.16 $
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* 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.
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* 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).
|
2004-07-13 13:28:36 +00:00
|
|
|
*
|
2008-04-10 21:17:21 +00:00
|
|
|
* 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.
|
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>
|
2009-05-07 12:38:03 +00:00
|
|
|
#include <basegfx/range/b2irange.hxx>
|
2008-02-12 15:29:19 +00:00
|
|
|
#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;
|
2009-05-07 12:38:03 +00:00
|
|
|
maTranslation = Point(0,0);
|
2004-07-13 13:28:36 +00:00
|
|
|
|
|
|
|
maShapes.clear();
|
|
|
|
while (rSelection.HasMoreElements())
|
|
|
|
{
|
2008-02-12 15:29:19 +00:00
|
|
|
const Rectangle aBox (rSelection.GetNextElement()->GetPageObject()->GetCurrentBoundRect());
|
2009-05-07 12:38:03 +00:00
|
|
|
maShapes.push_back(aBox);
|
|
|
|
maBoundingBox.Union(aBox);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
2008-02-12 15:29:19 +00:00
|
|
|
|
2009-05-07 12:38:03 +00:00
|
|
|
setVisible(maShapes.size() > 0);
|
2008-02-12 15:29:19 +00:00
|
|
|
// 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();
|
2009-05-07 12:38:03 +00:00
|
|
|
maBoundingBox.SetEmpty();
|
2008-02-12 15:29:19 +00:00
|
|
|
setVisible(false);
|
2004-07-13 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubstitutionOverlay::Move (const Point& rOffset)
|
|
|
|
{
|
2009-05-07 12:38:03 +00:00
|
|
|
maTranslation += rOffset;
|
|
|
|
maBoundingBox.Move(rOffset.X(), rOffset.Y());
|
2008-02-12 15:29:19 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2009-05-07 12:38:03 +00:00
|
|
|
const sal_uInt32 nSavedStripeLength (getOverlayManager()->getStripeLengthPixel());
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2009-05-07 12:38:03 +00:00
|
|
|
for (::std::vector<Rectangle>::const_iterator
|
|
|
|
iBox (maShapes.begin()),
|
|
|
|
iEnd (maShapes.end());
|
|
|
|
iBox!=iEnd;
|
|
|
|
++iBox)
|
|
|
|
{
|
|
|
|
// Reduce width and height by one pixel to make the box the same
|
|
|
|
// size as the frame of the page object.
|
|
|
|
Rectangle aScreenBox (rOutputDevice.LogicToPixel(*iBox));
|
|
|
|
aScreenBox.Right() -= 1;
|
|
|
|
aScreenBox.Bottom() -= 1;
|
|
|
|
|
|
|
|
// Add accumulated translation.
|
|
|
|
Rectangle aBox (rOutputDevice.PixelToLogic(aScreenBox));
|
|
|
|
aBox.Move(maTranslation.X(), maTranslation.Y());
|
|
|
|
|
|
|
|
ImpDrawPolygonStriped(rOutputDevice,
|
|
|
|
basegfx::tools::createPolygonFromRect(
|
|
|
|
basegfx::B2DRange(
|
|
|
|
basegfx::B2IRange(aBox.Left(), aBox.Top(), aBox.Right(),aBox.Bottom()))));
|
|
|
|
}
|
2004-07-13 13:28:36 +00:00
|
|
|
|
2009-05-07 12:38:03 +00:00
|
|
|
getOverlayManager()->setStripeLengthPixel(nSavedStripeLength);
|
2008-02-12 15:29:19 +00:00
|
|
|
}
|
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;
|
|
|
|
|
2009-05-07 12:38:03 +00:00
|
|
|
maBaseRange = basegfx::B2DRange(
|
|
|
|
basegfx::B2IRange(
|
|
|
|
maBoundingBox.Left(),
|
|
|
|
maBoundingBox.Top(),
|
|
|
|
maBoundingBox.Right(),
|
|
|
|
maBoundingBox.Bottom()));
|
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);
|
2009-05-07 12:38:03 +00:00
|
|
|
|
|
|
|
// Reduce width of indicator by one pixel to be of the same width as
|
|
|
|
// the page objects.
|
|
|
|
Rectangle aBox (rOutputDevice.LogicToPixel(maBoundingBox));
|
|
|
|
aBox.Right() -= 1;
|
|
|
|
rOutputDevice.DrawRect(rOutputDevice.PixelToLogic(aBox));
|
2008-02-12 15:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|