renaissance1: #i107215# First draft of the new slide sorter design.

This commit is contained in:
Andre Fischer 2010-01-27 11:41:30 +01:00
parent 5c2d284b0f
commit 23a61a9969
75 changed files with 6676 additions and 2492 deletions

View File

@ -154,5 +154,7 @@
#define STR_TABLEOBJECTBARSHELL RID_GLOB_START+225
#define RID_TABPAGE_PARA_NUMBERING RID_GLOB_START+226
#define RID_SLIDESORTER_ICONS RID_GLOB_START+227

View File

@ -40,6 +40,8 @@
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsLayouter.hxx"
#include "view/SlsPageObjectLayouter.hxx"
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <comphelper/accessibleeventnotifier.hxx>
@ -392,10 +394,11 @@ awt::Rectangle SAL_CALL AccessibleSlideSorterObject::getBounds (void)
const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
Rectangle aBBox (mrSlideSorter.GetView().GetPageBoundingBox (
mnPageNumber,
::sd::slidesorter::view::SlideSorterView::CS_SCREEN,
::sd::slidesorter::view::SlideSorterView::BBT_INFO));
Rectangle aBBox (
mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
mrSlideSorter.GetModel().GetPageDescriptor(mnPageNumber),
::sd::slidesorter::view::PageObjectLayouter::PageObject,
::sd::slidesorter::view::PageObjectLayouter::ScreenCoordinateSystem));
if (mxParent.is())
{

View File

@ -200,9 +200,10 @@ void ChangeRequestQueueProcessor::ProcessOneEvent (void)
// its state.
if (mpConfigurationUpdater.get() != NULL)
{
#ifdef VERBOSE
ConfigurationTracer::TraceConfiguration (
mxConfiguration, "updating to configuration");
#endif
mpConfigurationUpdater->RequestUpdate(mxConfiguration);
}
}

View File

