2004-07-13 13:28:17 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 05:28:11 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 13:28:17 +00:00
|
|
|
*
|
2005-09-09 05:28:11 +00:00
|
|
|
* $RCSfile: SlsPageObjectViewObjectContact.cxx,v $
|
2004-07-13 13:28:17 +00:00
|
|
|
*
|
2008-02-12 15:29:06 +00:00
|
|
|
* $Revision: 1.20 $
|
2004-07-13 13:28:17 +00:00
|
|
|
*
|
2008-02-12 15:29:06 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2008-02-12 16:29:06 $
|
2004-07-13 13:28:17 +00:00
|
|
|
*
|
2005-09-09 05:28:11 +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:17 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 05:28:11 +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:17 +00:00
|
|
|
*
|
2005-09-09 05:28:11 +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:17 +00:00
|
|
|
*
|
2005-09-09 05:28:11 +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:17 +00:00
|
|
|
*
|
2005-09-09 05:28:11 +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:17 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 18:11:29 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
#include "view/SlsPageObjectViewObjectContact.hxx"
|
|
|
|
|
|
|
|
#include "view/SlideSorterView.hxx"
|
|
|
|
#include "view/SlsPageObjectViewContact.hxx"
|
|
|
|
#include "view/SlsPageObject.hxx"
|
2005-03-18 15:53:23 +00:00
|
|
|
#include "view/SlsFontProvider.hxx"
|
2005-03-23 08:16:14 +00:00
|
|
|
#include "view/SlsPageNotificationObjectContact.hxx"
|
2004-07-13 13:28:17 +00:00
|
|
|
#include "model/SlsPageDescriptor.hxx"
|
|
|
|
#include "cache/SlsPageCache.hxx"
|
2005-10-24 06:45:00 +00:00
|
|
|
#include "cache/SlsPageCacheManager.hxx"
|
2004-07-13 13:28:17 +00:00
|
|
|
#include "res_bmp.hrc"
|
2004-08-04 07:57:40 +00:00
|
|
|
#include "tools/IconCache.hxx"
|
2005-07-07 12:38:05 +00:00
|
|
|
#include "PreviewRenderer.hxx"
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "glob.hrc"
|
2004-09-20 12:35:35 +00:00
|
|
|
#include "drawdoc.hxx"
|
2004-07-13 13:28:17 +00:00
|
|
|
#include <svx/sdr/contact/displayinfo.hxx>
|
|
|
|
#include <svx/sdr/contact/viewcontact.hxx>
|
2005-03-18 15:53:23 +00:00
|
|
|
#include <svx/sdr/contact/objectcontactofpageview.hxx>
|
2004-07-13 13:28:17 +00:00
|
|
|
#include <svx/svdopage.hxx>
|
|
|
|
#include <svx/xoutx.hxx>
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
#include <svx/xlndsit.hxx>
|
|
|
|
#include <svx/xlnclit.hxx>
|
2004-09-20 12:35:35 +00:00
|
|
|
#include <svx/svdoutl.hxx>
|
2004-07-13 13:28:17 +00:00
|
|
|
#include <vcl/bitmap.hxx>
|
|
|
|
#include <vcl/outdev.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
#include <vcl/lineinfo.hxx>
|
|
|
|
#include <tools/color.hxx>
|
2005-03-18 15:53:23 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2005-07-07 12:38:05 +00:00
|
|
|
#include <com/sun/star/uno/Exception.hpp>
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2006-11-14 13:36:48 +00:00
|
|
|
#ifndef _SV_SVAPP_HXX
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
using namespace ::sdr::contact;
|
|
|
|
using namespace ::sd::slidesorter::model;
|
|
|
|
|
2005-03-18 15:53:23 +00:00
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
namespace sd { namespace slidesorter { namespace view {
|
|
|
|
|
2005-03-18 15:53:23 +00:00
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnSelectionIndicatorOffset = 1;
|
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnSelectionIndicatorThickness = 3;
|
2004-07-13 13:28:17 +00:00
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnFocusIndicatorOffset = 2;
|
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnFadeEffectIndicatorOffset = 9;
|
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnFadeEffectIndicatorSize = 14;
|
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnPageNumberOffset = 9;
|
2004-09-20 12:35:35 +00:00
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnMouseOverEffectOffset = 2;
|
|
|
|
const sal_Int32 PageObjectViewObjectContact::mnMouseOverEffectThickness = 1;
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
PageObjectViewObjectContact::PageObjectViewObjectContact (
|
|
|
|
ObjectContact& rObjectContact,
|
|
|
|
ViewContact& rViewContact,
|
2005-10-24 06:45:00 +00:00
|
|
|
const ::boost::shared_ptr<cache::PageCache>& rpCache)
|
2004-07-13 13:28:17 +00:00
|
|
|
: ViewObjectContact (rObjectContact, rViewContact),
|
|
|
|
mbIsValid(true),
|
2005-10-24 06:45:00 +00:00
|
|
|
mpCache(rpCache),
|
|
|
|
mpNotifier(NULL),
|
|
|
|
mbInPrepareDelete(false)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
|
|
|
GetPageDescriptor().SetViewObjectContact (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-23 08:16:14 +00:00
|
|
|
PageObjectViewObjectContact::~PageObjectViewObjectContact (void)
|
|
|
|
{
|
2006-01-19 11:55:08 +00:00
|
|
|
if (mpCache.get() != NULL)
|
|
|
|
{
|
|
|
|
mpCache->ReleasePreviewBitmap(*this);
|
|
|
|
}
|
|
|
|
|
2005-03-23 08:16:14 +00:00
|
|
|
if (mpNotifier.get() != NULL)
|
|
|
|
{
|
2005-10-24 06:45:00 +00:00
|
|
|
mbInPrepareDelete = true;
|
2005-03-23 08:16:14 +00:00
|
|
|
mpNotifier->PrepareDelete();
|
|
|
|
mpNotifier.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-24 06:45:00 +00:00
|
|
|
void PageObjectViewObjectContact::SetCache (const ::boost::shared_ptr<cache::PageCache>& rpCache)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-10-24 06:45:00 +00:00
|
|
|
mpCache = rpCache;
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle PageObjectViewObjectContact::GetBoundingBox (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
BoundingBoxType eType,
|
|
|
|
CoordinateSystem eCoordinateSystem) const
|
2005-10-24 06:45:00 +00:00
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
// Most of the bounding boxes are based on the bounding box of the preview.
|
|
|
|
Rectangle aBoundingBox (static_cast<PageObjectViewContact&>(GetViewContact()
|
|
|
|
).GetPageObject().GetCurrentBoundRect());
|
2005-10-24 06:45:00 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
CoordinateSystem eCurrentCoordinateSystem (ModelCoordinateSystem);
|
|
|
|
switch(eType)
|
|
|
|
{
|
|
|
|
case PageObjectBoundingBox:
|
|
|
|
aBoundingBox = GetViewContact().GetPaintRectangle();
|
|
|
|
break;
|
|
|
|
case PreviewBoundingBox:
|
|
|
|
// The aBoundingBox already has the right value.
|
|
|
|
break;
|
|
|
|
case MouseOverIndicatorBoundingBox:
|
|
|
|
{
|
|
|
|
const sal_Int32 nBorderWidth (mnMouseOverEffectOffset+mnMouseOverEffectThickness);
|
|
|
|
const Size aBorderSize (rDevice.PixelToLogic(Size(nBorderWidth,nBorderWidth)));
|
|
|
|
aBoundingBox.Left() -= aBorderSize.Width();
|
|
|
|
aBoundingBox.Top() -= aBorderSize.Height();
|
|
|
|
aBoundingBox.Right() += aBorderSize.Width();
|
|
|
|
aBoundingBox.Bottom() += aBorderSize.Height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FocusIndicatorBoundingBox:
|
|
|
|
{
|
|
|
|
const sal_Int32 nBorderWidth (mnFocusIndicatorOffset+1);
|
|
|
|
const Size aBorderSize (rDevice.PixelToLogic(Size(nBorderWidth,nBorderWidth)));
|
|
|
|
aBoundingBox.Left() -= aBorderSize.Width();
|
|
|
|
aBoundingBox.Top() -= aBorderSize.Height();
|
|
|
|
aBoundingBox.Right() += aBorderSize.Width();
|
|
|
|
aBoundingBox.Bottom() += aBorderSize.Height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SelectionIndicatorBoundingBox:
|
|
|
|
{
|
|
|
|
const sal_Int32 nBorderWidth(mnSelectionIndicatorOffset+mnSelectionIndicatorThickness);
|
|
|
|
const Size aBorderSize (rDevice.PixelToLogic(Size(nBorderWidth,nBorderWidth)));
|
|
|
|
aBoundingBox.Left() -= aBorderSize.Width();
|
|
|
|
aBoundingBox.Top() -= aBorderSize.Height();
|
|
|
|
aBoundingBox.Right() += aBorderSize.Width();
|
|
|
|
aBoundingBox.Bottom() += aBorderSize.Height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PageNumberBoundingBox:
|
|
|
|
{
|
|
|
|
Size aModelOffset = rDevice.PixelToLogic(Size(mnPageNumberOffset,mnPageNumberOffset));
|
|
|
|
Size aNumberSize (GetPageDescriptor().GetPageNumberAreaModelSize());
|
|
|
|
aBoundingBox = Rectangle (
|
|
|
|
Point (
|
|
|
|
aBoundingBox.Left() - aModelOffset.Width() - aNumberSize.Width(),
|
|
|
|
aBoundingBox.Top()),
|
|
|
|
aNumberSize);
|
|
|
|
break;
|
|
|
|
}
|
2005-10-24 06:45:00 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
case NameBoundingBox:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FadeEffectIndicatorBoundingBox:
|
|
|
|
Size aModelOffset = rDevice.PixelToLogic(Size (0, mnFadeEffectIndicatorOffset));
|
|
|
|
// Flush left just outside the selection rectangle.
|
|
|
|
aBoundingBox = Rectangle (
|
|
|
|
Point (
|
|
|
|
aBoundingBox.Left(),
|
|
|
|
aBoundingBox.Bottom() + aModelOffset.Height()
|
|
|
|
),
|
|
|
|
rDevice.PixelToLogic (
|
|
|
|
IconCache::Instance().GetIcon(BMP_FADE_EFFECT_INDICATOR).GetSizePixel())
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
2005-10-24 06:45:00 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
// Make sure the bounding box uses the requested coordinate system.
|
|
|
|
if (eCurrentCoordinateSystem != eCoordinateSystem)
|
|
|
|
{
|
|
|
|
if (eCoordinateSystem == ModelCoordinateSystem)
|
|
|
|
aBoundingBox = Rectangle(
|
|
|
|
rDevice.PixelToLogic(aBoundingBox.TopLeft()),
|
|
|
|
rDevice.PixelToLogic(aBoundingBox.GetSize()));
|
|
|
|
else
|
|
|
|
aBoundingBox = Rectangle(
|
|
|
|
rDevice.LogicToPixel(aBoundingBox.TopLeft()),
|
|
|
|
rDevice.LogicToPixel(aBoundingBox.GetSize()));
|
|
|
|
}
|
|
|
|
return aBoundingBox;
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BitmapEx PageObjectViewObjectContact::CreatePreview (DisplayInfo& rDisplayInfo)
|
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
const SdPage* pPage = static_cast<const SdPage*>(GetPage());
|
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aPreviewPixelBox (GetBoundingBox(*pDevice,PreviewBoundingBox,PixelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2005-07-07 12:38:05 +00:00
|
|
|
PreviewRenderer aRenderer (pDevice);
|
|
|
|
Image aPreview (aRenderer.RenderPage(
|
|
|
|
pPage,
|
|
|
|
aPreviewPixelBox.GetSize(),
|
|
|
|
String()));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2005-07-07 12:38:05 +00:00
|
|
|
return aPreview.GetBitmapEx();
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BitmapEx PageObjectViewObjectContact::GetPreview (
|
|
|
|
DisplayInfo& rDisplayInfo,
|
|
|
|
const Rectangle& rNewSizePixel)
|
|
|
|
{
|
|
|
|
BitmapEx aBitmap;
|
|
|
|
|
2005-07-07 12:38:05 +00:00
|
|
|
try
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
if (mbIsValid)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
if (mpCache != NULL)
|
|
|
|
{
|
|
|
|
aBitmap = mpCache->GetPreviewBitmap(
|
|
|
|
*this,
|
|
|
|
rNewSizePixel.GetSize());
|
2005-10-24 06:45:00 +00:00
|
|
|
mpCache->SetPreciousFlag(*this, true);
|
2005-07-07 12:38:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aBitmap = CreatePreview (rDisplayInfo);
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
2005-07-07 12:38:05 +00:00
|
|
|
}
|
|
|
|
catch (const ::com::sun::star::uno::Exception&)
|
|
|
|
{
|
2005-07-08 14:12:31 +00:00
|
|
|
OSL_TRACE("PageObjectViewObjectContact::GetPreview: caught exception");
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintObject (DisplayInfo& rDisplayInfo)
|
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
try
|
2005-03-23 08:16:14 +00:00
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
// Make sure that our notification object contact exists...
|
|
|
|
if (mpNotifier.get() == NULL)
|
|
|
|
{
|
|
|
|
SdrPage* pPage = const_cast<SdrPage*>(GetPage());
|
|
|
|
mpNotifier.reset(new PageNotificationObjectContact(*pPage, *this));
|
|
|
|
}
|
|
|
|
// ...and that it has a valid contact object hierarchy.
|
|
|
|
mpNotifier->EnsureValidDrawHierarchy(rDisplayInfo);
|
2005-03-23 08:16:14 +00:00
|
|
|
|
2005-07-07 12:38:05 +00:00
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
|
|
|
// Check if buffering can and shall be done.
|
|
|
|
if (pDevice != NULL
|
|
|
|
&& !rDisplayInfo.OutputToPrinter()
|
|
|
|
&& !rDisplayInfo.OutputToRecordingMetaFile()
|
|
|
|
&& rDisplayInfo.IsBufferingAllowed()
|
|
|
|
&& mbIsValid)
|
|
|
|
{
|
|
|
|
// Transform the page borders from pixel coordinates to model
|
|
|
|
// coordinates and tell the view contact object about them. It
|
|
|
|
// would be nice if we had to do this only once (better yet not at
|
|
|
|
// all).
|
|
|
|
GetViewContact().InvalidatePaintRectangle();
|
|
|
|
|
|
|
|
// Set state flags. This overrides results from a contained
|
|
|
|
// call to PaintObject(..).
|
|
|
|
mbIsPainted = sal_True;
|
|
|
|
|
|
|
|
// Save (a part of) the state of the output device.
|
|
|
|
ULONG nPreviousDrawMode = pDevice->GetDrawMode();
|
|
|
|
const Color aOriginalFillColor (pDevice->GetFillColor());
|
|
|
|
const Color aOriginalLineColor (pDevice->GetLineColor());
|
|
|
|
Font aOriginalFont (pDevice->GetFont());
|
|
|
|
|
|
|
|
// Set default font.
|
|
|
|
pDevice->SetFont(*FontProvider::Instance().GetFont(*pDevice));
|
|
|
|
|
|
|
|
PaintContent (rDisplayInfo);
|
|
|
|
|
|
|
|
// Restore old device state.
|
|
|
|
pDevice->SetFont (aOriginalFont);
|
|
|
|
pDevice->SetLineColor (aOriginalLineColor);
|
|
|
|
pDevice->SetFillColor (aOriginalFillColor);
|
|
|
|
pDevice->SetDrawMode (nPreviousDrawMode);
|
|
|
|
|
|
|
|
// set painted rectangle
|
|
|
|
maPaintedRectangle = GetViewContact().GetPaintRectangle();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// paint normal, bitmap not available. Call parent.
|
|
|
|
ViewObjectContact::PaintObject(rDisplayInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const com::sun::star::uno::Exception&)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-07-08 14:12:31 +00:00
|
|
|
OSL_TRACE("PageObjectViewObjectContact::PaintObject: caught exception");
|
2005-09-23 10:02:52 +00:00
|
|
|
// Even though the object was not painted completely we set the
|
2005-07-07 12:38:05 +00:00
|
|
|
// state flags as if that has happened. We do this in order to
|
|
|
|
// avoid frequent repaints because when painting failed this time it
|
|
|
|
// may fail the next time, too.
|
2004-07-13 13:28:17 +00:00
|
|
|
mbIsPainted = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PrepareDelete (void)
|
|
|
|
{
|
|
|
|
mbIsValid = false;
|
2005-10-24 06:45:00 +00:00
|
|
|
mbInPrepareDelete = true;
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
GetPageDescriptor().SetViewObjectContact (NULL);
|
|
|
|
|
|
|
|
if (mpCache != NULL)
|
|
|
|
mpCache->ReleasePreviewBitmap(*this);
|
|
|
|
|
|
|
|
ViewObjectContact::PrepareDelete();
|
2005-10-24 06:45:00 +00:00
|
|
|
|
|
|
|
mbInPrepareDelete = false;
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const SdrPage* PageObjectViewObjectContact::GetPage (void) const
|
|
|
|
{
|
|
|
|
return static_cast<PageObjectViewContact&>(GetViewContact()).GetPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::ActionChanged (void)
|
|
|
|
{
|
2005-10-24 06:45:00 +00:00
|
|
|
// Even when we are called from PrepareDelete we still have to invalide
|
|
|
|
// the preview bitmap in the cache.
|
|
|
|
const SdrPage* pPage = GetPage();
|
|
|
|
SdDrawDocument* pDocument = dynamic_cast<SdDrawDocument*>(pPage->GetModel());
|
|
|
|
if (mpCache!=NULL && pPage!=NULL && pDocument!=NULL)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-10-24 06:45:00 +00:00
|
|
|
cache::PageCacheManager::Instance()->InvalidatePreviewBitmap(
|
|
|
|
pDocument,
|
|
|
|
GetPage());
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewObjectContact::ActionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintContent (
|
|
|
|
DisplayInfo& rDisplayInfo)
|
|
|
|
{
|
|
|
|
PaintPreview (rDisplayInfo);
|
2004-09-20 12:35:35 +00:00
|
|
|
PaintFrame (*rDisplayInfo.GetOutputDevice());
|
2004-07-13 13:28:17 +00:00
|
|
|
PaintFadeEffectIndicator (rDisplayInfo);
|
|
|
|
PaintPageName (rDisplayInfo);
|
|
|
|
PaintPageNumber (rDisplayInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintPreview (
|
|
|
|
DisplayInfo& rDisplayInfo)
|
|
|
|
{
|
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
2004-09-20 12:35:35 +00:00
|
|
|
if (pDevice != NULL)
|
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aNewSizePixel (
|
|
|
|
GetBoundingBox(*pDevice,PreviewBoundingBox,PixelCoordinateSystem));
|
2004-09-20 12:35:35 +00:00
|
|
|
BitmapEx aPreview (GetPreview(rDisplayInfo, aNewSizePixel));
|
|
|
|
|
|
|
|
// Paint using cached bitmap.
|
|
|
|
const sal_Bool bWasEnabled(pDevice->IsMapModeEnabled());
|
|
|
|
pDevice->EnableMapMode(sal_False);
|
|
|
|
pDevice->DrawBitmapEx(aNewSizePixel.TopLeft(), aPreview);
|
|
|
|
pDevice->EnableMapMode(bWasEnabled);
|
|
|
|
}
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintFrame (
|
2004-09-20 12:35:35 +00:00
|
|
|
OutputDevice& rDevice,
|
|
|
|
bool bShowMouseOverEffect) const
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2004-09-20 12:35:35 +00:00
|
|
|
PaintBorder (rDevice);
|
|
|
|
PaintSelectionIndicator (rDevice);
|
|
|
|
if ( ! GetPageDescriptor().IsSelected())
|
|
|
|
PaintMouseOverEffect (rDevice, bShowMouseOverEffect);
|
|
|
|
// else the mouse over effect is not visible when the selection
|
|
|
|
// indicator is painted already.
|
|
|
|
PaintFocusIndicator (rDevice,
|
|
|
|
GetPageDescriptor().IsSelected() || ! bShowMouseOverEffect);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintBorder (
|
|
|
|
OutputDevice& rDevice) const
|
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aFrameBox (GetBoundingBox(rDevice, PreviewBoundingBox, PixelCoordinateSystem));
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.EnableMapMode(FALSE);
|
|
|
|
rDevice.SetFillColor ();
|
2004-07-13 13:28:17 +00:00
|
|
|
svtools::ColorConfig aColorConfig;
|
2004-09-20 12:35:35 +00:00
|
|
|
Color aColor = aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor;
|
|
|
|
rDevice.SetLineColor (aColor);
|
|
|
|
rDevice.DrawRect (aFrameBox);
|
|
|
|
rDevice.EnableMapMode(TRUE);
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintSelectionIndicator (
|
2004-09-20 12:35:35 +00:00
|
|
|
OutputDevice& rDevice) const
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
|
|
|
if (GetPageDescriptor().IsSelected())
|
|
|
|
{
|
2004-09-20 12:35:35 +00:00
|
|
|
const Color aOldFillColor (rDevice.GetFillColor());
|
|
|
|
const Color aOldLineColor (rDevice.GetLineColor());
|
|
|
|
|
2006-05-05 09:07:02 +00:00
|
|
|
// Determine colors for the frame and the background and mix them to
|
|
|
|
// obtain a third color that is used for an antialiasing effect.
|
2004-07-13 13:28:17 +00:00
|
|
|
svtools::ColorConfig aColorConfig;
|
2004-09-20 12:35:35 +00:00
|
|
|
Color aFrameColor (
|
|
|
|
rDevice.GetSettings().GetStyleSettings().GetMenuHighlightColor());
|
|
|
|
Color aBackgroundColor (
|
2006-05-05 09:07:02 +00:00
|
|
|
rDevice.GetSettings().GetStyleSettings().GetWindowColor());
|
2004-09-20 12:35:35 +00:00
|
|
|
Color aCornerColor (aFrameColor);
|
|
|
|
aCornerColor.Merge (aBackgroundColor, 128);
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
// Set default draw mode to be able to correctly draw the selected
|
|
|
|
// (and only that) frame.
|
2004-09-20 12:35:35 +00:00
|
|
|
ULONG nPreviousDrawMode = rDevice.GetDrawMode();
|
|
|
|
rDevice.SetDrawMode (DRAWMODE_DEFAULT);
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aInner (GetBoundingBox(rDevice,PreviewBoundingBox,PixelCoordinateSystem));
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.EnableMapMode (FALSE);
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.SetFillColor ();
|
|
|
|
rDevice.SetLineColor (aFrameColor);
|
2004-07-13 13:28:17 +00:00
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
// Paint the frame.
|
2004-07-13 13:28:17 +00:00
|
|
|
for (int nOffset=mnSelectionIndicatorOffset;
|
2004-09-20 12:35:35 +00:00
|
|
|
nOffset<mnSelectionIndicatorOffset+mnSelectionIndicatorThickness;
|
2004-07-13 13:28:17 +00:00
|
|
|
nOffset++)
|
|
|
|
{
|
|
|
|
Rectangle aFrame (aInner);
|
|
|
|
aFrame.Left() -= nOffset;
|
|
|
|
aFrame.Top() -= nOffset;
|
|
|
|
aFrame.Right() += nOffset;
|
|
|
|
aFrame.Bottom() += nOffset;
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.DrawRect (aFrame);
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
// Paint the four corner pixels in backround color for a rounded
|
|
|
|
// effect.
|
|
|
|
int nFrameWidth (mnSelectionIndicatorOffset
|
|
|
|
+ mnSelectionIndicatorThickness - 1);
|
|
|
|
Rectangle aOuter (aInner);
|
|
|
|
aOuter.Left() -= nFrameWidth;
|
|
|
|
aOuter.Top() -= nFrameWidth;
|
|
|
|
aOuter.Right() += nFrameWidth;
|
|
|
|
aOuter.Bottom() += nFrameWidth;
|
|
|
|
Point aCorner (aOuter.TopLeft());
|
|
|
|
rDevice.DrawPixel (aCorner, aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()+1,aCorner.Y()),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()+1),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()+2,aCorner.Y()),aCornerColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()+2),aCornerColor);
|
|
|
|
aCorner = aOuter.TopRight();
|
|
|
|
rDevice.DrawPixel (aCorner, aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()-1,aCorner.Y()),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()+1),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()-2,aCorner.Y()), aCornerColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()+2), aCornerColor);
|
|
|
|
aCorner = aOuter.BottomLeft();
|
|
|
|
rDevice.DrawPixel (aCorner, aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()+1,aCorner.Y()),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()-1),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()+2,aCorner.Y()), aCornerColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()-2), aCornerColor);
|
|
|
|
aCorner = aOuter.BottomRight();
|
|
|
|
rDevice.DrawPixel (aCorner, aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()-1,aCorner.Y()),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()-1),aBackgroundColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X()-2,aCorner.Y()), aCornerColor);
|
|
|
|
rDevice.DrawPixel (Point(aCorner.X(),aCorner.Y()-2), aCornerColor);
|
|
|
|
|
|
|
|
rDevice.EnableMapMode (TRUE);
|
|
|
|
|
|
|
|
// Restore old values.
|
|
|
|
rDevice.SetLineColor (aOldLineColor);
|
|
|
|
rDevice.SetFillColor (aOldFillColor);
|
|
|
|
rDevice.SetDrawMode (nPreviousDrawMode);
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-20 12:35:35 +00:00
|
|
|
void PageObjectViewObjectContact::PaintMouseOverEffect (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
bool bVisible) const
|
|
|
|
{
|
2006-05-05 09:07:02 +00:00
|
|
|
ULONG nPreviousDrawMode = rDevice.GetDrawMode();
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.SetDrawMode (DRAWMODE_DEFAULT);
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aInner (GetBoundingBox(rDevice,PreviewBoundingBox,PixelCoordinateSystem));
|
2004-09-20 12:35:35 +00:00
|
|
|
rDevice.EnableMapMode (FALSE);
|
|
|
|
|
|
|
|
svtools::ColorConfig aColorConfig;
|
|
|
|
Color aSelectionColor (
|
|
|
|
rDevice.GetSettings().GetStyleSettings().GetMenuHighlightColor());
|
|
|
|
Color aBackgroundColor (
|
2006-05-05 09:07:02 +00:00
|
|
|
rDevice.GetSettings().GetStyleSettings().GetWindowColor());
|
2004-09-20 12:35:35 +00:00
|
|
|
Color aFrameColor (bVisible ? aSelectionColor : aBackgroundColor);
|
|
|
|
Color aCornerColor (aBackgroundColor);
|
|
|
|
|
|
|
|
rDevice.SetFillColor ();
|
|
|
|
rDevice.SetLineColor (aFrameColor);
|
|
|
|
|
|
|
|
// Paint the frame.
|
|
|
|
for (int nOffset=mnMouseOverEffectOffset;
|
|
|
|
nOffset<mnMouseOverEffectOffset+mnMouseOverEffectThickness;
|
|
|
|
nOffset++)
|
|
|
|
{
|
|
|
|
Rectangle aFrame (aInner);
|
|
|
|
aFrame.Left() -= nOffset;
|
|
|
|
aFrame.Top() -= nOffset;
|
|
|
|
aFrame.Right() += nOffset;
|
|
|
|
aFrame.Bottom() += nOffset;
|
|
|
|
rDevice.DrawRect (rDevice.PixelToLogic(aFrame));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paint the four corner pixels in backround color for a rounded effect.
|
|
|
|
int nFrameWidth (mnMouseOverEffectOffset
|
|
|
|
+ mnMouseOverEffectThickness - 1);
|
|
|
|
Rectangle aOuter (aInner);
|
|
|
|
aOuter.Left() -= nFrameWidth;
|
|
|
|
aOuter.Top() -= nFrameWidth;
|
|
|
|
aOuter.Right() += nFrameWidth;
|
|
|
|
aOuter.Bottom() += nFrameWidth;
|
|
|
|
Point aCorner (aOuter.TopLeft());
|
|
|
|
|
|
|
|
rDevice.DrawPixel (aCorner, aCornerColor);
|
|
|
|
aCorner = aOuter.TopRight();
|
|
|
|
rDevice.DrawPixel (aCorner, aCornerColor);
|
|
|
|
aCorner = aOuter.BottomLeft();
|
|
|
|
rDevice.DrawPixel (aCorner, aCornerColor);
|
|
|
|
aCorner = aOuter.BottomRight();
|
|
|
|
rDevice.DrawPixel (aCorner, aCornerColor);
|
|
|
|
|
|
|
|
rDevice.EnableMapMode (TRUE);
|
2006-05-05 09:07:02 +00:00
|
|
|
rDevice.SetDrawMode(nPreviousDrawMode);
|
2004-09-20 12:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
void PageObjectViewObjectContact::PaintFocusIndicator (
|
2004-09-20 12:35:35 +00:00
|
|
|
OutputDevice& rDevice,
|
|
|
|
bool bEraseBackground) const
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
(void)bEraseBackground;
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
if (GetPageDescriptor().IsFocused())
|
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aPagePixelBBox (
|
|
|
|
GetBoundingBox(rDevice,PreviewBoundingBox,PixelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
aPagePixelBBox.Left() -= mnFocusIndicatorOffset;
|
|
|
|
aPagePixelBBox.Top() -= mnFocusIndicatorOffset;
|
|
|
|
aPagePixelBBox.Right() += mnFocusIndicatorOffset;
|
|
|
|
aPagePixelBBox.Bottom() += mnFocusIndicatorOffset;
|
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
PaintDottedRectangle(rDevice, aPagePixelBBox);
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintFadeEffectIndicator (
|
|
|
|
DisplayInfo& rDisplayInfo,
|
2006-12-12 17:38:50 +00:00
|
|
|
bool ) const
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
|
|
|
if (GetPage() != NULL
|
2005-07-07 12:38:05 +00:00
|
|
|
&& static_cast<const SdPage*>(GetPage())->getTransitionType() > 0)
|
2004-07-13 13:28:17 +00:00
|
|
|
{
|
2005-07-07 12:38:05 +00:00
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
2008-02-12 15:29:06 +00:00
|
|
|
if (pDevice != NULL)
|
|
|
|
{
|
|
|
|
Rectangle aIndicatorBox (
|
|
|
|
GetBoundingBox(*pDevice, FadeEffectIndicatorBoundingBox, ModelCoordinateSystem));
|
2005-07-07 12:38:05 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
USHORT nIconId (BMP_FADE_EFFECT_INDICATOR);
|
|
|
|
if (pDevice->GetSettings().GetStyleSettings().GetHighContrastMode()!=0)
|
|
|
|
nIconId = BMP_FADE_EFFECT_INDICATOR_H;
|
2005-07-07 12:38:05 +00:00
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
pDevice->DrawImage (
|
|
|
|
aIndicatorBox.TopLeft(),
|
|
|
|
IconCache::Instance().GetIcon(nIconId));
|
|
|
|
}
|
2004-07-13 13:28:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintPageName (
|
|
|
|
DisplayInfo& rDisplayInfo) const
|
|
|
|
{
|
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aPageBox (GetBoundingBox(*pDevice, PreviewBoundingBox, ModelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
Font aOriginalFont (pDevice->GetFont());
|
2005-03-18 15:53:23 +00:00
|
|
|
pDevice->SetFont(*FontProvider::Instance().GetFont(*pDevice));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
const SdPage* pPage = static_cast<const SdPage*>(GetPage());
|
|
|
|
int nPage = (pPage->GetPageNum()-1) / 2;
|
|
|
|
// Name der Seite
|
|
|
|
Point aPos = aPageBox.BottomLeft();
|
|
|
|
Size aPageSize (aPageBox.GetSize());
|
|
|
|
Size aSize (pDevice->PixelToLogic (Size (0, mnFadeEffectIndicatorOffset)));
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aIndicatorBox (
|
|
|
|
GetBoundingBox(*pDevice, FadeEffectIndicatorBoundingBox, ModelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
aPos.Y() += aSize.Height();
|
|
|
|
aPos.X() += 2 * aIndicatorBox.GetWidth();
|
|
|
|
|
2005-03-18 15:53:23 +00:00
|
|
|
Size aTextBoxSize (aPageBox.Right() - aPos.X(), pDevice->GetFont().GetSize().Height());
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
String sName (const_cast<SdPage*>(pPage)->GetName());
|
|
|
|
if (sName.Len() == 0)
|
|
|
|
{
|
|
|
|
sName = String (SdResId(STR_PAGE));
|
|
|
|
sName += String::CreateFromInt32 (nPage + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nTextStyle
|
|
|
|
= TEXT_DRAW_RIGHT
|
|
|
|
| TEXT_DRAW_NEWSELLIPSIS;
|
|
|
|
|
|
|
|
pDevice->DrawText (Rectangle(aPos,aTextBoxSize), sName, nTextStyle);
|
|
|
|
|
|
|
|
pDevice->SetFont (aOriginalFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintPageNumber (
|
|
|
|
DisplayInfo& rDisplayInfo)
|
|
|
|
{
|
|
|
|
OutputDevice* pDevice = rDisplayInfo.GetOutputDevice();
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aPageBox (GetBoundingBox(*pDevice, PreviewBoundingBox, ModelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
const SdPage* pPage = static_cast<const SdPage*>(GetPage());
|
|
|
|
int nPageNumber ((pPage->GetPageNum()-1) / 2 + 1);
|
|
|
|
String sPageNumber (String::CreateFromInt32 (nPageNumber));
|
|
|
|
Point aPos = aPageBox.TopLeft();
|
|
|
|
Rectangle aBox (GetPageNumberArea (pDevice));
|
|
|
|
|
|
|
|
// Paint the page number centered in its box.
|
|
|
|
// TODO: What when the page number is wider than the page number box?
|
|
|
|
USHORT nTextStyle = TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER;
|
|
|
|
Rectangle aTextBox (pDevice->GetTextRect (aBox, sPageNumber, nTextStyle));
|
|
|
|
// int nLeft = aTextBox.Left();
|
|
|
|
// int nTop = aBox.Top() + (aBox.Top() - aTextBox.GetHeight()) / 2;
|
|
|
|
pDevice->SetFillColor ();
|
|
|
|
svtools::ColorConfig aColorConfig;
|
|
|
|
pDevice->SetLineColor (
|
|
|
|
pDevice->GetSettings().GetStyleSettings().GetActiveTextColor());
|
|
|
|
pDevice->DrawText (aTextBox, sPageNumber, nTextStyle);
|
|
|
|
|
|
|
|
// Paint box arround the page number. Strike through when slide is
|
|
|
|
// excluded from the presentation
|
|
|
|
if (pPage->IsExcluded())
|
|
|
|
{
|
|
|
|
// Make the box a little bit larger at the left so that the digits
|
|
|
|
// do not touch the border.
|
|
|
|
Size aOffset (pDevice->PixelToLogic(Size(1,0)));
|
|
|
|
aBox.Left() -= aOffset.Width();
|
|
|
|
|
|
|
|
pDevice->SetLineColor (
|
|
|
|
pDevice->GetSettings().GetStyleSettings().GetActiveColor());
|
|
|
|
pDevice->DrawRect (aBox);
|
|
|
|
pDevice->DrawLine (aBox.TopLeft(), aBox.BottomRight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle PageObjectViewObjectContact::GetPageNumberArea (
|
|
|
|
OutputDevice* pDevice)
|
|
|
|
{
|
2008-02-12 15:29:06 +00:00
|
|
|
Rectangle aPageModelBox (GetBoundingBox(*pDevice, PreviewBoundingBox, ModelCoordinateSystem));
|
2004-07-13 13:28:17 +00:00
|
|
|
Size aModelOffset = pDevice->PixelToLogic (
|
|
|
|
Size (mnPageNumberOffset, mnPageNumberOffset));
|
|
|
|
Size aNumberSize (GetPageDescriptor().GetPageNumberAreaModelSize());
|
|
|
|
|
|
|
|
Rectangle aPageNumberArea (
|
|
|
|
Point (
|
|
|
|
aPageModelBox.Left() - aModelOffset.Width() - aNumberSize.Width(),
|
|
|
|
aPageModelBox.Top()),
|
|
|
|
aNumberSize);
|
|
|
|
|
|
|
|
return aPageNumberArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SvBorder PageObjectViewObjectContact::CalculatePageModelBorder (
|
|
|
|
OutputDevice* pDevice,
|
|
|
|
int nPageCount)
|
|
|
|
{
|
|
|
|
SvBorder aModelBorder;
|
|
|
|
|
|
|
|
if (pDevice != NULL)
|
|
|
|
{
|
|
|
|
// 1. Initialize the border with the values that do not depend on
|
|
|
|
// the device.
|
|
|
|
Size aTopLeftBorders (pDevice->PixelToLogic (Size (
|
2005-07-07 12:38:05 +00:00
|
|
|
mnPageNumberOffset+1,
|
2004-07-13 13:28:17 +00:00
|
|
|
mnSelectionIndicatorOffset + mnSelectionIndicatorThickness)));
|
|
|
|
Size aBottomRightBorders (pDevice->PixelToLogic (Size (
|
|
|
|
mnSelectionIndicatorOffset + mnSelectionIndicatorThickness,
|
|
|
|
mnFadeEffectIndicatorOffset)));
|
|
|
|
aModelBorder = SvBorder (
|
|
|
|
aTopLeftBorders.Width(),
|
|
|
|
aTopLeftBorders.Height(),
|
|
|
|
aBottomRightBorders.Width(),
|
|
|
|
aBottomRightBorders.Height());
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Add the device dependent values.
|
|
|
|
|
|
|
|
// Calculate the area of the page number.
|
|
|
|
Size aPageNumberModelSize (
|
|
|
|
CalculatePageNumberAreaModelSize (pDevice, nPageCount));
|
|
|
|
|
|
|
|
// Update the border.
|
|
|
|
aModelBorder.Left() += aPageNumberModelSize.Width();
|
2005-03-18 15:53:23 +00:00
|
|
|
// The height of the page number area is the same as the height of
|
|
|
|
// the page name area.
|
2004-07-13 13:28:17 +00:00
|
|
|
aModelBorder.Bottom() += aPageNumberModelSize.Height();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aModelBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size PageObjectViewObjectContact::CalculatePageNumberAreaModelSize (
|
|
|
|
OutputDevice* pDevice,
|
|
|
|
int nPageCount)
|
|
|
|
{
|
|
|
|
// Set the correct font.
|
|
|
|
Font aOriginalFont (pDevice->GetFont());
|
2005-03-18 15:53:23 +00:00
|
|
|
pDevice->SetFont(*FontProvider::Instance().GetFont(*pDevice));
|
2004-07-13 13:28:17 +00:00
|
|
|
|
|
|
|
String sPageNumberTemplate;
|
|
|
|
if (nPageCount < 10)
|
|
|
|
sPageNumberTemplate = String::CreateFromAscii("9");
|
|
|
|
else if (nPageCount < 100)
|
|
|
|
sPageNumberTemplate = String::CreateFromAscii("99");
|
|
|
|
else if (nPageCount < 200)
|
|
|
|
// Just for the case that 1 is narrower than 9.
|
|
|
|
sPageNumberTemplate = String::CreateFromAscii("199");
|
|
|
|
else if (nPageCount < 1000)
|
|
|
|
sPageNumberTemplate = String::CreateFromAscii("999");
|
|
|
|
else
|
|
|
|
sPageNumberTemplate = String::CreateFromAscii("9999");
|
|
|
|
// More then 9999 pages are not handled.
|
|
|
|
|
|
|
|
Size aSize (
|
|
|
|
pDevice->GetTextWidth (sPageNumberTemplate),
|
|
|
|
pDevice->GetTextHeight ());
|
|
|
|
|
|
|
|
pDevice->SetFont (aOriginalFont);
|
|
|
|
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model::PageDescriptor&
|
|
|
|
PageObjectViewObjectContact::GetPageDescriptor (void) const
|
|
|
|
{
|
|
|
|
PageObjectViewContact& rViewContact (
|
|
|
|
static_cast<PageObjectViewContact&>(GetViewContact()));
|
|
|
|
PageObject& rPageObject (
|
|
|
|
static_cast<PageObject&>(rViewContact.GetPageObject()));
|
|
|
|
return rPageObject.GetDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 15:29:06 +00:00
|
|
|
|
|
|
|
void PageObjectViewObjectContact::PaintDottedRectangle (
|
|
|
|
OutputDevice& rDevice,
|
|
|
|
const Rectangle& rRectangle,
|
|
|
|
const DashType eDashType)
|
|
|
|
{
|
|
|
|
const Color aOriginalFillColor (rDevice.GetFillColor());
|
|
|
|
const Color aOriginalLineColor (rDevice.GetLineColor());
|
|
|
|
|
|
|
|
// The dots or dashes are painted indepently of the zoom factor because
|
|
|
|
// selection or focus rectangles are not part of the model.
|
|
|
|
const bool bOriginalMapModeState(rDevice.IsMapModeEnabled());
|
|
|
|
rDevice.EnableMapMode(FALSE);
|
|
|
|
|
|
|
|
// Paint a solid rectangle first.
|
|
|
|
rDevice.SetFillColor();
|
|
|
|
rDevice.SetLineColor(COL_WHITE);
|
|
|
|
rDevice.DrawRect(rRectangle);
|
|
|
|
|
|
|
|
// Now paint the dots or dashes.
|
|
|
|
LineInfo aDottedStyle (LINE_DASH);
|
|
|
|
aDottedStyle.SetDashCount(0);
|
|
|
|
aDottedStyle.SetDotCount(1);
|
|
|
|
switch (eDashType)
|
|
|
|
{
|
|
|
|
case Dotted:
|
|
|
|
default:
|
|
|
|
aDottedStyle.SetDotLen(1);
|
|
|
|
aDottedStyle.SetDistance(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Dashed:
|
|
|
|
aDottedStyle.SetDotLen(3);
|
|
|
|
aDottedStyle.SetDistance(3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rDevice.SetLineColor(COL_BLACK);
|
|
|
|
rDevice.DrawPolyLine(Polygon(rRectangle), aDottedStyle);
|
|
|
|
|
|
|
|
// Restore the original state.
|
|
|
|
rDevice.EnableMapMode(bOriginalMapModeState);
|
|
|
|
rDevice.SetFillColor(aOriginalFillColor);
|
|
|
|
rDevice.SetLineColor(aOriginalLineColor);
|
|
|
|
}
|
|
|
|
|
2004-07-13 13:28:17 +00:00
|
|
|
} } } // end of namespace ::sd::slidesorter::view
|