@ -49,7 +49,7 @@ using ::rtl::OUString;
using ::std::vector;
#undef VERBOSE
#define VERBOSE 2
//#define VERBOSE 2
namespace {
static const sal_Int32 snShortTimeout (100);

View File

@ -63,12 +63,12 @@ namespace sd { namespace slidesorter { namespace controller {
class Listener;
class SlideSorterController;
class SlotManager;
class Properties;
} } }
namespace sd { namespace slidesorter {
/** Show previews for all the slides in a document and allow the user to
insert or delete slides and modify the order of the slides.
@ -146,11 +146,6 @@ public:
*/
::boost::shared_ptr<sd::Window> GetContentWindow (void) const;
/** Return the active window as it is returned by a view shell.
Typically the content window.
*/
::sd::Window* GetActiveWindow (void) const;
model::SlideSorterModel& GetModel (void) const;
view::SlideSorterView& GetView (void) const;
@ -193,6 +188,11 @@ public:
*/
void SetCurrentFunction (const FunctionReference& rpFunction);
/** Return a collection of properties that are used througout the slide
sorter.
*/
::boost::shared_ptr<controller::Properties> GetProperties (void) const;
protected:
/** This virtual method makes it possible to create a specialization of
the slide sorter view shell that works with its own implementation
@ -238,6 +238,10 @@ private:
*/
bool mbLayoutPending;
/** Some slide sorter wide properties that are used in different
classes.
*/
::boost::shared_ptr<controller::Properties> mpProperties;
SlideSorter (
ViewShell& rViewShell,

View File

@ -126,7 +126,7 @@ PresenterPreviewCache::PresenterPreviewCache (const Reference<XComponentContext>
: PresenterPreviewCacheInterfaceBase(m_aMutex),
maPreviewSize(Size(200,200)),
mpCacheContext(new PresenterCacheContext()),
mpCache(new PageCache(maPreviewSize, mpCacheContext))
mpCache(new PageCache(maPreviewSize, false, mpCacheContext))
{
(void)rxContext;
}
@ -191,7 +191,7 @@ void SAL_CALL PresenterPreviewCache::setPreviewSize (
OSL_ASSERT(mpCache.get()!=NULL);
maPreviewSize = Size(rSize.Width, rSize.Height);
mpCache->ChangeSize(maPreviewSize);
mpCache->ChangeSize(maPreviewSize, false);
}
@ -213,7 +213,7 @@ Reference<rendering::XBitmap> SAL_CALL PresenterPreviewCache::getSlidePreview (
if (pPage == NULL)
throw RuntimeException();
const BitmapEx aPreview (mpCache->GetPreviewBitmap(pPage, maPreviewSize));
const BitmapEx aPreview (mpCache->GetPreviewBitmap(pPage));
if (aPreview.IsEmpty())
return NULL;
else

View File

@ -1181,9 +1181,9 @@ void SlideShow::StartFullscreenPresentation( )
// fullscreen.
const sal_Int32 nDisplay (GetDisplay());
WorkWindow* pWorkWindow = new FullScreenWorkWindow(this, mpCurrentViewShellBase);
pWorkWindow->SetBackground(Wallpaper(COL_BLACK));
pWorkWindow->StartPresentationMode( TRUE, mpDoc->getPresentationSettings().mbAlwaysOnTop ? PRESENTATION_HIDEALLAPPS : 0, nDisplay);
// pWorkWindow->ShowFullScreenMode(FALSE, nDisplay);
pWorkWindow->SetBackground(Wallpaper(COL_BLACK));
if (pWorkWindow->IsVisible())
{

View File

@ -1221,9 +1221,11 @@ void SlideshowImpl::onFirstPaint()
{
if( mpShowWindow )
{
/*
mpShowWindow->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
mpShowWindow->Erase();
mpShowWindow->SetBackground();
*/
}
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );

View File

@ -47,10 +47,10 @@ class BitmapCompressor;
/** This low level cache is the actual bitmap container. It supports a
precious flag for every preview bitmap and keeps track of total sizes
for all previews with as well as those without the flag. The precious
flag is used by compaction algorithms to determine which previews may be
compressed or even discarded and which have to remain in their original
form. The precious flag is usually set for the visible previews.
for all previews with/without this flag. The precious flag is used by
compaction algorithms to determine which previews may be compressed or
even discarded and which have to remain in their original form. The
precious flag is usually set for the visible previews.
*/
class BitmapCache
{

View File

@ -37,7 +37,6 @@
#include "PreviewRenderer.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "sdpage.hxx"
#include "Window.hxx"
#include <svx/svdtypes.hxx>
@ -52,7 +51,7 @@ class PageObjectViewObjectContact;
namespace sd { namespace slidesorter { namespace cache {
BitmapFactory::BitmapFactory (void)
: maRenderer(NULL,false)
: maRenderer(NULL, false)
{
}
@ -68,14 +67,23 @@ BitmapFactory::~BitmapFactory (void)
::boost::shared_ptr<BitmapEx> BitmapFactory::CreateBitmap (
const SdPage& rPage,
const Size& rPixelSize)
const Size& rPixelSize,
const bool bDoSuperSampling)
{
Image aPreview (maRenderer.RenderPage (
&rPage,
rPixelSize,
String()));
Size aSize (rPixelSize);
if (bDoSuperSampling)
{
aSize.Width() *= 2;
aSize.Height() *= 2;
}
return ::boost::shared_ptr<BitmapEx>(new BitmapEx(aPreview.GetBitmapEx()));
const Image aPreview (maRenderer.RenderPage (&rPage, aSize, String()));
::boost::shared_ptr<BitmapEx> pPreview (new BitmapEx(aPreview.GetBitmapEx()));
if (bDoSuperSampling)
pPreview->Scale(rPixelSize, BMP_SCALE_INTERPOLATE);
return pPreview;
}

View File

@ -56,7 +56,8 @@ public:
::boost::shared_ptr<BitmapEx> CreateBitmap (
const SdPage& rPage,
const Size& rPixelSize);
const Size& rPixelSize,
const bool bDoSuperSampling);
private:
PreviewRenderer maRenderer;

View File

@ -41,20 +41,26 @@
#include "cache/SlsPageCacheManager.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "controller/SlideSorterController.hxx"
namespace sd { namespace slidesorter { namespace cache {
GenericPageCache::GenericPageCache (
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: mpBitmapCache(),
maRequestQueue(rpCacheContext),
mpQueueProcessor(),
mpCacheContext(rpCacheContext),
maPreviewSize(rPreviewSize)
maPreviewSize(rPreviewSize),
mbDoSuperSampling(bDoSuperSampling)
{
// A large size may indicate an error of the caller. After all we
// are creating previews.
DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
"GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
"This may indicate an error.");
}
@ -91,36 +97,44 @@ void GenericPageCache::ProvideCacheAndProcessor (void)
maRequestQueue,
mpBitmapCache,
maPreviewSize,
mbDoSuperSampling,
mpCacheContext));
}
void GenericPageCache::ChangePreviewSize (const Size& rPreviewSize)
void GenericPageCache::ChangePreviewSize (
const Size& rPreviewSize,
const bool bDoSuperSampling)
{
if (rPreviewSize != maPreviewSize)
if (rPreviewSize!=maPreviewSize || bDoSuperSampling!=mbDoSuperSampling)
{
// A large size may indicate an error of the caller. After all we
// are creating previews.
DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
"GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
"This may indicate an error.");
if (mpBitmapCache.get() != NULL)
{
mpBitmapCache = PageCacheManager::Instance()->ChangeSize(
mpBitmapCache, maPreviewSize, rPreviewSize);
if (mpQueueProcessor.get() != NULL)
{
mpQueueProcessor->SetPreviewSize(rPreviewSize);
mpQueueProcessor->SetPreviewSize(rPreviewSize, bDoSuperSampling);
mpQueueProcessor->SetBitmapCache(mpBitmapCache);
}
}
maPreviewSize = rPreviewSize;
mbDoSuperSampling = bDoSuperSampling;
}
}
BitmapEx GenericPageCache::GetPreviewBitmap (
CacheKey aKey,
const Size& rSize)
BitmapEx GenericPageCache::GetPreviewBitmap (CacheKey aKey)
{
OSL_ASSERT(aKey != NULL);
@ -134,17 +148,12 @@ BitmapEx GenericPageCache::GetPreviewBitmap (
OSL_ASSERT(pPreview.get() != NULL);
aPreview = *pPreview;
Size aBitmapSize (aPreview.GetSizePixel());
if (aBitmapSize != rSize)
if (aBitmapSize != maPreviewSize)
{
// The bitmap has the wrong size.
DBG_ASSERT (rSize.Width() < 1000,
"GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
"This may indicate an error.");
// Scale the bitmap to the desired size when that is possible,
// i.e. the bitmap is not empty.
if (aBitmapSize.Width()>0 && aBitmapSize.Height()>0)
aPreview.Scale (rSize, BMP_SCALE_FAST);
aPreview.Scale (maPreviewSize, BMP_SCALE_FAST);
}
bMayBeUpToDate = true;
}
@ -154,7 +163,7 @@ BitmapEx GenericPageCache::GetPreviewBitmap (
// Request the creation of a correctly sized preview bitmap. We do this
// even when the size of the bitmap in the cache is correct because its
// content may be not up-to-date anymore.
RequestPreviewBitmap(aKey, rSize, bMayBeUpToDate);
RequestPreviewBitmap(aKey, bMayBeUpToDate);
return aPreview;
}
@ -164,7 +173,6 @@ BitmapEx GenericPageCache::GetPreviewBitmap (
void GenericPageCache::RequestPreviewBitmap (
CacheKey aKey,
const Size& rSize,
bool bMayBeUpToDate)
{
OSL_ASSERT(aKey != NULL);
@ -180,7 +188,7 @@ void GenericPageCache::RequestPreviewBitmap (
if (bIsUpToDate)
{
::boost::shared_ptr<BitmapEx> pPreview (mpBitmapCache->GetBitmap(pPage));
if (pPreview.get()==NULL || pPreview->GetSizePixel()!=rSize)
if (pPreview.get()==NULL || pPreview->GetSizePixel()!=maPreviewSize)
bIsUpToDate = false;
}

View File

@ -47,12 +47,18 @@ class QueueProcessor;
class GenericPageCache
{
public:
/** The page chache is created with references both to the SlideSorter.
This allows access to both view and model and the cache can so fill
itself with requests for all or just the visible pages.
/** The page chache is created with a reference to the SlideSorter and
thus has access to both view and model. This allows the cache to
fill itself with requests for all pages or just the visible ones.
@param rPreviewSize
The size of the previews is expected in pixel values.
@param bDoSuperSampling
When <TRUE/> the previews are rendered larger and then scaled
down to the requested size to improve image quality.
*/
GenericPageCache (
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext);
~GenericPageCache (void);
@ -61,10 +67,12 @@ public:
resize of the slide sorter window or a change of the number of
columns.
*/
void ChangePreviewSize (const Size& rPreviewSize);
void ChangePreviewSize (
const Size& rPreviewSize,
const bool bDoSuperSampling);
/** Request a preview bitmap for the specified page object in the
specified size. The returned bitmap may be preview of the preview,
specified size. The returned bitmap may be a preview of the preview,
i.e. either a scaled (up or down) version of a previous preview (of
the wrong size) or an empty bitmap. In this case a request for the
generation of a new preview is created and inserted into the request
@ -73,33 +81,26 @@ public:
receives the correctly sized preview bitmap.
@param rRequestData
This data is used to determine the preview.
@param rSize
The size of the requested preview bitmap.
@return
Returns a bitmap that is either empty, contains a scaled (up or
down) version or is the requested bitmap.
*/
BitmapEx GetPreviewBitmap (
CacheKey aKey,
const Size& rSize);
BitmapEx GetPreviewBitmap (CacheKey aKey);
/** When the requested preview bitmap does not yet exist or is not
up-to-date then the rendering of one is scheduled. Otherwise this
method does nothing.
@param rRequestData
This data is used to determine the preview.
@param rSize
The size of the requested preview bitmap in pixel coordinates.
@param bMayBeUpToDate
This flag helps the method to determine whether an existing
preview that matches the request is up to date. If the caller
know that it is not then by passing <FALSE/> he tells us that we
knows that it is not then by passing <FALSE/> he tells us that we
do not have to check the up-to-date flag a second time. If
unsure pass <TRUE/>.
unsure use <TRUE/>.
*/
void RequestPreviewBitmap (
CacheKey aKey,
const Size& rSize,
bool bMayBeUpToDate = true);
/** Tell the cache to replace the bitmap associated with the given
@ -147,6 +148,8 @@ private:
*/
Size maPreviewSize;
bool mbDoSuperSampling;
/** Both bitmap cache and queue processor are created on demand by this
method.
*/

View File

@ -48,10 +48,12 @@ namespace sd { namespace slidesorter { namespace cache {
PageCache::PageCache (
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: mpImplementation(
new GenericPageCache(
rPreviewSize,
bDoSuperSampling,
rpCacheContext))
{
}
@ -66,38 +68,39 @@ PageCache::~PageCache (void)
void PageCache::ChangeSize(const Size& rPreviewSize)
void PageCache::ChangeSize (
const Size& rPreviewSize,
const bool bDoSuperSampling)
{
mpImplementation->ChangePreviewSize(rPreviewSize);
mpImplementation->ChangePreviewSize(rPreviewSize, bDoSuperSampling);
}
BitmapEx PageCache::GetPreviewBitmap (
CacheKey aKey,
const Size& rSize)
BitmapEx PageCache::GetPreviewBitmap (CacheKey aKey)
{
return mpImplementation->GetPreviewBitmap(aKey, rSize);
return mpImplementation->GetPreviewBitmap(aKey);
}
void PageCache::RequestPreviewBitmap (
CacheKey aKey,
const Size& rSize)
void PageCache::RequestPreviewBitmap (CacheKey aKey)
{
return mpImplementation->RequestPreviewBitmap(aKey, rSize);
return mpImplementation->RequestPreviewBitmap(aKey);
}
void PageCache::InvalidatePreviewBitmap (
CacheKey aKey)
const CacheKey aKey,
const bool bRequestPreview)
{
mpImplementation->InvalidatePreviewBitmap(aKey);
if (bRequestPreview)
RequestPreviewBitmap(aKey);
}

View File

@ -44,6 +44,7 @@ QueueProcessor::QueueProcessor (
RequestQueue& rQueue,
const ::boost::shared_ptr<BitmapCache>& rpCache,
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: maMutex(),
maTimer(),
@ -51,6 +52,7 @@ QueueProcessor::QueueProcessor (
mnTimeBetweenLowPriorityRequests (100/*ms*/),
mnTimeBetweenRequestsWhenNotIdle (1000/*ms*/),
maPreviewSize(rPreviewSize),
mbDoSuperSampling(bDoSuperSampling),
mpCacheContext(rpCacheContext),
mrQueue(rQueue),
mpCache(rpCache),
@ -140,9 +142,12 @@ void QueueProcessor::Terminate (void)
void QueueProcessor::SetPreviewSize (const Size& rPreviewSize)
void QueueProcessor::SetPreviewSize (
const Size& rPreviewSize,
const bool bDoSuperSampling)
{
maPreviewSize = rPreviewSize;
mbDoSuperSampling = bDoSuperSampling;
}
@ -212,7 +217,7 @@ void QueueProcessor::ProcessOneRequest (
if (pSdPage != NULL)
{
const ::boost::shared_ptr<BitmapEx> pPreview (
maBitmapFactory.CreateBitmap(*pSdPage, maPreviewSize));
maBitmapFactory.CreateBitmap(*pSdPage, maPreviewSize, mbDoSuperSampling));
mpCache->SetBitmap (
pSdPage,
pPreview,

View File

@ -34,9 +34,7 @@
#include "cache/SlsPageCache.hxx"
#include "SlsRequestPriorityClass.hxx"
#include "SlsBitmapFactory.hxx"
#include "view/SlsPageObject.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "tools/IdleDetection.hxx"
#include "SlsBitmapCache.hxx"
#include "sdpage.hxx"
@ -74,6 +72,7 @@ public:
RequestQueue& rQueue,
const ::boost::shared_ptr<BitmapCache>& rpCache,
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext);
virtual ~QueueProcessor();
@ -93,7 +92,9 @@ public:
void Terminate (void);
void SetPreviewSize (const Size& rSize);
void SetPreviewSize (
const Size& rSize,
const bool bDoSuperSampling);
/** As we can not really terminate the rendering of a preview bitmap for
a request in midair this method acts more like a semaphor. It
@ -121,6 +122,7 @@ private:
sal_uInt32 mnTimeBetweenLowPriorityRequests;
sal_uInt32 mnTimeBetweenRequestsWhenNotIdle;
Size maPreviewSize;
bool mbDoSuperSampling;
SharedCacheContext mpCacheContext;
RequestQueue& mrQueue;
::boost::shared_ptr<BitmapCache> mpCache;

View File

@ -42,8 +42,8 @@
#include "SlsSelectionCommand.hxx"
#include "controller/SlsAnimator.hxx"
#include "controller/SlsClipboard.hxx"
#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsScrollBarManager.hxx"
#include "controller/SlsPageObjectFactory.hxx"
#include "controller/SlsSelectionManager.hxx"
#include "controller/SlsSlotManager.hxx"
#include "model/SlideSorterModel.hxx"
@ -53,6 +53,7 @@
#include "view/SlsLayouter.hxx"
#include "view/SlsViewOverlay.hxx"
#include "view/SlsFontProvider.hxx"
#include "view/SlsPageObjectLayouter.hxx"
#include "cache/SlsPageCache.hxx"
#include "cache/SlsPageCacheManager.hxx"
@ -101,6 +102,7 @@ using namespace ::com::sun::star::uno;
using namespace ::sd::slidesorter::model;
using namespace ::sd::slidesorter::view;
using namespace ::sd::slidesorter::controller;
using namespace ::basegfx;
namespace sd { namespace slidesorter { namespace controller {
@ -116,6 +118,7 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter)
mpScrollBarManager(),
mpCurrentSlideManager(),
mpSelectionManager(),
mpInsertionIndicatorHandler(new InsertionIndicatorHandler(rSlideSorter)),
mpAnimator(new Animator(rSlideSorter)),
mpListener(),
mnModelChangeLockCount(0),
@ -126,12 +129,11 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter)
mpEditModeChangeMasterPage(NULL),
maTotalWindowArea(),
mnPaintEntranceCount(0),
mbIsContextMenuOpen(false),
mpProperties(new Properties())
mbIsContextMenuOpen(false)
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
OSL_ASSERT(pWindow!=NULL);
if (pWindow != NULL)
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
OSL_ASSERT(pWindow);
if (pWindow)
{
// The whole background is painted by the view and controls.
::Window* pParentWindow = pWindow->GetParent();
@ -140,22 +142,12 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter)
// Connect the view with the window that has been created by our base
// class.
pWindow->SetBackground (Wallpaper());
mrView.AddWindowToPaintView(pWindow);
mrView.SetActualWin(pWindow);
pWindow->SetCenterAllowed (false);
pWindow->SetViewSize (mrView.GetModelArea().GetSize());
pWindow->EnableRTL(FALSE);
// Reinitialize colors in Properties with window specific values.
mpProperties->SetBackgroundColor(
pWindow->GetSettings().GetStyleSettings().GetWindowColor());
mpProperties->SetTextColor(
pWindow->GetSettings().GetStyleSettings().GetWindowTextColor());
mpProperties->SetSelectionColor(
pWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor());
mpProperties->SetHighlightColor(
pWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor());
// mrView.AddWindowToPaintView(pWindow.get());
// mrView.SetActualWin(pWindow.get());
pWindow->SetBackground(Wallpaper());
pWindow->SetCenterAllowed(false);
pWindow->SetMapMode(MapMode(MAP_PIXEL));
pWindow->SetViewSize(mrView.GetModelArea().GetSize());
}
}
@ -214,6 +206,14 @@ SlideSorterController::~SlideSorterController (void)
void SlideSorterController::Dispose (void)
{
mpAnimator->Dispose();
}
SlideSorter& SlideSorterController::GetSlideSorter (void) const
{
return mrSlideSorter;
@ -313,10 +313,20 @@ ScrollBarManager& SlideSorterController::GetScrollBarManager (void)
::boost::shared_ptr<InsertionIndicatorHandler>
SlideSorterController::GetInsertionIndicatorHandler (void) const
{
OSL_ASSERT(mpInsertionIndicatorHandler.get()!=NULL);
return mpInsertionIndicatorHandler;
}
void SlideSorterController::PrePaint()
{
// forward VCLs PrePaint window event to DrawingLayer
mrView.PrePaint();
//AF mrView.PrePaint();
}
@ -326,7 +336,7 @@ void SlideSorterController::Paint (
const Rectangle& rBBox,
::Window* pWindow)
{
// if (mnPaintEntranceCount == 0)
if (mnPaintEntranceCount == 0)
{
++mnPaintEntranceCount;
@ -335,7 +345,6 @@ void SlideSorterController::Paint (
if (GetSelectionManager()->IsMakeSelectionVisiblePending())
GetSelectionManager()->MakeSelectionVisible();
mrView.SetApplicationDocumentColor(GetProperties()->GetBackgroundColor());
mrView.CompleteRedraw(pWindow, Region(rBBox), 0);
}
catch (const Exception&)
@ -429,9 +438,8 @@ bool SlideSorterController::Command (
// When there is no selection, then we show the insertion
// indicator so that the user knows where a page insertion
// would take place.
mrView.GetOverlay().GetInsertionIndicatorOverlay().SetPosition(
GetInsertionIndicatorHandler()->Start(
pWindow->PixelToLogic(rEvent.GetMousePosPixel()));
mrView.GetOverlay().GetInsertionIndicatorOverlay().setVisible(true);
}
pWindow->ReleaseMouse();
@ -455,17 +463,18 @@ bool SlideSorterController::Command (
GetFocusManager().GetFocusedPageDescriptor());
if (pDescriptor.get() != NULL)
{
Rectangle aBBox (mrView.GetPageBoundingBox (
pDescriptor,
view::SlideSorterView::CS_SCREEN,
view::SlideSorterView::BBT_SHAPE));
Point aPosition (aBBox.Center());
Rectangle aBBox (
mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox (
pDescriptor,
PageObjectLayouter::PageObject,
PageObjectLayouter::WindowCoordinateSystem));
Point aCenter (aBBox.Center());
mbIsContextMenuOpen = true;
if (pViewShell != NULL)
pViewShell->GetViewFrame()->GetDispatcher()->ExecutePopup(
SdResId(nPopupId),
pWindow,
&aPosition);
&aCenter);
}
}
}
@ -476,8 +485,8 @@ bool SlideSorterController::Command (
// it is hidden, so that a pending slide insertion slot call
// finds the right place to insert a new slide.
GetSelectionManager()->SetInsertionPosition(
mrView.GetOverlay().GetInsertionIndicatorOverlay().GetInsertionPageIndex());
mrView.GetOverlay().GetInsertionIndicatorOverlay().setVisible(false);
GetInsertionIndicatorHandler()->GetInsertionPageIndex());
GetInsertionIndicatorHandler()->End();
}
bEventHasBeenHandled = true;
}
@ -531,8 +540,7 @@ void SlideSorterController::PreModelChange (void)
mpPageSelector->PrepareModelChange();
GetCurrentSlideManager()->PrepareModelChange();
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
if (pWindow != NULL)
if (mrSlideSorter.GetContentWindow())
mrView.PreModelChange();
mbPostModelChangePending = true;
@ -546,8 +554,8 @@ void SlideSorterController::PostModelChange (void)
mbPostModelChangePending = false;
mrModel.Resync();
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
if (pWindow != NULL)
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if (pWindow)
{
GetCurrentSlideManager()->HandleModelChange();
@ -593,22 +601,22 @@ IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent)
if (pEvent != NULL)
{
::Window* pWindow = pEvent->GetWindow();
::sd::Window* pActiveWindow = mrSlideSorter.GetActiveWindow();
::boost::shared_ptr<sd::Window> pActiveWindow (mrSlideSorter.GetContentWindow());
switch (pEvent->GetId())
{
case VCLEVENT_WINDOW_ACTIVATE:
case VCLEVENT_WINDOW_SHOW:
if (pActiveWindow != NULL && pWindow == pActiveWindow->GetParent())
if (pActiveWindow && pWindow == pActiveWindow->GetParent())
mrView.RequestRepaint();
break;
case VCLEVENT_WINDOW_GETFOCUS:
if (pActiveWindow != NULL && pWindow == pActiveWindow)
if (pActiveWindow && pWindow == pActiveWindow.get())
GetFocusManager().ShowFocus(false);
break;
case VCLEVENT_WINDOW_LOSEFOCUS:
if (pActiveWindow != NULL && pWindow == pActiveWindow)
if (pActiveWindow && pWindow == pActiveWindow.get())
GetFocusManager().HideFocus();
break;
@ -668,10 +676,9 @@ void SlideSorterController::GetCtrlState (SfxItemSet& rSet)
||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE
||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE)
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
if (pWindow != NULL)
if (mrSlideSorter.GetContentWindow())
{
ULONG nMode = pWindow->GetDrawMode();
ULONG nMode = mrSlideSorter.GetContentWindow()->GetDrawMode();
UINT16 nQuality = 0;
switch (nMode)
@ -744,7 +751,7 @@ void SlideSorterController::ExecStatusBar (SfxRequest& )
void SlideSorterController::UpdateAllPages (void)
{
// Do a redraw.
mrView.InvalidateAllWin();
mrSlideSorter.GetContentWindow()->Invalidate();
}
@ -770,8 +777,8 @@ Rectangle SlideSorterController::Rearrange (bool bForce)
{
Rectangle aNewContentArea (maTotalWindowArea);
::boost::shared_ptr<sd::Window> pWindow = mrSlideSorter.GetContentWindow();
if (pWindow.get() != NULL)
const ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if (pWindow)
{
// Place the scroll bars.
aNewContentArea = GetScrollBarManager().PlaceScrollBars(maTotalWindowArea);
@ -806,16 +813,13 @@ Rectangle SlideSorterController::Rearrange (bool bForce)
void SlideSorterController::SetZoom (long int nZoom)
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
long int nCurrentZoom ((long int)(
pWindow->GetMapMode().GetScaleX().operator double() * 100));
if (nZoom > nCurrentZoom)
{
Size aPageSize (mrView.GetPageBoundingBox(
0,
view::SlideSorterView::CS_MODEL,
view::SlideSorterView::BBT_SHAPE).GetSize());
Size aPageSize (mrView.GetLayouter().GetPageObjectSize());
Size aWindowSize (pWindow->PixelToLogic(
pWindow->GetOutputSizePixel()));
@ -831,13 +835,13 @@ void SlideSorterController::SetZoom (long int nZoom)
if (nZoom < 1)
nZoom = 1;
mrView.LockRedraw (TRUE);
mrView.GetLayouter().SetZoom(nZoom/100.0, pWindow);
mrView.LockRedraw(true);
mrView.GetLayouter().SetZoom(nZoom/100.0);
mrView.Layout();
GetScrollBarManager().UpdateScrollBars (false);
mrView.GetPreviewCache()->InvalidateCache();
mrView.RequestRepaint();
mrView.LockRedraw (FALSE);
mrView.LockRedraw(false);
/*
ViewShell::SetZoom (nZoom);
@ -960,8 +964,8 @@ void SlideSorterController::PageNameHasChanged (int nPageIndex, const String& rs
// that of the name change.
do
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
if (pWindow == NULL)
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if ( ! pWindow)
break;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
@ -1010,14 +1014,6 @@ bool SlideSorterController::IsContextMenuOpen (void) const
::boost::shared_ptr<Properties> SlideSorterController::GetProperties (void) const
{
return mpProperties;
}
void SlideSorterController::SetDocumentSlides (const Reference<container::XIndexAccess>& rxSlides)
{
if (mrModel.GetDocumentSlides() != rxSlides)

View File

@ -0,0 +1,287 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsAnimator.cxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_sd.hxx"
#include "controller/SlsAnimationFunction.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlideSorterView.hxx"
#include <osl/diagnose.hxx>
#include <rtl/math.hxx>
namespace sd { namespace slidesorter { namespace controller {
double AnimationFunction::FastInSlowOut_Sine (const double nTime)
{
OSL_ASSERT(nTime>=0.0 && nTime<=1.0);
const double nResult (sin(nTime * M_PI/2));
OSL_ASSERT(nResult>=0.0 && nResult<=1.0);
return nResult;
}
double AnimationFunction::FastInSlowOut_Root (const double nTime)
{
OSL_ASSERT(nTime>=0.0 && nTime<=1.0);
const double nResult (sqrt(nTime));
OSL_ASSERT(nResult>=0.0 && nResult<=1.0);
return nResult;
}
double AnimationFunction::SlowInSlowOut_0to0_Sine (const double nTime)
{
OSL_ASSERT(nTime>=0.0 && nTime<=1.0);
const double nResult (sin(nTime * M_PI));
OSL_ASSERT(nResult>=0.0 && nResult<=1.0);
return nResult;
}
double AnimationFunction::Vibrate_Sine (const double nTime)
{
return sin(nTime*M_PI*8);
}
Point AnimationFunction::ScalePoint (const Point& rPoint, const double nTime)
{
return Point(
sal_Int32(::rtl::math::round(rPoint.X() * nTime)),
sal_Int32(::rtl::math::round(rPoint.Y() * nTime)));
}
double AnimationFunction::Blend (
const double nStartValue,
const double nEndValue,
const double nTime)
{
return nStartValue*(1-nTime) + nEndValue*nTime;
}
void AnimationFunction::ApplyVisualStateChange (
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const double nTime)
{
if (rpDescriptor)
{
rpDescriptor->GetVisualState().SetVisualStateBlend(nTime);
rView.RequestRepaint(rpDescriptor);
}
}
void AnimationFunction::ApplyLocationOffsetChange (
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const Point aLocationOffset)
{
if (rpDescriptor)
{
const Rectangle aOldBoundingBox(rpDescriptor->GetBoundingBox());
rpDescriptor->GetVisualState().SetLocationOffset(aLocationOffset);
rView.RequestRepaint(aOldBoundingBox);
rView.RequestRepaint(rpDescriptor);
}
}
void AnimationFunction::ApplyButtonAlphaChange(
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const double nAlpha)
{
if (rpDescriptor)
{
rpDescriptor->GetVisualState().SetButtonAlpha(nAlpha);
rView.RequestRepaint(rpDescriptor);
}
}
//===== AnimationBezierFunction ===============================================
AnimationBezierFunction::AnimationBezierFunction (
const double nX1,
const double nY1,
const double nX2,
const double nY2)
: mnX1(nX1),
mnY1(nY1),
mnX2(nX2),
mnY2(nY2)
{
}
AnimationBezierFunction::AnimationBezierFunction (
const double nX1,
const double nY1)
: mnX1(nX1),
mnY1(nY1),
mnX2(1-nY1),
mnY2(1-nX1)
{
}
::basegfx::B2DPoint AnimationBezierFunction::operator() (const double nT)
{
return ::basegfx::B2DPoint(
EvaluateComponent(nT, mnX1, mnX2),
EvaluateComponent(nT, mnY1, mnY2));
}
double AnimationBezierFunction::EvaluateComponent (
const double nT,
const double nV1,
const double nV2)
{
const double nS (1-nT);
// While the control point values 1 and 2 are explicitly given the start
// and end values are implicitly given.
const double nV0 (0);
const double nV3 (1);
const double nV01 (nS*nV0 + nT*nV1);
const double nV12 (nS*nV1 + nT*nV2);
const double nV23 (nS*nV2 + nT*nV3);
const double nV012 (nS*nV01 + nT*nV12);
const double nV123 (nS*nV12 + nT*nV23);
const double nV0123 (nS*nV012 + nT*nV123);
return nV0123;
}
//===== AnimationParametricFunction ===========================================
AnimationParametricFunction::AnimationParametricFunction (const ParametricFunction& rFunction)
: maY()
{
const sal_Int32 nSampleCount (64);
// Sample the given parametric function.
::std::vector<basegfx::B2DPoint> aPoints;
aPoints.reserve(nSampleCount);
for (sal_Int32 nIndex=0; nIndex<nSampleCount; ++nIndex)
{
const double nT (nIndex/double(nSampleCount-1));
aPoints.push_back(basegfx::B2DPoint(rFunction(nT)));
}
// Interpolate at evenly spaced points.
maY.clear();
maY.reserve(nSampleCount);
double nX0 (aPoints[0].getX());
double nY0 (aPoints[0].getY());
double nX1 (aPoints[1].getX());
double nY1 (aPoints[1].getY());
sal_Int32 nIndex (1);
for (sal_Int32 nIndex2=0; nIndex2<nSampleCount; ++nIndex2)
{
const double nX (nIndex2 / double(nSampleCount-1));
while (nX > nX1 && nIndex<nSampleCount)
{
nX0 = nX1;
nY0 = nY1;
nX1 = aPoints[nIndex].getX();
nY1 = aPoints[nIndex].getY();
++nIndex;
}
const double nU ((nX-nX1) / (nX0 - nX1));
const double nY (nY0*nU + nY1*(1-nU));
maY.push_back(nY);
}
}
double AnimationParametricFunction::operator() (const double nX)
{
const sal_Int32 nIndex0 (nX * maY.size());
const double nX0 (nIndex0 / double(maY.size()-1));
const sal_Int32 nIndex1 (nIndex0 + 1);
const double nX1 (nIndex1 / double(maY.size()-1));
if (nIndex0<=0)
return maY[0];
else if (nIndex0>=maY.size() || nIndex1>=maY.size())
return maY[maY.size()-1];
const double nU ((nX-nX1) / (nX0 - nX1));
return maY[nIndex0]*nU + maY[nIndex1]*(1-nU);
}
} } } // end of namespace ::sd::slidesorter::controller

View File

@ -33,6 +33,7 @@
#include "controller/SlsAnimator.hxx"
#include "view/SlideSorterView.hxx"
#include "View.hxx"
#include <boost/bind.hpp>
namespace sd { namespace slidesorter { namespace controller {
@ -46,14 +47,23 @@ class Animator::Animation
{
public:
Animation (
const Animator::AnimationFunction& rAnimation,
const double nDelta);
const Animator::AnimationFunctor& rAnimation,
const double nDelta,
const double nEnd,
const Animator::AnimationId nAnimationId,
const Animator::FinishFunctor& rFinishFunctor);
~Animation (void);
bool Run (void);
void Expire (void);
bool IsExpired (void);
Animator::AnimationFunction maAnimation;
Animator::AnimationFunctor maAnimation;
Animator::FinishFunctor maFinishFunctor;
const Animator::AnimationId mnAnimationId;
double mnValue;
double mnDelta;
const double mnEnd;
const double mnDelta;
bool mbIsExpired;
};
@ -62,11 +72,11 @@ public:
class Animator::DrawLock
{
public:
DrawLock (View& rView);
DrawLock (view::SlideSorterView& rView);
~DrawLock (void);
private:
View& mrView;
view::SlideSorterView& mrView;
};
@ -75,8 +85,10 @@ private:
Animator::Animator (SlideSorter& rSlideSorter)
: mrSlideSorter(rSlideSorter),
maTimer(),
mbIsDisposed(false),
maAnimations(),
mpDrawLock()
mpDrawLock(),
mnNextAnimationId(0)
{
maTimer.SetTimeout(gnResolution);
maTimer.SetTimeoutHdl(LINK(this,Animator,TimeoutHandler));
@ -87,6 +99,19 @@ Animator::Animator (SlideSorter& rSlideSorter)
Animator::~Animator (void)
{
if ( ! mbIsDisposed)
{
OSL_ASSERT(mbIsDisposed);
Dispose();
}
}
void Animator::Dispose (void)
{
mbIsDisposed = true;
maTimer.Stop();
mpDrawLock.reset();
}
@ -94,25 +119,82 @@ Animator::~Animator (void)
void Animator::AddAnimation (
const AnimationFunction& rAnimation,
const sal_Int32 nDuration)
Animator::AnimationId Animator::AddAnimation (
const AnimationFunctor& rAnimation,
const sal_Int32 nDuration,
const FinishFunctor& rFinishFunctor)
{
OSL_ASSERT( ! mbIsDisposed);
const double nDelta = double(gnResolution) / double(nDuration);
maAnimations.push_back(boost::shared_ptr<Animation>(new Animation(rAnimation, nDelta)));
boost::shared_ptr<Animation> pAnimation (
new Animation(rAnimation, nDelta, 1.0, ++mnNextAnimationId, rFinishFunctor));
maAnimations.push_back(pAnimation);
// Prevent redraws except for the ones in TimeoutHandler.
// While the Animator is active it will schedule repaints regularly.
// Repaints in between would only lead to visual artifacts.
mpDrawLock.reset(new DrawLock(mrSlideSorter.GetView()));
maTimer.Start();
return pAnimation->mnAnimationId;
}
bool Animator::ServeAnimations (void)
Animator::AnimationId Animator::AddInfiniteAnimation (
const AnimationFunctor& rAnimation,
const double nDelta)
{
OSL_ASSERT( ! mbIsDisposed);
boost::shared_ptr<Animation> pAnimation (
new Animation(rAnimation, nDelta, -1.0, mnNextAnimationId++, FinishFunctor()));
maAnimations.push_back(pAnimation);
// Prevent redraws except for the ones in TimeoutHandler.
// While the Animator is active it will schedule repaints regularly.
// Repaints in between would only lead to visual artifacts.
mpDrawLock.reset(new DrawLock(mrSlideSorter.GetView()));
maTimer.Start();
return pAnimation->mnAnimationId;
}
void Animator::RemoveAnimation (const Animator::AnimationId nId)
{
OSL_ASSERT( ! mbIsDisposed);
const AnimationList::iterator iAnimation (::std::find_if(
maAnimations.begin(),
maAnimations.end(),
::boost::bind(
::std::equal_to<Animator::AnimationId>(),
nId,
::boost::bind(&Animation::mnAnimationId, _1))));
if (iAnimation != maAnimations.end())
{
OSL_ASSERT((*iAnimation)->mnAnimationId == nId);
(*iAnimation)->Expire();
maAnimations.erase(iAnimation);
}
// Reset the animation id when we can.
if (maAnimations.empty())
mnNextAnimationId = 0;
}
bool Animator::ProcessAnimations (void)
{
OSL_ASSERT( ! mbIsDisposed);
bool bExpired (false);
AnimationList aCopy (maAnimations);
@ -130,6 +212,8 @@ bool Animator::ServeAnimations (void)
void Animator::CleanUpAnimationList (void)
{
OSL_ASSERT( ! mbIsDisposed);
AnimationList aActiveAnimations;
AnimationList::const_iterator iAnimation;
@ -147,7 +231,10 @@ void Animator::CleanUpAnimationList (void)
IMPL_LINK(Animator, TimeoutHandler, Timer*, EMPTYARG)
{
if (ServeAnimations())
if (mbIsDisposed)
return 0;
if (ProcessAnimations())
CleanUpAnimationList();
// Unlock the draw lock. This should lead to a repaint.
@ -168,11 +255,18 @@ IMPL_LINK(Animator, TimeoutHandler, Timer*, EMPTYARG)
//===== Animator::Animation ===================================================
Animator::Animation::Animation (
const Animator::AnimationFunction& rAnimation,
const double nDelta)
const Animator::AnimationFunctor& rAnimation,
const double nDelta,
const double nEnd,
const Animator::AnimationId nId,
const Animator::FinishFunctor& rFinishFunctor)
: maAnimation(rAnimation),
maFinishFunctor(rFinishFunctor),
mnValue(0),
mnDelta(nDelta)
mnEnd(nEnd),
mnDelta(nDelta),
mnAnimationId(nId),
mbIsExpired(false)
{
maAnimation(mnValue);
@ -192,16 +286,35 @@ Animator::Animation::~Animation (void)
bool Animator::Animation::Run (void)
{
if (mnValue < 1.0)
if ( ! mbIsExpired)
{
maAnimation(mnValue);
mnValue += mnDelta;
return false;
if (mnEnd>=0 && mnValue>=mnEnd)
{
maAnimation(mnEnd);
Expire();
return true;
}
else
{
maAnimation(mnValue);
mnValue += mnDelta;
return false;
}
}
else
{
maAnimation(1.0);
return true;
}
void Animator::Animation::Expire (void)
{
if ( ! mbIsExpired)
{
mbIsExpired = true;
if (maFinishFunctor)
maFinishFunctor();
}
}
@ -210,7 +323,7 @@ bool Animator::Animation::Run (void)
bool Animator::Animation::IsExpired (void)
{
return mnValue >= 1.0;
return mbIsExpired;
}
@ -218,10 +331,10 @@ bool Animator::Animation::IsExpired (void)
//===== Animator::DrawLock ====================================================
Animator::DrawLock::DrawLock (View& rView)
Animator::DrawLock::DrawLock (view::SlideSorterView& rView)
: mrView(rView)
{
mrView.LockRedraw(TRUE);
mrView.LockRedraw(true);
}
@ -229,7 +342,7 @@ Animator::DrawLock::DrawLock (View& rView)
Animator::DrawLock::~DrawLock (void)
{
mrView.LockRedraw(FALSE);
mrView.LockRedraw(false);
}

View File

@ -39,8 +39,8 @@
#include "model/SlsPageEnumerationProvider.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsViewOverlay.hxx"
#include "view/SlsPageObject.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsPageSelector.hxx"
#include "controller/SlsSelectionFunction.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
@ -212,7 +212,7 @@ void Clipboard::DoPaste (::Window* pWindow)
sal_Int32 nInsertPageCount = PasteTransferable(nInsertPosition);
// Select the pasted pages and make the first of them the
// current page.
mrSlideSorter.GetView().GetWindow()->GrabFocus();
mrSlideSorter.GetContentWindow()->GrabFocus();
SelectPageRange(nInsertPosition, nInsertPageCount);
}
}
@ -233,11 +233,11 @@ sal_Int32 Clipboard::GetInsertionPosition (::Window* pWindow)
// selection.
// d) After the last page when there is no selection and no focus.
view::InsertionIndicatorOverlay& rInsertionIndicatorOverlay (
mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay());
if (rInsertionIndicatorOverlay.isVisible())
::boost::shared_ptr<controller::InsertionIndicatorHandler> pInsertionIndicatorHandler (
mrController.GetInsertionIndicatorHandler());
if (pInsertionIndicatorHandler->IsActive())
{
nInsertPosition = rInsertionIndicatorOverlay.GetInsertionPageIndex();
nInsertPosition = pInsertionIndicatorHandler->GetInsertionPageIndex();
}
else if (mrController.GetFocusManager().IsFocusShowing())
{
@ -426,13 +426,15 @@ void Clipboard::CreateSlideTransferable (
void Clipboard::StartDrag (
const Point&,
const Point& rPosition,
::Window* pWindow)
{
maPagesToRemove.clear();
maPagesToSelect.clear();
mbUpdateSelectionPending = false;
CreateSlideTransferable (pWindow, TRUE);
CreateSlideTransferable(pWindow, TRUE);
mrController.GetInsertionIndicatorHandler()->UpdatePosition(rPosition);
}
@ -441,8 +443,8 @@ void Clipboard::StartDrag (
void Clipboard::DragFinished (sal_Int8 nDropAction)
{
// Hide the substitution display and insertion indicator.
mrSlideSorter.GetView().GetOverlay().GetSubstitutionOverlay().setVisible(false);
mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay().setVisible(false);
mrSlideSorter.GetView().GetOverlay().GetSubstitutionOverlay()->SetIsVisible(false);
mrSlideSorter.GetController().GetInsertionIndicatorHandler()->End();
SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
@ -497,6 +499,11 @@ sal_Int8 Clipboard::AcceptDrop (
{
sal_Int8 nResult = DND_ACTION_NONE;
FunctionReference rFunction (mrSlideSorter.GetViewShell()->GetCurrentFunction());
SelectionFunction* pSelectionFunction = dynamic_cast<SelectionFunction*>(rFunction.get());
if (pSelectionFunction != NULL)
pSelectionFunction->MouseDragged(rEvent);
switch (IsDropAccepted())
{
case DT_PAGE:
@ -521,12 +528,11 @@ sal_Int8 Clipboard::AcceptDrop (
// Show the insertion marker and the substitution for a drop.
Point aPosition = pTargetWindow->PixelToLogic (rEvent.maPosPixel);
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
rOverlay.GetInsertionIndicatorOverlay().SetPosition (aPosition);
rOverlay.GetInsertionIndicatorOverlay().setVisible(true);
rOverlay.GetSubstitutionOverlay().SetPosition (aPosition);
mrController.GetInsertionIndicatorHandler()->UpdatePosition(aPosition);
rOverlay.GetSubstitutionOverlay()->SetPosition(aPosition);
// Scroll the window when the mouse reaches the window border.
mrController.GetScrollBarManager().AutoScroll (rEvent.maPosPixel);
// mrController.GetScrollBarManager().AutoScroll (rEvent.maPosPixel);
}
break;
@ -576,12 +582,11 @@ sal_Int8 Clipboard::ExecuteDrop (
// Get insertion position and then turn off the insertion indicator.
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
rOverlay.GetInsertionIndicatorOverlay().SetPosition(
aEventModelPosition);
USHORT nIndex = DetermineInsertPosition (*pDragTransferable);
mrController.GetInsertionIndicatorHandler()->UpdatePosition(aEventModelPosition);
USHORT nIndex = DetermineInsertPosition(*pDragTransferable);
OSL_TRACE ("Clipboard::AcceptDrop() called for index %d",
nIndex);
rOverlay.GetInsertionIndicatorOverlay().setVisible(false);
mrController.GetInsertionIndicatorHandler()->End();
if (bContinue)
{
@ -644,9 +649,8 @@ USHORT Clipboard::DetermineInsertPosition (const SdTransferable& )
// Tell the model to move the dragged pages behind the one with the
// index nInsertionIndex which first has to be transformed into an index
// understandable by the document.
view::InsertionIndicatorOverlay& rOverlay (
mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay());
sal_Int32 nInsertionIndex (rOverlay.GetInsertionPageIndex());
sal_Int32 nInsertionIndex (
mrController.GetInsertionIndicatorHandler()->GetInsertionPageIndex());
// The index returned by the overlay starts with 1 for the first slide.
// This is now converted that to an SdModel index that also starts with 1.

View File

@ -38,7 +38,6 @@
#include "controller/SlideSorterController.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "ViewShellBase.hxx"
#include "ViewShell.hxx"
#include "DrawViewShell.hxx"
@ -90,10 +89,7 @@ void CurrentSlideManager::CurrentSlideHasChanged (const sal_Int32 nSlideIndex)
void CurrentSlideManager::ReleaseCurrentSlide (void)
{
if (mpCurrentSlide.get() != NULL)
{
mpCurrentSlide->SetIsCurrentPage(false);
mrSlideSorter.GetView().RequestRepaint(mpCurrentSlide);
}
mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, false);
mpCurrentSlide.reset();
mnCurrentSlideIndex = -1;
@ -121,10 +117,7 @@ void CurrentSlideManager::AcquireCurrentSlide (const sal_Int32 nSlideIndex)
// document.
mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex);
if (mpCurrentSlide.get() != NULL)
{
mpCurrentSlide->SetIsCurrentPage(true);
mrSlideSorter.GetView().RequestRepaint(mpCurrentSlide);
}
mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, true);
}
}
@ -143,8 +136,8 @@ void CurrentSlideManager::SwitchCurrentSlide (const SharedPageDescriptor& rpDesc
{
if (rpDescriptor.get() != NULL)
{
mpCurrentSlide = rpDescriptor;
mnCurrentSlideIndex = (rpDescriptor->GetPage()->GetPageNum()-1)/2;
ReleaseCurrentSlide();
AcquireCurrentSlide((rpDescriptor->GetPage()->GetPageNum()-1)/2);
ViewShell* pViewShell = mrSlideSorter.GetViewShell();
if (pViewShell != NULL && pViewShell->IsMainViewShell())
@ -250,10 +243,9 @@ void CurrentSlideManager::HandleModelChange (void)
{
if (mnCurrentSlideIndex >= 0)
{
mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(
mnCurrentSlideIndex);
mpCurrentSlide = mrSlideSorter.GetModel().GetPageDescriptor(mnCurrentSlideIndex);
if (mpCurrentSlide.get() != NULL)
mpCurrentSlide->SetIsCurrentPage(true);
mrSlideSorter.GetView().SetState(mpCurrentSlide, PageDescriptor::ST_Current, true);
}
}

View File

@ -175,7 +175,7 @@ bool FocusManager::ToggleFocus (void)
bool FocusManager::HasFocus (void) const
{
return mrSlideSorter.GetView().GetWindow()->HasFocus();
return mrSlideSorter.GetContentWindow()->HasFocus();
}
@ -246,8 +246,7 @@ void FocusManager::HideFocusIndicator (const model::SharedPageDescriptor& rpDesc
{
if (rpDescriptor.get() != NULL)
{
rpDescriptor->RemoveFocus();
mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, false);
}
}
@ -260,7 +259,7 @@ void FocusManager::ShowFocusIndicator (
{
if (rpDescriptor.get() != NULL)
{
rpDescriptor->SetFocus ();
mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, true);
if (bScrollToFocus)
{
@ -268,10 +267,7 @@ void FocusManager::ShowFocusIndicator (
// it, so that the focus indicator becomes visible.
view::SlideSorterView& rView (mrSlideSorter.GetView());
mrSlideSorter.GetController().GetSelectionManager()->MakeRectangleVisible (
rView.GetPageBoundingBox (
GetFocusedPageDescriptor(),
view::SlideSorterView::CS_MODEL,
view::SlideSorterView::BBT_INFO));
GetFocusedPageDescriptor()->GetBoundingBox());
}
mrSlideSorter.GetView().RequestRepaint (rpDescriptor);

View File

@ -112,8 +112,10 @@ void HideSlideFunction::DoExecute (SfxRequest& rRequest)
while (aSelectedPages.HasMoreElements())
{
model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
pDescriptor->GetPage()->SetExcluded (eState==EXCLUDED);
static_cast<view::SlideSorterView*>(mpView)->RequestRepaint(pDescriptor);
static_cast<view::SlideSorterView*>(mpView)->SetState(
pDescriptor,
model::PageDescriptor::ST_Excluded,
eState==EXCLUDED);
}
}

View File

@ -0,0 +1,255 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsSelectionFunction.cxx,v $
* $Revision: 1.37 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_sd.hxx"
#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsProperties.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsViewOverlay.hxx"
#include "view/SlsLayouter.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "SlideSorter.hxx"
namespace sd { namespace slidesorter { namespace controller {
InsertionIndicatorHandler::InsertionIndicatorHandler (SlideSorter& rSlideSorter)
: mrSlideSorter(rSlideSorter),
mpInsertAnimator(),
mpInsertionIndicatorOverlay(
mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay()),
mnInsertionIndex(-1),
mbIsBeforePage(false),
mbIsActive(false)
{
}
InsertionIndicatorHandler::~InsertionIndicatorHandler (void)
{
}
void InsertionIndicatorHandler::Start (const Point& rMouseModelPosition)
{
if (mbIsActive)
{
OSL_ASSERT(!mbIsActive);
}
if (mrSlideSorter.GetProperties()->IsUIReadOnly())
return;
SetPosition(rMouseModelPosition);
mbIsActive = true;
}
void InsertionIndicatorHandler::UpdatePosition (const Point& rMouseModelPosition)
{
OSL_ASSERT(mbIsActive);
if (mrSlideSorter.GetProperties()->IsUIReadOnly())
return;
SetPosition(rMouseModelPosition);
}
void InsertionIndicatorHandler::End (void)
{
OSL_ASSERT(mbIsActive);
GetInsertAnimator()->SetInsertPosition(-1, false);
mbIsActive = false;
mpInsertionIndicatorOverlay->SetIsVisible(false);
GetInsertAnimator()->Reset();
}
bool InsertionIndicatorHandler::IsActive (void) const
{
return mbIsActive;
}
sal_Int32 InsertionIndicatorHandler::GetInsertionPageIndex (void) const
{
return mnInsertionIndex;
}
void InsertionIndicatorHandler::SetPosition (const Point& rPoint)
{
static const bool bAllowHorizontalInsertMarker = true;
view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter());
USHORT nPageCount ((USHORT)mrSlideSorter.GetModel().GetPageCount());
sal_Int32 nInsertionIndex = rLayouter.GetInsertionIndex (rPoint,
bAllowHorizontalInsertMarker);
if (nInsertionIndex >= nPageCount)
nInsertionIndex = nPageCount-1;
sal_Int32 nDrawIndex = nInsertionIndex;
bool bVertical = false;
bool bIsBeforePage = 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;
bIsBeforePage = (rPoint.Y() <= aPageCenter.Y());
}
else
{
bVertical = true;
bIsBeforePage = (rPoint.X() <= aPageCenter.X());
}
// Add one when the mark was painted below or to the right of the
// page object.
if ( ! bIsBeforePage)
nInsertionIndex += 1;
}
if (mnInsertionIndex!=nInsertionIndex || mbIsBeforePage!=bIsBeforePage)
{
mnInsertionIndex = nInsertionIndex;
mbIsBeforePage = bIsBeforePage;
mbIsInsertionTrivial = IsInsertionTrivial();
mpInsertionIndicatorOverlay->SetLocation(
rLayouter.GetInsertionMarkerLocation (
nDrawIndex,
bVertical,
mbIsBeforePage));
}
if (mnInsertionIndex>=0 && ! mbIsInsertionTrivial)
{
GetInsertAnimator()->SetInsertPosition(
mnInsertionIndex,
mbIsBeforePage);
mpInsertionIndicatorOverlay->SetIsVisible(true);
}
else
{
GetInsertAnimator()->Reset();
mpInsertionIndicatorOverlay->SetIsVisible(false);
}
}
::boost::shared_ptr<view::InsertAnimator> InsertionIndicatorHandler::GetInsertAnimator (void)
{
if ( ! mpInsertAnimator)
mpInsertAnimator.reset(new view::InsertAnimator(mrSlideSorter));
return mpInsertAnimator;
}
bool InsertionIndicatorHandler::IsInsertionTrivial (void) const
{
// Iterate over all selected pages and check whether there are
// holes. While we do this we remember the indices of the first and
// last selected page as preparation for the next step.
sal_Int32 nCurrentIndex = -1;
sal_Int32 nFirstIndex = -1;
sal_Int32 nLastIndex = -1;
model::PageEnumeration aSelectedPages (
model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
mrSlideSorter.GetModel()));
while (aSelectedPages.HasMoreElements())
{
model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
// Get the page number and compare it to the last one.
const sal_Int32 nPageNumber (pDescriptor->GetPageIndex());
if (nCurrentIndex>=0 && nPageNumber>(nCurrentIndex+1))
return false;
else
nCurrentIndex = nPageNumber;
// Remember indices of the first and last page of the selection.
if (nFirstIndex == -1)
nFirstIndex = nPageNumber;
nLastIndex = nPageNumber;
}
// When we come here then the selection has no holes. We still have
// to check that the insertion position is not directly in front or
// directly behind the selection and thus moving the selection there
// would not change the model.
if (mnInsertionIndex<nFirstIndex || mnInsertionIndex>(nLastIndex+1))
return false;
return true;
}
} } } // end of namespace ::sd::slidesorter::controller

View File

@ -28,8 +28,8 @@
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include "SlsListener.hxx"
#include "SlideSorter.hxx"
@ -40,6 +40,7 @@
#include "controller/SlsCurrentSlideManager.hxx"
#include "model/SlideSorterModel.hxx"
#include "view/SlideSorterView.hxx"
#include "cache/SlsPageCache.hxx"
#include "drawdoc.hxx"
#include "glob.hrc"
@ -129,7 +130,7 @@ Listener::Listener (
if (pMainViewShell != NULL
&& pMainViewShell!=pViewShell)
{
StartListening (*pMainViewShell);
StartListening(*pMainViewShell);
}
Link aLink (LINK(this, Listener, EventMultiplexerCallback));
@ -309,18 +310,27 @@ void Listener::Notify (
if (rHint.ISA(SdrHint))
{
SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint));
if(rSdrHint.GetKind() == HINT_PAGEORDERCHG )
switch (rSdrHint.GetKind())
{
if (rBroadcaster.ISA(SdDrawDocument))
{
SdDrawDocument& rDocument (
static_cast<SdDrawDocument&>(rBroadcaster));
if (rDocument.GetMasterSdPageCount(PK_STANDARD)
== rDocument.GetMasterSdPageCount(PK_NOTES))
case HINT_PAGEORDERCHG:
if (rBroadcaster.ISA(SdDrawDocument))
{
mrController.HandleModelChange();
SdDrawDocument& rDocument (static_cast<SdDrawDocument&>(rBroadcaster));
if (rDocument.GetMasterSdPageCount(PK_STANDARD)
== rDocument.GetMasterSdPageCount(PK_NOTES))
{
mrController.HandleModelChange();
}
}
}
break;
case HINT_OBJINSERTED:
case HINT_OBJREMOVED:
case HINT_OBJCHG:
mrSlideSorter.GetView().GetPreviewCache()->InvalidatePreviewBitmap(
rSdrHint.GetPage(),
true);
break;
}
}
else if (rHint.ISA(ViewShellHint))

View File

@ -36,6 +36,7 @@
#include "SlideSorterViewShell.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsSelectionManager.hxx"
#include "controller/SlsAnimator.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "model/SlideSorterModel.hxx"
@ -47,6 +48,8 @@
#include "ViewShellBase.hxx"
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <boost/bind.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@ -55,7 +58,6 @@ using namespace ::sd::slidesorter::view;
namespace sd { namespace slidesorter { namespace controller {
PageSelector::PageSelector (SlideSorter& rSlideSorter)
: mrModel(rSlideSorter.GetModel()),
mrSlideSorter(rSlideSorter),
@ -112,7 +114,7 @@ void PageSelector::UpdateAllPages (void)
bSelectionHasChanged = true;
}
if (pDescriptor->IsSelected())
if (pDescriptor->HasState(PageDescriptor::ST_Selected))
mnSelectedPageCount++;
}
@ -151,7 +153,8 @@ void PageSelector::SelectPage (const SdPage* pPage)
void PageSelector::SelectPage (const SharedPageDescriptor& rpDescriptor)
{
if (rpDescriptor.get()!=NULL && rpDescriptor->Select())
if (rpDescriptor.get()!=NULL
&& mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, true))
{
mnSelectedPageCount ++;
mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
@ -193,7 +196,8 @@ void PageSelector::DeselectPage (const SdPage* pPage)
void PageSelector::DeselectPage (const SharedPageDescriptor& rpDescriptor)
{
if (rpDescriptor.get()!=NULL && rpDescriptor->Deselect())
if (rpDescriptor.get()!=NULL
&& mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, false))
{
mnSelectedPageCount --;
mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
@ -213,7 +217,7 @@ bool PageSelector::IsPageSelected (int nPageIndex)
{
SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex));
if (pDescriptor.get() != NULL)
return pDescriptor->IsSelected();
return pDescriptor->HasState(PageDescriptor::ST_Selected);
else
return false;
}
@ -315,7 +319,7 @@ void PageSelector::DisableBroadcasting (void)
for (int nIndex=0; nIndex<nPageCount; nIndex++)
{
SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex));
if (pDescriptor.get()!=NULL && pDescriptor->IsSelected())
if (pDescriptor.get()!=NULL && pDescriptor->HasState(PageDescriptor::ST_Selected))
pSelection->push_back(pDescriptor->GetPage());
}

View File

@ -41,7 +41,7 @@ Properties::Properties (void)
mbIsShowSelection(true),
mbIsShowFocus(true),
mbIsCenterSelection(false),
mbIsSmoothSelectionScrolling(false),
mbIsSmoothSelectionScrolling(true),//false),
mbIsSuspendPreviewUpdatesDuringFullScreenPresentation(true),
maBackgroundColor(Application::GetSettings().GetStyleSettings().GetWindowColor()),
maTextColor(Application::GetSettings().GetStyleSettings().GetActiveTextColor()),

View File

@ -54,11 +54,13 @@ ScrollBarManager::ScrollBarManager (SlideSorter& rSlideSorter)
mpVerticalScrollBar(mrSlideSorter.GetVerticalScrollBar()),
mnHorizontalPosition (0),
mnVerticalPosition (0),
maScrollBorder (10,10),
maScrollBorder (20,20),
mnHorizontalScrollFactor (0.1),
mnVerticalScrollFactor (0.1),
mpScrollBarFiller(mrSlideSorter.GetScrollBarFiller()),
mpContentWindow(mrSlideSorter.GetContentWindow())
mpContentWindow(mrSlideSorter.GetContentWindow()),
mbIsAutoScrollActive(false),
maAutoScrollFunctor()
{
// Hide the scroll bars by default to prevent display errors while
// switching between view shells: In the short time between initiating
@ -69,7 +71,7 @@ ScrollBarManager::ScrollBarManager (SlideSorter& rSlideSorter)
mpVerticalScrollBar->Hide();
mpScrollBarFiller->Hide();
maAutoScrollTimer.SetTimeout(50);
maAutoScrollTimer.SetTimeout(25);
maAutoScrollTimer.SetTimeoutHdl (
LINK(this, ScrollBarManager, AutoScrollTimeoutHandler));
}
@ -176,9 +178,7 @@ void ScrollBarManager::PlaceVerticalScrollBar (const Rectangle& aArea)
if (mpVerticalScrollBar != NULL
&& mpVerticalScrollBar->IsVisible())
{
view::Layouter::DoublePoint aLayouterPosition
= mrSlideSorter.GetView().GetLayouter().ConvertModelToLayouterCoordinates (
Point (0, mpVerticalScrollBar->GetThumbPos()));
const double nThumbPosition (mpVerticalScrollBar->GetThumbPos());
// Place the scroll bar.
Size aScrollBarSize (mpVerticalScrollBar->GetSizePixel());
@ -187,11 +187,8 @@ void ScrollBarManager::PlaceVerticalScrollBar (const Rectangle& aArea)
mpVerticalScrollBar->SetPosSizePixel(aPosition, aSize);
// Restore the position.
mpVerticalScrollBar->SetThumbPos(
mrSlideSorter.GetView().GetLayouter().ConvertLayouterToModelCoordinates(
aLayouterPosition).Y());
mnVerticalPosition = double(mpVerticalScrollBar->GetThumbPos())
/ double(mpVerticalScrollBar->GetRange().Len());
mpVerticalScrollBar->SetThumbPos(nThumbPosition);
mnVerticalPosition = nThumbPosition / double(mpVerticalScrollBar->GetRange().Len());
}
}
@ -245,7 +242,7 @@ void ScrollBarManager::AdaptWindowSize (const Rectangle& rArea)
void ScrollBarManager::UpdateScrollBars (bool bResetThumbPosition, bool bUseScrolling)
{
Rectangle aModelArea (mrSlideSorter.GetView().GetModelArea());
::sd::Window* pWindow = mrSlideSorter.GetView().GetWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
Size aWindowModelSize (pWindow->PixelToLogic(pWindow->GetSizePixel()));
// The horizontal scroll bar is only shown when the window is
@ -329,12 +326,12 @@ IMPL_LINK(ScrollBarManager, VerticalScrollBarHandler, ScrollBar*, pScrollBar)
if (pScrollBar!=NULL
&& pScrollBar==mpVerticalScrollBar.get()
&& pScrollBar->IsVisible()
&& mrSlideSorter.GetView().GetWindow()!=NULL)
&& mrSlideSorter.GetContentWindow()!=NULL)
{
double nRelativePosition = double(pScrollBar->GetThumbPos())
/ double(pScrollBar->GetRange().Len());
mrSlideSorter.GetView().InvalidatePageObjectVisibilities();
mrSlideSorter.GetView().GetWindow()->SetVisibleXY (
mrSlideSorter.GetContentWindow()->SetVisibleXY (
-1,
nRelativePosition);
}
@ -349,12 +346,12 @@ IMPL_LINK(ScrollBarManager, HorizontalScrollBarHandler, ScrollBar*, pScrollBar)
if (pScrollBar!=NULL
&& pScrollBar==mpHorizontalScrollBar.get()
&& pScrollBar->IsVisible()
&& mrSlideSorter.GetView().GetWindow()!=NULL)
&& mrSlideSorter.GetContentWindow()!=NULL)
{
double nRelativePosition = double(pScrollBar->GetThumbPos())
/ double(pScrollBar->GetRange().Len());
mrSlideSorter.GetView().InvalidatePageObjectVisibilities();
mrSlideSorter.GetView().GetWindow()->SetVisibleXY (nRelativePosition, -1);
mrSlideSorter.GetContentWindow()->SetVisibleXY (nRelativePosition, -1);
}
return TRUE;
}
@ -369,7 +366,7 @@ void ScrollBarManager::SetWindowOrigin (
mnHorizontalPosition = nHorizontalPosition;
mnVerticalPosition = nVerticalPosition;
::sd::Window* pWindow = mrSlideSorter.GetView().GetWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
Size aViewSize (pWindow->GetViewSize());
Point aOrigin (
(long int) (mnHorizontalPosition * aViewSize.Width()),
@ -440,6 +437,8 @@ bool ScrollBarManager::TestScrollBarVisibilities (
{
bool bAreVisibilitiesOK = true;
model::SlideSorterModel& rModel (mrSlideSorter.GetModel());
// Adapt the available size by subtracting the sizes of the scroll bars
// visible in this combination.
Size aBrowserSize (rAvailableArea.GetSize());
@ -455,22 +454,21 @@ bool ScrollBarManager::TestScrollBarVisibilities (
{
bRearrangeSuccess = mrSlideSorter.GetView().GetLayouter().RearrangeHorizontal (
aBrowserSize,
mrSlideSorter.GetModel().GetPageDescriptor(0)->GetPage()->GetSize(),
mpContentWindow.get(),
mrSlideSorter.GetModel().GetPageCount());
rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
rModel.GetPageCount());
}
else
{
bRearrangeSuccess = mrSlideSorter.GetView().GetLayouter().RearrangeVertical (
aBrowserSize,
mrSlideSorter.GetModel().GetPageDescriptor(0)->GetPage()->GetSize(),
mpContentWindow.get());
rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
rModel.GetPageCount());
}
if (bRearrangeSuccess)
{
Size aPageSize = mrSlideSorter.GetView().GetLayouter().GetPageBox (
mrSlideSorter.GetModel().GetPageCount()).GetSize();
rModel.GetPageCount()).GetSize();
Size aWindowModelSize = mpContentWindow->PixelToLogic(aBrowserSize);
bool bHorizontallyClipped = (aPageSize.Width() > aWindowModelSize.Width());
@ -493,11 +491,11 @@ void ScrollBarManager::SetTop (const sal_Int32 nNewTop)
&& mpVerticalScrollBar->GetThumbPos() != nNewTop)
{
// Flush pending repaints before scrolling to avoid temporary artifacts.
mrSlideSorter.GetView().GetWindow()->Update();
mrSlideSorter.GetContentWindow()->Update();
mpVerticalScrollBar->SetThumbPos(nNewTop);
mnVerticalPosition = double(nNewTop) / double(mpVerticalScrollBar->GetRange().Len());
mrSlideSorter.GetView().GetWindow()->SetVisibleXY (
mrSlideSorter.GetContentWindow()->SetVisibleXY (
mnHorizontalPosition, mnVerticalPosition);
}
}
@ -505,17 +503,28 @@ void ScrollBarManager::SetTop (const sal_Int32 nNewTop)
sal_Int32 ScrollBarManager::GetTop (void) const
{
if (mpVerticalScrollBar != NULL)
return mpVerticalScrollBar->GetThumbPos();
else
return 0;
}
void ScrollBarManager::SetLeft (const sal_Int32 nNewLeft)
{
if (mpHorizontalScrollBar != NULL
&& mpHorizontalScrollBar->GetThumbPos() != nNewLeft)
{
// Flush pending repaints before scrolling to avoid temporary artifacts.
mrSlideSorter.GetView().GetWindow()->Update();
mrSlideSorter.GetContentWindow()->Update();
mpHorizontalScrollBar->SetThumbPos(nNewLeft);
mnHorizontalPosition = double(nNewLeft) / double(mpHorizontalScrollBar->GetRange().Len());
mrSlideSorter.GetView().GetWindow()->SetVisibleXY (
mrSlideSorter.GetContentWindow()->SetVisibleXY (
mnHorizontalPosition, mnVerticalPosition);
}
}
@ -523,6 +532,17 @@ void ScrollBarManager::SetLeft (const sal_Int32 nNewLeft)
sal_Int32 ScrollBarManager::GetLeft (void) const
{
if (mpHorizontalScrollBar != NULL)
return mpHorizontalScrollBar->GetThumbPos();
else
return 0;
}
int ScrollBarManager::GetVerticalScrollBarWidth (void) const
{
if (mpVerticalScrollBar != NULL && mpVerticalScrollBar->IsVisible())
@ -547,7 +567,7 @@ int ScrollBarManager::GetHorizontalScrollBarHeight (void) const
void ScrollBarManager::CalcAutoScrollOffset (const Point& rMouseWindowPosition)
{
::sd::Window* pWindow = mrSlideSorter.GetView().GetWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
int nDx = 0;
int nDy = 0;
@ -602,14 +622,16 @@ void ScrollBarManager::CalcAutoScrollOffset (const Point& rMouseWindowPosition)
bool ScrollBarManager::AutoScroll (const Point& rMouseWindowPosition)
bool ScrollBarManager::AutoScroll (
const Point& rMouseWindowPosition,
const ::boost::function<void(void)>& rAutoScrollFunctor)
{
CalcAutoScrollOffset (rMouseWindowPosition);
bool bResult = RepeatAutoScroll();
if (bResult)
{
maAutoScrollTimer.Start();
}
maAutoScrollFunctor = rAutoScrollFunctor;
CalcAutoScrollOffset(rMouseWindowPosition);
bool bResult (true);
if ( ! mbIsAutoScrollActive)
bResult = RepeatAutoScroll();
return bResult;
}
@ -619,6 +641,7 @@ bool ScrollBarManager::AutoScroll (const Point& rMouseWindowPosition)
void ScrollBarManager::StopAutoScroll (void)
{
maAutoScrollTimer.Stop();
mbIsAutoScrollActive = false;
}
@ -630,13 +653,23 @@ bool ScrollBarManager::RepeatAutoScroll (void)
{
if (mrSlideSorter.GetViewShell() != NULL)
{
mrSlideSorter.GetViewShell()->ScrollLines(
mrSlideSorter.GetViewShell()->Scroll(
maAutoScrollOffset.Width(),
maAutoScrollOffset.Height());
maAutoScrollOffset.Height());
mrSlideSorter.GetView().InvalidatePageObjectVisibilities();
if (maAutoScrollFunctor)
maAutoScrollFunctor();
mbIsAutoScrollActive = true;
maAutoScrollTimer.Start();
return true;
}
}
maAutoScrollFunctor = ::boost::function<void(void)>();
mbIsAutoScrollActive = false;
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@
#include "SlsSelectionCommand.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsAnimator.hxx"
#include "controller/SlsAnimationFunction.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
#include "controller/SlsFocusManager.hxx"
#include "controller/SlsProperties.hxx"
@ -46,6 +47,7 @@
#include "model/SlsPageEnumerationProvider.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsLayouter.hxx"
#include "drawdoc.hxx"
#include "Window.hxx"
#include <svx/svxids.hrc>
@ -80,6 +82,7 @@ namespace {
SlideSorter& mrSlideSorter;
double mnStart;
double mnEnd;
::boost::function<double(double)> maAccelerationFunction;
};
class HorizontalVisibleAreaScroller
{
@ -91,6 +94,7 @@ namespace {
SlideSorter& mrSlideSorter;
double mnStart;
double mnEnd;
::boost::function<double(double)> maAccelerationFunction;
};
}
@ -329,6 +333,14 @@ bool SelectionManager::IsMakeSelectionVisiblePending (void) const
void SelectionManager::ResetMakeSelectionVisiblePending (void)
{
mbIsMakeSelectionVisiblePending = false;
}
/** We have to distinguish three cases: 1) the selection is empty, 2) the
selection fits completely into the visible area, 3) it does not.
1) The visible area is not modified.
@ -346,7 +358,7 @@ bool SelectionManager::IsMakeSelectionVisiblePending (void) const
*/
Size SelectionManager::MakeSelectionVisible (const SelectionHint eSelectionHint)
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if (pWindow == NULL)
return Size(0,0);
@ -357,6 +369,7 @@ Size SelectionManager::MakeSelectionVisible (const SelectionHint eSelectionHint)
model::SharedPageDescriptor pFirst;
model::SharedPageDescriptor pLast;
Rectangle aSelectionBox;
const view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter());
model::PageEnumeration aSelectedPages (
PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel()));
while (aSelectedPages.HasMoreElements())
@ -367,10 +380,7 @@ Size SelectionManager::MakeSelectionVisible (const SelectionHint eSelectionHint)
pFirst = pDescriptor;
pLast = pDescriptor;
aSelectionBox.Union (mrSlideSorter.GetView().GetPageBoundingBox (
pDescriptor,
view::SlideSorterView::CS_MODEL,
view::SlideSorterView::BBT_INFO));
aSelectionBox.Union(rLayouter.GetPageObjectBox(pDescriptor->GetPageIndex(), true));
}
if (pFirst != NULL)
@ -395,7 +405,7 @@ Size SelectionManager::MakeSelectionVisible (const SelectionHint eSelectionHint)
Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if (pWindow == NULL)
return Size(0,0);
@ -408,7 +418,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
{
// Scroll the visible area to make aSelectionBox visible.
sal_Int32 nNewTop (aVisibleArea.Top());
if (mrSlideSorter.GetController().GetProperties()->IsCenterSelection())
if (mrSlideSorter.GetProperties()->IsCenterSelection())
{
nNewTop = rBox.Top() - (aVisibleArea.GetHeight() - rBox.GetHeight()) / 2;
}
@ -431,11 +441,12 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
// Scroll.
if (nNewTop != aVisibleArea.Top())
{
mrController.GetAnimator()->AddAnimation(
VerticalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Top(), nNewTop),
mrSlideSorter.GetController().GetProperties()->IsSmoothSelectionScrolling() ?
1000 : 0
);
if (mrSlideSorter.GetProperties()->IsSmoothSelectionScrolling())
mrController.GetAnimator()->AddAnimation(
VerticalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Top(), nNewTop),
300);
else
VerticalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Top(), nNewTop)(1.0);
}
return Size(0,aVisibleArea.Top() - nNewTop);
@ -444,7 +455,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
{
// Scroll the visible area to make aSelectionBox visible.
sal_Int32 nNewLeft (aVisibleArea.Left());
if (mrSlideSorter.GetController().GetProperties()->IsCenterSelection())
if (mrSlideSorter.GetProperties()->IsCenterSelection())
{
nNewLeft = rBox.Left() - (aVisibleArea.GetWidth() - rBox.GetWidth()) / 2;
}
@ -467,11 +478,12 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
// Scroll.
if (nNewLeft != aVisibleArea.Left())
{
mrController.GetAnimator()->AddAnimation(
HorizontalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Left(), nNewLeft),
mrSlideSorter.GetController().GetProperties()->IsSmoothSelectionScrolling() ?
1000 : 0
);
if (mrSlideSorter.GetProperties()->IsSmoothSelectionScrolling())
mrController.GetAnimator()->AddAnimation(
HorizontalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Left(), nNewLeft),
300);
else
HorizontalVisibleAreaScroller(mrSlideSorter, aVisibleArea.Left(), nNewLeft)(1.0);
}
return Size(aVisibleArea.Left() - nNewLeft, 0);
@ -509,7 +521,7 @@ void SelectionManager::RemoveSelectionChangeListener(const Link&rListener)
bool SelectionManager::DoesSelectionExceedVisibleArea (const Rectangle& rSelectionBox) const
{
::sd::Window* pWindow = mrSlideSorter.GetActiveWindow();
::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
if (pWindow == NULL)
return true;
@ -562,10 +574,7 @@ Rectangle SelectionManager::ResolveLargeSelection (
}
OSL_ASSERT(pRepresentative.get() != NULL);
return mrSlideSorter.GetView().GetPageBoundingBox (
pRepresentative,
view::SlideSorterView::CS_MODEL,
view::SlideSorterView::BBT_INFO);
return pRepresentative->GetBoundingBox();
}
@ -624,40 +633,55 @@ VerticalVisibleAreaScroller::VerticalVisibleAreaScroller (
const double nEnd)
: mrSlideSorter(rSlideSorter),
mnStart(nStart),
mnEnd(nEnd)
mnEnd(nEnd),
maAccelerationFunction(
controller::AnimationParametricFunction(
controller::AnimationBezierFunction (0.1,0.6)))
{
}
void VerticalVisibleAreaScroller::operator() (const double nValue)
void VerticalVisibleAreaScroller::operator() (const double nTime)
{
const double nLocalTime (maAccelerationFunction(nTime));
const sal_Int32 nNewTop (mnStart * (1.0 - nLocalTime) + mnEnd * nLocalTime);
mrSlideSorter.GetViewShell()->Scroll(
0,
nNewTop - mrSlideSorter.GetController().GetScrollBarManager().GetTop());
mrSlideSorter.GetView().InvalidatePageObjectVisibilities();
mrSlideSorter.GetController().GetScrollBarManager().SetTop(
int(mnStart * (1.0 - nValue) + mnEnd * nValue));
}
//===== HorizontalVisibleAreaScroller =========================================
HorizontalVisibleAreaScroller::HorizontalVisibleAreaScroller (
SlideSorter& rSlideSorter,
const double nStart,
const double nEnd)
: mrSlideSorter(rSlideSorter),
mnStart(nStart),
mnEnd(nEnd)
mnEnd(nEnd),
maAccelerationFunction(
controller::AnimationParametricFunction(
controller::AnimationBezierFunction (0.1,0.6)))
{
}
void HorizontalVisibleAreaScroller::operator() (const double nValue)
void HorizontalVisibleAreaScroller::operator() (const double nTime)
{
const double nLocalTime (maAccelerationFunction(nTime));
const sal_Int32 nNewLeft (mnStart * (1.0 - nLocalTime) + mnEnd * nLocalTime);
mrSlideSorter.GetViewShell()->Scroll(
nNewLeft - mrSlideSorter.GetController().GetScrollBarManager().GetLeft(),
0);
mrSlideSorter.GetView().InvalidatePageObjectVisibilities();
mrSlideSorter.GetController().GetScrollBarManager().SetLeft(
int(mnStart * (1.0 - nValue) + mnEnd * nValue));
}
} // end of anonymous namespace

View File

@ -49,7 +49,7 @@ SlideFunction::SlideFunction (
SfxRequest& rRequest)
: FuPoor (
rSlideSorter.GetViewShell(),
rSlideSorter.GetView().GetWindow(),
rSlideSorter.GetContentWindow().get(),
&rSlideSorter.GetView(),
rSlideSorter.GetModel().GetDocument(),
rRequest)

View File

@ -36,13 +36,13 @@
#include "SlideSorter.hxx"
#include "SlideSorterViewShell.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsPageSelector.hxx"
#include "controller/SlsClipboard.hxx"
#include "controller/SlsSelectionFunction.hxx"
#include "controller/SlsFocusManager.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
#include "controller/SlsFocusManager.hxx"
#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsPageSelector.hxx"
#include "controller/SlsSelectionFunction.hxx"
#include "controller/SlsSelectionManager.hxx"
#include "SlsHideSlideFunction.hxx"
#include "SlsCommand.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
@ -103,6 +103,24 @@ using namespace ::com::sun::star::presentation;
namespace sd { namespace slidesorter { namespace controller {
namespace {
/** The state of a set of slides with respect to being excluded from the
slide show.
*/
enum SlideExclusionState {UNDEFINED, EXCLUDED, INCLUDED, MIXED};
void ChangeSlideExclusionState (SlideSorter& rSlideSorter, SfxRequest& rRequest);
/** Return for the given set of slides whether they included are
excluded from the slide show.
*/
SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet);
} // end of anonymous namespace
SlotManager::SlotManager (SlideSorter& rSlideSorter)
: mrSlideSorter(rSlideSorter),
maCommandQueue()
@ -139,7 +157,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_HIDE_SLIDE:
case SID_SHOW_SLIDE:
HideSlideFunction::Create(mrSlideSorter, rRequest);
ChangeSlideExclusionState(mrSlideSorter, rRequest);
break;
case SID_PAGES_PER_ROW:
@ -167,6 +185,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_SELECTALL:
mrSlideSorter.GetController().GetPageSelector().SelectAllPages();
mrSlideSorter.GetController().GetSelectionManager()->ResetMakeSelectionVisiblePending();
rRequest.Done();
break;
@ -184,7 +203,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_PRESENTATION_DLG:
FuSlideShowDlg::Create (
pShell,
mrSlideSorter.GetView().GetWindow(),
mrSlideSorter.GetContentWindow().get(),
&mrSlideSorter.GetView(),
pDocument,
rRequest);
@ -193,7 +212,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_CUSTOMSHOW_DLG:
FuCustomShowDlg::Create (
pShell,
mrSlideSorter.GetView().GetWindow(),
mrSlideSorter.GetContentWindow().get(),
&mrSlideSorter.GetView(),
pDocument,
rRequest);
@ -202,7 +221,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_EXPAND_PAGE:
FuExpandPage::Create (
pShell,
mrSlideSorter.GetView().GetWindow(),
mrSlideSorter.GetContentWindow().get(),
&mrSlideSorter.GetView(),
pDocument,
rRequest);
@ -211,7 +230,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
case SID_SUMMARY_PAGE:
FuSummaryPage::Create (
pShell,
mrSlideSorter.GetView().GetWindow(),
mrSlideSorter.GetContentWindow().get(),
&mrSlideSorter.GetView(),
pDocument,
rRequest);
@ -518,7 +537,7 @@ void SlotManager::GetCtrlState (SfxItemSet& rSet)
||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE
||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE)
{
ULONG nMode = mrSlideSorter.GetView().GetWindow()->GetDrawMode();
ULONG nMode = mrSlideSorter.GetContentWindow()->GetDrawMode();
UINT16 nQuality = 0;
switch (nMode)
@ -671,23 +690,22 @@ void SlotManager::GetMenuState ( SfxItemSet& rSet)
model::PageEnumeration aSelectedPages (
model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
mrSlideSorter.GetModel()));
HideSlideFunction::ExclusionState eState (
HideSlideFunction::GetExclusionState(aSelectedPages));
const SlideExclusionState eState (GetSlideExclusionState(aSelectedPages));
switch (eState)
{
case HideSlideFunction::MIXED:
case MIXED:
// Show both entries.
break;
case HideSlideFunction::EXCLUDED:
case EXCLUDED:
rSet.DisableItem(SID_HIDE_SLIDE);
break;
case HideSlideFunction::INCLUDED:
case INCLUDED:
rSet.DisableItem(SID_SHOW_SLIDE);
break;
case HideSlideFunction::UNDEFINED:
case UNDEFINED:
rSet.DisableItem(SID_HIDE_SLIDE);
rSet.DisableItem(SID_SHOW_SLIDE);
break;
@ -904,7 +922,7 @@ void SlotManager::RenameSlide (void)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");
AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog(
mrSlideSorter.GetActiveWindow(),
mrSlideSorter.GetContentWindow().get(),
aPageName, aDescr);
DBG_ASSERT(aNameDlg, "Dialogdiet fail!");
aNameDlg->SetText( aTitle );
@ -1076,11 +1094,11 @@ void SlotManager::InsertSlide (SfxRequest& rRequest)
// No selection. Is there an insertion indicator?
else if (mrSlideSorter.GetView().GetOverlay()
.GetInsertionIndicatorOverlay().isVisible())
.GetInsertionIndicatorOverlay()->IsVisible())
{
// Select the page before the insertion indicator.
nInsertionIndex = mrSlideSorter.GetView().GetOverlay()
.GetInsertionIndicatorOverlay().GetInsertionPageIndex();
nInsertionIndex
= mrSlideSorter.GetController().GetInsertionIndicatorHandler()->GetInsertionPageIndex();
nInsertionIndex --;
rSelector.SelectPage (nInsertionIndex);
}
@ -1157,15 +1175,18 @@ void SlotManager::InsertSlide (SfxRequest& rRequest)
}
}
// When a new page has been inserted then select it and make it the
// current page.
// When a new page has been inserted then select it, make it the
// current page, and focus it.
mrSlideSorter.GetView().LockRedraw(TRUE);
if (mrSlideSorter.GetModel().GetPageCount() > nPageCount)
{
nInsertionIndex++;
model::SharedPageDescriptor pDescriptor = mrSlideSorter.GetModel().GetPageDescriptor(nInsertionIndex);
if (pDescriptor.get() != NULL)
{
mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor);
mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(pDescriptor);
}
}
rSelector.EnableBroadcasting();
mrSlideSorter.GetView().LockRedraw(FALSE);
@ -1230,5 +1251,103 @@ IMPL_LINK(SlotManager, UserEventCallback, void*, EMPTYARG)
return 1;
}
//-----------------------------------------------------------------------------
namespace {
void ChangeSlideExclusionState (
SlideSorter& rSlideSorter,
SfxRequest& rRequest)
{
model::PageEnumeration aSelectedPages (
model::PageEnumerationProvider::CreateSelectedPagesEnumeration(rSlideSorter.GetModel()));
SlideExclusionState eState (UNDEFINED);
switch (rRequest.GetSlot())
{
case SID_HIDE_SLIDE:
eState = EXCLUDED;
break;
case SID_SHOW_SLIDE:
eState = INCLUDED;
break;
default:
eState = UNDEFINED;
break;
}
if (eState != UNDEFINED)
{
// Set status at the selected pages.
aSelectedPages.Rewind ();
while (aSelectedPages.HasMoreElements())
{
model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
rSlideSorter.GetView().SetState(
pDescriptor,
model::PageDescriptor::ST_Excluded,
eState==EXCLUDED);
}
}
SfxBindings& rBindings = rSlideSorter.GetViewShell()->GetViewFrame()->GetBindings();
rBindings.Invalidate(SID_PRESENTATION);
rBindings.Invalidate(SID_REHEARSE_TIMINGS);
rBindings.Invalidate(SID_HIDE_SLIDE);
rBindings.Invalidate(SID_SHOW_SLIDE);
rSlideSorter.GetModel().GetDocument()->SetChanged();
}
SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet)
{
SlideExclusionState eState (UNDEFINED);
BOOL bState;
// Get toggle state of the selected pages.
while (rPageSet.HasMoreElements() && eState!=MIXED)
{
bState = rPageSet.GetNextElement()->GetPage()->IsExcluded();
switch (eState)
{
case UNDEFINED:
// Use the first selected page to set the inital value.
eState = bState ? EXCLUDED : INCLUDED;
break;
case EXCLUDED:
// The pages before where all not part of the show,
// this one is.
if ( ! bState)
eState = MIXED;
break;
case INCLUDED:
// The pages before where all part of the show,
// this one is not.
if (bState)
eState = MIXED;
break;
case MIXED:
default:
// No need to change anything.
break;
}
}
return eState;
}
} // end of anonymous namespace
} } } // end of namespace ::sd::slidesorter::controller

View File

@ -49,22 +49,20 @@ PRJINC=..$/..
SLOFILES = \
$(SLO)$/SlideSorterController.obj \
$(SLO)$/SlsAnimator.obj \
$(SLO)$/SlsAnimationFunction.obj \
$(SLO)$/SlsClipboard.obj \
$(SLO)$/SlsCurrentSlideManager.obj \
$(SLO)$/SlsFocusManager.obj \
$(SLO)$/SlsInsertionIndicatorHandler.obj\
$(SLO)$/SlsListener.obj \
$(SLO)$/SlsPageObjectFactory.obj \
$(SLO)$/SlsPageSelector.obj \
$(SLO)$/SlsProperties.obj \
$(SLO)$/SlsScrollBarManager.obj \
$(SLO)$/SlsSelectionCommand.obj \
$(SLO)$/SlsSelectionFunction.obj \
$(SLO)$/SlsSelectionManager.obj \
$(SLO)$/SlsSlotManager.obj \
$(SLO)$/SlsTransferable.obj \
\
$(SLO)$/SlsHideSlideFunction.obj \
$(SLO)$/SlsSelectionFunction.obj \
$(SLO)$/SlsSlideFunction.obj
$(SLO)$/SlsTransferable.obj
EXCEPTIONSFILES= \
$(SLO)$/SlideSorterController.obj

View File

@ -97,11 +97,14 @@ public:
*/
PageCache (
const Size& rPreviewSize,
const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext);
~PageCache (void);
void ChangeSize(const Size& rPreviewSize);
void ChangeSize(
const Size& rPreviewSize,
const bool bDoSuperSampling);
/** Request a preview bitmap for the specified page object in the
specified size. The returned bitmap may be a preview of the
@ -113,33 +116,27 @@ public:
method again if receives the correctly sized preview bitmap.
@param rRequestData
This data is used to determine the preview.
@param rSize
The size of the requested preview bitmap.
@return
Returns a bitmap that is either empty, contains a scaled (up or
down) version or is the requested bitmap.
*/
BitmapEx GetPreviewBitmap (
CacheKey aKey,
const Size& rSize);
BitmapEx GetPreviewBitmap (CacheKey aKey);
/** When the requested preview bitmap does not yet exist or is not
up-to-date then the rendering of one is scheduled. Otherwise this
method does nothing.
*/
void RequestPreviewBitmap (
CacheKey aKey,
const Size& rSize);
void RequestPreviewBitmap (CacheKey aKey);
/** Tell the cache that the bitmap associated with the given request
data is not up-to-date anymore. Unlike the RequestPreviewBitmap()
method this does not trigger the rendering itself. It just
remembers to render it when the preview is requested the next time.
@param rRequestData
It is safe to pass a (barly) living object. It will called only
once to obtain its page object.
data is not up-to-date anymore.
@param bRequestPreview
When <TRUE/> then a new preview is requested and will lead
eventually to a repaint of the associated page object.
*/
void InvalidatePreviewBitmap (CacheKey aKey);
void InvalidatePreviewBitmap (
const CacheKey aKey,
const bool bRequestPreview);
/** Call this method when a view-object-contact object is being deleted
and does not need (a) its current bitmap in the cache and (b) a

View File

@ -64,9 +64,9 @@ class Animator;
class Clipboard;
class CurrentSlideManager;
class FocusManager;
class InsertionIndicatorHandler;
class Listener;
class PageSelector;
class Properties;
class ScrollBarManager;
class SelectionManager;
class SlotManager;
@ -88,6 +88,8 @@ public:
virtual ~SlideSorterController (void);
void Dispose (void);
/** Place and size the scroll bars and the browser window so that the
given rectangle is filled.
@return
@ -138,6 +140,7 @@ public:
::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager (void) const;
::boost::shared_ptr<SlotManager> GetSlotManager (void) const;
::boost::shared_ptr<SelectionManager> GetSelectionManager (void) const;
::boost::shared_ptr<InsertionIndicatorHandler> GetInsertionIndicatorHandler (void) const;
// forward VCLs PrePaint window event to DrawingLayer
void PrePaint();
@ -240,11 +243,6 @@ public:
*/
bool IsContextMenuOpen (void) const;
/** Return a collection of properties that are used througout the slide
sorter.
*/
::boost::shared_ptr<Properties> GetProperties (void) const;
/** Provide the set of pages to be displayed in the slide sorter. The
GetDocumentSlides() method can be found only in the SlideSorterModel.
*/
@ -265,6 +263,7 @@ private:
::std::auto_ptr<ScrollBarManager> mpScrollBarManager;
mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
::boost::shared_ptr<SelectionManager> mpSelectionManager;
::boost::shared_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
::boost::shared_ptr<Animator> mpAnimator;
// The listener listens to UNO events and thus is a UNO object.
@ -307,11 +306,6 @@ private:
*/
bool mbIsContextMenuOpen;
/** Some slide sorter wide properties that are used in different
classes.
*/
::boost::shared_ptr<Properties> mpProperties;
/** Delete the given list of normal pages. This method is a helper
function for DeleteSelectedPages().
@param rSelectedNormalPages

View File

@ -0,0 +1,178 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsAnimator.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_CONTROLLER_ANIMATION_FUNCTION_HXX
#define SD_SLIDESORTER_CONTROLLER_ANIMATION_FUNCTION_HXX
#include "model/SlsSharedPageDescriptor.hxx"
#include <basegfx/point/b2dpoint.hxx>
#include <boost/noncopyable.hpp>
#include <boost/function.hpp>
#include <tools/gen.hxx>
#include <vector>
namespace sd { namespace slidesorter { namespace view {
class SlideSorterView;
} } }
namespace sd { namespace slidesorter { namespace controller {
/** A collection of functions that are usefull when creating animations.
They are collected here until a better place is found.
*/
class AnimationFunction
: private ::boost::noncopyable
{
public:
/** Acceleration function that maps [0,1] to [0,1]. Speed starts fast
and ends slow following the sine function.
*/
static double FastInSlowOut_Sine (const double nTime);
/** Acceleration function that maps [0,1] to [0,1]. Speed starts fast
and ends slow following the square root function.
*/
static double FastInSlowOut_Root (const double nTime);
/** Acceleration function that maps [0,1] to [0,0]. Speed starts slow,
rises, drops and ends slow following the sine function.
*/
static double SlowInSlowOut_0to0_Sine (const double nTime);
/** Acceleration function that maps [0,1] to [0,0]. Speed starts slow,
rises and drops several times and ends slow following multiple
cycles of the the sine function.
*/
static double Vibrate_Sine (const double nTime);
/** Scale point linearly.
*/
static Point ScalePoint (const Point& rPoint, const double nTime);
/** Blend two points together according to the given weight.
*/
static double Blend (const double nStartValue, const double nEndValue, const double nWeight);
/** Apply a gradual visual state change. The kind of change, i.e. the
previous and the new states are expected to be already set. This
method only adjusts the blending of the visual representation from
one state to the other.
*/
static void ApplyVisualStateChange (
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const double nTime);
/** Apply a gradual change of a previously set offset to the location of
a page object.
*/
static void ApplyLocationOffsetChange (
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const Point aLocationOffset);
/** Apply a gradual change the alpha value from the old value to a
new value (set prior to this call.)
*/
static void ApplyButtonAlphaChange(
const model::SharedPageDescriptor& rpDescriptor,
view::SlideSorterView& rView,
const double nAlpha);
};
class AnimationBezierFunction
{
public:
/** Create a cubic bezier curve whose start and end points are given
implicitly as P0=(0,0) and P3=(1,1).
*/
AnimationBezierFunction (
const double nX1,
const double nY1,
const double nX2,
const double nY2);
/** Create a cubic bezier curve whose start and end points are given
implicitly as P0=(0,0) and P3=(1,1). The second control point is
implicitly given as P2=(1-nY1,1-nX1).
*/
AnimationBezierFunction (
const double nX1,
const double nY1);
::basegfx::B2DPoint operator() (const double nT);
private:
const double mnX1;
const double mnY1;
const double mnX2;
const double mnY2;
double EvaluateComponent (
const double nT,
const double nV1,
const double nV2);
};
/** Turn a parametric function into one whose y-Values depend on its
x-Values. Note a lot of interpolation takes place. The resulting
accuracy should be good enough for the purpose of acceleration
function for animations.
*/
class AnimationParametricFunction
{
public:
typedef ::boost::function<basegfx::B2DPoint(double)> ParametricFunction;
AnimationParametricFunction (const ParametricFunction& rFunction);
double operator() (const double nX);
private:
/** y-Values of the parametric function given to the constructor
evaluated (and interpolated) for evenly spaced x-Values.
*/
::std::vector<double> maY;
};
} } } // end of namespace ::sd::slidesorter::controller
#endif

View File

@ -53,10 +53,19 @@ public:
Animator (SlideSorter& rSlideSorter);
~Animator (void);
/** When disposed the animator will stop its work immediately and not
process any timer events anymore.
*/
void Dispose (void);
/** An animation object is called with values between 0 and 1 as single
argument to its operator() method.
*/
typedef ::boost::function1<void, double> AnimationFunction;
typedef ::boost::function1<void, double> AnimationFunctor;
typedef ::boost::function0<void> FinishFunctor;
typedef sal_Int32 AnimationId;
static const AnimationId NotAnAnimationId = -1;
/** Schedule a new animation for execution. The () operator of that
animation will be called with increasing values between 0 and 1 for
@ -66,14 +75,26 @@ public:
@param nDuration
The duration in milli seconds.
*/
void AddAnimation (
const AnimationFunction& rAnimation,
const sal_Int32 nDuration);
AnimationId AddAnimation (
const AnimationFunctor& rAnimation,
const sal_Int32 nDuration,
const FinishFunctor& rFinishFunctor = FinishFunctor());
AnimationId AddInfiniteAnimation (
const AnimationFunctor& rAnimation,
const double nDelta);
/** Abort and remove an animation. In order to reduce the bookkeeping
on the caller side, it is OK to call this method with an animation
function that is not currently being animated. Such a call is
silently ignored.
*/
void RemoveAnimation (const AnimationId nAnimationId);
private:
SlideSorter& mrSlideSorter;
Timer maTimer;
bool mbIsDisposed;
class Animation;
typedef ::std::vector<boost::shared_ptr<Animation> > AnimationList;
AnimationList maAnimations;
@ -81,6 +102,8 @@ private:
class DrawLock;
::boost::scoped_ptr<DrawLock> mpDrawLock;
AnimationId mnNextAnimationId;
DECL_LINK(TimeoutHandler, Timer*);
/** Execute one step of every active animation.
@ -88,13 +111,14 @@ private:
When one or more animation has finished then <TRUE/> is
returned. Call CleanUpAnimationList() in this case.
*/
bool ServeAnimations (void);
bool ProcessAnimations (void);
/** Remove animations that have expired.
*/
void CleanUpAnimationList (void);
};
} } } // end of namespace ::sd::slidesorter::controller
#endif

View File

@ -0,0 +1,99 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsSelectionFunction.cxx,v $
* $Revision: 1.37 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_INSERTION_INDICATOR_HANDLER_HXX
#define SD_SLIDESORTER_INSERTION_INDICATOR_HANDLER_HXX
#include "view/SlsInsertAnimator.hxx"
namespace sd { namespace slidesorter { class SlideSorter; } }
namespace sd { namespace slidesorter { namespace view {
class InsertAnimator;
class InsertionIndicatorOverlay;
} } }
namespace sd { namespace slidesorter { namespace controller {
/** Manage the visibility and location of the insertion indicator. Its
actual display is controlled by the InsertionIndicatorOverlay.
*/
class InsertionIndicatorHandler
{
public:
InsertionIndicatorHandler (SlideSorter& rSlideSorter);
~InsertionIndicatorHandler (void);
/** Activate the insertion marker at the given coordinates.
*/
void Start (const Point& rMouseModelPosition);
/** Set the position of the insertion marker to the given coordinates.
*/
void UpdatePosition (const Point& rMouseModelPosition);
/** Deactivate the insertion marker.
*/
void End (void);
/** Return whether the insertion marker is active.
*/
bool IsActive (void) const;
/** Return the insertion index that corresponds with the current
graphical location of the insertion indicator.
*/
sal_Int32 GetInsertionPageIndex (void) const;
/** Determine whether moving the current selection to the current
position of the insertion marker would alter the document. This
would be the case when the selection is not consecutive or would be
moved to a position outside and not adjacent to the selection.
*/
bool IsInsertionTrivial (void) const;
private:
SlideSorter& mrSlideSorter;
::boost::shared_ptr<view::InsertAnimator> mpInsertAnimator;
::boost::shared_ptr<view::InsertionIndicatorOverlay> mpInsertionIndicatorOverlay;
sal_Int32 mnInsertionIndex;
bool mbIsBeforePage;
bool mbIsInsertionTrivial;
bool mbIsActive;
void SetPosition (const Point& rPoint);
::boost::shared_ptr<view::InsertAnimator> GetInsertAnimator (void);
};
} } } // end of namespace ::sd::slidesorter::controller
#endif

View File

@ -35,6 +35,7 @@
#include <tools/gen.hxx>
#include <vcl/timer.hxx>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
class Point;
class Rectangle;
@ -133,11 +134,15 @@ public:
*/
void SetTop (const sal_Int32 nTop);
sal_Int32 GetTop (void) const;
/** Update the horizontal scroll bar so that the visible area has the
given left value.
*/
void SetLeft (const sal_Int32 nLeft);
sal_Int32 GetLeft (void) const;
/** Return the width of the vertical scroll bar, which--when
shown--should be fixed in contrast to its height.
@return
@ -157,11 +162,17 @@ public:
/** Call this method to scroll a window while the mouse is in dragging a
selection. If the mouse is near the window border or is outside the
window then scroll the window accordingly.
@param rMouseWindowPosition
The mouse position for which the scroll amount is calculated.
@param rAutoScrollFunctor
Every time when the window is scrolled then this functor is executed.
@return
When the window is scrolled then this method returns <TRUE/>.
When the window is not changed then <FALSE/> is returned.
*/
bool AutoScroll (const Point& rMouseWindowPosition);
bool AutoScroll (
const Point& rMouseWindowPosition,
const ::boost::function<void(void)>& rAutoScrollFunctor);
void StopAutoScroll (void);
@ -200,12 +211,15 @@ private:
*/
Timer maAutoScrollTimer;
Size maAutoScrollOffset;
bool mbIsAutoScrollActive;
/** The content window is the one whose view port is controlled by the
scroll bars.
*/
::boost::shared_ptr<sd::Window> mpContentWindow;
::boost::function<void(void)> maAutoScrollFunctor;
void SetWindowOrigin (
double nHorizontalPosition,
double nVerticalPosition);

View File

@ -31,10 +31,13 @@
#ifndef SD_SLIDESORTER_SELECTION_FUNCTION_HXX
#define SD_SLIDESORTER_SELECTION_FUNCTION_HXX
#include "controller/SlsSlideFunction.hxx"
#include "model/SlsSharedPageDescriptor.hxx"
#include <tools/list.hxx>
#include <memory>
#include "controller/SlsFocusManager.hxx"
#include "fupoor.hxx"
#include <svtools/transfer.hxx>
//#include <memory>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
class SdSlideViewShell;
class SdWindow;
@ -51,7 +54,8 @@ namespace sd { namespace slidesorter { namespace controller {
class SlideSorterController;
class SelectionFunction
: public SlideFunction
: public FuPoor,
private ::boost::noncopyable
{
public:
TYPEINFO();
@ -63,10 +67,9 @@ public:
virtual BOOL MouseMove(const MouseEvent& rMEvt);
virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
virtual void Paint(const Rectangle&, ::sd::Window* );
virtual void Activate(); // Function aktivieren
virtual void Deactivate(); // Function deaktivieren
virtual void Activate();
virtual void Deactivate();
virtual void ScrollStart();
virtual void ScrollEnd();
@ -89,6 +92,8 @@ public:
*/
virtual bool cancel();
void MouseDragged (const AcceptDropEvent& rEvent);
protected:
SlideSorter& mrSlideSorter;
SlideSorterController& mrController;
@ -101,8 +106,8 @@ protected:
private:
class SubstitutionHandler;
class RectangleSelector;
class EventDescriptor;
class InsertionIndicatorHandler;
/// Set in MouseButtonDown this flag indicates that a page has been hit.
bool mbPageHit;
@ -122,12 +127,23 @@ private:
*/
bool mbProcessingMouseButtonDown;
::std::auto_ptr<SubstitutionHandler> mpSubstitutionHandler;
::boost::scoped_ptr<SubstitutionHandler> mpSubstitutionHandler;
::boost::scoped_ptr<RectangleSelector> mpRectangleSelector;
::std::auto_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
/** Remember where the left mouse button was pressed.
*/
sal_Int32 mnButtonDownPageIndex;
sal_Int32 mnButtonDownButtonIndex;
bool mbIsDeselectionPending;
/** Remember the slide where the shift key was pressed and started a
multiselection via keyboard.
*/
sal_Int32 mnShiftKeySelectionAnchor;
DECL_LINK( DragSlideHdl, Timer* );
void StartDrag (void);
void StartDrag (const Point& rMousePosition);
/** Set the selection to exactly the specified page and also set it as
the current page.
@ -154,37 +170,20 @@ private:
// What follows are a couple of helper methods that are used by
// ProcessMouseEvent().
/// Select the specified page and set the selection anchor.
void SelectHitPage (const model::SharedPageDescriptor& rpDescriptor);
/// Deselect the specified page.
void DeselectHitPage (const model::SharedPageDescriptor& rpDescriptor);
/// Deselect all pages.
void DeselectAllPages (void);
/** for a possibly following mouse motion by starting the drag timer
/** For a possibly following mouse motion by starting the drag timer
that after a short time of pressed but un-moved mouse starts a drag
operation.
*/
void PrepareMouseMotion (const Point& aMouseModelPosition);
void StartDragTimer (void);
/** Select all pages between and including the selection anchor and the
specified page.
*/
void RangeSelect (const model::SharedPageDescriptor& rpDescriptor);
/** Start a rectangle selection at the given position.
*/
void StartRectangleSelection (const Point& aMouseModelPosition);
/** Update the rectangle selection so that the given position becomes
the new second point of the selection rectangle.
*/
void UpdateRectangleSelection (const Point& aMouseModelPosition);
/** Select all pages that lie completly in the selection rectangle.
*/
void ProcessRectangleSelection (bool bToggleSelection);
/** Hide and clear the insertion indiciator, substitution display and
selection rectangle.
*/
@ -204,9 +203,27 @@ private:
const EventDescriptor& rDescriptor,
const KeyEvent& rEvent) const;
/** Compute a numerical code that describes the current state like
whether the selection rectangle is visible or whether the page under
the mouse or the one that has the focus is selected.
*/
sal_uInt32 EncodeState (const EventDescriptor& rDescriptor) const;
void EventPreprocessing (const EventDescriptor& rEvent);
bool EventProcessing (const EventDescriptor& rEvent);
void EventPostprocessing (const EventDescriptor& rEvent);
void UpdatePageUnderMouse (
const Point& rMousePosition,
const bool bIsMouseButtonDown);
void ProcessButtonClick (
const model::SharedPageDescriptor& rpDescriptor,
const sal_Int32 nButtonIndex);
void MoveFocus (
const FocusManager::FocusMoveDirection eDirection,
const bool bIsShiftDown);
};
} } } // end of namespace ::sd::slidesorter::controller

View File

@ -35,6 +35,7 @@
#include "model/SlsSharedPageDescriptor.hxx"
#include <sal/types.h>
#include <tools/gen.hxx>
#include <basegfx/range/b2irectangle.hxx>
#include <vector>
class Link;
@ -84,6 +85,10 @@ public:
*/
bool IsMakeSelectionVisiblePending (void) const;
/** Reset any request to make the set of selected pages visible.
*/
void ResetMakeSelectionVisiblePending (void);
enum SelectionHint { SH_FIRST, SH_LAST, SH_RECENT };
/** Try to make all currently selected page objects visible, i.e. set

View File

@ -46,6 +46,8 @@ class SdDrawDocument;
namespace css = ::com::sun::star;
class SdrPage;
namespace sd { namespace slidesorter {
class SlideSorter;
} }
@ -69,6 +71,7 @@ public:
SlideSorterModel (SlideSorter& rSlideSorter);
virtual ~SlideSorterModel (void);
void Dispose (void);
/** This method is present to let the view create a ShowView for
displaying slides.
@ -132,6 +135,18 @@ public:
sal_Int32 GetIndex (
const ::com::sun::star::uno::Reference<com::sun::star::drawing::XDrawPage>& rxSlide) const;
/** Return a page descriptor for the given SdrPage. Page descriptors
are created on demand. The page descriptor is found (or not found)
in (at most) linear time. Note that all page descriptors in front of
the one associated with the given XDrawPage are created when not yet
present. When the SdrPage is not found then all descriptors are
created.
@return
Returns the index to the requested page descriptor or -1 when
there is no such page descriptor.
*/
sal_Int32 GetIndex (const SdrPage* pPage) const;
/** Call this method after the document has changed its structure. This
will get the model in sync with the SdDrawDocument. This method
tries not to throw away to much information already gathered. This
@ -154,17 +169,6 @@ public:
*/
void SynchronizeModelSelection (void);
/** Replace the factory for the creation of the page objects and
contacts with the given object. The old factory is destroyed.
*/
void SetPageObjectFactory(
::std::auto_ptr<controller::PageObjectFactory> pPageObjectFactory);
/** Return the page object factory. It none has been set so far or it
has been reset, then a new one is created.
*/
const controller::PageObjectFactory& GetPageObjectFactory (void) const;
/** Return the mutex so that the caller can lock it and then safely
access the model.
*/
@ -197,7 +201,6 @@ private:
EditMode meEditMode;
typedef ::std::vector<SharedPageDescriptor> DescriptorContainer;
mutable DescriptorContainer maPageDescriptors;
mutable ::std::auto_ptr<controller::PageObjectFactory> mpPageObjectFactory;
/** Resize the descriptor container according to current values of
page kind and edit mode.

View File

@ -31,6 +31,7 @@
#ifndef SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX
#define SD_SLIDESORTER_PAGE_DESCRIPTOR_HXX
#include "model/SlsVisualState.hxx"
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <tools/gen.hxx>
#include <tools/link.hxx>
@ -90,8 +91,7 @@ public:
PageDescriptor (
const css::uno::Reference<css::drawing::XDrawPage>& rxPage,
SdPage* pPage,
const sal_Int32 nIndex,
const controller::PageObjectFactory& rPageObjectFactory);
const sal_Int32 nIndex);
~PageDescriptor (void);
@ -110,33 +110,12 @@ public:
*/
sal_Int32 GetPageIndex (void) const;
/** Return the page shape that is used for visualizing the page.
*/
view::PageObject* GetPageObject (void);
void ReleasePageObject (void);
enum State { ST_Visible, ST_Selected, ST_WasSelected,
ST_Focused, ST_MouseOver, ST_Current, ST_Excluded };
/** Return <TRUE/> when the page object is fully or parially visible. */
bool IsVisible (void) const;
bool HasState (const State eState) const;
/** Set the visible state that is returned by the IsVisible() method.
This method is typically called by the view who renders the object
onto the screen.
*/
void SetVisible (bool bVisible);
/** Make sure that the page is selected and return whether the
selection state changed.
*/
bool Select (void);
/** Make sure that the page is not selected and return whether the
selection state changed.
*/
bool Deselect (void);
/** Return whether the page is selected (and thus bypasses the internal
mbIsSelected flag.
*/
bool IsSelected (void) const;
bool SetState (const State eState, const bool bStateValue);
/** Set the internal mbIsSelected flag to the selection state of the
page. Use this method to synchronize a page descriptor with the
@ -149,72 +128,30 @@ public:
*/
bool UpdateSelection (void);
bool IsFocused (void) const;
void SetFocus (void);
void RemoveFocus (void);
VisualState& GetVisualState (void);
view::PageObjectViewObjectContact* GetViewObjectContact (void) const;
void SetViewObjectContact (
view::PageObjectViewObjectContact* pViewObjectContact);
/** Return the currently used page object factory.
*/
const controller::PageObjectFactory& GetPageObjectFactory (void) const;
/** Replace the current page object factory by the given one.
*/
void SetPageObjectFactory (const controller::PageObjectFactory& rFactory);
void SetModelBorder (const SvBorder& rBorder);
SvBorder GetModelBorder (void) const;
/** The size of the area in which the page number is displayed is
calculated by the SlideSorterView and then stored in the page
descriptors so that the contact objects can access them. The
contact objects can not calculate them on demand because the total
number of slides is needed to do that and this number is not known
to the contact objects.
*/
void SetPageNumberAreaModelSize (const Size& rSize);
Size GetPageNumberAreaModelSize (void) const;
/** Returns <TRUE/> when the slide is the current slide.
*/
bool IsCurrentPage (void) const;
/** Set or revoke the state of this slide being the current slide.
*/
void SetIsCurrentPage (const bool bIsCurrent);
Rectangle GetBoundingBox (void) const;
Point GetLocation (void) const;
void SetBoundingBox (const Rectangle& rBoundingBox);
private:
SdPage* mpPage;
css::uno::Reference<css::drawing::XDrawPage> mxPage;
/** This index is displayed as page number in the view. It may or may
not be actual page index.
not be the actual page index.
*/
const sal_Int32 mnIndex;
/// The factory that is used to create PageObject objects.
const controller::PageObjectFactory* mpPageObjectFactory;
bool mbIsSelected : 1;
bool mbWasSelected : 1;
bool mbIsVisible : 1;
bool mbIsFocused : 1;
bool mbIsCurrent : 1;
bool mbIsMouseOver : 1;
/** The page object will be destroyed by the page into which it has
been inserted.
*/
view::PageObject* mpPageObject;
Rectangle maBoundingBox;
bool mbIsSelected;
bool mbIsVisible;
bool mbIsFocused;
bool mbIsCurrent;
view::PageObjectViewObjectContact* mpViewObjectContact;
/// The borders in model coordinates arround the page object.
SvBorder maModelBorder;
/// The size of the page number area in model coordinates.
Size maPageNumberAreaModelSize;
VisualState maVisualState;
// Do not use the copy constructor operator. It is not implemented.
PageDescriptor (const PageDescriptor& rDescriptor);

View File

@ -0,0 +1,109 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsPageDescriptor.hxx,v $
* $Revision: 1.8 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_VISUAL_STATE_HXX
#define SD_SLIDESORTER_VISUAL_STATE_HXX
#include <sal/types.h>
#include <tools/gen.hxx>
#include <boost/function.hpp>
namespace sd { namespace slidesorter { namespace model {
class PageDescriptor;
/** This class gives access to values related to the visualization of page
objects. This includes animation state when blending from one state to
another.
*/
class VisualState
{
public:
enum State {
VS_Selected,
VS_Focused,
VS_Current,
VS_Excluded,
VS_None };
VisualState (const sal_Int32 nPageId);
~VisualState (void);
State GetCurrentVisualState (void) const;
State GetOldVisualState (void) const;
void SetVisualState (const State eState);
double GetVisualStateBlend (void) const;
void SetVisualStateBlend (const double nBlend);
void UpdateVisualState (const PageDescriptor& rDescriptor);
void SetMouseOverState (const bool bIsMouseOver);
sal_Int32 GetStateAnimationId (void) const;
void SetStateAnimationId (const sal_Int32 nAnimationId);
Point GetLocationOffset (void) const;
bool SetLocationOffset (const Point& rPoint);
sal_Int32 GetLocationAnimationId (void) const;
void SetLocationAnimationId (const sal_Int32 nAnimationId);
double GetButtonAlpha (void) const;
void SetButtonAlpha (const double nAlpha);
sal_Int32 GetButtonAlphaAnimationId (void) const;
void SetButtonAlphaAnimationId (const sal_Int32 nAnimationId);
enum ButtonState { BS_Normal, BS_MouseOver, BS_Pressed };
void SetActiveButtonState (const sal_Int32 nIndex, const ButtonState eState);
ButtonState GetButtonState (const sal_Int32 nIndex);
const sal_Int32 mnPageId; // For debugging
private:
State meCurrentVisualState;
State meOldVisualState;
double mnVisualStateBlend;
sal_Int32 mnStateAnimationId;
bool mbOldMouseOverState;
bool mbCurrentMouseOverState;
Point maLocationOffset;
sal_Int32 mnLocationAnimationId;
double mnButtonAlpha;
sal_Int32 mnButtonAlphaAnimationId;
sal_Int32 mnActiveButtonIndex;
ButtonState meActiveButtonState;
};
} } } // end of namespace ::sd::slidesorter::model
#endif

View File

@ -31,28 +31,30 @@
#ifndef SD_SLIDESORTER_SLIDE_SORTER_VIEW_HXX
#define SD_SLIDESORTER_SLIDE_SORTER_VIEW_HXX
#include "View.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsSharedPageDescriptor.hxx"
#include "View.hxx"
#include <sfx2/viewfrm.hxx>
#include "pres.hxx"
#include <tools/gen.hxx>
#include <svx/svdmodel.hxx>
#include <vcl/region.hxx>
#include <vcl/outdev.hxx>
#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
#include <memory>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
class Point;
namespace sdr { namespace contact {
class ObjectContact;
} }
namespace sd { namespace slidesorter {
class SlideSorter;
} }
namespace sd { namespace slidesorter { namespace controller {
class SlideSorterController;
class Properties;
} } }
namespace sd { namespace slidesorter { namespace cache {
@ -65,15 +67,18 @@ class SlideSorterModel;
namespace sd { namespace slidesorter { namespace view {
class LayeredDevice;
class Layouter;
class PageObjectPainter;
class ViewOverlay;
class SlideSorterView
: public View
: public sd::View,
public ::boost::noncopyable
{
public:
TYPEINFO();
TYPEINFO ();
/** Create a new view for the slide sorter.
@param rViewShell
@ -84,6 +89,7 @@ public:
SlideSorterView (SlideSorter& rSlideSorter);
virtual ~SlideSorterView (void);
void Dispose (void);
enum Orientation { HORIZONTAL, VERTICAL };
void SetOrientation (const Orientation eOrientation);
@ -91,44 +97,10 @@ public:
void RequestRepaint (void);
void RequestRepaint (const model::SharedPageDescriptor& rDescriptor);
void RequestRepaint (const Rectangle& rRepaintBox);
Rectangle GetModelArea (void);
enum CoordinateSystem { CS_SCREEN, CS_MODEL };
enum BoundingBoxType { BBT_SHAPE, BBT_INFO };
/** Return the rectangle that bounds the page object represented by the
given page descriptor.
@param rDescriptor
The descriptor of the page for which to return the bounding box.
@param eCoordinateSystem
Specifies whether to return the screen or model coordinates.
@param eBoundingBoxType
Specifies whether to return the bounding box of only the page
object or the one that additionally includes other displayed
information like page name and fader symbol.
*/
Rectangle GetPageBoundingBox (
const model::SharedPageDescriptor& rpDescriptor,
CoordinateSystem eCoordinateSystem,
BoundingBoxType eBoundingBoxType) const;
/** Return the rectangle that bounds the page object represented by the
given page index .
@param nIndex
The index of the page for which to return the bounding box.
@param eCoordinateSystem
Specifies whether to return the screen or model coordinates.
@param eBoundingBoxType
Specifies whether to return the bounding box of only the page
object or the one that additionally includes other displayed
information like page name and fader symbol.
*/
Rectangle GetPageBoundingBox (
sal_Int32 nIndex,
CoordinateSystem eCoordinateSystem,
BoundingBoxType eBoundingBoxType) const;
/** Return the index of the page that is rendered at the given position.
@param rPosition
The position is expected to be in pixel coordinates.
@ -167,12 +139,11 @@ public:
void HandleDrawModeChange (void);
virtual void Resize (void);
virtual void CompleteRedraw (OutputDevice* pDevice, const Region& rPaintArea, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L);
virtual void InvalidateOneWin (
::Window& rWindow);
virtual void InvalidateOneWin (
::Window& rWindow,
const Rectangle& rPaintArea );
virtual void CompleteRedraw (
OutputDevice* pDevice,
const Region& rPaintArea,
sdr::contact::ViewObjectContactRedirector* pRedirector = NULL);
void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea);
void Layout (void);
/** This tells the view that it has to re-determine the visibility of
@ -182,8 +153,7 @@ public:
/** Return the window to which this view renders its output.
*/
::sd::Window* GetWindow (void) const;
// ::boost::shared_ptr<sd::Window> GetWindow (void) const;
::boost::shared_ptr<cache::PageCache> GetPreviewCache (void);
@ -209,8 +179,6 @@ public:
*/
void SetSelectionRectangleVisibility (bool bVisible);
::sdr::contact::ObjectContact& GetObjectContact (void) const;
typedef ::std::pair<sal_Int32,sal_Int32> PageRange;
/** Return the range of currently visible page objects including the
first and last one in that range.
@ -220,84 +188,59 @@ public:
*/
PageRange GetVisiblePageRange (void);
/** Return the size of the area where the page numbers are displayed.
@return
The returned size is given in model coordinates.
*/
Size GetPageNumberAreaModelSize (void) const;
/** Return the size of the border around the original SdrPageObj.
*/
SvBorder GetModelBorder (void) const;
/** Add a shape to the page. Typically used from inside
PostModelChange().
*/
void AddSdrObject (SdrObject& rObject);
/** Lock or unlock painting into the content window.
@param bLock
When <TRUE/> then painting is locked. When <FALSE/> then
painting is unlocked.
*/
void LockRedraw (const bool bLock);
void SetPageUnderMouse (const model::SharedPageDescriptor& rpDescriptor);
void SetButtonUnderMouse (const sal_Int32 nButtonIndex);
void AddVisualStateAnimation (const model::SharedPageDescriptor& rpDescriptor);
bool SetState (
const model::SharedPageDescriptor& rpDescriptor,
const model::PageDescriptor::State eState,
const bool bStateValue);
::boost::shared_ptr<PageObjectPainter> GetPageObjectPainter (void);
protected:
virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint);
private:
SlideSorter& mrSlideSorter;
model::SlideSorterModel& mrModel;
/// This model is used for the maPage object and for the page visualizers
/// (SdrPageObj)
SdrModel maPageModel;
/** This page acts as container for the page objects that represent the
pages of the document that is represented by the SlideSorterModel.
*/
SdrPage* mpPage;
::std::auto_ptr<Layouter> mpLayouter;
bool mbPageObjectVisibilitiesValid;
::boost::shared_ptr<cache::PageCache> mpPreviewCache;
::std::auto_ptr<ViewOverlay> mpViewOverlay;
::boost::shared_ptr<LayeredDevice> mpLayeredDevice;
::boost::shared_ptr<ViewOverlay> mpViewOverlay;
int mnFirstVisiblePageIndex;
int mnLastVisiblePageIndex;
SvBorder maPagePixelBorder;
bool mbModelChangedWhileModifyEnabled;
Size maPreviewSize;
bool mbPreciousFlagUpdatePending;
Size maPageNumberAreaModelSize;
SvBorder maModelBorder;
Orientation meOrientation;
/** Adapt the coordinates of the given bounding box according to the
other parameters.
@param rModelPageObjectBoundingBox
Bounding box given in model coordinates that bounds only the
page object.
@param eCoordinateSystem
When CS_SCREEN is given then the bounding box is converted into
screen coordinates.
@param eBoundingBoxType
When BBT_INFO is given then the bounding box is made larger so
that it encloses all relevant displayed information.
*/
void AdaptBoundingBox (
Rectangle& rModelPageObjectBoundingBox,
CoordinateSystem eCoordinateSystem,
BoundingBoxType eBoundingBoxType) const;
::boost::shared_ptr<controller::Properties> mpProperties;
model::SharedPageDescriptor mpPageUnderMouse;
sal_Int32 mnButtonUnderMouse;
::boost::shared_ptr<PageObjectPainter> mpPageObjectPainter;
/** Determine the visibility of all page objects.
*/
void DeterminePageObjectVisibilities (void);
/** Update the page borders used by the layouter by using those returned
by the first page. Call this function when the model changes,
especially when the number of pages changes, or when the window is
resized as the borders may be device dependent.
*/
void UpdatePageBorders (void);
void UpdatePreciousFlags (void);
::drawinglayer::primitive2d::Primitive2DSequence GetPrimitive2DHierarchy (
const Region& rPaintArea) const;
};

View File

@ -0,0 +1,64 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_VIEW_LAYER_PAINTER_HXX
#define SD_SLIDESORTER_VIEW_LAYER_PAINTER_HXX
#include <boost/shared_ptr.hpp>
#include <sal/types.h>
class OutputDevice;
class Rectangle;
namespace sd { namespace slidesorter { namespace view {
class ILayerInvalidator
{
public:
virtual void Invalidate (const Rectangle& rInvalidationBox) = 0;
};
typedef ::boost::shared_ptr<ILayerInvalidator> SharedILayerInvalidator;
class ILayerPainter
{
public:
virtual void SetLayerInvalidator (
const SharedILayerInvalidator& rpInvalidator) = 0;
virtual void Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea) = 0;
};
typedef ::boost::shared_ptr<ILayerPainter> SharedILayerPainter;
} } } // end of namespace ::sd::slidesorter::view
#endif

View File

@ -0,0 +1,64 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_VIEW_INSERT_ANIMATOR_HXX
#define SD_SLIDESORTER_VIEW_INSERT_ANIMATOR_HXX
#include "controller/SlsAnimator.hxx"
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
namespace sd { namespace slidesorter { namespace view {
/** Animate the positions of page objects to make room at the insert
position while a move or copy operation takes place.
*/
class InsertAnimator
: private ::boost::noncopyable
{
public:
InsertAnimator (SlideSorter& rSlideSorter);
void SetInsertPosition (
const sal_Int32 nPageIndex,
const bool bInsertBefore);
void Reset (void);
private:
class Implementation;
::boost::shared_ptr<Implementation> mpImplementation;
};
} } } // end of namespace ::sd::slidesorter::view
#endif

View File

@ -31,6 +31,8 @@
#ifndef SD_SLIDESORTER_VIEW_LAYOUTER_HXX
#define SD_SLIDESORTER_VIEW_LAYOUTER_HXX
#include "SlideSorter.hxx"
#include "SlsPageObjectLayouter.hxx"
#include <sal/types.h>
#include <tools/fract.hxx>
#include <vcl/mapmod.hxx>
@ -69,15 +71,19 @@ namespace sd { namespace slidesorter { namespace view {
class Layouter
{
public:
Layouter (void);
Layouter (const ::boost::shared_ptr< ::Window>& rpWindow);
~Layouter (void);
::boost::shared_ptr<PageObjectLayouter> GetPageObjectLayouter (void) const;
/** Set the minimal, the maximal, and the desired width of the page
objects. The three parameters have to fullfill the constraint
nMinimalWidth <= nPreferredWidth <= nMaximalWidth or the call is
ignored.
*/
void SetObjectWidth (sal_Int32 nMinimalWidth, sal_Int32 nMaximalWidth,
void SetObjectWidth (
sal_Int32 nMinimalWidth,
sal_Int32 nMaximalWidth,
sal_Int32 nPreferredWidth);
/** Set the horizontal and vertical borders in pixel coordinates between
@ -100,23 +106,6 @@ public:
void SetBorders (sal_Int32 nLeftBorder, sal_Int32 nRightBorder,
sal_Int32 nTopBorder, sal_Int32 nBottomBorder);
/** Set the borders arround every page object.
@param nLeftBorder
A negative value indicates that the left border shall not be
modified. A value of 0 is the default.
@param nRightBorder
A negative value indicates that the left border shall not be
modified. A value of 0 is the default.
@param nTopBorder
A negative value indicates that the left border shall not be
modified. A value of 0 is the default.
@param nBottomBorder
A negative value indicates that the left border shall not be
modified. A value of 0 is the default.
*/
void SetPageBorders (sal_Int32 nLeftBorder, sal_Int32 nRightBorder,
sal_Int32 nTopBorder, sal_Int32 nBottomBorder);
/** Set the horizontal and vertical gaps between adjacent page objects.
These gaps are only relevant when there is more than one column or
more than one row. Negative values indicate that the respective gap
@ -140,36 +129,44 @@ public:
dimension or the call is ignored.
@param rWindowSize
The size of the window in pixels that the slide sorter is
displayed in.
@param rPageObjectSize
displayed in. This can differ from the size of mpWindow during
detection of whether or not the scroll bars should be visible.
@param rPreviewModelSize
Size of each page in model coordinates.
@param pDevice
The map mode of this output device is adapted to the new layout
of the page objects.
@param rpWindow
The map mode of this window is adapted to the new layout of the
page objects.
@return
The return value indicates whether the Get... methods can be
used to obtain valid values (<TRUE/>).
*/
bool RearrangeHorizontal (
const Size& rWindowSize,
const Size& rPageObjectSize,
OutputDevice* pDevice,
const Size& rPreviewModelSize,
const sal_uInt32 nPageCount);
bool RearrangeVertical (
const Size& rWindowSize,
const Size& rPageObjectSize,
OutputDevice* pDevice);
const Size& rPreviewModelSize,
const sal_uInt32 nPageCount);
/** Change the zoom factor. This does not change the general layout
(number of columns).
*/
void SetZoom (double nZoomFactor, OutputDevice* pDevice);
void SetZoom (Fraction nZoomFactor, OutputDevice* pDevice);
void SetZoom (double nZoomFactor);
void SetZoom (Fraction nZoomFactor);
/** Return the number of columns.
*/
sal_Int32 GetColumnCount (void) const;
sal_Int32 GetRowCount (void) const;
sal_Int32 GetRow (const sal_Int32 nIndex) const;
sal_Int32 GetColumn (const sal_Int32 nIndex) const;
sal_Int32 GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const;
/** Returns whether the column count is fixed (<TRUE/>) or variable
(<FALSE/>). It is fixed if SetColumnCount() was called with the
same value for minimal and maximal column count.
@ -183,17 +180,19 @@ public:
Size GetPageObjectSize (void) const;
/** Return the bounding box in model coordinates of the nIndex-th page
/** Return the bounding box in window coordinates of the nIndex-th page
object.
*/
Rectangle GetPageObjectBox (sal_Int32 nIndex) const;
Rectangle GetPageObjectBox (
const sal_Int32 nIndex,
const bool bIncludeBorderAndGap = false) const;
/** Return the bounding box in model coordinates of the page that
contains the given amount of page objects.
*/
Rectangle GetPageBox (sal_Int32 nObjectCount) const;
Rectangle GetPageBox (const sal_Int32 nObjectCount = -1) const;
/** Return the rectangle that bounds the insertion marker that is
/** Return the location of the center of the insertion marker that is
specified by the parameters.
@param nIndex
Index of the page object from which the position of the marker
@ -210,16 +209,15 @@ public:
<FALSE/> is given then the marker will be positioned below or to
the right of the page object.
*/
Rectangle GetInsertionMarkerBox (
sal_Int32 nIndex,
bool bVertical,
bool bLeftOrTop) const;
Point GetInsertionMarkerLocation (
const sal_Int32 nIndex,
const bool bVertical,
const bool bLeftOrTop) const;
/** Return the index of the first fully or partially visible page
object. This takes into account only the vertical dimension.
*/
sal_Int32 GetIndexOfFirstVisiblePageObject (
const Rectangle& rVisibleArea) const;
sal_Int32 GetIndexOfFirstVisiblePageObject (const Rectangle& rVisibleArea) const;
/** Return the index of the last fully or partially visible page
object. This takes into account only the vertical dimension.
@ -227,8 +225,7 @@ public:
The returned index may be larger than the number of existing
page objects.
*/
sal_Int32 GetIndexOfLastVisiblePageObject (
const Rectangle& rVisibleArea) const;
sal_Int32 GetIndexOfLastVisiblePageObject (const Rectangle& rVisibleArea) const;
/** Return the index of the page object that is rendered at the given
point.
@ -247,7 +244,7 @@ public:
*/
sal_Int32 GetIndexAtPoint (
const Point& rModelPosition,
bool bIncludePageBorders = false) const;
const bool bIncludePageBorders = false) const;
/** Return the page index of where to do an insert operation when the
user would release the the mouse button at the given position after
@ -275,58 +272,29 @@ public:
const Point& rModelPosition,
bool bAllowVerticalPosition) const;
typedef ::std::pair<double,double> DoublePoint;
/** Transform a point given in model coordinates in to layouter
coordinates. Layouter coordinates are floating point numbers where
the integer part denotes a row or a column and the part after the
decimal point is a relative position in that row or column.
*/
DoublePoint ConvertModelToLayouterCoordinates (
const Point& rModelPoint) const;
/** Transform a point given in layouter coordinates to model
coordinates. See ConvertModelToLayouterCoordinates for a
description of layouter coordinates.
*/
Point ConvertLayouterToModelCoordinates (
const DoublePoint&rLayouterPoint) const;
typedef ::std::vector<Rectangle> BackgroundRectangleList;
const BackgroundRectangleList& GetBackgroundRectangleList (void) const;
private:
class ScreenAndModelValue {public:
sal_Int32 mnScreen,mnModel;
explicit ScreenAndModelValue (sal_Int32 nScreen, sal_Int32 nModel = 0)
: mnScreen(nScreen),mnModel(nModel) {}
};
ScreenAndModelValue mnRequestedLeftBorder;
ScreenAndModelValue mnRequestedRightBorder;
ScreenAndModelValue mnRequestedTopBorder;
ScreenAndModelValue mnRequestedBottomBorder;
ScreenAndModelValue mnLeftBorder;
ScreenAndModelValue mnRightBorder;
ScreenAndModelValue mnTopBorder;
ScreenAndModelValue mnBottomBorder;
ScreenAndModelValue mnLeftPageBorder;
ScreenAndModelValue mnRightPageBorder;
ScreenAndModelValue mnTopPageBorder;
ScreenAndModelValue mnBottomPageBorder;
ScreenAndModelValue mnVerticalGap;
ScreenAndModelValue mnHorizontalGap;
ScreenAndModelValue mnInsertionMarkerThickness;
ScreenAndModelValue mnTotalVerticalGap;
ScreenAndModelValue mnTotalHorizontalGap;
::boost::shared_ptr< ::Window> mpWindow;
sal_Int32 mnRequestedLeftBorder;
sal_Int32 mnRequestedRightBorder;
sal_Int32 mnRequestedTopBorder;
sal_Int32 mnRequestedBottomBorder;
sal_Int32 mnLeftBorder;
sal_Int32 mnRightBorder;
sal_Int32 mnTopBorder;
sal_Int32 mnBottomBorder;
sal_Int32 mnVerticalGap;
sal_Int32 mnHorizontalGap;
sal_Int32 mnMinimalWidth;
sal_Int32 mnPreferredWidth;
sal_Int32 mnMaximalWidth;
sal_Int32 mnMinimalColumnCount;
sal_Int32 mnMaximalColumnCount;
sal_Int32 mnPageCount;
sal_Int32 mnColumnCount;
Size maPageObjectModelSize;
Size maPageObjectPixelSize;
sal_Int32 mnRowCount;
Size maPageObjectSize;
BackgroundRectangleList maBackgroundRectangleList;
::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
enum GapMembership { GM_NONE, GM_PREVIOUS, GM_BOTH, GM_NEXT,
GM_PAGE_BORDER};
@ -384,9 +352,6 @@ private:
@param nIndex
The row index of the upper row or the column index of the left
column.
@param nLeftOrTopPageBorder
Width in model coordinates of the border the the right of or
below a page.
@param nGap
Width or height of the gap in model coordiantes between the
page borders.
@ -399,7 +364,6 @@ private:
sal_Int32 nDistanceIntoGap,
GapMembership eGapMembership,
sal_Int32 nIndex,
sal_Int32 nLeftOrTopPageBorder,
sal_Int32 nGap) const;
};

View File

@ -0,0 +1,178 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_PAGE_OBJECT_LAYOUTER_HXX
#define SD_SLIDESORTER_PAGE_OBJECT_LAYOUTER_HXX
#include "SlideSorter.hxx"
#include "model/SlsSharedPageDescriptor.hxx"
#include "tools/gen.hxx"
#include <vcl/image.hxx>
namespace sd { namespace slidesorter { namespace view {
/** In contrast to the Layouter that places page objects in the view, the
PageObjectLayouter places the parts of individual page objects like page
number area, borders, preview.
*/
class PageObjectLayouter
{
public:
/** Create a new PageObjectLayouter object.
@param rPageObjectSize
In general either the width or the height will be 0 in order to
signal that this size component has to be calculated from the other.
This calculation will make the preview as large as possible.
@param nPageCount
The page count is used to determine how wide the page number
area has to be, how many digits to except for the largest page number.
*/
PageObjectLayouter (
const Size& rPageObjectWindowSize,
const Size& rPreviewModelSize,
const ::boost::shared_ptr< ::Window>& rpWindow,
const int nPageCount);
enum Part {
// This is the outer bounding box that includes the preview, page
// number, title.
PageObject,
// Bounding box of the actual preview.
Preview,
// Bounding box of the mouse indicator indicator frame.
MouseOverIndicator,
// Bounding box of the focus indicator frame.
FocusIndicator,
// Bounding box of the selection indicator frame.
SelectionIndicator,
// Bounding box of the page number.
PageNumber,
// Bounding box of the pane name.
Name,
// Indicator whether or not there is a slide transition associated
// with this slide.
TransitionEffectIndicator,
ButtonArea,
Button
};
/** Two coordinate systems are supported. They differ only in
translation not in scale. Both relate to pixel values in the window.
A position in the window coordinate system does not change when the window content is
scrolled up or down. In the screen coordinate system (relative
to the top left point of the window)scrolling leads to different values.
Example: Scroll up the point (0,0) in the the window coordinate
system by 20 pixels. It lies not inside the visible area of the
window anymore. Its screen coordinates are now (-20,0).
WindowCoordinateSystem corresponds to the logic coordinate system of
class Window, while ScreenCoordinateSystem corresponds to its pixel
coordinate system.
*/
enum CoordinateSystem {
WindowCoordinateSystem,
ScreenCoordinateSystem};
/** Return the bounding box of the page object or one of its graphical
parts.
@param rWindow
This device is used to translate between model and window
coordinates.
@param rpPageDescriptor
The page for which to calculate the bounding box.
@param ePart
The part of the page object for which to return the bounding
box.
@param eCoodinateSystem
The bounding box can be returned in model and in pixel
(window) coordinates.
@param nIndex
Used only for some parts (Button) to distinguish between
different parts of the same type.
*/
Rectangle GetBoundingBox (
const model::SharedPageDescriptor& rpPageDescriptor,
const Part ePart,
const CoordinateSystem eCoordinateSystem,
const sal_Int32 nIndex = 0);
/** Return the size in pixel of the whole page object.
*/
Size GetPageObjectSize (void) const;
/** Return the size in pixel of the preview.
*/
Size GetPreviewSize (void) const;
Image GetTransitionEffectIcon (void) const;
// void Update (void);
sal_Int32 GetButtonIndexAt (
const model::SharedPageDescriptor& rpPageDescriptor,
const Point& rWindowLocation);
private:
/// Gap between border of page object and inside of selection rectangle.
static const sal_Int32 mnSelectionIndicatorOffset;
/// Thickness of the selection rectangle.
static const sal_Int32 mnSelectionIndicatorThickness;
/// Gap between border of page object and inside of focus rectangle.
static const sal_Int32 mnFocusIndicatorOffset;
/// Minimal border around the page number area.
static const sal_Int32 mnPageNumberOffset;
static const sal_Int32 mnOuterBorderWidth;
static const Size maButtonSize;
static const sal_Int32 mnButtonGap;
const ::boost::shared_ptr< ::Window> mpWindow;
Size maPageObjectSize;
double mnModelToWindowScale;
Rectangle maPageObjectBoundingBox;
Rectangle maPageNumberAreaBoundingBox;
Rectangle maPreviewBoundingBox;
Rectangle maFocusIndicatorBoundingBox;
Rectangle maSelectionIndicatorBoundingBox;
Rectangle maTransitionEffectBoundingBox;
Rectangle maButtonAreaBoundingBox;
const Image maTransitionEffectIcon;
Size GetPageNumberAreaSize (const int nPageCount);
Rectangle CalculatePreviewBoundingBox (
Size& rPageObjectSize,
const Size& rPreviewModelSize,
const Size& rPageNumberAreaSize);
};
} } } // end of namespace ::sd::slidesorter::view
#endif

View File

@ -0,0 +1,90 @@
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: baseprimitive2d.hxx,v $
*
* $Revision: 1.8 $
*
* last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $
*
* 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 SD_SLIDESORTER_PAGE_OBJECT_PAINTER_HEADER
#define SD_SLIDESORTER_PAGE_OBJECT_PAINTER_HEADER
#include "SlideSorter.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlsLayouter.hxx"
namespace sd { namespace slidesorter { namespace cache { class PageCache; } } }
namespace sd { namespace slidesorter { namespace view {
class Layouter;
class PageObjectLayouter;
class PageObjectPainter
{
public:
PageObjectPainter (const SlideSorter& rSlideSorter);
void PaintPageObject (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor);
private:
const Layouter& mrLayouter;
::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
::boost::shared_ptr<cache::PageCache> mpCache;
::boost::shared_ptr<controller::Properties> mpProperties;
::boost::scoped_ptr<Font> mpFont;
BitmapEx maStartPresentationIcon;
BitmapEx maShowSlideIcon;
BitmapEx maNewSlideIcon;
void PaintBackground (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const;
void PaintPreview (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const;
void PaintPageNumber (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const;
void PaintTransitionEffect (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const;
void PaintButtons (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const;
ColorData GetColorForVisualState (const model::SharedPageDescriptor& rpDescriptor) const;
};
} } } // end of namespace sd::slidesorter::view
#endif

View File

@ -32,14 +32,19 @@
#define SD_SLIDESORTER_VIEW_OVERLAY_HXX
#include "model/SlsSharedPageDescriptor.hxx"
#include "view/SlsILayerPainter.hxx"
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <osl/mutex.hxx>
#include <svx/sdr/overlay/overlayobject.hxx>
#include <tools/gen.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/image.hxx>
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <vector>
#include <boost/weak_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/enable_shared_from_this.hpp>
class OutputDevice;
class Region;
@ -57,15 +62,11 @@ namespace sd { namespace slidesorter { namespace controller {
class SlideSorterController;
} } }
namespace sdr { namespace overlay {
class OverlayManager;
} }
namespace sd { namespace slidesorter { namespace view {
class LayeredDevice;
class InsertionIndicatorOverlay;
class PageObjectViewObjectContact;
class SelectionRectangleOverlay;
class SubstitutionOverlay;
class ViewOverlay;
@ -73,23 +74,37 @@ class ViewOverlay;
/** This base class of slide sorter overlays uses the drawing layer overlay
support for the display.
*/
class OverlayBase
: public sdr::overlay::OverlayObject
class OverlayBase :
public ILayerPainter,
public ::boost::enable_shared_from_this<OverlayBase>
{
public:
OverlayBase (ViewOverlay& rViewOverlay);
OverlayBase (ViewOverlay& rViewOverlay, const sal_Int32 nLayer);
virtual ~OverlayBase (void);
bool IsVisible (void) const;
void SetIsVisible (const bool bIsVisible);
virtual void SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator);
sal_Int32 GetLayerIndex (void) const;
protected:
::osl::Mutex maMutex;
ViewOverlay& mrViewOverlay;
SharedILayerInvalidator mpLayerInvalidator;
/** Make sure that the overlay object is registered at the
OverlayManager. This registration is done on demand.
*/
void EnsureRegistration (void);
void RemoveRegistration();
class Invalidator;
friend class Invalidator;
virtual Rectangle GetBoundingBox (void) const = 0;
private:
bool mbIsVisible;
const sal_Int32 mnLayerIndex;
void Invalidate (const Rectangle& rInvalidationBox);
};
@ -102,7 +117,7 @@ class SubstitutionOverlay
: public OverlayBase
{
public:
SubstitutionOverlay (ViewOverlay& rViewOverlay);
SubstitutionOverlay (ViewOverlay& rViewOverlay, const sal_Int32 nLayer);
virtual ~SubstitutionOverlay (void);
/** Setup the substitution display of the given set of selected pages.
@ -111,7 +126,8 @@ public:
*/
void Create (
model::PageEnumeration& rSelection,
const Point& rPosition);
const Point& rPosition,
const model::SharedPageDescriptor& rpHitDescriptor);
/** Clear the substitution display. Until the next call of Create() no
substution is painted.
@ -124,16 +140,36 @@ public:
void SetPosition (const Point& rPosition);
Point GetPosition (void) const;
// react on stripe definition change
virtual void stripeDefinitionHasChanged();
virtual void Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea);
protected:
// geometry creation for OverlayObject
virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
virtual Rectangle GetBoundingBox (void) const;
private:
Point maPosition;
basegfx::B2DPolyPolygon maShapes;
Point maTranslation;
/** The substitution paints only the page object under the mouse and the
8-neighborhood around it. It uses different levels of transparency
for the center and the four elements at its sides and the four
elements at its corners. All values between 0 (opaque) and 100
(fully transparent.)
*/
static const sal_Int32 mnCenterTransparency;
static const sal_Int32 mnSideTransparency;
static const sal_Int32 mnCornerTransparency;
class ItemDescriptor
{
public:
BitmapEx maImage;
Point maLocation;
double mnTransparency;
basegfx::B2DPolygon maShape;
};
::std::vector<ItemDescriptor> maItems;
Rectangle maBoundingBox;
};
@ -147,20 +183,19 @@ class SelectionRectangleOverlay
: public OverlayBase
{
public:
SelectionRectangleOverlay (ViewOverlay& rViewOverlay);
virtual ~SelectionRectangleOverlay();
SelectionRectangleOverlay (ViewOverlay& rViewOverlay, const sal_Int32 nLayer);
void Start (const Point& rAnchor);
void Update (const Point& rSecondCorner);
Rectangle GetSelectionRectangle (void);
// react on stripe definition change
virtual void stripeDefinitionHasChanged();
virtual void Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea);
protected:
// geometry creation for OverlayObject
virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
virtual Rectangle GetBoundingBox (void) const;
private:
Point maAnchor;
@ -177,64 +212,39 @@ class InsertionIndicatorOverlay
: public OverlayBase
{
public:
InsertionIndicatorOverlay (ViewOverlay& rViewOverlay);
virtual ~InsertionIndicatorOverlay();
InsertionIndicatorOverlay (ViewOverlay& rViewOverlay, const sal_Int32 nLayer);
/** Given a position in model coordinates this method calculates the
insertion marker both as an index in the document and as a rectangle
insertion marker both as an index in the document and as a location
used for drawing the insertion indicator.
*/
void SetPosition (const Point& rPosition);
void SetLocation (const Point& rPosition);
sal_Int32 GetInsertionPageIndex (void) const;
virtual void Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea);
protected:
// geometry creation for OverlayObject
virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
virtual Rectangle GetBoundingBox (void) const;
private:
sal_Int32 mnInsertionIndex;
Rectangle maBoundingBox;
// Center of the insertion indicator.
Point maLocation;
/** Remember whether the insertion indicator is displayed before (left
of or above) or after (right of or below) the page at the insertion
index.
*/
bool mbIsBeforePage;
ImageList maIcons;
Image maIconWithBorder;
Image maIcon;
Image maMask;
void SetPositionAndSize (const Rectangle& rBoundingBox);
};
/** Paint a frame around the slide preview under the mouse. The actual
painting is done by the PageObjectViewObjectContact of the slidesorter.
*/
class MouseOverIndicatorOverlay
: public OverlayBase
{
public:
MouseOverIndicatorOverlay (ViewOverlay& rViewOverlay);
virtual ~MouseOverIndicatorOverlay (void);
/** Set the page object for which to paint a mouse over indicator.
@param pContact
A value of <NULL/> indicates to not paint the mouse over indicator.
*/
void SetSlideUnderMouse (const model::SharedPageDescriptor& rpDescriptor);
protected:
// geometry creation for OverlayObject
virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
private:
/** The page under the mouse is stored as weak shared pointer so that
model changes can be handled without having the SlideSorterModel
inform this class explicitly.
*/
::boost::weak_ptr<model::PageDescriptor> mpPageUnderMouse;
view::PageObjectViewObjectContact* GetViewObjectContact (void) const;
};
/** The view overlay manages and paints some indicators that are painted on
top of the regular view content (the page objects). It is separated
from the view to allow the indicators to be altered in position and size
@ -249,24 +259,24 @@ private:
class ViewOverlay
{
public:
ViewOverlay (SlideSorter& rSlideSorter);
~ViewOverlay (void);
ViewOverlay (
SlideSorter& rSlideSorter,
const ::boost::shared_ptr<LayeredDevice>& rpLayeredDevice);
virtual ~ViewOverlay (void);
SelectionRectangleOverlay& GetSelectionRectangleOverlay (void);
MouseOverIndicatorOverlay& GetMouseOverIndicatorOverlay (void);
InsertionIndicatorOverlay& GetInsertionIndicatorOverlay (void);
SubstitutionOverlay& GetSubstitutionOverlay (void);
::boost::shared_ptr<SelectionRectangleOverlay> GetSelectionRectangleOverlay (void);
::boost::shared_ptr<InsertionIndicatorOverlay> GetInsertionIndicatorOverlay (void);
::boost::shared_ptr<SubstitutionOverlay> GetSubstitutionOverlay (void);
SlideSorter& GetSlideSorter (void) const;
sdr::overlay::OverlayManager* GetOverlayManager (void) const;
::boost::shared_ptr<LayeredDevice> GetLayeredDevice (void) const;
private:
SlideSorter& mrSlideSorter;
SelectionRectangleOverlay maSelectionRectangleOverlay;
MouseOverIndicatorOverlay maMouseOverIndicatorOverlay;
InsertionIndicatorOverlay maInsertionIndicatorOverlay;
SubstitutionOverlay maSubstitutionOverlay;
const ::boost::shared_ptr<LayeredDevice> mpLayeredDevice;
::boost::shared_ptr<SelectionRectangleOverlay> mpSelectionRectangleOverlay;
::boost::shared_ptr<InsertionIndicatorOverlay> mpInsertionIndicatorOverlay;
::boost::shared_ptr<SubstitutionOverlay> mpSubstitutionOverlay;
};

View File

@ -36,7 +36,6 @@
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsPageObjectFactory.hxx"
#include "controller/SlsProperties.hxx"
#include "controller/SlsPageSelector.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
@ -79,8 +78,7 @@ SlideSorterModel::SlideSorterModel (SlideSorter& rSlideSorter)
mxSlides(),
mePageKind(PK_STANDARD),
meEditMode(EM_PAGE),
maPageDescriptors(0),
mpPageObjectFactory(NULL)
maPageDescriptors(0)
{
}
@ -95,6 +93,14 @@ SlideSorterModel::~SlideSorterModel (void)
void SlideSorterModel::Dispose (void)
{
ClearDescriptorList ();
}
SdDrawDocument* SlideSorterModel::GetDocument (void)
{
if (mrSlideSorter.GetViewShellBase() != NULL)
@ -195,8 +201,7 @@ SharedPageDescriptor SlideSorterModel::GetPageDescriptor (
pDescriptor.reset(new PageDescriptor (
Reference<drawing::XDrawPage>(mxSlides->getByIndex(nPageIndex),UNO_QUERY),
pPage,
nPageIndex,
GetPageObjectFactory()));
nPageIndex));
maPageDescriptors[nPageIndex] = pDescriptor;
}
}
@ -263,6 +268,47 @@ sal_Int32 SlideSorterModel::GetIndex (const Reference<drawing::XDrawPage>& rxSli
sal_Int32 SlideSorterModel::GetIndex (const SdrPage* pPage) const
{
if (pPage == NULL)
return -1;
::osl::MutexGuard aGuard (maMutex);
// First try to guess the right index.
sal_Int16 nNumber ((pPage->GetPageNum()-1)/2);
SharedPageDescriptor pDescriptor (GetPageDescriptor(nNumber, false));
if (pDescriptor.get() != NULL
&& pDescriptor->GetPage() == pPage)
{
return nNumber;
}
// Guess was wrong, iterate over all slides and search for the right
// one.
const sal_Int32 nCount (maPageDescriptors.size());
for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
{
SharedPageDescriptor pDescriptor (maPageDescriptors[nIndex]);
// Make sure that the descriptor exists. Without it the given slide
// can not be found.
if (pDescriptor.get() == NULL)
{
// Call GetPageDescriptor() to create the missing descriptor.
pDescriptor = GetPageDescriptor(nIndex, true);
}
if (pDescriptor->GetPage() == pPage)
return nIndex;
}
return -1;
}
/** For now this method uses a trivial algorithm: throw away all descriptors
and create them anew (on demand). The main problem that we are facing
when designing a better algorithm is that we can not compare pointers to
@ -312,7 +358,7 @@ void SlideSorterModel::SynchronizeDocumentSelection (void)
while (aAllPages.HasMoreElements())
{
SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
pDescriptor->GetPage()->SetSelected (pDescriptor->IsSelected());
pDescriptor->GetPage()->SetSelected(pDescriptor->HasState(PageDescriptor::ST_Selected));
}
}
@ -327,55 +373,13 @@ void SlideSorterModel::SynchronizeModelSelection (void)
while (aAllPages.HasMoreElements())
{
SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
if (pDescriptor->GetPage()->IsSelected())
pDescriptor->Select ();
else
pDescriptor->Deselect ();
pDescriptor->SetState(PageDescriptor::ST_Selected, pDescriptor->GetPage()->IsSelected());
}
}
void SlideSorterModel::SetPageObjectFactory(
::std::auto_ptr<controller::PageObjectFactory> pPageObjectFactory)
{
::osl::MutexGuard aGuard (maMutex);
mpPageObjectFactory = pPageObjectFactory;
// When a NULL pointer was given then create a default factory.
const controller::PageObjectFactory& rFactory (GetPageObjectFactory());
PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(*this));
while (aAllPages.HasMoreElements())
{
SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
pDescriptor->SetPageObjectFactory(rFactory);
}
}
const controller::PageObjectFactory&
SlideSorterModel::GetPageObjectFactory (void) const
{
::osl::MutexGuard aGuard (maMutex);
if (mpPageObjectFactory.get() == NULL)
{
// We have to create a new factory. The pointer is mutable so we
// are alowed to do so.
mpPageObjectFactory = ::std::auto_ptr<controller::PageObjectFactory> (
new controller::PageObjectFactory(
mrSlideSorter.GetView().GetPreviewCache(),
mrSlideSorter.GetController().GetProperties()));
}
return *mpPageObjectFactory.get();
}
::osl::Mutex& SlideSorterModel::GetMutex (void)
{
return maMutex;

View File

@ -32,9 +32,6 @@
#include "precompiled_sd.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlsPageObject.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "controller/SlsPageObjectFactory.hxx"
#include "sdpage.hxx"
#include "drawdoc.hxx"
@ -51,20 +48,18 @@ namespace sd { namespace slidesorter { namespace model {
PageDescriptor::PageDescriptor (
const Reference<drawing::XDrawPage>& rxPage,
SdPage* pPage,
const sal_Int32 nIndex,
const controller::PageObjectFactory& rPageObjectFactory)
const sal_Int32 nIndex)
: mpPage(pPage),
mxPage(rxPage),
mnIndex(nIndex),
mpPageObjectFactory(&rPageObjectFactory),
mpPageObject(NULL),
mbIsSelected(false),
mbWasSelected(false),
mbIsVisible(false),
mbIsFocused(false),
mbIsCurrent(false),
mpViewObjectContact(NULL),
maModelBorder(0,0,0,0),
maPageNumberAreaModelSize(0,0)
mbIsMouseOver(false),
maBoundingBox(),
maVisualState(nIndex)
{
OSL_ASSERT(mpPage == SdPage::getImplementation(rxPage));
}
@ -103,74 +98,104 @@ sal_Int32 PageDescriptor::GetPageIndex (void) const
view::PageObject* PageDescriptor::GetPageObject (void)
bool PageDescriptor::HasState (const State eState) const
{
if (mpPageObject==NULL && mpPageObjectFactory!=NULL && mpPage != NULL)
switch (eState)
{
mpPageObject = mpPageObjectFactory->CreatePageObject(mpPage, shared_from_this());
case ST_Visible:
return mbIsVisible;
case ST_Selected:
return mbIsSelected;
case ST_WasSelected:
return mbWasSelected;
case ST_Focused:
return mbIsFocused;
case ST_MouseOver:
return mbIsMouseOver;
case ST_Current:
return mbIsCurrent;
case ST_Excluded:
return mpPage!=NULL && mpPage->IsExcluded();
default:
OSL_ASSERT(false);
return false;
}
}
bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
{
bool bModified (false);
switch (eState)
{
case ST_Visible:
bModified = (bNewStateValue!=mbIsVisible);
if (bModified)
mbIsVisible = bNewStateValue;
break;
case ST_Selected:
bModified = (bNewStateValue!=mbIsSelected);
if (bModified)
mbIsSelected = bNewStateValue;
break;
case ST_WasSelected:
bModified = (bNewStateValue!=mbWasSelected);
if (bModified)
mbWasSelected = bNewStateValue;
break;
case ST_Focused:
bModified = (bNewStateValue!=mbIsFocused);
if (bModified)
mbIsFocused = bNewStateValue;
break;
case ST_MouseOver:
bModified = (bNewStateValue!=mbIsMouseOver);
if (bModified)
mbIsMouseOver = bNewStateValue;
break;
case ST_Current:
bModified = (bNewStateValue!=mbIsCurrent);
if (bModified)
mbIsCurrent = bNewStateValue;
break;
case ST_Excluded:
// This is a state of the page and has to be handled differently
// from the view-only states.
if (mpPage != NULL)
if (bNewStateValue != (mpPage->IsExcluded()==TRUE))
{
mpPage->SetExcluded(bNewStateValue);
bModified = true;
}
break;
}
return mpPageObject;
if (bModified)
maVisualState.UpdateVisualState(*this);
return bModified;
}
void PageDescriptor::ReleasePageObject (void)
VisualState& PageDescriptor::GetVisualState (void)
{
mpPageObject = NULL;
}
bool PageDescriptor::IsVisible (void) const
{
return mbIsVisible;
}
void PageDescriptor::SetVisible (bool bIsVisible)
{
mbIsVisible = bIsVisible;
}
bool PageDescriptor::Select (void)
{
if ( ! IsSelected())
{
mbIsSelected = true;
return true;
}
else
return false;
}
bool PageDescriptor::Deselect (void)
{
if (IsSelected())
{
mbIsSelected = false;
return true;
}
else
return false;
}
bool PageDescriptor::IsSelected (void) const
{
return mbIsSelected;
return maVisualState;
}
@ -179,10 +204,7 @@ bool PageDescriptor::IsSelected (void) const
bool PageDescriptor::UpdateSelection (void)
{
if (mpPage!=NULL && (mpPage->IsSelected()==TRUE) != mbIsSelected)
{
mbIsSelected = ! mbIsSelected;
return true;
}
return SetState(ST_Selected, !mbIsSelected);
else
return false;
}
@ -190,109 +212,28 @@ bool PageDescriptor::UpdateSelection (void)
bool PageDescriptor::IsFocused (void) const
Rectangle PageDescriptor::GetBoundingBox (void) const
{
return mbIsFocused;
Rectangle aBox (maBoundingBox);
const Point aOffset (maVisualState.GetLocationOffset());
aBox.Move(aOffset.X(), aOffset.Y());
return aBox;
}
void PageDescriptor::SetFocus (void)
Point PageDescriptor::GetLocation (void) const
{
mbIsFocused = true;
return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
}
void PageDescriptor::RemoveFocus (void)
void PageDescriptor::SetBoundingBox (const Rectangle& rBoundingBox)
{
mbIsFocused = false;
}
view::PageObjectViewObjectContact*
PageDescriptor::GetViewObjectContact (void) const
{
return mpViewObjectContact;
}
void PageDescriptor::SetViewObjectContact (
view::PageObjectViewObjectContact* pViewObjectContact)
{
mpViewObjectContact = pViewObjectContact;
}
const controller::PageObjectFactory&
PageDescriptor::GetPageObjectFactory (void) const
{
return *mpPageObjectFactory;
}
void PageDescriptor::SetPageObjectFactory (
const controller::PageObjectFactory& rFactory)
{
mpPageObjectFactory = &rFactory;
}
void PageDescriptor::SetModelBorder (const SvBorder& rBorder)
{
maModelBorder = rBorder;
}
SvBorder PageDescriptor::GetModelBorder (void) const
{
return maModelBorder;
}
void PageDescriptor::SetPageNumberAreaModelSize (const Size& rSize)
{
maPageNumberAreaModelSize = rSize;
}
Size PageDescriptor::GetPageNumberAreaModelSize (void) const
{
return maPageNumberAreaModelSize;
}
bool PageDescriptor::IsCurrentPage (void) const
{
return mbIsCurrent;
}
void PageDescriptor::SetIsCurrentPage (const bool bIsCurrent)
{
mbIsCurrent = bIsCurrent;
maBoundingBox = rBoundingBox;
}

View File

@ -60,7 +60,7 @@ class SelectedPagesPredicate
public:
bool operator() (const SharedPageDescriptor& rpDescriptor)
{
return rpDescriptor->IsSelected();
return rpDescriptor->HasState(PageDescriptor::ST_Selected);
}
};
@ -72,7 +72,7 @@ class VisiblePagesPredicate
public:
bool operator() (const SharedPageDescriptor& rpDescriptor)
{
return rpDescriptor->IsVisible();
return rpDescriptor->HasState(PageDescriptor::ST_Visible);
}
};

View File

@ -0,0 +1,236 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsPageDescriptor.hxx,v $
* $Revision: 1.8 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "model/SlsVisualState.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "controller/SlsAnimator.hxx"
namespace sd { namespace slidesorter { namespace model {
VisualState::VisualState (const sal_Int32 nPageId)
: mnPageId(nPageId),
meCurrentVisualState(VS_None),
meOldVisualState(VS_None),
mnVisualStateBlend(1.0),
mnStateAnimationId(controller::Animator::NotAnAnimationId),
maLocationOffset(0,0),
mnLocationAnimationId(controller::Animator::NotAnAnimationId),
mnButtonAlpha(1.0),
mnButtonAlphaAnimationId(controller::Animator::NotAnAnimationId)
{
}
VisualState::~VisualState (void)
{
OSL_ASSERT(mnStateAnimationId == controller::Animator::NotAnAnimationId);
OSL_ASSERT(mnLocationAnimationId == controller::Animator::NotAnAnimationId);
}
VisualState::State VisualState::GetCurrentVisualState (void) const
{
return meCurrentVisualState;
}
VisualState::State VisualState::GetOldVisualState (void) const
{
return meOldVisualState;
}
void VisualState::SetVisualState (const State eState)
{
meOldVisualState = meCurrentVisualState;
meCurrentVisualState = eState;
mnVisualStateBlend = 1.0;
}
double VisualState::GetVisualStateBlend (void) const
{
return mnVisualStateBlend;
}
void VisualState::SetVisualStateBlend (const double nBlend)
{
mnVisualStateBlend = nBlend;
}
void VisualState::UpdateVisualState (const PageDescriptor& rDescriptor)
{
if (rDescriptor.HasState(PageDescriptor::ST_Excluded))
SetVisualState(VS_Excluded);
else if (rDescriptor.HasState(PageDescriptor::ST_Current))
SetVisualState(VS_Current);
else if (rDescriptor.HasState(PageDescriptor::ST_Focused))
SetVisualState(VS_Focused);
else if (rDescriptor.HasState(PageDescriptor::ST_Selected))
SetVisualState(VS_Selected);
else
SetVisualState(VS_None);
SetMouseOverState(rDescriptor.HasState(PageDescriptor::ST_MouseOver));
}
void VisualState::SetMouseOverState (const bool bIsMouseOver)
{
mbOldMouseOverState = mbCurrentMouseOverState;
mbCurrentMouseOverState = bIsMouseOver;
}
sal_Int32 VisualState::GetStateAnimationId (void) const
{
return mnStateAnimationId;
}
void VisualState::SetStateAnimationId (const sal_Int32 nAnimationId)
{
mnStateAnimationId = nAnimationId;
}
Point VisualState::GetLocationOffset (void) const
{
return maLocationOffset;
}
bool VisualState::SetLocationOffset (const Point& rOffset)
{
if (maLocationOffset != rOffset)
{
maLocationOffset = rOffset;
return true;
}
else
return false;
}
sal_Int32 VisualState::GetLocationAnimationId (void) const
{
return mnLocationAnimationId;
}
void VisualState::SetLocationAnimationId (const sal_Int32 nAnimationId)
{
mnLocationAnimationId = nAnimationId;
}
double VisualState::GetButtonAlpha (void) const
{
return mnButtonAlpha;
}
void VisualState::SetButtonAlpha (const double nAlpha)
{
mnButtonAlpha = nAlpha;
}
sal_Int32 VisualState::GetButtonAlphaAnimationId (void) const
{
return mnButtonAlphaAnimationId;
}
void VisualState::SetButtonAlphaAnimationId (const sal_Int32 nAnimationId)
{
mnButtonAlphaAnimationId = nAnimationId;
}
void VisualState::SetActiveButtonState (const sal_Int32 nIndex, const ButtonState eState)
{
mnActiveButtonIndex = nIndex;
meActiveButtonState = eState;
}
VisualState::ButtonState VisualState::GetButtonState (const sal_Int32 nIndex)
{
if (nIndex == mnActiveButtonIndex)
return meActiveButtonState;
else
return BS_Normal;
}
} } } // end of namespace ::sd::slidesorter::model

View File

@ -50,6 +50,7 @@ SLOFILES = \
$(SLO)$/SlsPageDescriptor.obj \
$(SLO)$/SlsPageEnumeration.obj \
$(SLO)$/SlsPageEnumerationProvider.obj \
$(SLO)$/SlsVisualState.obj \
$(SLO)$/SlideSorterModel.obj
EXCEPTIONSFILES=

View File

@ -36,6 +36,7 @@
#include "SlideSorterViewShell.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsScrollBarManager.hxx"
#include "controller/SlsProperties.hxx"
#include "view/SlideSorterView.hxx"
#include "model/SlideSorterModel.hxx"
@ -138,7 +139,8 @@ SlideSorter::SlideSorter (
mpHorizontalScrollBar(rpHorizontalScrollBar),
mpVerticalScrollBar(rpVerticalScrollBar),
mpScrollBarBox(rpScrollBarBox),
mbLayoutPending(true)
mbLayoutPending(true),
mpProperties(new controller::Properties())
{
}
@ -160,7 +162,8 @@ SlideSorter::SlideSorter (
mpHorizontalScrollBar(new ScrollBar(&rParentWindow,WinBits(WB_HSCROLL | WB_DRAG))),
mpVerticalScrollBar(new ScrollBar(&rParentWindow,WinBits(WB_VSCROLL | WB_DRAG))),
mpScrollBarBox(new ScrollBarBox(&rParentWindow)),
mbLayoutPending(true)
mbLayoutPending(true),
mpProperties(new controller::Properties())
{
}
@ -172,12 +175,26 @@ void SlideSorter::Init (void)
if (mpViewShellBase != NULL)
mxControllerWeak = mpViewShellBase->GetController();
// Reinitialize colors in Properties with window specific values.
if (mpContentWindow)
{
mpProperties->SetBackgroundColor(
mpContentWindow->GetSettings().GetStyleSettings().GetWindowColor());
mpProperties->SetTextColor(
mpContentWindow->GetSettings().GetStyleSettings().GetWindowTextColor());
mpProperties->SetSelectionColor(
mpContentWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor());
mpProperties->SetHighlightColor(
mpContentWindow->GetSettings().GetStyleSettings().GetMenuHighlightColor());
}
CreateModelViewController ();
SetupListeners ();
// Initialize the window.
::sd::Window* pWindow = GetActiveWindow();
::boost::shared_ptr<sd::Window> pWindow (GetContentWindow());
if (pWindow != NULL)
{
::Window* pParentWindow = pWindow->GetParent();
@ -207,6 +224,12 @@ SlideSorter::~SlideSorter (void)
ReleaseListeners();
// Dispose model, view and controller to avoid calls between them when
// they are being destructed and one or two of them are already gone.
mpSlideSorterController->Dispose();
mpSlideSorterView->Dispose();
mpSlideSorterModel->Dispose();
// Reset the auto pointers explicitly to control the order of destruction.
mpSlideSorterController.reset();
mpSlideSorterView.reset();
@ -215,6 +238,9 @@ SlideSorter::~SlideSorter (void)
mpHorizontalScrollBar.reset();
mpVerticalScrollBar.reset();
mpScrollBarBox.reset();
const int nCount (mpContentWindow.use_count());
OSL_ASSERT(mpContentWindow.unique());
OSL_ASSERT(mpContentWindow.use_count()==1);
mpContentWindow.reset();
}
@ -308,17 +334,6 @@ void SlideSorter::Paint (const Rectangle& rRepaintArea)
::sd::Window* SlideSorter::GetActiveWindow (void) const
{
if (mpViewShell != NULL)
return mpViewShell->GetActiveWindow();
else
return mpContentWindow.get();
}
ViewShellBase* SlideSorter::GetViewShellBase (void) const
{
return mpViewShellBase;
@ -346,8 +361,8 @@ void SlideSorter::SetupControls (::Window* )
void SlideSorter::SetupListeners (void)
{
::sd::Window* pWindow = GetActiveWindow();
if (pWindow != NULL)
::boost::shared_ptr<sd::Window> pWindow (GetContentWindow());
if (pWindow)
{
::Window* pParentWindow = pWindow->GetParent();
if (pParentWindow != NULL)
@ -378,8 +393,8 @@ void SlideSorter::ReleaseListeners (void)
{
mpSlideSorterController->GetScrollBarManager().Disconnect();
::sd::Window* pWindow = GetActiveWindow();
if (pWindow != NULL)
::boost::shared_ptr<sd::Window> pWindow (GetContentWindow());
if (pWindow)
{
pWindow->RemoveEventListener(
@ -468,22 +483,17 @@ void SlideSorter::ArrangeGUIElements (
// Prevent untimely redraws while the view is not yet correctly
// resized.
mpSlideSorterView->LockRedraw (TRUE);
if (GetActiveWindow() != NULL)
GetActiveWindow()->EnablePaint (FALSE);
if (GetContentWindow())
GetContentWindow()->EnablePaint (FALSE);
// maAllWindowRectangle =
mpSlideSorterController->Resize (Rectangle(aOrigin, rSize));
if (GetActiveWindow() != NULL)
GetActiveWindow()->EnablePaint (TRUE);
if (GetContentWindow())
GetContentWindow()->EnablePaint (TRUE);
mbLayoutPending = false;
mpSlideSorterView->LockRedraw (FALSE);
}
else
{
// maAllWindowRectangle = Rectangle();
}
}
@ -553,6 +563,14 @@ void SlideSorter::SetCurrentFunction (const FunctionReference& rpFunction)
::boost::shared_ptr<controller::Properties> SlideSorter::GetProperties (void) const
{
return mpProperties;
}
//===== ContentWindow =========================================================
namespace {

View File

@ -321,7 +321,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsHighlightCurrentSlide (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return false;
else
return mpSlideSorter->GetController().GetProperties()->IsHighlightCurrentSlide();
return mpSlideSorter->GetProperties()->IsHighlightCurrentSlide();
}
@ -333,7 +333,7 @@ void SAL_CALL SlideSorterService::setIsHighlightCurrentSlide (sal_Bool bValue)
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
{
mpSlideSorter->GetController().GetProperties()->SetHighlightCurrentSlide(bValue);
mpSlideSorter->GetProperties()->SetHighlightCurrentSlide(bValue);
controller::SlideSorterController::ModelChangeLock aLock (mpSlideSorter->GetController());
mpSlideSorter->GetController().HandleModelChange();
}
@ -349,7 +349,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsShowSelection (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return false;
else
return mpSlideSorter->GetController().GetProperties()->IsShowSelection();
return mpSlideSorter->GetProperties()->IsShowSelection();
}
@ -360,7 +360,7 @@ void SAL_CALL SlideSorterService::setIsShowSelection (sal_Bool bValue)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetShowSelection(bValue);
mpSlideSorter->GetProperties()->SetShowSelection(bValue);
}
@ -373,7 +373,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsShowFocus (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return false;
else
return mpSlideSorter->GetController().GetProperties()->IsShowFocus();
return mpSlideSorter->GetProperties()->IsShowFocus();
}
@ -384,7 +384,7 @@ void SAL_CALL SlideSorterService::setIsShowFocus (sal_Bool bValue)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetShowFocus(bValue);
mpSlideSorter->GetProperties()->SetShowFocus(bValue);
}
@ -397,7 +397,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsCenterSelection (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return false;
else
return mpSlideSorter->GetController().GetProperties()->IsCenterSelection();
return mpSlideSorter->GetProperties()->IsCenterSelection();
}
@ -408,7 +408,7 @@ void SAL_CALL SlideSorterService::setIsCenterSelection (sal_Bool bValue)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetCenterSelection(bValue);
mpSlideSorter->GetProperties()->SetCenterSelection(bValue);
}
@ -421,7 +421,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsSuspendPreviewUpdatesDuringFullScreen
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return true;
else
return mpSlideSorter->GetController().GetProperties()
return mpSlideSorter->GetProperties()
->IsSuspendPreviewUpdatesDuringFullScreenPresentation();
}
@ -434,7 +434,7 @@ void SAL_CALL SlideSorterService::setIsSuspendPreviewUpdatesDuringFullScreenPres
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()
mpSlideSorter->GetProperties()
->SetSuspendPreviewUpdatesDuringFullScreenPresentation(bValue);
}
@ -474,7 +474,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsSmoothScrolling (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return false;
else
return mpSlideSorter->GetController().GetProperties()->IsSmoothSelectionScrolling();
return mpSlideSorter->GetProperties()->IsSmoothSelectionScrolling();
}
@ -485,7 +485,7 @@ void SAL_CALL SlideSorterService::setIsSmoothScrolling (sal_Bool bValue)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetSmoothSelectionScrolling(bValue);
mpSlideSorter->GetProperties()->SetSmoothSelectionScrolling(bValue);
}
@ -499,7 +499,7 @@ util::Color SAL_CALL SlideSorterService::getBackgroundColor (void)
return util::Color();
else
return util::Color(
mpSlideSorter->GetController().GetProperties()->GetBackgroundColor().GetColor());
mpSlideSorter->GetProperties()->GetBackgroundColor().GetColor());
}
@ -510,8 +510,7 @@ void SAL_CALL SlideSorterService::setBackgroundColor (util::Color aBackgroundCol
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetBackgroundColor(
Color(aBackgroundColor));
mpSlideSorter->GetProperties()->SetBackgroundColor(Color(aBackgroundColor));
}
@ -525,7 +524,7 @@ util::Color SAL_CALL SlideSorterService::getTextColor (void)
return util::Color();
else
return util::Color(
mpSlideSorter->GetController().GetProperties()->GetTextColor().GetColor());
mpSlideSorter->GetProperties()->GetTextColor().GetColor());
}
@ -536,8 +535,7 @@ void SAL_CALL SlideSorterService::setTextColor (util::Color aTextColor)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetTextColor(
Color(aTextColor));
mpSlideSorter->GetProperties()->SetTextColor(Color(aTextColor));
}
@ -551,7 +549,7 @@ util::Color SAL_CALL SlideSorterService::getSelectionColor (void)
return util::Color();
else
return util::Color(
mpSlideSorter->GetController().GetProperties()->GetSelectionColor().GetColor());
mpSlideSorter->GetProperties()->GetSelectionColor().GetColor());
}
@ -562,8 +560,7 @@ void SAL_CALL SlideSorterService::setSelectionColor (util::Color aSelectionColor
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetSelectionColor(
Color(aSelectionColor));
mpSlideSorter->GetProperties()->SetSelectionColor(Color(aSelectionColor));
}
@ -577,7 +574,7 @@ util::Color SAL_CALL SlideSorterService::getHighlightColor (void)
return util::Color();
else
return util::Color(
mpSlideSorter->GetController().GetProperties()->GetHighlightColor().GetColor());
mpSlideSorter->GetProperties()->GetHighlightColor().GetColor());
}
@ -588,8 +585,7 @@ void SAL_CALL SlideSorterService::setHighlightColor (util::Color aHighlightColor
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetHighlightColor(
Color(aHighlightColor));
mpSlideSorter->GetProperties()->SetHighlightColor(Color(aHighlightColor));
}
@ -601,7 +597,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsUIReadOnly (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return true;
else
return mpSlideSorter->GetController().GetProperties()->IsUIReadOnly();
return mpSlideSorter->GetProperties()->IsUIReadOnly();
}
@ -612,8 +608,7 @@ void SAL_CALL SlideSorterService::setIsUIReadOnly (sal_Bool bIsUIReadOnly)
{
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetController().GetProperties()->SetUIReadOnly(
bIsUIReadOnly);
mpSlideSorter->GetProperties()->SetUIReadOnly(bIsUIReadOnly);
}

View File

@ -191,8 +191,8 @@ void SlideSorterViewShell::Initialize (void)
// the new view shell. (One is created earlier while the construtor
// of the base class is executed. At that time the correct
// accessibility object can not be constructed.)
::Window* pWindow = mpSlideSorter->GetActiveWindow();
if (pWindow != NULL)
::boost::shared_ptr<sd::Window> pWindow (mpSlideSorter->GetContentWindow());
if (pWindow)
{
pWindow->Hide();
pWindow->Show();
@ -641,10 +641,7 @@ void SlideSorterViewShell::SetZoom (long int )
void SlideSorterViewShell::SetZoomRect (const Rectangle& rZoomRect)
{
OSL_ASSERT(mpSlideSorter.get()!=NULL);
Size aPageSize (mpSlideSorter->GetView().GetPageBoundingBox(
0,
view::SlideSorterView::CS_MODEL,
view::SlideSorterView::BBT_SHAPE).GetSize());
Size aPageSize (mpSlideSorter->GetView().GetLayouter().GetPageObjectSize());
Rectangle aRect(rZoomRect);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: CondFormat.hrc,v $
* $Revision: 1.4 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_ICONS_HRC
#define SD_SLIDESORTER_ICONS_HRC
#include "glob.hrc"
#define IMG_ICONS RID_SLIDESORTER_ICONS
#define IMAGE_INSERTION_INDICATOR_NORMAL 1
#define IMAGE_INSERTION_INDICATOR_MASK 2
#define IMAGE_INSERTION_INDICATOR_SELECT 3
#define IMAGE_PRESENTATION 4
#define IMAGE_SHOW_SLIDE 5
#define IMAGE_NEW_SLIDE 6
#endif

View File

@ -0,0 +1,51 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_ICONS_HXX
#define SD_SLIDESORTER_ICONS_HXX
#include "SlsIcons.hrc"
#include "sdresid.hxx"
#include <tools/rc.hxx>
namespace sd { namespace slidesorter { namespace view {
class LocalResource : public Resource
{
public:
LocalResource (const sal_uInt16 nResourceId) : Resource(SdResId(nResourceId)){}
~LocalResource (void) { FreeResource(); }
};
} } } // end of namespace ::sd::slidesorter::view
#endif

View File

@ -0,0 +1,65 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: CondFormat.src,v $
* $Revision: 1.6 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "SlsIcons.hrc"
Resource IMG_ICONS
{
Image IMAGE_INSERTION_INDICATOR_NORMAL
{
ImageBitmap = Bitmap { File = "moving_50.png" ; };
};
Image IMAGE_INSERTION_INDICATOR_MASK
{
ImageBitmap = Bitmap { File = "moving_50_mask.png" ; };
};
Image IMAGE_INSERTION_INDICATOR_SELECT
{
ImageBitmap = Bitmap { File = "moving_50_select.png" ; };
};
Image IMAGE_PRESENTATION
{
ImageBitmap = Bitmap { File = "commandimagelist/lc_presentation.png" ; };
};
Image IMAGE_SHOW_SLIDE
{
ImageBitmap = Bitmap { File = "commandimagelist/lc_showslide.png" ; };
};
Image IMAGE_NEW_SLIDE
{
ImageBitmap = Bitmap { File = "commandimagelist/lc_insertpage.png" ; };
};
};

View File

@ -0,0 +1,465 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_sd.hxx"
#include "view/SlsInsertAnimator.hxx"
#include "controller/SlideSorterController.hxx"
#include "controller/SlsAnimationFunction.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsLayouter.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include <set>
#include <boost/bind.hpp>
namespace sd { namespace slidesorter { namespace view {
namespace {
class PageObjectRun;
class AnimatorAccess
{
public:
virtual void RemoveRun (PageObjectRun* pRun) = 0;
virtual model::SlideSorterModel& GetModel (void) const = 0;
virtual view::SlideSorterView& GetView (void) const = 0;
virtual ::boost::shared_ptr<controller::Animator> GetAnimator (void) = 0;
};
/** Controller of the position offsets of all page objects in one row or one
column.
*/
class PageObjectRun
{
public:
PageObjectRun (
AnimatorAccess& rAnimatorAccess,
const sal_Int32 nRunIndex,
const sal_Int32 nStartIndex,
const sal_Int32 nEndIndex);
~PageObjectRun (void);
void operator () (const double nTime);
void UpdateOffsets(
const sal_Int32 nInsertIndex,
const Point& rLeadingOffset,
const Point& rTrailingOffset);
/// Index of the row or column that this run represents.
sal_Int32 mnRunIndex;
/// The index at which to make place for the insertion indicator (-1 for
/// no indicator).
sal_Int32 mnInsertIndex;
/// Index of the first page in the run.
sal_Int32 mnStartIndex;
/// Index of the last page in the run.
sal_Int32 mnEndIndex;
/// Offset of each item in the run at the start of the current animation.
::std::vector<Point> maStartOffset;
/// Target offset of each item in the run at the end of the current animation.
::std::vector<Point> maEndOffset;
/// Time at which the current animation started.
double mnStartTime;
class Comparator
{
public: bool operator() (
const ::boost::shared_ptr<PageObjectRun>& rpRunA,
const ::boost::shared_ptr<PageObjectRun>& rpRunB) const
{
return rpRunA->mnRunIndex < rpRunB->mnRunIndex;
}
};
private:
controller::Animator::AnimationId mnAnimationId;
AnimatorAccess& mrAnimatorAccess;
::boost::function<double(double)> maAccelerationFunction;
void RestartAnimation (void);
};
typedef ::boost::shared_ptr<PageObjectRun> SharedPageObjectRun;
Point Blend (const Point& rPointA, const Point& rPointB, const double nT)
{
return Point(
sal_Int32(rPointA.X() * (1-nT) + rPointB.X() * nT),
sal_Int32(rPointA.Y() * (1-nT) + rPointB.Y() * nT));
}
} // end of anonymous namespace
class InsertAnimator::Implementation : public AnimatorAccess
{
public:
Implementation (SlideSorter& rSlideSorter);
virtual ~Implementation (void);
void SetInsertPosition (
const sal_Int32 nPageIndex,
const bool bInsertBefore);
void Reset (void);
virtual void RemoveRun (PageObjectRun* pRun);
virtual model::SlideSorterModel& GetModel (void) const { return mrModel; }
virtual view::SlideSorterView& GetView (void) const { return mrView; }
virtual ::boost::shared_ptr<controller::Animator> GetAnimator (void) { return mpAnimator; }
private:
model::SlideSorterModel& mrModel;
view::SlideSorterView& mrView;
::boost::shared_ptr<controller::Animator> mpAnimator;
typedef ::std::set<SharedPageObjectRun, PageObjectRun::Comparator> RunContainer;
RunContainer maRuns;
/// The current insertion index. The special value -1 means that there
/// is no current insertion index.
sal_Int32 mnCurrentInsertPosition;
bool mbCurrentInsertBefore;
void StopAnimation (void);
SharedPageObjectRun GetRun (
view::Layouter& rLayouter,
const sal_Int32 nPageIndex,
const bool bInsertBefore,
const bool bCreate = true);
RunContainer::iterator FindRun (const sal_Int32 nRunIndex) const;
};
//===== InsertAnimator ========================================================
InsertAnimator::InsertAnimator (SlideSorter& rSlideSorter)
: mpImplementation(new Implementation(rSlideSorter))
{
}
void InsertAnimator::SetInsertPosition (
const sal_Int32 nPageIndex,
const bool bInsertBefore)
{
mpImplementation->SetInsertPosition(nPageIndex, bInsertBefore);
}
void InsertAnimator::Reset (void)
{
mpImplementation->Reset();
}
//===== InsertAnimator::Implementation ========================================
InsertAnimator::Implementation::Implementation (SlideSorter& rSlideSorter)
: mrModel(rSlideSorter.GetModel()),
mrView(rSlideSorter.GetView()),
mpAnimator(rSlideSorter.GetController().GetAnimator()),
maRuns(),
mnCurrentInsertPosition(-1),
mbCurrentInsertBefore(false)
{
}
InsertAnimator::Implementation::~Implementation (void)
{
Reset();
}
void InsertAnimator::Implementation::SetInsertPosition (
const sal_Int32 nPageIndex,
const bool bInsertBefore)
{
if (nPageIndex==mnCurrentInsertPosition && bInsertBefore==mbCurrentInsertBefore)
return;
SharedPageObjectRun pOldRun (
GetRun(mrView.GetLayouter(), mnCurrentInsertPosition, mbCurrentInsertBefore));
SharedPageObjectRun pCurrentRun (
GetRun(mrView.GetLayouter(), nPageIndex, bInsertBefore));
mnCurrentInsertPosition = nPageIndex;
mbCurrentInsertBefore = bInsertBefore;
// When the new insert position is in a different run then move the page
// objects in the old run to their default positions.
if (pOldRun != pCurrentRun)
{
if (pOldRun)
{
pOldRun->UpdateOffsets(-1, Point(0,0), Point(0,0));
maRuns.insert(pOldRun);
}
}
if (pCurrentRun)
{
const sal_Int32 nColumnCount (mrView.GetLayouter().GetColumnCount());
pCurrentRun->UpdateOffsets(
mnCurrentInsertPosition,
nColumnCount > 1 ? Point(-20,0) : Point(0,-20),
nColumnCount > 1 ? Point(+20,0) : Point(0,+20));
maRuns.insert(pCurrentRun);
}
}
void InsertAnimator::Implementation::Reset (void)
{
SetInsertPosition(-1, false);
}
SharedPageObjectRun InsertAnimator::Implementation::GetRun (
view::Layouter& rLayouter,
const sal_Int32 nPageIndex,
const bool bInsertBefore,
const bool bCreate)
{
if (nPageIndex < 0)
return SharedPageObjectRun();
RunContainer::iterator iRun (maRuns.end());
if (rLayouter.GetColumnCount() == 1)
{
// There is only one run that contains all slides.
if (maRuns.empty() && bCreate)
maRuns.insert(SharedPageObjectRun(new PageObjectRun(
*this,
0,
0,
mrModel.GetPageCount()-1)));
iRun = maRuns.begin();
}
else
{
// Look up the row that contains the insert position (take into
// acount the flag that states whether the indicator is to place
// before or after the page object at that position.)
int nIndex (nPageIndex);
if ( ! bInsertBefore && nPageIndex > 0)
--nIndex;
const sal_Int32 nRow (rLayouter.GetRow(nIndex));
iRun = FindRun(nRow);
if (iRun == maRuns.end() && bCreate)
{
// Create a new run.
const sal_Int32 nStartIndex (rLayouter.GetIndex(nRow,0));
const sal_Int32 nEndIndex (rLayouter.GetIndex(nRow, rLayouter.GetColumnCount()-1));
if (nStartIndex <= nEndIndex)
{
iRun = maRuns.insert(SharedPageObjectRun(new PageObjectRun(
*this,
nRow,
nStartIndex,
nEndIndex))).first;
OSL_ASSERT(iRun != maRuns.end());
}
}
}
if (iRun != maRuns.end())
return *iRun;
else
return SharedPageObjectRun();
}
InsertAnimator::Implementation::RunContainer::iterator
InsertAnimator::Implementation::FindRun (const sal_Int32 nRunIndex) const
{
return std::find_if(
maRuns.begin(),
maRuns.end(),
::boost::bind(
::std::equal_to<sal_Int32>(),
::boost::bind(&PageObjectRun::mnRunIndex, _1),
nRunIndex));
}
void InsertAnimator::Implementation::RemoveRun (PageObjectRun* pRun)
{
if (pRun != NULL)
{
// Do not remove runs that show the space for the insertion indicator.
if (pRun->mnInsertIndex == -1)
maRuns.erase(FindRun(pRun->mnRunIndex));
}
else
{
OSL_ASSERT(pRun!=NULL);
}
}
//===== PageObjectRun =========================================================
PageObjectRun::PageObjectRun (
AnimatorAccess& rAnimatorAccess,
const sal_Int32 nRunIndex,
const sal_Int32 nStartIndex,
const sal_Int32 nEndIndex)
: mnRunIndex(nRunIndex),
mnInsertIndex(-1),
mnStartIndex(nStartIndex),
mnEndIndex(nEndIndex),
maStartOffset(),
maEndOffset(),
mnStartTime(-1),
mnAnimationId(controller::Animator::NotAnAnimationId),
mrAnimatorAccess(rAnimatorAccess),
maAccelerationFunction(
controller::AnimationParametricFunction(
controller::AnimationBezierFunction (0.1,0.6)))
{
maStartOffset.resize(nEndIndex - nStartIndex + 1);
maEndOffset.resize(nEndIndex - nStartIndex + 1);
}
PageObjectRun::~PageObjectRun (void)
{
}
void PageObjectRun::UpdateOffsets(
const sal_Int32 nInsertIndex,
const Point& rLeadingOffset,
const Point& rTrailingOffset)
{
if (nInsertIndex != mnInsertIndex)
{
mnInsertIndex = nInsertIndex;
model::SlideSorterModel& rModel (mrAnimatorAccess.GetModel());
for (sal_Int32 nIndex=mnStartIndex; nIndex<=mnEndIndex; ++nIndex)
{
model::SharedPageDescriptor pDescriptor (rModel.GetPageDescriptor(nIndex));
if (pDescriptor)
maStartOffset[nIndex-mnStartIndex] = pDescriptor->GetVisualState().GetLocationOffset();
maEndOffset[nIndex-mnStartIndex] = nIndex < nInsertIndex
? rLeadingOffset
: rTrailingOffset;
}
RestartAnimation();
}
}
void PageObjectRun::RestartAnimation (void)
{
// Stop the current animation.
if (mnAnimationId != controller::Animator::NotAnAnimationId)
{
mrAnimatorAccess.GetAnimator()->RemoveAnimation(mnAnimationId);
}
// Restart the animation.
mnAnimationId = mrAnimatorAccess.GetAnimator()->AddAnimation(
::boost::ref(*this),
300,
::boost::bind(&AnimatorAccess::RemoveRun, ::boost::ref(mrAnimatorAccess), this));
}
void PageObjectRun::operator () (const double nGlobalTime)
{
if (mnStartTime < 0)
mnStartTime = nGlobalTime;
double nLocalTime (nGlobalTime - mnStartTime);
if (nLocalTime > 1.0)
nLocalTime = 1.0;
nLocalTime = maAccelerationFunction(nLocalTime);
model::SlideSorterModel& rModel (mrAnimatorAccess.GetModel());
view::SlideSorterView& rView (mrAnimatorAccess.GetView());
for (sal_Int32 nIndex=mnStartIndex; nIndex<=mnEndIndex; ++nIndex)
{
model::SharedPageDescriptor pDescriptor (rModel.GetPageDescriptor(nIndex));
const Rectangle aOldBoundingBox (pDescriptor->GetBoundingBox());
pDescriptor->GetVisualState().SetLocationOffset(
Blend(
maStartOffset[nIndex-mnStartIndex],
maEndOffset[nIndex-mnStartIndex],
nLocalTime));
rView.RequestRepaint(aOldBoundingBox);
rView.RequestRepaint(pDescriptor);
}
}
} } } // end of namespace ::sd::slidesorter::view

View File

@ -0,0 +1,478 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_sd.hxx"
#include "SlsLayeredDevice.hxx"
#include <vcl/window.hxx>
#include <vcl/virdev.hxx>
#include <boost/bind.hpp>
#include <boost/function.hpp>
namespace sd { namespace slidesorter { namespace view {
namespace {
static const sal_Int32 gnMaximumLayerCount = 8;
class LayerInvalidator : public ILayerInvalidator
{
public:
LayerInvalidator (
const ::boost::shared_ptr<LayeredDevice>& rpLayeredDevice,
const ::boost::shared_ptr< ::Window>& rpTargetWindow,
const int nLayer)
: mpLayeredDevice(rpLayeredDevice),
mpTargetWindow(rpTargetWindow),
mnLayer(nLayer)
{
}
virtual void Invalidate (const Rectangle& rInvalidationBox)
{
mpLayeredDevice->Invalidate(rInvalidationBox, mnLayer);
mpTargetWindow->Invalidate(rInvalidationBox);
}
private:
const ::boost::shared_ptr<LayeredDevice> mpLayeredDevice;
const ::boost::shared_ptr< ::Window> mpTargetWindow;
const int mnLayer;
};
void DeviceCopy (
OutputDevice& rTargetDevice,
OutputDevice& rSourceDevice,
const Rectangle& rBox)
{
rTargetDevice.DrawOutDev(
rBox.TopLeft(),
rBox.GetSize(),
rBox.TopLeft(),
rBox.GetSize(),
rSourceDevice);
}
void ForAllRectangles (const Region& rRegion, ::boost::function<void(const Rectangle&)> aFunction)
{
OSL_ASSERT(aFunction);
if (rRegion.GetRectCount() <= 1)
{
aFunction(rRegion.GetBoundRect());
}
else
{
Region aMutableRegionCopy (rRegion);
RegionHandle aHandle(aMutableRegionCopy.BeginEnumRects());
Rectangle aBox;
while (aMutableRegionCopy.GetNextEnumRect(aHandle, aBox))
aFunction(aBox);
aMutableRegionCopy.EndEnumRects(aHandle);
}
}
} // end of anonymous namespace
LayeredDevice::LayeredDevice (const ::boost::shared_ptr< ::Window>& rpTargetWindow)
: mpTargetWindow(rpTargetWindow),
maLayers(1),
mpBackBuffer(new VirtualDevice(*mpTargetWindow)),
maSavedMapMode(rpTargetWindow->GetMapMode())
{
mpBackBuffer->SetOutputSizePixel(mpTargetWindow->GetSizePixel());
}
LayeredDevice::~LayeredDevice (void)
{
}
void LayeredDevice::Invalidate (
const Rectangle& rInvalidationArea,
const sal_Int32 nLayer)
{
if (nLayer<0 || nLayer>=maLayers.size())
{
OSL_ASSERT(nLayer>=0 && nLayer<maLayers.size());
return;
}
maLayers[nLayer].Invalidate(rInvalidationArea);
}
void LayeredDevice::InvalidateAllLayers (const Rectangle& rInvalidationArea)
{
for (sal_Int32 nLayer=0; nLayer<maLayers.size(); ++nLayer)
maLayers[nLayer].Invalidate(rInvalidationArea);
}
void LayeredDevice::RegisterPainter (
const SharedILayerPainter& rpPainter,
const sal_Int32 nLayer)
{
if ( ! rpPainter)
{
OSL_ASSERT(rpPainter);
return;
}
if (nLayer<0 || nLayer>=gnMaximumLayerCount)
{
OSL_ASSERT(nLayer>=0 && nLayer<gnMaximumLayerCount);
return;
}
if (nLayer >= maLayers.size())
maLayers.resize(nLayer+1);
maLayers[nLayer].AddPainter(rpPainter);
if (nLayer == 0)
maLayers[nLayer].Initialize(mpTargetWindow);
rpPainter->SetLayerInvalidator(
SharedILayerInvalidator(new LayerInvalidator(shared_from_this(),mpTargetWindow,nLayer)));
}
void LayeredDevice::RemovePainter (
const SharedILayerPainter& rpPainter,
const sal_Int32 nLayer)
{
if ( ! rpPainter)
{
OSL_ASSERT(rpPainter);
return;
}
if (nLayer<0 || nLayer>=maLayers.size())
{
OSL_ASSERT(nLayer>=0 && nLayer<maLayers.size());
return;
}
rpPainter->SetLayerInvalidator(SharedILayerInvalidator());
maLayers[nLayer].RemovePainter(rpPainter);
// Remove top most layers that do not contain any painters.
while ( ! maLayers.empty() && ! maLayers.back().HasPainter())
maLayers.erase(maLayers.end()-1);
}
bool LayeredDevice::HasPainter (const sal_Int32 nLayer)
{
return maLayers.size()>nLayer && maLayers[nLayer].HasPainter();
}
void LayeredDevice::Repaint (const Region& rRepaintRegion)
{
HandleMapModeChange();
// Validate the contents of all layers (that have their own devices.)
::std::for_each(
maLayers.begin(),
maLayers.end(),
::boost::bind(&Layer::Validate, _1, mpTargetWindow->GetMapMode()));
ForAllRectangles(rRepaintRegion, ::boost::bind(&LayeredDevice::RepaintRectangle, this, _1));
}
void LayeredDevice::RepaintRectangle (const Rectangle& rRepaintRectangle)
{
if (maLayers.size() <= 1)
{
// Just copy the main layer into the target device.
maLayers[0].Repaint(*mpTargetWindow, rRepaintRectangle);
}
else
{
// Paint all layers first into the back buffer (to avoid flickering
// due to synchronous paints) and then copy that into the target
// device.
mpBackBuffer->SetMapMode(mpTargetWindow->GetMapMode());
::std::for_each(
maLayers.begin(),
maLayers.end(),
::boost::bind(&Layer::Repaint, _1, ::boost::ref(*mpBackBuffer), rRepaintRectangle));
DeviceCopy(*mpTargetWindow, *mpBackBuffer, rRepaintRectangle);
}
}
void LayeredDevice::Resize (void)
{
const Size aSize (mpTargetWindow->GetSizePixel());
mpBackBuffer->SetOutputSizePixel(aSize);
::std::for_each(maLayers.begin(), maLayers.end(), ::boost::bind(&Layer::Resize, _1, aSize));
}
void LayeredDevice::Dispose (void)
{
::std::for_each(maLayers.begin(), maLayers.end(), ::boost::bind(&Layer::Dispose, _1));
maLayers.clear();
}
void LayeredDevice::HandleMapModeChange (void)
{
const MapMode& rMapMode (mpTargetWindow->GetMapMode());
if (maSavedMapMode == rMapMode)
return;
const Rectangle aLogicWindowBox (
mpTargetWindow->PixelToLogic(Rectangle(Point(0,0), mpTargetWindow->GetSizePixel())));
if (maSavedMapMode.GetScaleX() != rMapMode.GetScaleX()
|| maSavedMapMode.GetScaleY() != rMapMode.GetScaleY()
|| maSavedMapMode.GetMapUnit() != rMapMode.GetMapUnit())
{
// When the scale has changed then we have to paint everything.
::std::for_each(
maLayers.begin(),
maLayers.end(),
::boost::bind(&Layer::Invalidate, _1, ::boost::cref(aLogicWindowBox)));
}
else if (maSavedMapMode.GetOrigin() != rMapMode.GetOrigin())
{
// Window has been scrolled. Adapt contents of backbuffers and
// layer devices.
const Point aDelta (rMapMode.GetOrigin() - maSavedMapMode.GetOrigin());
mpBackBuffer->CopyArea(
aLogicWindowBox.TopLeft(),
mpTargetWindow->PixelToLogic(Point(0,0), maSavedMapMode),
aLogicWindowBox.GetSize());
InvalidateAllLayers(aLogicWindowBox);
/*
const Rectangle aWindowBox (Point(0,0), mpTargetWindow->GetSizePixel());
if (aDelta.X < 0)
Invalidate(
mpTargetWindow->PixelToLogic(
aWindowBox.TopRight(),
Point(mpTargetWindow->GetSizePixel().Right()X+aDelta.X,0)),
mpTargetWindow->PixelToLogic(
Point(mpTargetWindow->GetSizePixel().X+aDelta.X,0)),
*/
}
else
{
// Can this happen? Lets trigger a warning when it does.
OSL_ASSERT(false);
}
maSavedMapMode = rMapMode;
}
//===== LayeredDevice::Layer ==================================================
LayeredDevice::Layer::Layer (void)
: mpLayerDevice(),
maPainters(),
maInvalidationRegion()
{
}
void LayeredDevice::Layer::Initialize (const ::boost::shared_ptr< ::Window>& rpTargetWindow)
{
if ( ! mpLayerDevice)
{
mpLayerDevice.reset(new VirtualDevice(*rpTargetWindow));
mpLayerDevice->SetOutputSizePixel(rpTargetWindow->GetSizePixel());
}
}
void LayeredDevice::Layer::Invalidate (const Rectangle& rInvalidationBox)
{
maInvalidationRegion.Union(rInvalidationBox);
}
void LayeredDevice::Layer::Validate (const MapMode& rMapMode)
{
if (mpLayerDevice && ! maInvalidationRegion.IsEmpty())
{
mpLayerDevice->SetMapMode(rMapMode);
ForAllRectangles(
maInvalidationRegion,
::boost::bind(&LayeredDevice::Layer::ValidateRectangle, this, _1));
}
// else nothing to do now. The painting is done in Repaint() directly
// into the back buffer.
maInvalidationRegion.SetEmpty();
}
void LayeredDevice::Layer::ValidateRectangle (const Rectangle& rBox)
{
const Region aSavedClipRegion (mpLayerDevice->GetClipRegion());
mpLayerDevice->SetClipRegion(Region(rBox));
for (::std::vector<SharedILayerPainter>::const_iterator
iPainter(maPainters.begin()),
iEnd(maPainters.end());
iPainter!=iEnd;
++iPainter)
{
(*iPainter)->Paint(*mpLayerDevice, rBox);
}
mpLayerDevice->SetClipRegion(aSavedClipRegion);
}
void LayeredDevice::Layer::Repaint (
OutputDevice& rTargetDevice,
const Rectangle& rRepaintRectangle)
{
if (mpLayerDevice)
{
DeviceCopy(rTargetDevice, *mpLayerDevice, rRepaintRectangle);
}
else
{
::std::for_each(
maPainters.begin(),
maPainters.end(),
::boost::bind(&ILayerPainter::Paint,
_1,
::boost::ref(rTargetDevice),
rRepaintRectangle));
}
}
void LayeredDevice::Layer::Resize (const Size& rSize)
{
if (mpLayerDevice)
{
mpLayerDevice->SetOutputSizePixel(rSize);
maInvalidationRegion.Union(Rectangle(Point(0,0), rSize));
}
}
void LayeredDevice::Layer::AddPainter (const SharedILayerPainter& rpPainter)
{
OSL_ASSERT(::std::find(maPainters.begin(), maPainters.end(), rpPainter) == maPainters.end());
maPainters.push_back(rpPainter);
}
void LayeredDevice::Layer::RemovePainter (const SharedILayerPainter& rpPainter)
{
const ::std::vector<SharedILayerPainter>::iterator iPainter (
::std::find(maPainters.begin(), maPainters.end(), rpPainter));
if (iPainter != maPainters.end())
{
maPainters.erase(iPainter);
}
else
{
DBG_ASSERT(false,"LayeredDevice::RemovePainter called for painter that is not registered");
}
}
bool LayeredDevice::Layer::HasPainter (void) const
{
return !maPainters.empty();
}
void LayeredDevice::Layer::Dispose (void)
{
maPainters.clear();
}
} } } // end of namespace ::sd::slidesorter::view

View File

@ -0,0 +1,118 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SD_SLIDESORTER_VIEW_LAYERED_DEVICE_HXX
#define SD_SLIDESORTER_VIEW_LAYERED_DEVICE_HXX
#include "view/SlsILayerPainter.hxx"
#include <tools/gen.hxx>
#include <vcl/region.hxx>
#include <vcl/virdev.hxx>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <vector>
class Window;
namespace sd { namespace slidesorter { namespace view {
class LayeredDevice
: public ::boost::enable_shared_from_this<LayeredDevice>
{
public:
LayeredDevice (const ::boost::shared_ptr< ::Window>& rpTargetWindow);
~LayeredDevice (void);
void Invalidate (
const Rectangle& rInvalidationBox,
const sal_Int32 nLayer);
void InvalidateAllLayers (
const Rectangle& rInvalidationBox);
void RegisterPainter (
const SharedILayerPainter& rPainter,
const sal_Int32 nLayer);
void RemovePainter (
const SharedILayerPainter& rPainter,
const sal_Int32 nLayer);
bool HasPainter (const sal_Int32 nLayer);
void Repaint (const Region& rRepaintRegion);
void Resize (void);
void Dispose (void);
class Layer
{
public:
Layer (void);
void Initialize (const ::boost::shared_ptr< ::Window>& rpTargetWindow);
void Invalidate (const Rectangle& rInvalidationBox);
void Validate (const MapMode& rMapMode);
void Repaint (
OutputDevice& rTargetDevice,
const Rectangle& rRepaintRectangle);
void Resize (const Size& rSize);
void AddPainter (const SharedILayerPainter& rpPainter);
void RemovePainter (const SharedILayerPainter& rpPainter);
bool HasPainter (void) const;
void Dispose (void);
private:
::boost::shared_ptr<VirtualDevice> mpLayerDevice;
::std::vector<SharedILayerPainter> maPainters;
Region maInvalidationRegion;
void ValidateRectangle (const Rectangle& rBox);
};
private:
const ::boost::shared_ptr< ::Window> mpTargetWindow;
::std::vector<Layer> maLayers;
::boost::scoped_ptr<VirtualDevice> mpBackBuffer;
MapMode maSavedMapMode;
void RepaintRectangle (const Rectangle& rRepaintRectangle);
void HandleMapModeChange (void);
};
} } } // end of namespace ::sd::slidesorter::view
#endif

View File

@ -32,37 +32,33 @@
#include "view/SlsLayouter.hxx"
#include <vcl/outdev.hxx>
#include <rtl/math.hxx>
#include "Window.hxx"
#include <basegfx/numeric/ftools.hxx>
namespace sd { namespace slidesorter { namespace view {
Layouter::Layouter (void)
: mnRequestedLeftBorder(10),
mnRequestedRightBorder(10),
Layouter::Layouter (const ::boost::shared_ptr< ::Window>& rpWindow)
: mpWindow(rpWindow),
mnRequestedLeftBorder(35),
mnRequestedRightBorder(35),
mnRequestedTopBorder(10),
mnRequestedBottomBorder(10),
mnLeftBorder(10),
mnRightBorder(10),
mnLeftBorder(30),
mnRightBorder(30),
mnTopBorder(10),
mnBottomBorder(10),
mnLeftPageBorder(0),
mnRightPageBorder(0),
mnTopPageBorder(0),
mnBottomPageBorder(0),
mnVerticalGap (20),
mnHorizontalGap (20),
mnInsertionMarkerThickness (4),
mnTotalVerticalGap(0),
mnTotalHorizontalGap(0),
mnMinimalWidth (100),
mnPreferredWidth (200),
mnMaximalWidth (300),
mnMinimalColumnCount (1),
mnMaximalColumnCount (5),
mnColumnCount (1),
maPageObjectModelSize (1,1),
maPageObjectPixelSize (1,1)
mnPageCount(0),
mnColumnCount(1),
mnRowCount(0),
maPageObjectSize(1,1)
{
}
@ -74,6 +70,16 @@ Layouter::~Layouter (void)
}
::boost::shared_ptr<PageObjectLayouter> Layouter::GetPageObjectLayouter (void) const
{
return mpPageObjectLayouter;
}
void Layouter::SetObjectWidth (
sal_Int32 nMinimalWidth,
sal_Int32 nMaximalWidth,
@ -97,32 +103,13 @@ void Layouter::SetBorders (
sal_Int32 nBottomBorder)
{
if (nLeftBorder >= 0)
mnRequestedLeftBorder.mnScreen = nLeftBorder;
mnRequestedLeftBorder = nLeftBorder;
if (nRightBorder >= 0)
mnRequestedRightBorder.mnScreen = nRightBorder;
mnRequestedRightBorder = nRightBorder;
if (nTopBorder >= 0)
mnRequestedTopBorder.mnScreen = nTopBorder;
mnRequestedTopBorder = nTopBorder;
if (nBottomBorder >= 0)
mnRequestedBottomBorder.mnScreen = nBottomBorder;
}
void Layouter::SetPageBorders (
sal_Int32 nLeftBorder,
sal_Int32 nRightBorder,
sal_Int32 nTopBorder,
sal_Int32 nBottomBorder)
{
if (nLeftBorder >= 0)
mnLeftPageBorder.mnScreen = nLeftBorder;
if (nRightBorder >= 0)
mnRightPageBorder.mnScreen = nRightBorder;
if (nTopBorder >= 0)
mnTopPageBorder.mnScreen = nTopBorder;
if (nBottomBorder >= 0)
mnBottomPageBorder.mnScreen = nBottomBorder;
mnRequestedBottomBorder = nBottomBorder;
}
@ -133,9 +120,9 @@ void Layouter::SetGaps (
sal_Int32 nVerticalGap)
{
if (nHorizontalGap >= 0)
mnHorizontalGap.mnScreen = nHorizontalGap;
mnHorizontalGap = nHorizontalGap;
if (nVerticalGap >= 0)
mnVerticalGap.mnScreen = nVerticalGap;
mnVerticalGap = nVerticalGap;
}
@ -158,45 +145,42 @@ void Layouter::SetColumnCount (
bool Layouter::RearrangeHorizontal (
const Size& rWindowSize,
const Size& rPageObjectSize,
OutputDevice* pDevice,
const Size& rPageSize,
const sal_uInt32 nPageCount)
{
OSL_ASSERT(mpWindow);
mnPageCount = nPageCount;
if (rWindowSize.Width() > 0
&& rWindowSize.Height() > 0
&& rPageObjectSize.Width() > 0
&& rPageObjectSize.Height() > 0)
&& rPageSize.Width() > 0
&& rPageSize.Height() > 0)
{
mnTotalHorizontalGap.mnScreen = mnHorizontalGap.mnScreen
+ mnRightPageBorder.mnScreen + mnLeftPageBorder.mnScreen;
mnTotalVerticalGap.mnScreen = mnVerticalGap.mnScreen
+ mnTopPageBorder.mnScreen + mnBottomPageBorder.mnScreen;
// Calculate the column count.
mnColumnCount = nPageCount;
mnRowCount = 1;
// Update the border values. The insertion marker has to have space.
mnLeftBorder.mnScreen = mnRequestedLeftBorder.mnScreen;
mnTopBorder.mnScreen = mnRequestedTopBorder.mnScreen;
mnRightBorder.mnScreen = mnRequestedRightBorder.mnScreen;
mnBottomBorder.mnScreen = mnRequestedBottomBorder.mnScreen;
// Update the border values.
mnLeftBorder = mnRequestedLeftBorder;
mnTopBorder = mnRequestedTopBorder;
mnRightBorder = mnRequestedRightBorder;
mnBottomBorder = mnRequestedBottomBorder;
if (mnColumnCount > 1)
{
int nMinimumBorderWidth = mnInsertionMarkerThickness.mnScreen
+ mnHorizontalGap.mnScreen/2;
if (mnLeftBorder.mnScreen < nMinimumBorderWidth)
mnLeftBorder.mnScreen = nMinimumBorderWidth;
if (mnRightBorder.mnScreen < nMinimumBorderWidth)
mnRightBorder.mnScreen = nMinimumBorderWidth;
int nMinimumBorderWidth = mnHorizontalGap/2;
if (mnLeftBorder < nMinimumBorderWidth)
mnLeftBorder = nMinimumBorderWidth;
if (mnRightBorder < nMinimumBorderWidth)
mnRightBorder = nMinimumBorderWidth;
}
else
{
int nMinimumBorderHeight = mnInsertionMarkerThickness.mnScreen
+ mnVerticalGap.mnScreen/2;
if (mnTopBorder.mnScreen < nMinimumBorderHeight)
mnTopBorder.mnScreen = nMinimumBorderHeight;
if (mnBottomBorder.mnScreen < nMinimumBorderHeight)
mnBottomBorder.mnScreen = nMinimumBorderHeight;
int nMinimumBorderHeight = mnVerticalGap/2;
if (mnTopBorder < nMinimumBorderHeight)
mnTopBorder = nMinimumBorderHeight;
if (mnBottomBorder < nMinimumBorderHeight)
mnBottomBorder = nMinimumBorderHeight;
}
// Calculate the width of each page object.
@ -204,40 +188,26 @@ bool Layouter::RearrangeHorizontal (
sal_uInt32 nRowCount = 1;
if (mnColumnCount > 0)
nTargetHeight = (rWindowSize.Height()
- mnTopBorder.mnScreen
- mnBottomBorder.mnScreen
- nRowCount * (mnTopPageBorder.mnScreen
+ mnBottomPageBorder.mnScreen)
- (nRowCount-1) * mnTotalVerticalGap.mnScreen
- mnTopBorder
- mnBottomBorder
- (nRowCount-1) * mnVerticalGap
)
/ nRowCount;
sal_uInt32 nMinimalHeight (
mnMinimalWidth * rPageObjectSize.Height() / rPageObjectSize.Width());
sal_uInt32 nMaximalHeight (
mnMaximalWidth * rPageObjectSize.Height() / rPageObjectSize.Width());
sal_uInt32 nMinimalHeight (mnMinimalWidth * rPageSize.Height() / rPageSize.Width());
sal_uInt32 nMaximalHeight (mnMaximalWidth * rPageSize.Height() / rPageSize.Width());
if (nTargetHeight < nMinimalHeight)
nTargetHeight = nMinimalHeight;
if (nTargetHeight > nMaximalHeight)
nTargetHeight = nMaximalHeight;
// Initialize the device with some arbitrary zoom factor just in
// case that the current zoom factor is numerically instable when
// used in a multiplication.
MapMode aMapMode (pDevice->GetMapMode());
aMapMode.SetScaleX (Fraction(1,1));
aMapMode.SetScaleY (Fraction(1,1));
pDevice->SetMapMode (aMapMode);
// Calculate the resulting scale factor and the page object size in
// pixels.
maPageObjectModelSize = rPageObjectSize;
int nPagePixelHeight (pDevice->LogicToPixel(maPageObjectModelSize).Height());
// Adapt the layout of the given output device to the new layout of
// page objects. The zoom factor is set so that the page objects in
// one column fill the screen.
Fraction aScaleFactor (nTargetHeight, nPagePixelHeight);
SetZoom (aMapMode.GetScaleX() * aScaleFactor, pDevice);
// Setup the page object layouter and ask it for the page object size.
mpPageObjectLayouter.reset(
new PageObjectLayouter(
Size(0, nTargetHeight),
rPageSize,
mpWindow,
nPageCount));
maPageObjectSize = mpPageObjectLayouter->GetPageObjectSize();
return true;
}
@ -250,86 +220,71 @@ bool Layouter::RearrangeHorizontal (
bool Layouter::RearrangeVertical (
const Size& rWindowSize,
const Size& rPageObjectSize,
OutputDevice* pDevice)
const Size& rPreviewModelSize,
const sal_uInt32 nPageCount)
{
OSL_ASSERT(mpWindow);
mnPageCount = nPageCount;
if (rWindowSize.Width() > 0
&& rWindowSize.Height() > 0
&& rPageObjectSize.Width() > 0
&& rPageObjectSize.Height() > 0)
&& rPreviewModelSize.Width() > 0
&& rPreviewModelSize.Height() > 0)
{
mnTotalHorizontalGap.mnScreen = mnHorizontalGap.mnScreen
+ mnRightPageBorder.mnScreen + mnLeftPageBorder.mnScreen;
mnTotalVerticalGap.mnScreen = mnVerticalGap.mnScreen
+ mnTopPageBorder.mnScreen + mnBottomPageBorder.mnScreen;
// Calculate the column count.
mnColumnCount = (rWindowSize.Width()
- mnRequestedLeftBorder.mnScreen - mnRequestedRightBorder.mnScreen)
/ (mnPreferredWidth + mnTotalHorizontalGap.mnScreen);
mnColumnCount = (rWindowSize.Width() - mnRequestedLeftBorder - mnRequestedRightBorder)
/ (mnPreferredWidth + mnHorizontalGap);
if (mnColumnCount < mnMinimalColumnCount)
mnColumnCount = mnMinimalColumnCount;
if (mnColumnCount > mnMaximalColumnCount)
mnColumnCount = mnMaximalColumnCount;
mnRowCount = (nPageCount + mnColumnCount-1)/mnColumnCount;
// Update the border values. The insertion marker has to have space.
mnLeftBorder.mnScreen = mnRequestedLeftBorder.mnScreen;
mnTopBorder.mnScreen = mnRequestedTopBorder.mnScreen;
mnRightBorder.mnScreen = mnRequestedRightBorder.mnScreen;
mnBottomBorder.mnScreen = mnRequestedBottomBorder.mnScreen;
// Update the border values.
mnLeftBorder = mnRequestedLeftBorder;
mnTopBorder = mnRequestedTopBorder;
mnRightBorder = mnRequestedRightBorder;
mnBottomBorder = mnRequestedBottomBorder;
if (mnColumnCount > 1)
{
int nMinimumBorderWidth = mnInsertionMarkerThickness.mnScreen
+ mnHorizontalGap.mnScreen/2;
if (mnLeftBorder.mnScreen < nMinimumBorderWidth)
mnLeftBorder.mnScreen = nMinimumBorderWidth;
if (mnRightBorder.mnScreen < nMinimumBorderWidth)
mnRightBorder.mnScreen = nMinimumBorderWidth;
int nMinimumBorderWidth = mnHorizontalGap/2;
if (mnLeftBorder < nMinimumBorderWidth)
mnLeftBorder = nMinimumBorderWidth;
if (mnRightBorder < nMinimumBorderWidth)
mnRightBorder = nMinimumBorderWidth;
}
else
{
int nMinimumBorderHeight = mnInsertionMarkerThickness.mnScreen
+ mnVerticalGap.mnScreen/2;
if (mnTopBorder.mnScreen < nMinimumBorderHeight)
mnTopBorder.mnScreen = nMinimumBorderHeight;
if (mnBottomBorder.mnScreen < nMinimumBorderHeight)
mnBottomBorder.mnScreen = nMinimumBorderHeight;
int nMinimumBorderHeight = mnVerticalGap/2;
if (mnTopBorder < nMinimumBorderHeight)
mnTopBorder = nMinimumBorderHeight;
if (mnBottomBorder < nMinimumBorderHeight)
mnBottomBorder = nMinimumBorderHeight;
}
// Calculate the width of each page object.
sal_Int32 nTargetWidth = 0;
if (mnColumnCount > 0)
nTargetWidth = (rWindowSize.Width()
- mnLeftBorder.mnScreen
- mnRightBorder.mnScreen
- mnColumnCount * (mnRightPageBorder.mnScreen
+ mnLeftPageBorder.mnScreen)
- (mnColumnCount-1) * mnTotalHorizontalGap.mnScreen
- mnLeftBorder
- mnRightBorder
- (mnColumnCount-1) * mnHorizontalGap
)
/ mnColumnCount;
/ mnColumnCount;
if (nTargetWidth < mnMinimalWidth)
nTargetWidth = mnMinimalWidth;
if (nTargetWidth > mnMaximalWidth)
nTargetWidth = mnMaximalWidth;
// Initialize the device with some arbitrary zoom factor just in
// case that the current zoom factor is numerically instable when
// used in a multiplication.
MapMode aMapMode (pDevice->GetMapMode());
aMapMode.SetScaleX (Fraction(1,1));
aMapMode.SetScaleY (Fraction(1,1));
pDevice->SetMapMode (aMapMode);
// Calculate the resulting scale factor and the page object size in
// pixels.
maPageObjectModelSize = rPageObjectSize;
int nPagePixelWidth (pDevice->LogicToPixel (maPageObjectModelSize).Width());
// Adapt the layout of the given output device to the new layout of
// page objects. The zoom factor is set so that the page objects in
// one row fill the screen.
Fraction aScaleFactor (nTargetWidth, nPagePixelWidth);
SetZoom (aMapMode.GetScaleX() * aScaleFactor, pDevice);
// Setup the page object layouter and ask it for the page object size.
mpPageObjectLayouter.reset(
new PageObjectLayouter(
Size(nTargetWidth, 0),
rPreviewModelSize,
mpWindow,
nPageCount));
maPageObjectSize = mpPageObjectLayouter->GetPageObjectSize();
return true;
}
@ -340,62 +295,23 @@ bool Layouter::RearrangeVertical (
void Layouter::SetZoom (double nZoomFactor, OutputDevice* pDevice)
void Layouter::SetZoom (double nZoomFactor)
{
SetZoom(Fraction(nZoomFactor), pDevice);
SetZoom(Fraction(nZoomFactor));
}
void Layouter::SetZoom (Fraction nZoomFactor, OutputDevice* pDevice)
void Layouter::SetZoom (Fraction nZoomFactor)
{
MapMode aMapMode (pDevice->GetMapMode());
OSL_ASSERT(mpWindow);
MapMode aMapMode (mpWindow->GetMapMode());
aMapMode.SetScaleX (nZoomFactor);
aMapMode.SetScaleY (nZoomFactor);
maPageObjectPixelSize = pDevice->LogicToPixel (maPageObjectModelSize);
pDevice->SetMapMode (aMapMode);
// Transform frequently used values from pixel to model coordinates.
Size aTotalGap (pDevice->PixelToLogic (Size (
mnTotalHorizontalGap.mnScreen,
mnTotalVerticalGap.mnScreen)));
mnTotalHorizontalGap.mnModel = aTotalGap.Width();
mnTotalVerticalGap.mnModel = aTotalGap.Height();
Size aGap (pDevice->PixelToLogic (Size (
mnHorizontalGap.mnScreen,
mnVerticalGap.mnScreen)));
mnHorizontalGap.mnModel = aGap.Width();
mnVerticalGap.mnModel = aGap.Height();
Size aTopLeftBorder (pDevice->PixelToLogic (Size (
mnLeftBorder.mnScreen,
mnTopBorder.mnScreen)));
mnLeftBorder.mnModel = aTopLeftBorder.Width();
mnTopBorder.mnModel = aTopLeftBorder.Height();
Size aBottomRightBorder (pDevice->PixelToLogic (Size (
mnLeftBorder.mnScreen,
mnTopBorder.mnScreen)));
mnRightBorder.mnModel = aBottomRightBorder.Width();
mnBottomBorder.mnModel = aBottomRightBorder.Height();
Size aTopLeftPageBorder (pDevice->PixelToLogic (Size (
mnLeftPageBorder.mnScreen,
mnTopPageBorder.mnScreen)));
mnLeftPageBorder.mnModel = aTopLeftPageBorder.Width();
mnTopPageBorder.mnModel = aTopLeftPageBorder.Height();
Size aBottomRightPageBorder (pDevice->PixelToLogic (Size (
mnRightPageBorder.mnScreen,
mnBottomPageBorder.mnScreen)));
mnRightPageBorder.mnModel = aBottomRightPageBorder.Width();
mnBottomPageBorder.mnModel = aBottomRightPageBorder.Height();
mnInsertionMarkerThickness.mnModel = pDevice->PixelToLogic (
Size(mnInsertionMarkerThickness.mnScreen,0)).Width();
// maPageObjectPixelSize = mpWindow->LogicToPixel (maPageObjectModelSize);
mpWindow->SetMapMode (aMapMode);
}
@ -409,6 +325,40 @@ sal_Int32 Layouter::GetColumnCount (void) const
sal_Int32 Layouter::GetRowCount (void) const
{
return mnRowCount;
}
sal_Int32 Layouter::GetRow (const sal_Int32 nIndex) const
{
return nIndex / mnColumnCount;
}
sal_Int32 Layouter::GetColumn (const sal_Int32 nIndex) const
{
return nIndex % mnColumnCount;
}
sal_Int32 Layouter::GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const
{
const sal_Int32 nIndex (nRow * mnColumnCount + nColumn);
OSL_ASSERT(nIndex>=0);
return ::std::min(nIndex, mnPageCount-1);
}
bool Layouter::IsColumnCountFixed (void) const
{
return mnMinimalColumnCount == mnMaximalColumnCount;
@ -419,53 +369,76 @@ bool Layouter::IsColumnCountFixed (void) const
Size Layouter::GetPageObjectSize (void) const
{
return maPageObjectModelSize;
return maPageObjectSize;
}
Rectangle Layouter::GetPageObjectBox (sal_Int32 nIndex) const
Rectangle Layouter::GetPageObjectBox (
const sal_Int32 nIndex,
const bool bIncludeBorderAndGap) const
{
int nColumn = nIndex % mnColumnCount;
int nRow = nIndex / mnColumnCount;
return Rectangle (
Point (mnLeftBorder.mnModel
+ nColumn * maPageObjectModelSize.Width()
+ mnLeftPageBorder.mnModel
+ (nColumn>0 ? nColumn : 0) * mnTotalHorizontalGap.mnModel,
mnTopBorder.mnModel
+ nRow * maPageObjectModelSize.Height()
+ mnTopPageBorder.mnModel
+ (nRow>0 ? nRow : 0) * mnTotalVerticalGap.mnModel),
maPageObjectModelSize);
Rectangle aBoundingBox(
Point (mnLeftBorder
+ nColumn * maPageObjectSize.Width()
+ (nColumn>0 ? nColumn : 0) * mnHorizontalGap,
mnTopBorder
+ nRow * maPageObjectSize.Height()
+ (nRow>0 ? nRow : 0) * mnVerticalGap),
maPageObjectSize);
if (bIncludeBorderAndGap)
{
const sal_Int32 nRow (GetRow(nIndex));
const sal_Int32 nColumn (GetColumn(nIndex));
if (nColumn == 0)
aBoundingBox.Left() = 0;
else
aBoundingBox.Left() -= mnHorizontalGap/2;
if (nColumn == mnColumnCount-1)
aBoundingBox.Right() += mnRightBorder;
else
aBoundingBox.Right() += mnHorizontalGap/2;
if (nRow == 0)
aBoundingBox.Top() = 0;
else
aBoundingBox.Top() -= mnVerticalGap/2;
if (nRow == mnRowCount-1)
aBoundingBox.Bottom() += mnBottomBorder;
else
aBoundingBox.Bottom() += mnVerticalGap/2;
}
return aBoundingBox;
}
Rectangle Layouter::GetPageBox (sal_Int32 nObjectCount) const
Rectangle Layouter::GetPageBox (const sal_Int32 nObjectCount) const
{
sal_Int32 nCount (nObjectCount);
if (nCount < 0)
nCount = mnPageCount;
sal_Int32 nHorizontalSize = 0;
sal_Int32 nVerticalSize = 0;
if (mnColumnCount > 0)
{
sal_Int32 nRowCount = (nObjectCount+mnColumnCount-1) / mnColumnCount;
sal_Int32 nRowCount = (nCount+mnColumnCount-1) / mnColumnCount;
nHorizontalSize =
mnLeftBorder.mnModel
+ mnRightBorder.mnModel
+ mnColumnCount * maPageObjectModelSize.Width()
+ mnLeftPageBorder.mnModel + mnRightPageBorder.mnModel;
mnLeftBorder
+ mnRightBorder
+ mnColumnCount * maPageObjectSize.Width();
if (mnColumnCount > 1)
nHorizontalSize
+= (mnColumnCount-1) * mnTotalHorizontalGap.mnModel;
nHorizontalSize += (mnColumnCount-1) * mnHorizontalGap;
nVerticalSize =
mnTopBorder.mnModel
+ mnBottomBorder.mnModel
+ nRowCount * maPageObjectModelSize.Height()
+ mnTopPageBorder.mnModel + mnBottomPageBorder.mnModel;
mnTopBorder
+ mnBottomBorder
+ nRowCount * maPageObjectSize.Height();
if (nRowCount > 1)
nVerticalSize += (nRowCount-1) * mnTotalVerticalGap.mnModel;
nVerticalSize += (nRowCount-1) * mnVerticalGap;
}
return Rectangle (
@ -477,55 +450,42 @@ Rectangle Layouter::GetPageBox (sal_Int32 nObjectCount) const
Rectangle Layouter::GetInsertionMarkerBox (
Point Layouter::GetInsertionMarkerLocation (
sal_Int32 nIndex,
bool bVertical,
bool bLeftOrTop) const
{
Rectangle aBox (GetPageObjectBox (nIndex));
Point aLocation = aBox.Center();
if (bVertical)
{
sal_Int32 nHorizontalInsertionMarkerOffset
= (mnHorizontalGap.mnModel-mnInsertionMarkerThickness.mnModel) / 2;
if (bLeftOrTop)
{
// Left.
aBox.Left() -= mnLeftPageBorder.mnModel
+ mnHorizontalGap.mnModel
- nHorizontalInsertionMarkerOffset;
aLocation.setX(aBox.Left() - (mnHorizontalGap+1)/2 - 1);
}
else
{
// Right.
aBox.Left() = aBox.Right()
+ mnRightPageBorder.mnModel
+ nHorizontalInsertionMarkerOffset;
aLocation.setX(aBox.Right() + mnHorizontalGap/2);
}
aBox.Right() = aBox.Left() + mnInsertionMarkerThickness.mnModel;
}
else
{
sal_Int32 nVerticalInsertionMarkerOffset
= (mnVerticalGap.mnModel - mnInsertionMarkerThickness.mnModel) / 2;
if (bLeftOrTop)
{
// Above.
aBox.Top() -= mnTopPageBorder.mnModel
+ mnVerticalGap.mnModel
- nVerticalInsertionMarkerOffset;
aLocation.setY(aBox.Top() - mnVerticalGap/2);
}
else
{
// Below.
aBox.Top() = aBox.Bottom()
+ mnBottomPageBorder.mnModel
+ nVerticalInsertionMarkerOffset;
aLocation.setY(aBox.Bottom() + mnVerticalGap/2);
}
aBox.Bottom() = aBox.Top() + mnInsertionMarkerThickness.mnModel;
}
return aBox;
return aLocation;
}
@ -603,59 +563,6 @@ sal_Int32 Layouter::GetInsertionIndex (
Layouter::DoublePoint
Layouter::ConvertModelToLayouterCoordinates (
const Point& rModelPoint) const
{
sal_Int32 nColumn = GetColumnAtPosition (rModelPoint.X(), true, GM_BOTH);
sal_Int32 nColumnWidth
= maPageObjectModelSize.Width() + mnTotalHorizontalGap.mnModel;
sal_Int32 nDistanceIntoColumn =
rModelPoint.X() - mnLeftBorder.mnModel - mnLeftPageBorder.mnModel
- nColumn * nColumnWidth;
sal_Int32 nRow = GetRowAtPosition (rModelPoint.Y(), true, GM_BOTH);
sal_Int32 nRowHeight
= maPageObjectModelSize.Height() + mnTotalVerticalGap.mnModel;
sal_Int32 nDistanceIntoRow =
rModelPoint.Y() - mnTopBorder.mnModel - mnTopPageBorder.mnModel
- nRow * nRowHeight;
return DoublePoint (
nColumn + double(nDistanceIntoColumn) / double(nColumnWidth),
nRow + double(nDistanceIntoRow) / double(nRowHeight));
}
Point Layouter::ConvertLayouterToModelCoordinates (
const DoublePoint & rLayouterPoint) const
{
sal_Int32 nColumn = (sal_Int32) ::rtl::math::round(rLayouterPoint.first,
0,rtl_math_RoundingMode_Floor);
sal_Int32 nColumnWidth
= maPageObjectModelSize.Width() + mnTotalHorizontalGap.mnModel;
sal_Int32 nDistanceIntoColumn
= (sal_Int32)((rLayouterPoint.first - nColumn) * nColumnWidth);
sal_Int32 nRow = (sal_Int32) ::rtl::math::round(rLayouterPoint.second,
0,rtl_math_RoundingMode_Floor);
sal_Int32 nRowHeight
= maPageObjectModelSize.Height() + mnTotalVerticalGap.mnModel;
sal_Int32 nDistanceIntoRow
= (sal_Int32)((rLayouterPoint.second - nRow) * nRowHeight);
return Point (
mnLeftBorder.mnModel + mnLeftPageBorder.mnModel
+ nColumn * nColumnWidth + nDistanceIntoColumn,
mnTopBorder.mnModel + mnTopPageBorder.mnModel
+ nRow * nRowHeight + nDistanceIntoRow);
}
sal_Int32 Layouter::GetRowAtPosition (
sal_Int32 nYPosition,
bool bIncludeBordersAndGaps,
@ -663,19 +570,16 @@ sal_Int32 Layouter::GetRowAtPosition (
{
sal_Int32 nRow = -1;
const sal_Int32 nY = nYPosition
- mnTopBorder.mnModel - mnTopPageBorder.mnModel;
const sal_Int32 nY = nYPosition - mnTopBorder;
if (nY >= 0)
{
// Vertical distance from one row to the next.
const sal_Int32 nRowOffset (
maPageObjectModelSize.Height() + mnTotalVerticalGap.mnModel);
const sal_Int32 nRowOffset (maPageObjectSize.Height() + mnVerticalGap);
// Calculate row consisting of page objects and gap below.
nRow = nY / nRowOffset;
const sal_Int32 nDistanceIntoGap (
(nY - nRow*nRowOffset) - maPageObjectModelSize.Height());
const sal_Int32 nDistanceIntoGap ((nY - nRow*nRowOffset) - maPageObjectSize.Height());
// When inside the gap below then nYPosition is not over a page
// object.
if (nDistanceIntoGap > 0)
@ -683,8 +587,7 @@ sal_Int32 Layouter::GetRowAtPosition (
nDistanceIntoGap,
eGapMembership,
nRow,
mnBottomPageBorder.mnModel,
mnVerticalGap.mnModel);
mnVerticalGap);
}
else if (bIncludeBordersAndGaps)
{
@ -706,13 +609,11 @@ sal_Int32 Layouter::GetColumnAtPosition (
{
sal_Int32 nColumn = -1;
sal_Int32 nX = nXPosition
- mnLeftBorder.mnModel - mnLeftPageBorder.mnModel;
sal_Int32 nX = nXPosition - mnLeftBorder;
if (nX >= 0)
{
// Horizontal distance from one column to the next.
const sal_Int32 nColumnOffset (
maPageObjectModelSize.Width() + mnTotalHorizontalGap.mnModel);
const sal_Int32 nColumnOffset (maPageObjectSize.Width() + mnHorizontalGap);
// Calculate row consisting of page objects and gap below.
nColumn = nX / nColumnOffset;
@ -721,8 +622,7 @@ sal_Int32 Layouter::GetColumnAtPosition (
else if (nColumn >= mnColumnCount)
nColumn = mnColumnCount-1;
const sal_Int32 nDistanceIntoGap (
(nX - nColumn*nColumnOffset) - maPageObjectModelSize.Width());
const sal_Int32 nDistanceIntoGap ((nX - nColumn*nColumnOffset) - maPageObjectSize.Width());
// When inside the gap at the right then nXPosition is not over a
// page object.
if (nDistanceIntoGap > 0)
@ -730,8 +630,7 @@ sal_Int32 Layouter::GetColumnAtPosition (
nDistanceIntoGap,
eGapMembership,
nColumn,
mnRightPageBorder.mnModel,
mnHorizontalGap.mnModel);
mnHorizontalGap);
}
else if (bIncludeBordersAndGaps)
{
@ -750,7 +649,6 @@ sal_Int32 Layouter::ResolvePositionInGap (
sal_Int32 nDistanceIntoGap,
GapMembership eGapMembership,
sal_Int32 nIndex,
sal_Int32 nLeftOrTopPageBorder,
sal_Int32 nGap) const
{
switch (eGapMembership)
@ -763,7 +661,7 @@ sal_Int32 Layouter::ResolvePositionInGap (
case GM_BOTH:
{
// The lower half of the gap belongs to the next row or column.
sal_Int32 nFirstHalfGapWidth = nLeftOrTopPageBorder + nGap / 2;
sal_Int32 nFirstHalfGapWidth = nGap / 2;
if (nDistanceIntoGap > nFirstHalfGapWidth)
nIndex ++;
break;
@ -779,9 +677,9 @@ sal_Int32 Layouter::ResolvePositionInGap (
break;
case GM_PAGE_BORDER:
if (nDistanceIntoGap > nLeftOrTopPageBorder)
if (nDistanceIntoGap > 0)
{
if (nDistanceIntoGap > nLeftOrTopPageBorder + nGap)
if (nDistanceIntoGap > nGap)
{
// Inside the border of the next row or column.
nIndex ++;
@ -804,13 +702,4 @@ sal_Int32 Layouter::ResolvePositionInGap (
const Layouter::BackgroundRectangleList&
Layouter::GetBackgroundRectangleList (void) const
{
return maBackgroundRectangleList;
}
} } } // end of namespace ::sd::slidesorter::namespace

View File

@ -0,0 +1,327 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SlsViewCacheContext.hxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "view/SlsPageObjectLayouter.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlsFontProvider.hxx"
#include "tools/IconCache.hxx"
#include "Window.hxx"
#include "res_bmp.hrc"
namespace sd { namespace slidesorter { namespace view {
const sal_Int32 PageObjectLayouter::mnSelectionIndicatorOffset = 0;
const sal_Int32 PageObjectLayouter::mnSelectionIndicatorThickness = 3;
const sal_Int32 PageObjectLayouter::mnFocusIndicatorOffset = 3;
const sal_Int32 PageObjectLayouter::mnPageNumberOffset = 9;
const sal_Int32 PageObjectLayouter::mnOuterBorderWidth = 5;
const Size PageObjectLayouter::maButtonSize (32,32);
const sal_Int32 PageObjectLayouter::mnButtonGap (5);
PageObjectLayouter::PageObjectLayouter (
const Size& rPageObjectWindowSize,
const Size& rPageSize,
const ::boost::shared_ptr< ::Window>& rpWindow,
const int nPageCount)
: mpWindow(rpWindow),
maPageObjectSize(rPageObjectWindowSize.Width(), rPageObjectWindowSize.Height()),
mnModelToWindowScale(1),
maPageObjectBoundingBox(),
maPageNumberAreaBoundingBox(),
maPreviewBoundingBox(),
maFocusIndicatorBoundingBox(),
maSelectionIndicatorBoundingBox(),
maTransitionEffectBoundingBox(),
maButtonAreaBoundingBox(),
maTransitionEffectIcon(IconCache::Instance().GetIcon(BMP_FADE_EFFECT_INDICATOR))
{
const Size aPageNumberAreaSize (GetPageNumberAreaSize(nPageCount));
const int nMaximumBorderWidth (mnSelectionIndicatorOffset + mnOuterBorderWidth);
maPageNumberAreaBoundingBox = Rectangle(
mnPageNumberOffset,
nMaximumBorderWidth,
mnPageNumberOffset + aPageNumberAreaSize.Width(),
nMaximumBorderWidth + aPageNumberAreaSize.Height());
maPreviewBoundingBox = CalculatePreviewBoundingBox(
maPageObjectSize,
Size(rPageSize.Width(), rPageSize.Height()),
aPageNumberAreaSize);
maPageObjectBoundingBox = Rectangle(Point(0,0), maPageObjectSize);
maFocusIndicatorBoundingBox = maPreviewBoundingBox;
maFocusIndicatorBoundingBox.Left() -= mnFocusIndicatorOffset;
maFocusIndicatorBoundingBox.Top() -= mnFocusIndicatorOffset;
maFocusIndicatorBoundingBox.Right() += mnFocusIndicatorOffset;
maFocusIndicatorBoundingBox.Bottom() += mnFocusIndicatorOffset;
maSelectionIndicatorBoundingBox = maPreviewBoundingBox;
maSelectionIndicatorBoundingBox.Left() -= mnSelectionIndicatorOffset;
maSelectionIndicatorBoundingBox.Top() -= mnSelectionIndicatorOffset;
maSelectionIndicatorBoundingBox.Right() += mnSelectionIndicatorOffset;
maSelectionIndicatorBoundingBox.Bottom() += mnSelectionIndicatorOffset;
const Size aIconSize (maTransitionEffectIcon.GetSizePixel());
const int nLeft (maPreviewBoundingBox.Left()
- mnPageNumberOffset - aIconSize.Width() - nMaximumBorderWidth);
const int nTop (maPreviewBoundingBox.Bottom() - aIconSize.Height());
maTransitionEffectBoundingBox = Rectangle(
nLeft,
nTop,
nLeft + aIconSize.Width(),
nTop + aIconSize.Height());
maButtonAreaBoundingBox = Rectangle(
0,
maPageObjectBoundingBox.Bottom() - maButtonSize.Height() - mnButtonGap,
maPageObjectBoundingBox.Right() - mnButtonGap,
maPageObjectBoundingBox.Bottom() - mnButtonGap);
}
Rectangle PageObjectLayouter::CalculatePreviewBoundingBox (
Size& rPageObjectSize,
const Size& rPageSize,
const Size& rPageNumberAreaSize)
{
const int nMaximumBorderWidth (mnSelectionIndicatorOffset + mnOuterBorderWidth);
const int nLeftAreaWidth (
2*mnPageNumberOffset
+ ::std::max(
rPageNumberAreaSize.Width(),
maTransitionEffectIcon.GetSizePixel().Width()));
int nPreviewWidth;
int nPreviewHeight;
const double nPageAspectRatio (double(rPageSize.Width()) / double(rPageSize.Height()));
if (rPageObjectSize.Height() == 0)
{
// Calculate height so that the preview fills the available
// horizontal space completely while observing the aspect ratio of
// the preview.
nPreviewWidth = rPageObjectSize.Width() - nLeftAreaWidth - 2*nMaximumBorderWidth - 1;
nPreviewHeight = ::basegfx::fround(nPreviewWidth / nPageAspectRatio);
rPageObjectSize.setHeight(nPreviewHeight + 2*nMaximumBorderWidth + 1);
}
else if (rPageObjectSize.Width() == 0)
{
// Calculate the width of the page object so that the preview fills
// the available vertical space completely while observing the
// aspect ratio of the preview.
nPreviewHeight = rPageObjectSize.Height() - 2*nMaximumBorderWidth - 1;
nPreviewWidth = ::basegfx::fround(nPreviewHeight * nPageAspectRatio);
rPageObjectSize.setWidth(nPreviewWidth + nLeftAreaWidth + 2*nMaximumBorderWidth + 1);
}
else
{
// The size of the page object is given. Calculate the size of the
// preview.
nPreviewWidth = rPageObjectSize.Width() - nLeftAreaWidth - 2*nMaximumBorderWidth - 1;
nPreviewHeight = rPageObjectSize.Height() - 2*nMaximumBorderWidth - 1;
if (double(nPreviewWidth)/double(nPreviewHeight) > nPageAspectRatio)
nPreviewWidth = ::basegfx::fround(nPreviewHeight * nPageAspectRatio);
else
nPreviewHeight = ::basegfx::fround(nPreviewWidth / nPageAspectRatio);
}
// When the preview does not fill the available space completely then
// place it flush right and vertically centered.
const int nLeft (rPageObjectSize.Width() - nMaximumBorderWidth - nPreviewWidth - 1);
const int nTop (nMaximumBorderWidth
+ (rPageObjectSize.Height() - 2*nMaximumBorderWidth - nPreviewHeight)/2);
return Rectangle(
nLeft,
nTop,
nLeft + nPreviewWidth,
nTop + nPreviewHeight);
}
Rectangle PageObjectLayouter::GetBoundingBox (
const model::SharedPageDescriptor& rpPageDescriptor,
const Part ePart,
const CoordinateSystem eCoordinateSystem,
const sal_Int32 nIndex)
{
if ( ! rpPageDescriptor)
{
OSL_ASSERT(rpPageDescriptor);
return Rectangle();
}
Rectangle aBoundingBox;
switch (ePart)
{
case PageObject:
case MouseOverIndicator:
aBoundingBox = maPageObjectBoundingBox;
break;
case Preview:
aBoundingBox = maPreviewBoundingBox;
break;
case FocusIndicator:
aBoundingBox = maFocusIndicatorBoundingBox;
break;
case SelectionIndicator:
aBoundingBox = maSelectionIndicatorBoundingBox;
break;
case PageNumber:
aBoundingBox = maPageNumberAreaBoundingBox;
break;
case Name:
aBoundingBox = maPageNumberAreaBoundingBox;
break;
case TransitionEffectIndicator:
aBoundingBox = maTransitionEffectBoundingBox;
break;
case ButtonArea:
aBoundingBox = maButtonAreaBoundingBox;
break;
case Button:
aBoundingBox = Rectangle(
maPageObjectBoundingBox.BottomRight()
- Point(
(nIndex+1)*(maButtonSize.Width() + mnButtonGap),
maButtonSize.Height() + mnButtonGap),
maButtonSize);
break;
}
Point aLocation (rpPageDescriptor->GetLocation());
if (eCoordinateSystem == ScreenCoordinateSystem)
aLocation += mpWindow->GetMapMode().GetOrigin();
return Rectangle(
aBoundingBox.TopLeft() + aLocation,
aBoundingBox.BottomRight() + aLocation);
return aBoundingBox;
}
Size PageObjectLayouter::GetPageObjectSize (void) const
{
return maPageObjectSize;
}
Size PageObjectLayouter::GetPreviewSize (void) const
{
return maPreviewBoundingBox.GetSize();
}
Size PageObjectLayouter::GetPageNumberAreaSize (const int nPageCount)
{
OSL_ASSERT(mpWindow);
// Set the correct font.
Font aOriginalFont (mpWindow->GetFont());
mpWindow->SetFont(*FontProvider::Instance().GetFont(*mpWindow));
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.
const Size aSize (
mpWindow->GetTextWidth(sPageNumberTemplate),
mpWindow->GetTextHeight());
mpWindow->SetFont(aOriginalFont);
return aSize;
}
Image PageObjectLayouter::GetTransitionEffectIcon (void) const
{
return maTransitionEffectIcon;
}
sal_Int32 PageObjectLayouter::GetButtonIndexAt (
const model::SharedPageDescriptor& rpPageDescriptor,
const Point& rWindowLocation)
{
if ( ! GetBoundingBox(rpPageDescriptor, ButtonArea, WindowCoordinateSystem)
.IsInside(rWindowLocation))
{
return -1;
}
for (sal_Int32 nIndex=0; nIndex<3; ++nIndex)
{
if (GetBoundingBox(rpPageDescriptor, Button, WindowCoordinateSystem, nIndex)
.IsInside(rWindowLocation))
{
return nIndex;
}
}
return -1;
}
} } } // end of namespace ::sd::slidesorter::view

View File

@ -0,0 +1,457 @@
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: baseprimitive2d.hxx,v $
*
* $Revision: 1.8 $
*
* last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $
*
* 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
*
************************************************************************/
#include "view/SlsPageObjectPainter.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsPageObjectLayouter.hxx"
#include "view/SlsLayouter.hxx"
#include "SlsIcons.hxx"
#include "cache/SlsPageCache.hxx"
#include "controller/SlsProperties.hxx"
#include "Window.hxx"
#include "sdpage.hxx"
#include "sdresid.hxx"
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <vcl/svapp.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/bmpacc.hxx>
using namespace ::drawinglayer::primitive2d;
using namespace ::basegfx;
namespace sd { namespace slidesorter { namespace view {
namespace {
// Reds
#define Amber 0xff7e00
// Greens
#define AndroidGreen 0xa4c639
#define AppleGreen 0x8db600
#define Asparagus 0x87a96b
// Blues
#define Azure 0x000fff
#define DarkCerulean 0x08457e
#define StellaBlue 0x009ee1
#define AirForceBlue 0x5d8aa8
// Off white
#define OldLace 0xfdf5e6
// Off grays
#define Arsenic 0x3b444b
#define MouseOverColor (0x59000000 | StellaBlue)
#define CornerRadius 4.0
UINT8 Blend (
const UINT8 nValue1,
const UINT8 nValue2,
const double nWeight)
{
const double nValue (nValue1*(1-nWeight) + nValue2 * nWeight);
if (nValue < 0)
return 0;
else if (nValue > 255)
return 255;
else
return (UINT8)nValue;
}
sal_uInt8 ClampColorChannel (const double nValue)
{
if (nValue <= 0)
return 0;
else if (nValue >= 255)
return 255;
else
return sal_uInt8(nValue);
}
sal_uInt8 CalculateColorChannel(
const double nColor1,
const double nColor2,
const double nAlpha1,
const double nAlpha2,
const double nAlpha0)
{
if (nAlpha0 == 0)
return 0;
const double nColor0 ((nAlpha1*nColor1 + nAlpha1*nAlpha2*nColor1 + nAlpha2*nColor2) / nAlpha0);
return ClampColorChannel(255 * nColor0);
}
void AdaptTransparency (AlphaMask& rMask, const double nAlpha)
{
BitmapWriteAccess* pBitmap = rMask.AcquireWriteAccess();
if (pBitmap != NULL)
{
const sal_Int32 nWidth (pBitmap->Width());
const sal_Int32 nHeight (pBitmap->Height());
const BitmapColor aWhite (255,255,255);
for (sal_Int32 nY = 0; nY<nHeight; ++nY)
for (sal_Int32 nX = 0; nX<nWidth; ++nX)
{
const BYTE nValue (255 - pBitmap->GetPixel(nY, nX).GetBlueOrIndex());
const BYTE nNewValue (nValue * (1-nAlpha));
pBitmap->SetPixel(
nY,
nX,
255-nNewValue);
}
}
}
} // end of anonymous namespace
PageObjectPainter::PageObjectPainter (
const SlideSorter& rSlideSorter)
: mrLayouter(rSlideSorter.GetView().GetLayouter()),
mpPageObjectLayouter(),
mpCache(rSlideSorter.GetView().GetPreviewCache()),
mpProperties(rSlideSorter.GetProperties()),
mpFont(),
maStartPresentationIcon(),
maShowSlideIcon(),
maNewSlideIcon()
{
LocalResource aResource (IMG_ICONS);
maStartPresentationIcon = Image(SdResId(IMAGE_PRESENTATION)).GetBitmapEx();
maShowSlideIcon = Image(SdResId(IMAGE_SHOW_SLIDE)).GetBitmapEx();
maNewSlideIcon = Image(SdResId(IMAGE_NEW_SLIDE)).GetBitmapEx();
}
void PageObjectPainter::PaintPageObject (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor)
{
// The page object layouter is quite volatile. It may have been replaced
// since the last call. Update it now.
mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
if ( ! mpPageObjectLayouter)
{
OSL_ASSERT(mpPageObjectLayouter);
return;
}
if ( ! mpFont)
{
mpFont.reset(new Font(rDevice.GetFont()));
mpFont->SetWeight(WEIGHT_BOLD);
}
if (mpFont)
rDevice.SetFont(*mpFont);
PaintBackground(rDevice, rpDescriptor);
PaintPreview(rDevice, rpDescriptor);
PaintPageNumber(rDevice, rpDescriptor);
PaintTransitionEffect(rDevice, rpDescriptor);
PaintButtons(rDevice, rpDescriptor);
// PaintBorder(rDevice, rpDescriptor);
}
void PageObjectPainter::PaintBackground (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::PageObject,
PageObjectLayouter::WindowCoordinateSystem));
rDevice.SetLineColor();
const USHORT nSavedAntialiasingMode (rDevice.GetAntialiasing());
rDevice.SetAntialiasing(nSavedAntialiasingMode | ANTIALIASING_ENABLE_B2DDRAW);
const ColorData nColor (GetColorForVisualState(rpDescriptor));
rDevice.SetFillColor(Color(nColor & 0x00ffffff));
const double nTransparency (COLORDATA_TRANSPARENCY(nColor)/255.0);
rDevice.DrawTransparent(
::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect(
::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right(), aBox.Bottom()),
CornerRadius/aBox.GetWidth(),
CornerRadius/aBox.GetHeight())),
nTransparency);
if (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver))
{
rDevice.SetFillColor(Color(MouseOverColor & 0x00ffffff));
double nTransparency (COLORDATA_TRANSPARENCY(MouseOverColor)/255.0);
nTransparency *= 1-rpDescriptor->GetVisualState().GetVisualStateBlend();
rDevice.DrawTransparent(
::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect(
::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right(), aBox.Bottom()),
CornerRadius/aBox.GetWidth(),
CornerRadius/aBox.GetHeight())),
nTransparency);
}
rDevice.SetAntialiasing(nSavedAntialiasingMode);
}
void PageObjectPainter::PaintPreview (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::Preview,
PageObjectLayouter::WindowCoordinateSystem));
if (mpCache != NULL)
{
const SdrPage* pPage = rpDescriptor->GetPage();
BitmapEx aBitmap (mpCache->GetPreviewBitmap(pPage));
mpCache->SetPreciousFlag(pPage, true);
if (rpDescriptor->GetVisualState().GetCurrentVisualState()
== model::VisualState::VS_Excluded)
{
AlphaMask aMask (aBitmap.GetSizePixel());
aMask.Erase(128);
aBitmap = BitmapEx(aBitmap.GetBitmap(), aMask);
}
rDevice.DrawBitmapEx(aBox.TopLeft(), aBitmap);
}
rDevice.SetLineColor(Color(0,0,0));
rDevice.SetFillColor();
rDevice.DrawRect(aBox);
}
void PageObjectPainter::PaintPageNumber (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::PageNumber,
PageObjectLayouter::WindowCoordinateSystem));
// Paint the page number.
OSL_ASSERT(rpDescriptor->GetPage()!=NULL);
const sal_Int32 nPageNumber ((rpDescriptor->GetPage()->GetPageNum() - 1) / 2 + 1);
const String sPageNumber (String::CreateFromInt32(nPageNumber));
rDevice.SetTextColor(Color(0x0848a8f));
rDevice.DrawText(aBox.TopLeft(), sPageNumber);
if (rpDescriptor->GetVisualState().GetCurrentVisualState()
== model::VisualState::VS_Excluded)
{
// Paint border around the number.
aBox.Left()-= 2;
aBox.Top() -= 1;
aBox.Right() += 2;
aBox.Bottom() += 1;
rDevice.SetLineColor(Color(Azure));
rDevice.SetFillColor();
rDevice.DrawRect(aBox);
rDevice.DrawLine(aBox.TopLeft(), aBox.BottomRight());
}
}
void PageObjectPainter::PaintTransitionEffect (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::TransitionEffectIndicator,
PageObjectLayouter::WindowCoordinateSystem));
rDevice.DrawBitmapEx(
aBox.TopLeft(),
mpPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
}
void PageObjectPainter::PaintButtons (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
if (rpDescriptor->GetVisualState().GetButtonAlpha() >= 1)
return;
const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::Preview,
PageObjectLayouter::WindowCoordinateSystem));
const USHORT nSavedAntialiasingMode (rDevice.GetAntialiasing());
rDevice.SetAntialiasing(nSavedAntialiasingMode | ANTIALIASING_ENABLE_B2DDRAW);
rDevice.SetLineColor(Color(Arsenic));
const double nCornerRadius(3);
for (int nButtonIndex=0; nButtonIndex<3; ++nButtonIndex)
{
Color aButtonFillColor (AirForceBlue);
const Rectangle aBox (
mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::Button,
PageObjectLayouter::WindowCoordinateSystem,
nButtonIndex));
switch (rpDescriptor->GetVisualState().GetButtonState(nButtonIndex))
{
case model::VisualState::BS_Normal:
break;
case model::VisualState::BS_MouseOver:
aButtonFillColor.IncreaseLuminance(50);
break;
case model::VisualState::BS_Pressed:
aButtonFillColor.DecreaseLuminance(50);
break;
}
rDevice.SetFillColor(aButtonFillColor);
rDevice.DrawTransparent(
::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect(
::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right(), aBox.Bottom()),
nCornerRadius/aBox.GetWidth(),
nCornerRadius/aBox.GetHeight())),
rpDescriptor->GetVisualState().GetButtonAlpha());
// Choose icon.
const BitmapEx* pImage = NULL;
switch (nButtonIndex)
{
case 0:
pImage = &maNewSlideIcon;
break;
case 1:
pImage = &maShowSlideIcon;
break;
case 2:
pImage = &maStartPresentationIcon;
break;
}
// Paint icon over the button background.
if (pImage != NULL)
{
AlphaMask aMask (pImage->GetMask());
AdaptTransparency(
aMask,
rpDescriptor->GetVisualState().GetButtonAlpha());
rDevice.DrawImage(
Point(
aBox.Left()+(aBox.GetWidth()-pImage->GetSizePixel().Width())/2,
aBox.Top()+(aBox.GetHeight()-pImage->GetSizePixel().Height())/2),
BitmapEx(pImage->GetBitmap(), aMask));
}
}
rDevice.SetAntialiasing(nSavedAntialiasingMode);
}
ColorData PageObjectPainter::GetColorForVisualState (
const model::SharedPageDescriptor& rpDescriptor) const
{
ColorData nColor;
switch (rpDescriptor->GetVisualState().GetCurrentVisualState())
{
case model::VisualState::VS_Selected:
nColor = 0x80000000 | StellaBlue;
break;
case model::VisualState::VS_Focused:
nColor = AndroidGreen;
break;
case model::VisualState::VS_Current:
nColor = 0x80000000 | StellaBlue;
// aColor = mpProperties->GetSelectionColor();
break;
case model::VisualState::VS_Excluded:
nColor = 0xcc929ca2;
break;
case model::VisualState::VS_None:
default:
nColor = OldLace;//0x80000000 | OldLace;
break;
}
return nColor;
}
} } } // end of namespace sd::slidesorter::view

View File

@ -35,11 +35,11 @@
#include "SlsViewCacheContext.hxx"
#include "SlideSorter.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "view/SlideSorterView.hxx"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "sdpage.hxx"
#include "Window.hxx"
#include "drawdoc.hxx"
@ -52,11 +52,9 @@
namespace sd { namespace slidesorter { namespace view {
ViewCacheContext::ViewCacheContext (
model::SlideSorterModel& rModel,
SlideSorterView& rView)
: mrModel(rModel),
mrView(rView)
ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter)
: mrModel(rSlideSorter.GetModel()),
mrSlideSorter(rSlideSorter)
{
}
@ -78,16 +76,12 @@ void ViewCacheContext::NotifyPreviewCreation (
const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
if (pDescriptor.get() != NULL)
{
// Use direct view-invalidate here and no ActionChanged() at the VC
// since the VC is a PageObjectViewObjectContact and in its ActionChanged()
// implementation invalidates the cache entry again.
view::PageObjectViewObjectContact* pContact = pDescriptor->GetViewObjectContact();
if (pContact != NULL)
pContact->GetObjectContact().InvalidatePartOfView(pContact->getObjectRange());
// Force a repaint that will trigger their re-creation.
mrSlideSorter.GetView().RequestRepaint(pDescriptor);
}
else
{
OSL_ASSERT(pDescriptor.get() != NULL);
OSL_ASSERT(pDescriptor);
}
}
@ -96,7 +90,7 @@ void ViewCacheContext::NotifyPreviewCreation (
bool ViewCacheContext::IsIdle (void)
{
sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrView.GetWindow()));
sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get()));
if (nIdleState == tools::IdleDetection::IDET_IDLE)
return true;
else
@ -108,7 +102,7 @@ bool ViewCacheContext::IsIdle (void)
bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
{
return GetDescriptor(aKey)->IsVisible();
return GetDescriptor(aKey)->HasState(model::PageDescriptor::ST_Visible);
}

View File

@ -39,9 +39,12 @@ namespace sd { namespace slidesorter { namespace model {
class SlideSorterModel;
} } }
namespace sd { namespace slidesorter {
class SlideSorter;
} }
namespace sd { namespace slidesorter { namespace view {
class SlideSorterView;
/** The cache context for the SlideSorter as used by Draw and Impress. See
the base class for documentation of the individual methods.
@ -49,9 +52,7 @@ class SlideSorterView;
class ViewCacheContext : public cache::CacheContext
{
public:
ViewCacheContext (
model::SlideSorterModel& rModel,
SlideSorterView& rView);
ViewCacheContext (SlideSorter& rSlideSorter);
virtual ~ViewCacheContext (void);
virtual void NotifyPreviewCreation (cache::CacheKey aKey, const ::boost::shared_ptr<BitmapEx>& rPreview);
virtual bool IsIdle (void);
@ -63,7 +64,7 @@ public:
private:
model::SlideSorterModel& mrModel;
SlideSorterView& mrView;
SlideSorter& mrSlideSorter;
model::SharedPageDescriptor GetDescriptor (cache::CacheKey aKey);
};

View File

@ -33,29 +33,31 @@
#include "view/SlsViewOverlay.hxx"
#include "SlideSorter.hxx"
#include "SlideSorterViewShell.hxx"
#include "SlsLayeredDevice.hxx"
#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"
#include "view/SlsPageObjectViewObjectContact.hxx"
#include "SlsIcons.hxx"
#include "cache/SlsPageCache.hxx"
#include "ViewShell.hxx"
#include "ViewShellBase.hxx"
#include "UpdateLockManager.hxx"
#include "Window.hxx"
#include "sdpage.hxx"
#include "sdresid.hxx"
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/range/b2irange.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
#include <svx/svdpagv.hxx>
@ -66,21 +68,53 @@
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
using namespace ::sdr::overlay;
using namespace ::basegfx;
#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
namespace {
const static sal_Int32 gnSubstitutionStripeLength (3);
#define AirForceBlue 0x5d8aa8
#define Arsenic 0x3b444b
#define Amber 0x007fff
#define Charcoal 0x36454f
Rectangle GrowRectangle (const Rectangle& rBox, const sal_Int32 nOffset)
{
return Rectangle (
rBox.Left() - nOffset,
rBox.Top() - nOffset,
rBox.Right() + nOffset,
rBox.Bottom() + nOffset);
}
Rectangle ConvertRectangle (const B2DRectangle& rBox)
{
const B2IRange rIntegerBox (unotools::b2ISurroundingRangeFromB2DRange(rBox));
return Rectangle(
rIntegerBox.getMinX(),
rIntegerBox.getMinY(),
rIntegerBox.getMaxX(),
rIntegerBox.getMaxY());
}
} // end of anonymous namespace
namespace sd { namespace slidesorter { namespace view {
//===== ViewOverlay =========================================================
ViewOverlay::ViewOverlay (SlideSorter& rSlideSorter)
ViewOverlay::ViewOverlay (
SlideSorter& rSlideSorter,
const ::boost::shared_ptr<LayeredDevice>& rpLayeredDevice)
: mrSlideSorter(rSlideSorter),
maSelectionRectangleOverlay(*this),
maMouseOverIndicatorOverlay(*this),
maInsertionIndicatorOverlay(*this),
maSubstitutionOverlay(*this)
mpLayeredDevice(rpLayeredDevice),
mpSelectionRectangleOverlay(new SelectionRectangleOverlay(*this, 2)),
mpInsertionIndicatorOverlay(new InsertionIndicatorOverlay(*this, 3)),
mpSubstitutionOverlay(new SubstitutionOverlay(*this, 2))
{
}
@ -94,33 +128,25 @@ ViewOverlay::~ViewOverlay (void)
SelectionRectangleOverlay& ViewOverlay::GetSelectionRectangleOverlay (void)
::boost::shared_ptr<SelectionRectangleOverlay> ViewOverlay::GetSelectionRectangleOverlay (void)
{
return maSelectionRectangleOverlay;
return mpSelectionRectangleOverlay;
}
MouseOverIndicatorOverlay& ViewOverlay::GetMouseOverIndicatorOverlay (void)
::boost::shared_ptr<InsertionIndicatorOverlay> ViewOverlay::GetInsertionIndicatorOverlay (void)
{
return maMouseOverIndicatorOverlay;
return mpInsertionIndicatorOverlay;
}
InsertionIndicatorOverlay& ViewOverlay::GetInsertionIndicatorOverlay (void)
::boost::shared_ptr<SubstitutionOverlay> ViewOverlay::GetSubstitutionOverlay (void)
{
return maInsertionIndicatorOverlay;
}
SubstitutionOverlay& ViewOverlay::GetSubstitutionOverlay (void)
{
return maSubstitutionOverlay;
return mpSubstitutionOverlay;
}
@ -134,32 +160,52 @@ SlideSorter& ViewOverlay::GetSlideSorter (void) const
OverlayManager* ViewOverlay::GetOverlayManager (void) const
::boost::shared_ptr<LayeredDevice> ViewOverlay::GetLayeredDevice (void) const
{
OverlayManager* pOverlayManager = NULL;
return mpLayeredDevice;
}
SlideSorterView& rView (mrSlideSorter.GetView());
SdrPageView* pPageView = rView.GetSdrPageView();
if (pPageView != NULL && pPageView->PageWindowCount()>0)
//===== OverlayBase::Invalidator ==============================================
class OverlayBase::Invalidator
{
public:
Invalidator (OverlayBase& rOverlayObject)
: mrOverlayObject(rOverlayObject),
maOldBoundingBox(rOverlayObject.IsVisible()
? rOverlayObject.GetBoundingBox()
: Rectangle())
{
SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0);
if (pPageWindow != NULL)
pOverlayManager = pPageWindow->GetOverlayManager();
}
return pOverlayManager;
}
~Invalidator (void)
{
if ( ! maOldBoundingBox.IsEmpty())
mrOverlayObject.Invalidate(maOldBoundingBox);
if (mrOverlayObject.IsVisible())
mrOverlayObject.Invalidate(mrOverlayObject.GetBoundingBox());
}
private:
OverlayBase& mrOverlayObject;
const Rectangle maOldBoundingBox;
};
//===== OverlayBase =========================================================
OverlayBase::OverlayBase (ViewOverlay& rViewOverlay)
: OverlayObject(Color(0,0,0)),
mrViewOverlay(rViewOverlay)
OverlayBase::OverlayBase (
ViewOverlay& rViewOverlay,
const sal_Int32 nLayerIndex)
: mrViewOverlay(rViewOverlay),
mbIsVisible(false),
mnLayerIndex(nLayerIndex)
{
setVisible(false);
}
@ -167,30 +213,70 @@ OverlayBase::OverlayBase (ViewOverlay& rViewOverlay)
OverlayBase::~OverlayBase (void)
{
OSL_ENSURE(!getOverlayManager(), "Please call RemoveRegistration() in the derived class; it's too late to call it in the base class since virtual methods will be missing when called in the destructor.");
}
void OverlayBase::EnsureRegistration (void)
bool OverlayBase::IsVisible (void) const
{
if (getOverlayManager() == NULL)
return mbIsVisible;
}
void OverlayBase::SetIsVisible (const bool bIsVisible)
{
if (mbIsVisible != bIsVisible)
{
OverlayManager* pOverlayManager = mrViewOverlay.GetOverlayManager();
if (pOverlayManager != NULL)
pOverlayManager->add(*this);
Invalidator aInvalidator (*this);
mbIsVisible = bIsVisible;
::boost::shared_ptr<LayeredDevice> pDevice (mrViewOverlay.GetLayeredDevice());
if (pDevice)
if (mbIsVisible)
{
pDevice->RegisterPainter(shared_from_this(), GetLayerIndex());
Invalidate(GetBoundingBox());
}
else
{
Invalidate(GetBoundingBox());
pDevice->RemovePainter(shared_from_this(), GetLayerIndex());
}
}
}
void OverlayBase::SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator)
{
if ( ! rpInvalidator)
Invalidate(GetBoundingBox());
mpLayerInvalidator = rpInvalidator;
if (mbIsVisible)
Invalidate(GetBoundingBox());
}
void OverlayBase::RemoveRegistration()
void OverlayBase::Invalidate (const Rectangle& rInvalidationBox)
{
OverlayManager* pOverlayManager = getOverlayManager();
if (pOverlayManager != NULL)
pOverlayManager->remove(*this);
if (mpLayerInvalidator)
mpLayerInvalidator->Invalidate(rInvalidationBox);
}
sal_Int32 OverlayBase::GetLayerIndex (void) const
{
return mnLayerIndex;
}
@ -198,10 +284,18 @@ void OverlayBase::RemoveRegistration()
//===== SubstitutionOverlay =================================================
SubstitutionOverlay::SubstitutionOverlay (ViewOverlay& rViewOverlay)
: OverlayBase(rViewOverlay),
const sal_Int32 SubstitutionOverlay::mnCenterTransparency (60);
const sal_Int32 SubstitutionOverlay::mnSideTransparency (85);
const sal_Int32 SubstitutionOverlay::mnCornerTransparency (95);
SubstitutionOverlay::SubstitutionOverlay (
ViewOverlay& rViewOverlay,
const sal_Int32 nLayerIndex)
: OverlayBase(rViewOverlay, nLayerIndex),
maPosition(0,0),
maShapes()
maTranslation(0,0),
maItems(),
maBoundingBox()
{
}
@ -210,7 +304,6 @@ SubstitutionOverlay::SubstitutionOverlay (ViewOverlay& rViewOverlay)
SubstitutionOverlay::~SubstitutionOverlay (void)
{
RemoveRegistration();
}
@ -218,28 +311,75 @@ SubstitutionOverlay::~SubstitutionOverlay (void)
void SubstitutionOverlay::Create (
model::PageEnumeration& rSelection,
const Point& rPosition)
const Point& rPosition,
const model::SharedPageDescriptor& rpHitDescriptor)
{
EnsureRegistration();
maPosition = rPosition;
maTranslation = Point(0,0);
maShapes.clear();
::boost::shared_ptr<cache::PageCache> pPreviewCache (
mrViewOverlay.GetSlideSorter().GetView().GetPreviewCache());
view::Layouter& rLayouter (mrViewOverlay.GetSlideSorter().GetView().GetLayouter());
::boost::shared_ptr<view::PageObjectLayouter> pPageObjectLayouter (
rLayouter.GetPageObjectLayouter());
const sal_Int32 nRow0 (rpHitDescriptor
? rLayouter.GetRow(rpHitDescriptor->GetPageIndex())
: -1);
const sal_Int32 nColumn0 (rpHitDescriptor
? rLayouter.GetColumn(rpHitDescriptor->GetPageIndex())
: -1);
maItems.clear();
while (rSelection.HasMoreElements())
{
const Rectangle aBox (rSelection.GetNextElement()->GetPageObject()->GetCurrentBoundRect());
model::SharedPageDescriptor pDescriptor (rSelection.GetNextElement());
sal_uInt8 nTransparency (128);
// Calculate distance between current page object and the one under
// the mouse.
if (nRow0>=0 || nColumn0>=0)
{
const sal_Int32 nRow (rLayouter.GetRow(pDescriptor->GetPageIndex()));
const sal_Int32 nColumn (rLayouter.GetColumn(pDescriptor->GetPageIndex()));
const sal_Int32 nRowDistance (abs(nRow - nRow0));
const sal_Int32 nColumnDistance (abs(nColumn - nColumn0));
if (nRowDistance>1 || nColumnDistance>1)
continue;
if (nRowDistance!=0 && nColumnDistance!=0)
nTransparency = 255 * mnCornerTransparency / 100;
else if (nRowDistance!=0 || nColumnDistance!=0)
nTransparency = 255 * mnSideTransparency / 100;
else
nTransparency = 255 * mnCenterTransparency / 100;
}
const Rectangle aBox (pDescriptor->GetBoundingBox());
maBoundingBox.Union(aBox);
basegfx::B2DRectangle aB2DBox(
aBox.Left(),
aBox.Top(),
aBox.Right(),
aBox.Bottom());
maShapes.append(basegfx::tools::createPolygonFromRect(aB2DBox), 4);
const Bitmap aBitmap (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage()).GetBitmap());
AlphaMask aMask (aBitmap.GetSizePixel());
aMask.Erase(nTransparency);
maItems.push_back(ItemDescriptor());
maItems.back().maImage = BitmapEx(
aBitmap,
aMask);
maItems.back().maLocation = pPageObjectLayouter->GetBoundingBox(
pDescriptor,
PageObjectLayouter::Preview,
PageObjectLayouter::WindowCoordinateSystem).TopLeft();
maItems.back().mnTransparency = nTransparency/255.0;
maItems.back().maShape = basegfx::tools::createPolygonFromRect(aB2DBox);
}
setVisible(maShapes.count() > 0);
// The selection indicator may have been visible already so call
// objectChange() to enforce an update.
objectChange();
SetIsVisible(maItems.size() > 0);
}
@ -247,8 +387,8 @@ void SubstitutionOverlay::Create (
void SubstitutionOverlay::Clear (void)
{
maShapes.clear();
setVisible(false);
SetIsVisible(false);
maItems.clear();
}
@ -256,12 +396,11 @@ void SubstitutionOverlay::Clear (void)
void SubstitutionOverlay::Move (const Point& rOffset)
{
const basegfx::B2DHomMatrix aTranslation(basegfx::tools::createTranslateB2DHomMatrix(rOffset.X(), rOffset.Y()));
Invalidator aInvalidator (*this);
maShapes.transform(aTranslation);
maPosition += rOffset;
objectChange();
maTranslation += rOffset;
maBoundingBox.Move(rOffset.X(), rOffset.Y());
}
@ -283,42 +422,51 @@ Point SubstitutionOverlay::GetPosition (void) const
drawinglayer::primitive2d::Primitive2DSequence SubstitutionOverlay::createOverlayObjectPrimitive2DSequence()
void SubstitutionOverlay::Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea)
{
drawinglayer::primitive2d::Primitive2DSequence aRetval;
const sal_uInt32 nCount(maShapes.count());
(void)rRepaintArea;
if(nCount && getOverlayManager())
if ( ! IsVisible())
return;
basegfx::B2DHomMatrix aTranslation;
aTranslation.translate(maTranslation.X(), maTranslation.Y());
rDevice.SetFillColor(Color(AirForceBlue));
rDevice.SetLineColor();
for (::std::vector<ItemDescriptor>::const_iterator
iItem(maItems.begin()),
iEnd(maItems.end());
iItem!=iEnd;
++iItem)
{
aRetval.realloc(nCount);
const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
for(sal_uInt32 a(0); a < nCount; a++)
{
aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
maShapes.getB2DPolygon(a),
aRGBColorA,
aRGBColorB,
gnSubstitutionStripeLength));
}
::basegfx::B2DPolyPolygon aPolygon (iItem->maShape);
aPolygon.transform(aTranslation);
rDevice.DrawTransparent(aPolygon, iItem->mnTransparency);
rDevice.DrawBitmapEx(iItem->maLocation+maTranslation, iItem->maImage);
}
return aRetval;
}
void SubstitutionOverlay::stripeDefinitionHasChanged()
Rectangle SubstitutionOverlay::GetBoundingBox (void) const
{
// react on OverlayManager's stripe definition change
objectChange();
return maBoundingBox;
}
//===== SelectionRectangleOverlay ===========================================
SelectionRectangleOverlay::SelectionRectangleOverlay (ViewOverlay& rViewOverlay)
: OverlayBase (rViewOverlay),
SelectionRectangleOverlay::SelectionRectangleOverlay (
ViewOverlay& rViewOverlay,
const sal_Int32 nLayerIndex)
: OverlayBase (rViewOverlay, nLayerIndex),
maAnchor(0,0),
maSecondCorner(0,0)
{
@ -326,14 +474,6 @@ SelectionRectangleOverlay::SelectionRectangleOverlay (ViewOverlay& rViewOverlay)
SelectionRectangleOverlay::~SelectionRectangleOverlay()
{
RemoveRegistration();
}
Rectangle SelectionRectangleOverlay::GetSelectionRectangle (void)
{
return Rectangle(maAnchor, maSecondCorner);
@ -344,9 +484,9 @@ Rectangle SelectionRectangleOverlay::GetSelectionRectangle (void)
void SelectionRectangleOverlay::Start (const Point& rAnchor)
{
EnsureRegistration();
setVisible(false);
SetIsVisible(false);
maAnchor = rAnchor;
maSecondCorner = rAnchor;
}
@ -354,43 +494,50 @@ void SelectionRectangleOverlay::Start (const Point& rAnchor)
void SelectionRectangleOverlay::Update (const Point& rSecondCorner)
{
Invalidator aInvalidator (*this);
maSecondCorner = rSecondCorner;
setVisible(true);
// The selection rectangle may have been visible already so call
// objectChange() to enforce an update.
objectChange();
SetIsVisible(true);
}
drawinglayer::primitive2d::Primitive2DSequence SelectionRectangleOverlay::createOverlayObjectPrimitive2DSequence()
void SelectionRectangleOverlay::Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea)
{
drawinglayer::primitive2d::Primitive2DSequence aRetval;
const basegfx::B2DRange aRange(maAnchor.X(), maAnchor.Y(), maSecondCorner.X(), maSecondCorner.Y());
const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRange));
if ( ! IsVisible())
return;
if(aPolygon.count())
{
const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
aPolygon,
aRGBColorA,
aRGBColorB,
gnSubstitutionStripeLength));
rDevice.SetFillColor(Color(Amber));
rDevice.SetLineColor(Color(Amber));
aRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
}
return aRetval;
const Rectangle aBox (
::std::min(maAnchor.X(), maSecondCorner.X()),
::std::min(maAnchor.Y(), maSecondCorner.Y()),
::std::max(maAnchor.X(), maSecondCorner.X()),
::std::max(maAnchor.Y(), maSecondCorner.Y()));
rDevice.DrawTransparent(
::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect(
::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right(), aBox.Bottom()),
5.0/aBox.GetWidth(),
5.0/aBox.GetHeight())),
0.5);
}
void SelectionRectangleOverlay::stripeDefinitionHasChanged()
Rectangle SelectionRectangleOverlay::GetBoundingBox (void) const
{
// react on OverlayManager's stripe definition change
objectChange();
return GrowRectangle(Rectangle(
::std::min(maAnchor.X(), maSecondCorner.X()),
::std::min(maAnchor.Y(), maSecondCorner.Y()),
::std::max(maAnchor.X(), maSecondCorner.X()),
::std::max(maAnchor.Y(), maSecondCorner.Y())),
+1);
}
@ -398,208 +545,60 @@ void SelectionRectangleOverlay::stripeDefinitionHasChanged()
//===== InsertionIndicatorOverlay ===========================================
InsertionIndicatorOverlay::InsertionIndicatorOverlay (ViewOverlay& rViewOverlay)
: OverlayBase (rViewOverlay),
mnInsertionIndex(-1),
maBoundingBox()
InsertionIndicatorOverlay::InsertionIndicatorOverlay (
ViewOverlay& rViewOverlay,
const sal_Int32 nLayerIndex)
: OverlayBase (rViewOverlay, nLayerIndex),
maLocation(),
maIconWithBorder(),
maIcon(),
maMask()
{
LocalResource aResource (IMG_ICONS);
maIconWithBorder = Image(SdResId(IMAGE_INSERTION_INDICATOR_SELECT));
maIcon = Image(SdResId(IMAGE_INSERTION_INDICATOR_NORMAL));
maMask = Image(SdResId(IMAGE_INSERTION_INDICATOR_MASK));
}
InsertionIndicatorOverlay::~InsertionIndicatorOverlay()
void InsertionIndicatorOverlay::SetLocation (const Point& rLocation)
{
RemoveRegistration();
}
void InsertionIndicatorOverlay::SetPositionAndSize (const Rectangle& aNewBoundingBox)
{
EnsureRegistration();
maBoundingBox = aNewBoundingBox;
setVisible( ! maBoundingBox.IsEmpty());
// The insertion indicator may have been visible already so call
// objectChange() to enforce an update.
objectChange();
}
void InsertionIndicatorOverlay::SetPosition (const Point& rPoint)
{
static const bool bAllowHorizontalInsertMarker = true;
Layouter& rLayouter (mrViewOverlay.GetSlideSorter().GetView().GetLayouter());
USHORT nPageCount
= (USHORT)mrViewOverlay.GetSlideSorter().GetModel().GetPageCount();
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)
const Point aTopLeft (
rLocation - Point(
maIconWithBorder.GetSizePixel().Width()/2,
maIconWithBorder.GetSizePixel().Height()/2));
if (maLocation != aTopLeft)
{
// 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;
}
drawinglayer::primitive2d::Primitive2DSequence InsertionIndicatorOverlay::createOverlayObjectPrimitive2DSequence()
{
drawinglayer::primitive2d::Primitive2DSequence aRetval(2);
const basegfx::B2DRange aRange(maBoundingBox.Left(), maBoundingBox.Top(), maBoundingBox.Right(), maBoundingBox.Bottom());
const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRange));
const basegfx::BColor aRGBColor(Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetFontColor().getBColor());
aRetval[0] = drawinglayer::primitive2d::Primitive2DReference(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon(aPolygon),
aRGBColor));
aRetval[1] = drawinglayer::primitive2d::Primitive2DReference(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPolygon,
aRGBColor));
return aRetval;
}
//===== MouseOverIndicatorOverlay ===========================================
MouseOverIndicatorOverlay::MouseOverIndicatorOverlay (ViewOverlay& rViewOverlay)
: OverlayBase (rViewOverlay),
mpPageUnderMouse()
{
}
MouseOverIndicatorOverlay::~MouseOverIndicatorOverlay (void)
{
RemoveRegistration();
}
void MouseOverIndicatorOverlay::SetSlideUnderMouse (
const model::SharedPageDescriptor& rpDescriptor)
{
ViewShellBase* pBase = mrViewOverlay.GetSlideSorter().GetViewShellBase();
if (pBase==NULL || ! pBase->GetUpdateLockManager()->IsLocked())
{
model::SharedPageDescriptor pDescriptor;
if ( ! mpPageUnderMouse.expired())
{
try
{
pDescriptor = model::SharedPageDescriptor(mpPageUnderMouse);
}
catch (::boost::bad_weak_ptr)
{
}
}
if (pDescriptor != rpDescriptor)
{
// Switch to the new (possibly empty) descriptor.
mpPageUnderMouse = rpDescriptor;
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();
}
Invalidator aInvalidator (*this);
maLocation = aTopLeft;
}
}
drawinglayer::primitive2d::Primitive2DSequence MouseOverIndicatorOverlay::createOverlayObjectPrimitive2DSequence()
void InsertionIndicatorOverlay::Paint (
OutputDevice& rDevice,
const Rectangle& rRepaintArea)
{
view::PageObjectViewObjectContact* pContact = GetViewObjectContact();
(void)rRepaintArea;
if(pContact)
{
return pContact->createMouseOverEffectPrimitive2DSequence();
}
if ( ! IsVisible())
return;
return drawinglayer::primitive2d::Primitive2DSequence();
rDevice.DrawImage(
maLocation,
maIconWithBorder);
}
view::PageObjectViewObjectContact* MouseOverIndicatorOverlay::GetViewObjectContact (void) const
Rectangle InsertionIndicatorOverlay::GetBoundingBox (void) const
{
if ( ! mpPageUnderMouse.expired())
{
model::SharedPageDescriptor pDescriptor (mpPageUnderMouse);
return pDescriptor->GetViewObjectContact();
}
return NULL;
return Rectangle(maLocation, maIconWithBorder.GetSizePixel());
}

View File

@ -39,6 +39,8 @@ ENABLE_EXCEPTIONS=TRUE
AUTOSEG=true
PRJINC=..$/..
IMGLST_SRS=$(SRS)$/$(TARGET).srs
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
@ -46,19 +48,21 @@ PRJINC=..$/..
# --- Files --------------------------------------------------------
SRS1NAME=$(TARGET)
SRC1FILES = \
SlsIcons.src
SLOFILES = \
$(SLO)$/SlsFontProvider.obj \
$(SLO)$/SlsPageObject.obj \
$(SLO)$/SlsPageObjectViewContact.obj \
$(SLO)$/SlsPageObjectViewObjectContact.obj \
$(SLO)$/SlsLayouter.obj \
$(SLO)$/SlideSorterView.obj \
$(SLO)$/SlsFontProvider.obj \
$(SLO)$/SlsInsertAnimator.obj \
$(SLO)$/SlsLayeredDevice.obj \
$(SLO)$/SlsLayouter.obj \
$(SLO)$/SlsPageObjectLayouter.obj \
$(SLO)$/SlsPageObjectPainter.obj \
$(SLO)$/SlsViewCacheContext.obj \
$(SLO)$/SlsViewOverlay.obj
EXCEPTIONSFILES= \
$(SLO)$/SlsPageObjectViewObjectContact.obj
# --- Tagets -------------------------------------------------------
.INCLUDE : target.mk

View File

@ -45,7 +45,7 @@
#include <hash_map>
#undef VERBOSE
#define VERBOSE 2
//#define VERBOSE 2
namespace sd {

View File

@ -54,6 +54,7 @@ RESLIB1SRSFILES=\
$(SRS)$/notes.srs \
$(SRS)$/animui.srs \
$(SRS)$/slideshow.srs \
$(SRS)$/slsview.srs \
$(SRS)$/uitable.srs \
$(SRS)$/view.srs \
$(SRS)$/uiannotations.srs \