summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sd/inc/glob.hrc2
-rw-r--r--sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx11
-rw-r--r--sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx3
-rw-r--r--sd/source/ui/framework/configuration/ConfigurationUpdater.cxx2
-rw-r--r--sd/source/ui/inc/SlideSorter.hxx16
-rw-r--r--sd/source/ui/presenter/PresenterPreviewCache.cxx6
-rw-r--r--sd/source/ui/slideshow/slideshow.cxx2
-rw-r--r--sd/source/ui/slideshow/slideshowimpl.cxx2
-rw-r--r--sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx8
-rw-r--r--sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx24
-rw-r--r--sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx3
-rw-r--r--sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx44
-rw-r--r--sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx33
-rw-r--r--sd/source/ui/slidesorter/cache/SlsPageCache.cxx25
-rw-r--r--sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx9
-rw-r--r--sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx8
-rw-r--r--sd/source/ui/slidesorter/controller/SlideSorterController.cxx130
-rw-r--r--sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx287
-rw-r--r--sd/source/ui/slidesorter/controller/SlsAnimator.cxx165
-rw-r--r--sd/source/ui/slidesorter/controller/SlsClipboard.cxx46
-rw-r--r--sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx20
-rw-r--r--sd/source/ui/slidesorter/controller/SlsFocusManager.cxx12
-rw-r--r--sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx6
-rw-r--r--sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx255
-rw-r--r--sd/source/ui/slidesorter/controller/SlsListener.cxx32
-rw-r--r--sd/source/ui/slidesorter/controller/SlsPageSelector.cxx16
-rw-r--r--sd/source/ui/slidesorter/controller/SlsProperties.cxx2
-rw-r--r--sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx107
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx1237
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx86
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx2
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSlotManager.cxx163
-rw-r--r--sd/source/ui/slidesorter/controller/makefile.mk10
-rw-r--r--sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx29
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx16
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx178
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx36
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx99
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx16
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx77
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx5
-rw-r--r--sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx27
-rw-r--r--sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx101
-rw-r--r--sd/source/ui/slidesorter/inc/model/SlsVisualState.hxx109
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx153
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsILayerPainter.hxx64
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx64
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx146
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx178
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx90
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx176
-rw-r--r--sd/source/ui/slidesorter/model/SlideSorterModel.cxx102
-rw-r--r--sd/source/ui/slidesorter/model/SlsPageDescriptor.cxx237
-rw-r--r--sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx4
-rw-r--r--sd/source/ui/slidesorter/model/SlsVisualState.cxx236
-rw-r--r--sd/source/ui/slidesorter/model/makefile.mk1
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorter.cxx72
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterService.cxx49
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx9
-rw-r--r--sd/source/ui/slidesorter/view/SlideSorterView.cxx840
-rw-r--r--sd/source/ui/slidesorter/view/SlsIcons.hrc45
-rw-r--r--sd/source/ui/slidesorter/view/SlsIcons.hxx51
-rw-r--r--sd/source/ui/slidesorter/view/SlsIcons.src65
-rw-r--r--sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx465
-rw-r--r--sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx478
-rw-r--r--sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx118
-rw-r--r--sd/source/ui/slidesorter/view/SlsLayouter.cxx533
-rw-r--r--sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx327
-rw-r--r--sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx457
-rw-r--r--sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx24
-rw-r--r--sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx11
-rw-r--r--sd/source/ui/slidesorter/view/SlsViewOverlay.cxx601
-rw-r--r--sd/source/ui/slidesorter/view/makefile.mk18
-rwxr-xr-xsd/source/ui/view/ViewShellManager.cxx2
-rw-r--r--sd/util/makefile.mk1
75 files changed, 6634 insertions, 2450 deletions
diff --git a/sd/inc/glob.hrc b/sd/inc/glob.hrc
index 7ef9ecad779c..2181f2dfeb30 100644
--- a/sd/inc/glob.hrc
+++ b/sd/inc/glob.hrc
@@ -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
+
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
index 2fd6cdb3cd39..41804bc8bdbc 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
@@ -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())
{
diff --git a/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx b/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx
index 918aaacd0bd7..4739bda92151 100644
--- a/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx
+++ b/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx
@@ -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);
}
}
diff --git a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
index e2aab7316937..5721f483595f 100644
--- a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
+++ b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx
@@ -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);
diff --git a/sd/source/ui/inc/SlideSorter.hxx b/sd/source/ui/inc/SlideSorter.hxx
index 06bea31f8ff6..3e2c69232fe3 100644
--- a/sd/source/ui/inc/SlideSorter.hxx
+++ b/sd/source/ui/inc/SlideSorter.hxx
@@ -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,
diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx
index 798e2e3f211f..523097f53247 100644
--- a/sd/source/ui/presenter/PresenterPreviewCache.cxx
+++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx
@@ -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
diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx
index f1cb2cf4afb9..50db60c57e17 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -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())
{
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index e59f45b71e12..972e75a7f486 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -1221,9 +1221,11 @@ void SlideshowImpl::onFirstPaint()
{
if( mpShowWindow )
{
+ /*
mpShowWindow->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
mpShowWindow->Erase();
mpShowWindow->SetBackground();
+ */
}
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
index 283c0e08cf62..fbdd09032a29 100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
@@ -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
{
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
index 915daccecd50..82575d0bce11 100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
@@ -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;
}
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
index 5eca09bbaa8c..51d7d1c60f1b 100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
@@ -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;
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
index 702517029fb6..ba1eb21e9ca6 100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
@@ -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;
}
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
index d11c74c50839..7afa01a9b860 100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
@@ -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.
*/
diff --git a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
index 1f9c7b1ccbd6..0e0b7e2f01c4 100644
--- a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
@@ -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);
}
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
index 09c633424c6d..16c49c48f23f 100644
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
@@ -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,
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
index f7f8a36190cd..53e9eb71f34b 100644
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
@@ -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;
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
index 5303b9dc6426..98d6ca4afee9 100644
--- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
+++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
@@ -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)
diff --git a/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx b/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx
new file mode 100644
index 000000000000..905b28ee5f6b
--- /dev/null
+++ b/sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx
index 9878d7b36a47..d7679d88328e 100644
--- a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx
@@ -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);
}
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 805628396a35..0e5b839a1de9 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -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.
diff --git a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
index 9220532239ab..2f97124d8576 100644
--- a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
@@ -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);
}
}
diff --git a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
index 1077184b7db7..8128752417fe 100644
--- a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
@@ -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);
diff --git a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx b/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx
index 035f6ecd2dd1..d8d42d6bbbe9 100644
--- a/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx
@@ -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);
}
}
diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx
new file mode 100644
index 000000000000..8b9cc659fd54
--- /dev/null
+++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/controller/SlsListener.cxx b/sd/source/ui/slidesorter/controller/SlsListener.cxx
index 9c51643b2b49..b78abb2e5298 100644
--- a/sd/source/ui/slidesorter/controller/SlsListener.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsListener.cxx
@@ -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))
diff --git a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
index 0c69a2b27c11..d715acfec252 100644
--- a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
@@ -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());
}
diff --git a/sd/source/ui/slidesorter/controller/SlsProperties.cxx b/sd/source/ui/slidesorter/controller/SlsProperties.cxx
index 6015c36e9510..829cc1b05368 100644
--- a/sd/source/ui/slidesorter/controller/SlsProperties.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsProperties.cxx
@@ -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()),
diff --git a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
index ed363dc6743e..e874f67ce48e 100644
--- a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
@@ -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;
}
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
index 9ed68156f701..8cb815fd5787 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
@@ -40,6 +40,7 @@
#include "controller/SlsScrollBarManager.hxx"
#include "controller/SlsClipboard.hxx"
#include "controller/SlsCurrentSlideManager.hxx"
+#include "controller/SlsInsertionIndicatorHandler.hxx"
#include "controller/SlsSelectionManager.hxx"
#include "controller/SlsProperties.hxx"
#include "model/SlideSorterModel.hxx"
@@ -48,16 +49,11 @@
#include "view/SlideSorterView.hxx"
#include "view/SlsViewOverlay.hxx"
#include "view/SlsLayouter.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
+#include "view/SlsPageObjectLayouter.hxx"
#include "framework/FrameworkHelper.hxx"
#include "showview.hxx"
#include "ViewShellBase.hxx"
#include "DrawController.hxx"
-#include <vcl/sound.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/dispatch.hxx>
-#include <svx/svdpagv.hxx>
-#include <vcl/msgbox.hxx>
#include "Window.hxx"
#include "sdpage.hxx"
#include "drawdoc.hxx"
@@ -67,6 +63,13 @@
#include "app.hrc"
#include "sdresid.hxx"
#include "strings.hrc"
+#include <vcl/sound.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdpagv.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svxids.hrc>
+#include <boost/bind.hpp>
namespace {
static const sal_uInt32 SINGLE_CLICK (0x00000001);
@@ -77,11 +80,13 @@ static const sal_uInt32 MIDDLE_BUTTON (0x00000040);
static const sal_uInt32 BUTTON_DOWN (0x00000100);
static const sal_uInt32 BUTTON_UP (0x00000200);
static const sal_uInt32 MOUSE_MOTION (0x00000400);
+static const sal_uInt32 MOUSE_DRAG (0x00000800);
// The rest leaves the lower 16 bit untouched so that it can be used with
// key codes.
static const sal_uInt32 OVER_SELECTED_PAGE (0x00010000);
static const sal_uInt32 OVER_UNSELECTED_PAGE (0x00020000);
static const sal_uInt32 OVER_FADE_INDICATOR (0x00040000);
+static const sal_uInt32 OVER_BUTTON (0x00080000);
static const sal_uInt32 SHIFT_MODIFIER (0x00100000);
static const sal_uInt32 CONTROL_MODIFIER (0x00200000);
static const sal_uInt32 SUBSTITUTION_VISIBLE (0x01000000);
@@ -94,6 +99,9 @@ static const sal_uInt32 NO_MODIFIER (0x00000000);
static const sal_uInt32 SUBSTITUTION_NOT_VISIBLE (0x00000000);
static const sal_uInt32 NOT_OVER_PAGE (0x00000000);
+// Masks
+static const sal_uInt32 MODIFIER_MASK (SHIFT_MODIFIER | CONTROL_MODIFIER);
+
} // end of anonymous namespace
@@ -106,6 +114,8 @@ public:
SubstitutionHandler (SlideSorter& rSlideSorter);
~SubstitutionHandler (void);
+ void SetHitDescriptor (const model::SharedPageDescriptor& rpHitDescriptor);
+
/** Create a substitution display of the currently selected pages and
use the given position as the anchor point.
*/
@@ -115,7 +125,9 @@ public:
travelled since the last call to this method or to
CreateSubstitution(). The given point becomes the new anchor.
*/
- void UpdatePosition (const Point& rMouseModelPosition);
+ void UpdatePosition (
+ const Point& rMousePosition,
+ const bool bAllowAutoScroll = true);
/** Move the substitution display of the currently selected pages.
*/
@@ -123,42 +135,50 @@ public:
void End (void);
- bool HasBeenMoved (void) const;
+ bool IsActive (void) const;
private:
SlideSorter& mrSlideSorter;
-
- bool mbHasBeenMoved;
-
- /** Determine whether there is a) a substitution and b) its insertion at
- the current position of the insertion marker would alter the
- document. This would be the case when the substitution has been
- moved or is not consecutive.
- */
- bool IsSubstitutionInsertionNonTrivial (void) const;
+ model::SharedPageDescriptor mpHitDescriptor;
+ bool mbIsActive;
+ sal_Int32 mnInsertionIndex;
};
-class SelectionFunction::InsertionIndicatorHandler
+class SelectionFunction::RectangleSelector
{
public:
- InsertionIndicatorHandler (SlideSorter& rSlideSorter);
- ~InsertionIndicatorHandler (void);
-
- /** Show the insertion marker at the given coordinates.
+ /** Start a rectangle selection at the given position.
*/
- void Start (const Point& rMouseModelPosition);
+ RectangleSelector (
+ SlideSorter& rSlideSorter,
+ const Point& rMouseModelPosition);
+ ~RectangleSelector (void);
- void UpdatePosition (const Point& rMouseModelPosition);
+ void RestoreInitialSelection (void);
- /** Hide the insertion marker.
+ /** Update the rectangle selection so that the given position becomes
+ the new second point of the selection rectangle.
*/
- void End (void);
+ void UpdatePosition (
+ const Point& rMousePosition,
+ const bool bAllowAutoScroll = true);
+
+ enum SelectionMode { SM_Normal, SM_Add, SM_Toggle };
+ void SetSelectionMode (const SelectionMode eSelectionMode);
+ void SetSelectionModeFromModifier (const sal_uInt32 nEventCode);
private:
SlideSorter& mrSlideSorter;
+ SelectionMode meSelectionMode;
+ ::std::set<sal_Int32> maInitialSelection;
+
+ /** Select all pages that lie completly in the selection rectangle.
+ */
+ void ProcessRectangleSelection (void);
};
+
class SelectionFunction::EventDescriptor
{
public:
@@ -168,6 +188,7 @@ public:
::boost::weak_ptr<model::PageDescriptor> mpHitDescriptor;
SdrPage* mpHitPage;
sal_uInt32 mnEventCode;
+ sal_Int32 mnButtonIndex;
EventDescriptor (
sal_uInt32 nEventType,
@@ -176,6 +197,10 @@ public:
EventDescriptor (
const KeyEvent& rEvent,
SlideSorter& rSlideSorter);
+ EventDescriptor (
+ const AcceptDropEvent& rEvent,
+ SlideSorter& rSlideSorter);
+ EventDescriptor (const EventDescriptor& rDescriptor);
};
@@ -185,14 +210,23 @@ TYPEINIT1(SelectionFunction, FuPoor);
SelectionFunction::SelectionFunction (
SlideSorter& rSlideSorter,
SfxRequest& rRequest)
- : SlideFunction (rSlideSorter, rRequest),
+ : FuPoor (
+ rSlideSorter.GetViewShell(),
+ rSlideSorter.GetContentWindow().get(),
+ &rSlideSorter.GetView(),
+ rSlideSorter.GetModel().GetDocument(),
+ rRequest),
mrSlideSorter(rSlideSorter),
mrController(mrSlideSorter.GetController()),
mbDragSelection(false),
maInsertionMarkerBox(),
mbProcessingMouseButtonDown(false),
mpSubstitutionHandler(new SubstitutionHandler(mrSlideSorter)),
- mpInsertionIndicatorHandler(new InsertionIndicatorHandler(mrSlideSorter))
+ mpRectangleSelector(),
+ mnButtonDownPageIndex(-1),
+ mnButtonDownButtonIndex(-1),
+ mbIsDeselectionPending(false),
+ mnShiftKeySelectionAnchor(-1)
{
//af aDelayToScrollTimer.SetTimeout(50);
aDragTimer.SetTimeoutHdl( LINK( this, SelectionFunction, DragSlideHdl ) );
@@ -221,6 +255,7 @@ BOOL SelectionFunction::MouseButtonDown (const MouseEvent& rEvent)
{
// #95491# remember button state for creation of own MouseEvents
SetMouseButtonCode (rEvent.GetButtons());
+ aMDPos = rEvent.GetPosPixel();
mbProcessingMouseButtonDown = true;
mpWindow->CaptureMouse();
@@ -237,16 +272,6 @@ BOOL SelectionFunction::MouseMove (const MouseEvent& rEvent)
{
Point aMousePosition (rEvent.GetPosPixel());
- // Determine page under mouse and show the mouse over effect.
- model::SharedPageDescriptor pHitDescriptor (mrController.GetPageAt(aMousePosition));
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetMouseOverIndicatorOverlay().SetSlideUnderMouse(
- rEvent.IsLeaveWindow() ? model::SharedPageDescriptor() : pHitDescriptor);
- if (pHitDescriptor.get() != NULL)
- rOverlay.GetMouseOverIndicatorOverlay().setVisible(true);
- else
- rOverlay.GetMouseOverIndicatorOverlay().setVisible(false);
-
// Allow one mouse move before the drag timer is disabled.
if (aDragTimer.IsActive())
{
@@ -256,12 +281,26 @@ BOOL SelectionFunction::MouseMove (const MouseEvent& rEvent)
aDragTimer.Stop();
}
+
+ // In some modes (dragging, moving) the mouse over indicator is only
+ // annoying. Turn it off in these cases.
+ if (mrSlideSorter.GetView().GetOverlay().GetSubstitutionOverlay()->IsVisible()
+ || mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay()->IsVisible())
+ {
+ mrSlideSorter.GetView().SetPageUnderMouse(model::SharedPageDescriptor());
+ }
+ else
+ {
+ UpdatePageUnderMouse(aMousePosition, (rEvent.GetButtons() & MOUSE_LEFT)!=0);
+ }
+
+ view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
Rectangle aRectangle (Point(0,0),mpWindow->GetOutputSizePixel());
if ( ! aRectangle.IsInside(aMousePosition)
- && rOverlay.GetSubstitutionOverlay().isVisible())
+ && rOverlay.GetSubstitutionOverlay()->IsVisible())
{
// Mouse left the window with pressed left button. Make it a drag.
- StartDrag();
+ StartDrag(aMousePosition);
}
else
{
@@ -301,6 +340,31 @@ BOOL SelectionFunction::MouseButtonUp (const MouseEvent& rEvent)
+void SelectionFunction::MouseDragged (const AcceptDropEvent& rEvent)
+{
+ // 1. Compute some frequently used values relating to the event.
+ ::std::auto_ptr<EventDescriptor> pEventDescriptor (
+ new EventDescriptor(rEvent, mrSlideSorter));
+
+ // 2. Detect whether we are dragging pages or dragging a selection rectangle.
+ view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
+ if (rOverlay.GetSubstitutionOverlay()->IsVisible())
+ pEventDescriptor->mnEventCode |= SUBSTITUTION_VISIBLE;
+ if (mpRectangleSelector)
+ pEventDescriptor->mnEventCode |= RECTANGLE_VISIBLE;
+
+ // 3. Process the event.
+ EventPreprocessing(*pEventDescriptor);
+ if ( ! EventProcessing(*pEventDescriptor))
+ {
+ OSL_TRACE ("can not handle event code %x", pEventDescriptor->mnEventCode);
+ }
+ EventPostprocessing(*pEventDescriptor);
+}
+
+
+
+
BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
{
FocusManager& rFocusManager (mrController.GetFocusManager());
@@ -334,6 +398,13 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
case KEY_ESCAPE:
rFocusManager.SetFocusToToolBox();
+ if (mpSubstitutionHandler->IsActive())
+ mpSubstitutionHandler->End();
+ if (mpRectangleSelector)
+ {
+ mpRectangleSelector->RestoreInitialSelection();
+ mpRectangleSelector.reset();
+ }
bResult = TRUE;
break;
@@ -345,7 +416,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
{
// Doing a multi selection by default. Can we ask the event
// for the state of the shift key?
- if (pDescriptor->IsSelected())
+ if (pDescriptor->HasState(model::PageDescriptor::ST_Selected))
mrController.GetPageSelector().DeselectPage(pDescriptor);
else
mrController.GetPageSelector().SelectPage(pDescriptor);
@@ -357,25 +428,25 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
// Move the focus indicator left.
case KEY_LEFT:
- rFocusManager.MoveFocus (FocusManager::FMD_LEFT);
+ MoveFocus(FocusManager::FMD_LEFT, rEvent.GetKeyCode().IsShift());
bResult = TRUE;
break;
// Move the focus indicator right.
case KEY_RIGHT:
- rFocusManager.MoveFocus (FocusManager::FMD_RIGHT);
+ MoveFocus(FocusManager::FMD_RIGHT, rEvent.GetKeyCode().IsShift());
bResult = TRUE;
break;
// Move the focus indicator up.
case KEY_UP:
- rFocusManager.MoveFocus (FocusManager::FMD_UP);
+ MoveFocus(FocusManager::FMD_UP, rEvent.GetKeyCode().IsShift());
bResult = TRUE;
break;
// Move the focus indicator down.
case KEY_DOWN:
- rFocusManager.MoveFocus (FocusManager::FMD_DOWN);
+ MoveFocus(FocusManager::FMD_DOWN, rEvent.GetKeyCode().IsShift());
bResult = TRUE;
break;
@@ -394,7 +465,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
case KEY_DELETE:
case KEY_BACKSPACE:
{
- if (mrController.GetProperties()->IsUIReadOnly())
+ if (mrSlideSorter.GetProperties()->IsUIReadOnly())
break;
int nSelectedPagesCount = 0;
@@ -414,13 +485,18 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
if (nSelectedPagesCount > 0)
mrController.GetSelectionManager()->DeleteSelectedPages();
+ mnShiftKeySelectionAnchor = -1;
bResult = TRUE;
}
break;
case KEY_F10:
if (rEvent.GetKeyCode().IsShift())
- ProcessKeyEvent(rEvent);
+ {
+ DeselectAllPages();
+ mrController.GetPageSelector().SelectPage(
+ mrSlideSorter.GetController().GetFocusManager().GetFocusedPageDescriptor());
+ }
break;
default:
@@ -428,7 +504,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
}
if ( ! bResult)
- bResult = SlideFunction::KeyInput (rEvent);
+ bResult = FuPoor::KeyInput(rEvent);
return bResult;
}
@@ -436,6 +512,62 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
+void SelectionFunction::MoveFocus (
+ const FocusManager::FocusMoveDirection eDirection,
+ const bool bIsShiftDown)
+{
+ // Remember the anchor of shift key multi selection.
+ if (bIsShiftDown)
+ {
+ if (mnShiftKeySelectionAnchor<0)
+ {
+ model::SharedPageDescriptor pFocusedDescriptor (
+ mrController.GetFocusManager().GetFocusedPageDescriptor());
+ mnShiftKeySelectionAnchor = pFocusedDescriptor->GetPageIndex();
+ }
+ }
+ else
+ mnShiftKeySelectionAnchor = -1;
+
+ mrController.GetFocusManager().MoveFocus(eDirection);
+
+ // When shift is pressed then select all pages in the range between the
+ // currently and the previously focused pages, including them.
+ if (bIsShiftDown)
+ {
+ model::SharedPageDescriptor pFocusedDescriptor (
+ mrController.GetFocusManager().GetFocusedPageDescriptor());
+ if (pFocusedDescriptor)
+ {
+ PageSelector& rSelector (mrController.GetPageSelector());
+ sal_Int32 nPageRangeEnd (pFocusedDescriptor->GetPageIndex());
+ model::PageEnumeration aPages (
+ model::PageEnumerationProvider::CreateAllPagesEnumeration(
+ mrSlideSorter.GetModel()));
+ while (aPages.HasMoreElements())
+ {
+ model::SharedPageDescriptor pDescriptor (aPages.GetNextElement());
+ if (pDescriptor)
+ {
+ const sal_Int32 nPageIndex(pDescriptor->GetPageIndex());
+ if ((nPageIndex>=mnShiftKeySelectionAnchor && nPageIndex<=nPageRangeEnd)
+ || (nPageIndex<=mnShiftKeySelectionAnchor && nPageIndex>=nPageRangeEnd))
+ {
+ rSelector.SelectPage(pDescriptor);
+ }
+ else
+ {
+ rSelector.DeselectPage(pDescriptor);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+
+
void SelectionFunction::Activate()
{
FuPoor::Activate();
@@ -467,7 +599,7 @@ void SelectionFunction::ScrollEnd (void)
void SelectionFunction::DoCut (void)
{
- if ( ! mrController.GetProperties()->IsUIReadOnly())
+ if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
{
mrController.GetClipboard().DoCut();
}
@@ -486,7 +618,7 @@ void SelectionFunction::DoCopy (void)
void SelectionFunction::DoPaste (void)
{
- if ( ! mrController.GetProperties()->IsUIReadOnly())
+ if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
{
mrController.GetClipboard().DoPaste();
}
@@ -495,8 +627,13 @@ void SelectionFunction::DoPaste (void)
-void SelectionFunction::Paint (const Rectangle&, ::sd::Window* )
+void SelectionFunction::StartDragTimer (void)
{
+ if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
+ {
+ bFirstMouseMove = TRUE;
+ aDragTimer.Start();
+ }
}
@@ -504,20 +641,20 @@ void SelectionFunction::Paint (const Rectangle&, ::sd::Window* )
IMPL_LINK( SelectionFunction, DragSlideHdl, Timer*, EMPTYARG )
{
- StartDrag();
+ StartDrag(aMDPos);
return 0;
}
-void SelectionFunction::StartDrag (void)
+void SelectionFunction::StartDrag (const Point& rMousePosition)
{
if (mbPageHit
- && ! mrController.GetProperties()->IsUIReadOnly())
+ && ! mrSlideSorter.GetProperties()->IsUIReadOnly())
{
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- mpSubstitutionHandler->Start(rOverlay.GetSubstitutionOverlay().GetPosition());
+ mpSubstitutionHandler->Start(rMousePosition);
mbPageHit = false;
mpWindow->ReleaseMouse();
@@ -525,9 +662,7 @@ void SelectionFunction::StartDrag (void)
{
SlideSorterViewShell* pSlideSorterViewShell
= dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell());
- pSlideSorterViewShell->StartDrag (
- rOverlay.GetSubstitutionOverlay().GetPosition(),
- mpWindow);
+ pSlideSorterViewShell->StartDrag (rMousePosition, mpWindow);
}
}
}
@@ -544,105 +679,11 @@ bool SelectionFunction::cancel (void)
-void SelectionFunction::SelectHitPage (const model::SharedPageDescriptor& rpDescriptor)
-{
- mrController.GetPageSelector().SelectPage(rpDescriptor);
-}
-
-
-
-
-void SelectionFunction::DeselectHitPage (const model::SharedPageDescriptor& rpDescriptor)
-{
- mrController.GetPageSelector().DeselectPage(rpDescriptor);
-}
-
-
-
-
void SelectionFunction::DeselectAllPages (void)
{
+ mbIsDeselectionPending = false;
mrController.GetPageSelector().DeselectAllPages();
-}
-
-
-
-
-void SelectionFunction::StartRectangleSelection (const Point& rMouseModelPosition)
-{
- if (mrController.GetProperties()->IsShowSelection())
- {
- mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay().Start(
- rMouseModelPosition);
- }
-}
-
-
-
-
-void SelectionFunction::UpdateRectangleSelection (const Point& rMouseModelPosition)
-{
- if (mrController.GetProperties()->IsShowSelection())
- {
- mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay().Update(
- rMouseModelPosition);
- }
-}
-
-
-
-
-void SelectionFunction::ProcessRectangleSelection (bool bToggleSelection)
-{
- if ( ! mrController.GetProperties()->IsShowSelection())
- return;
-
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- if (rOverlay.GetSelectionRectangleOverlay().isVisible())
- {
- PageSelector& rSelector (mrController.GetPageSelector());
-
- rOverlay.GetSelectionRectangleOverlay().setVisible(false);
-
- // Select all pages whose page object lies completly inside the drag
- // rectangle.
- const Rectangle& rSelectionRectangle (
- rOverlay.GetSelectionRectangleOverlay().GetSelectionRectangle());
- model::PageEnumeration aPages (
- model::PageEnumerationProvider::CreateAllPagesEnumeration(
- mrSlideSorter.GetModel()));
- while (aPages.HasMoreElements())
- {
- model::SharedPageDescriptor pDescriptor (aPages.GetNextElement());
- Rectangle aPageBox (mrSlideSorter.GetView().GetPageBoundingBox(
- pDescriptor,
- view::SlideSorterView::CS_MODEL,
- view::SlideSorterView::BBT_SHAPE));
- if (rSelectionRectangle.IsOver(aPageBox))
- {
- // When we are extending the selection (shift key is
- // pressed) then toggle the selection state of the page.
- // Otherwise select it: this results in the previously
- // selected pages becoming deslected.
- if (bToggleSelection && pDescriptor->IsSelected())
- rSelector.DeselectPage(pDescriptor);
- else
- rSelector.SelectPage(pDescriptor);
- }
- }
- }
-}
-
-
-
-
-void SelectionFunction::PrepareMouseMotion (const Point& )
-{
- if ( ! mrController.GetProperties()->IsUIReadOnly())
- {
- bFirstMouseMove = TRUE;
- aDragTimer.Start();
- }
+ mnShiftKeySelectionAnchor = -1;
}
@@ -708,6 +749,7 @@ void SelectionFunction::GotoNextPage (int nOffset)
OSL_ASSERT(pNextPageDescriptor.get() != NULL);
}
}
+ mnShiftKeySelectionAnchor = -1;
}
@@ -717,11 +759,10 @@ void SelectionFunction::ClearOverlays (void)
{
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetSubstitutionOverlay().setVisible(false);
- rOverlay.GetSubstitutionOverlay().Clear();
+ rOverlay.GetSubstitutionOverlay()->SetIsVisible(false);
+ rOverlay.GetSubstitutionOverlay()->Clear();
- mpInsertionIndicatorHandler->End();
- rOverlay.GetMouseOverIndicatorOverlay().SetSlideUnderMouse(model::SharedPageDescriptor());
+ mrController.GetInsertionIndicatorHandler()->End();
}
@@ -738,7 +779,8 @@ void SelectionFunction::ProcessMouseEvent (sal_uInt32 nEventType, const MouseEve
// 2. Compute a numerical code that describes the event and that is used
// for fast look-up of the associated reaction.
- pEventDescriptor->mnEventCode = EncodeMouseEvent(*pEventDescriptor, rEvent);
+ pEventDescriptor->mnEventCode
+ = EncodeMouseEvent(*pEventDescriptor, rEvent) | EncodeState(*pEventDescriptor);
// 3. Process the event.
EventPreprocessing(*pEventDescriptor);
@@ -777,54 +819,22 @@ sal_uInt32 SelectionFunction::EncodeMouseEvent (
case 2: nEventCode |= DOUBLE_CLICK; break;
}
- // Detect whether the event has happened over a page object.
- if (rDescriptor.mpHitPage != NULL && ! rDescriptor.mpHitDescriptor.expired())
- {
- model::SharedPageDescriptor pHitDescriptor (rDescriptor.mpHitDescriptor);
- if (pHitDescriptor->IsSelected())
- nEventCode |= OVER_SELECTED_PAGE;
- else
- nEventCode |= OVER_UNSELECTED_PAGE;
- }
-
// Detect pressed modifier keys.
if (rEvent.IsShift())
nEventCode |= SHIFT_MODIFIER;
if (rEvent.IsMod1())
nEventCode |= CONTROL_MODIFIER;
- // Detect whether we are dragging pages or dragging a selection rectangle.
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- if (rOverlay.GetSubstitutionOverlay().isVisible())
- nEventCode |= SUBSTITUTION_VISIBLE;
- if (rOverlay.GetSelectionRectangleOverlay().isVisible())
- nEventCode |= RECTANGLE_VISIBLE;
+ // Detect whether the mouse is over one of the active elements inside a
+ // page object.
+ if (rDescriptor.mnButtonIndex >= 0)
+ nEventCode |= OVER_BUTTON;
return nEventCode;
}
-
-void SelectionFunction::ProcessKeyEvent (const KeyEvent& rEvent)
-{
- // 1. Compute some frequently used values relating to the event.
- ::std::auto_ptr<EventDescriptor> pEventDescriptor (
- new EventDescriptor(rEvent, mrSlideSorter));
-
- // 2. Encode the event.
- pEventDescriptor->mnEventCode = EncodeKeyEvent(*pEventDescriptor, rEvent);
-
- // 3. Process the event.
- EventPreprocessing(*pEventDescriptor);
- if ( ! EventProcessing(*pEventDescriptor))
- OSL_TRACE ("can not handle event code %x", pEventDescriptor->mnEventCode);
- EventPostprocessing(*pEventDescriptor);
-}
-
-
-
-
sal_uInt32 SelectionFunction::EncodeKeyEvent (
const EventDescriptor& rDescriptor,
const KeyEvent& rEvent) const
@@ -841,21 +851,37 @@ sal_uInt32 SelectionFunction::EncodeKeyEvent (
if (rEvent.GetKeyCode().IsMod1())
nEventCode |= CONTROL_MODIFIER;
+ return nEventCode;
+}
+
+
+
+
+sal_uInt32 SelectionFunction::EncodeState (
+ const EventDescriptor& rDescriptor) const
+{
+ sal_uInt32 nEventCode (0);
+
// Detect whether the event has happened over a page object.
if (rDescriptor.mpHitPage != NULL && ! rDescriptor.mpHitDescriptor.expired())
{
model::SharedPageDescriptor pHitDescriptor (rDescriptor.mpHitDescriptor);
- if (pHitDescriptor->IsSelected())
+ if (pHitDescriptor->HasState(model::PageDescriptor::ST_Selected))
nEventCode |= OVER_SELECTED_PAGE;
else
nEventCode |= OVER_UNSELECTED_PAGE;
+
+ // Detect whether the mouse is over one of the active elements
+ // inside a page object.
+ if (rDescriptor.mnButtonIndex >= 0)
+ nEventCode |= OVER_BUTTON;
}
// Detect whether we are dragging pages or dragging a selection rectangle.
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- if (rOverlay.GetSubstitutionOverlay().isVisible())
+ if (rOverlay.GetSubstitutionOverlay()->IsVisible())
nEventCode |= SUBSTITUTION_VISIBLE;
- if (rOverlay.GetSelectionRectangleOverlay().isVisible())
+ if (mpRectangleSelector)
nEventCode |= RECTANGLE_VISIBLE;
return nEventCode;
@@ -863,6 +889,27 @@ sal_uInt32 SelectionFunction::EncodeKeyEvent (
+
+void SelectionFunction::ProcessKeyEvent (const KeyEvent& rEvent)
+{
+ // 1. Compute some frequently used values relating to the event.
+ ::std::auto_ptr<EventDescriptor> pEventDescriptor (
+ new EventDescriptor(rEvent, mrSlideSorter));
+
+ // 2. Encode the event.
+ pEventDescriptor->mnEventCode
+ = EncodeKeyEvent(*pEventDescriptor, rEvent) | EncodeState(*pEventDescriptor);
+
+ // 3. Process the event.
+ EventPreprocessing(*pEventDescriptor);
+ if ( ! EventProcessing(*pEventDescriptor))
+ OSL_TRACE ("can not handle event code %x", pEventDescriptor->mnEventCode);
+ EventPostprocessing(*pEventDescriptor);
+}
+
+
+
+
void SelectionFunction::EventPreprocessing (const EventDescriptor& rDescriptor)
{
// Some general processing that is not specific to the exact event code.
@@ -870,8 +917,21 @@ void SelectionFunction::EventPreprocessing (const EventDescriptor& rDescriptor)
mbPageHit = (rDescriptor.mpHitPage!=NULL);
// Set the focus to the slide under the mouse.
- if (rDescriptor.mpHitPage != NULL)
- mrController.GetFocusManager().FocusPage((rDescriptor.mpHitPage->GetPageNum()-1)/2);
+ // if (rDescriptor.mpHitPage != NULL)
+ //
+ // mrController.GetFocusManager().FocusPage((rDescriptor.mpHitPage->GetPageNum()-1)/2);
+}
+
+
+
+
+bool Match (
+ const sal_uInt32 nEventCode,
+ const sal_uInt32 nPositivePattern,
+ const sal_uInt32 nNegativePattern = 0)
+{
+ return (nEventCode & nPositivePattern)==nPositivePattern
+ && (nEventCode & nNegativePattern)==0;
}
@@ -880,13 +940,13 @@ void SelectionFunction::EventPreprocessing (const EventDescriptor& rDescriptor)
bool SelectionFunction::EventProcessing (const EventDescriptor& rDescriptor)
{
// Define some macros to make the following switch statement more readable.
-#define ANY_MODIFIER(code) \
- code|NO_MODIFIER: \
- case code|SHIFT_MODIFIER: \
+#define ANY_MODIFIER(code) \
+ code|NO_MODIFIER: \
+ case code|SHIFT_MODIFIER: \
case code|CONTROL_MODIFIER
-#define ANY_PAGE(code) \
- code|NOT_OVER_PAGE: \
- case code|OVER_UNSELECTED_PAGE: \
+#define ANY_PAGE(code) \
+ code|NOT_OVER_PAGE: \
+ case code|OVER_UNSELECTED_PAGE: \
case code|OVER_SELECTED_PAGE
#define ANY_PAGE_AND_MODIFIER(code) \
ANY_PAGE(code|NO_MODIFIER): \
@@ -907,148 +967,180 @@ bool SelectionFunction::EventProcessing (const EventDescriptor& rDescriptor)
if ( ! rDescriptor.mpHitDescriptor.expired())
pHitDescriptor = model::SharedPageDescriptor(rDescriptor.mpHitDescriptor);
- switch (rDescriptor.mnEventCode)
+ switch (rDescriptor.mnEventCode & (SUBSTITUTION_VISIBLE | RECTANGLE_VISIBLE))
{
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE:
- SetCurrentPage(pHitDescriptor);
- PrepareMouseMotion(mpWindow->PixelToLogic(rDescriptor.maMousePosition));
- mpSubstitutionHandler->Start(rDescriptor.maMouseModelPosition);
- break;
-
- case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
- SetCurrentPage(pHitDescriptor);
- mpSubstitutionHandler->End();
- break;
-
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
- PrepareMouseMotion(mpWindow->PixelToLogic(rDescriptor.maMousePosition));
- mpSubstitutionHandler->Start(rDescriptor.maMouseModelPosition);
- break;
-
- case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_SELECTED_PAGE:
- case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_UNSELECTED_PAGE:
- // A double click allways shows the selected slide in the center
- // pane in an edit view.
- SetCurrentPage(pHitDescriptor);
- SwitchView(pHitDescriptor);
- break;
-
- // Multi selection with the control modifier.
- case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | CONTROL_MODIFIER:
- DeselectHitPage(pHitDescriptor);
- PrepareMouseMotion(mpWindow->PixelToLogic(rDescriptor.maMousePosition));
- break;
-
- case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | CONTROL_MODIFIER:
- SelectHitPage(pHitDescriptor);
- PrepareMouseMotion(mpWindow->PixelToLogic(rDescriptor.maMousePosition));
-
- break;
-
- // Range selection with the shift modifier.
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | SHIFT_MODIFIER:
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | SHIFT_MODIFIER:
- RangeSelect(pHitDescriptor);
- break;
-
- // Was: Preview of the page transition effect.
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_FADE_INDICATOR:
- // No action.
- break;
-
- // Right button for context menu.
- case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE:
- case KEY_EVENT | KEY_F10 | SHIFT_MODIFIER | OVER_UNSELECTED_PAGE:
- // Single right click and shift+F10 select as preparation to
- // show the context menu. Change the selection only when the
- // page under the mouse is not selected. In this case the
- // selection is set to this single page. Otherwise the
- // selection is not modified.
- DeselectAllPages();
- SelectHitPage(pHitDescriptor);
- SetCurrentPage(pHitDescriptor);
- bMakeSelectionVisible = false;
- break;
-
- case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
- case KEY_EVENT | KEY_F10 | OVER_SELECTED_PAGE | SHIFT_MODIFIER:
- // Do not change the selection. Just adjust the insertion indicator.
- bMakeSelectionVisible = false;
- break;
-
- case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE:
- // The Shift+F10 key event is here just for completeness. It should
- // not be possible to really receive this (not being over a page.)
- case KEY_EVENT | KEY_F10 | SHIFT_MODIFIER | NOT_OVER_PAGE:
- DeselectAllPages();
- bMakeSelectionVisible = false;
- break;
-
- // A mouse motion without visible substitution starts that.
- case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE):
- mrController.GetScrollBarManager().AutoScroll(rDescriptor.maMousePosition);
- mpSubstitutionHandler->Start(rDescriptor.maMouseModelPosition);
- break;
-
- // Move substitution.
- case ANY_PAGE_AND_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | SUBSTITUTION_VISIBLE):
- if ((rDescriptor.mnEventCode & CONTROL_MODIFIER) != 0)
- StartDrag();
- mrController.GetScrollBarManager().AutoScroll(rDescriptor.maMousePosition);
- mpSubstitutionHandler->UpdatePosition(rDescriptor.maMouseModelPosition);
- break;
-
- // Place substitution.
- case ANY_PAGE_AND_MODIFIER(BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | SUBSTITUTION_VISIBLE):
- // When the substitution has not been moved the button up event
- // is taken to be part of a single click. The selected pages
- // are therefore not moved (which technically would be necessary
- // for unconsecutive multi selections). Instead the page under
- // the mouse becomes the only selected page.
- if (mpSubstitutionHandler->HasBeenMoved())
+ case SUBSTITUTION_VISIBLE:
+ // The substitution is visible. Handle events accordingly.
+ if (Match(rDescriptor.mnEventCode, MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK))
+ {
+ // Move substitution.
+ mpSubstitutionHandler->SetHitDescriptor(pHitDescriptor);
+ if ((rDescriptor.mnEventCode & CONTROL_MODIFIER) != 0)
+ StartDrag(rDescriptor.maMousePosition);
+ mpSubstitutionHandler->UpdatePosition(rDescriptor.maMousePosition);
+ }
+ else if (Match(rDescriptor.mnEventCode, MOUSE_DRAG))
+ {
+ mpSubstitutionHandler->UpdatePosition(rDescriptor.maMousePosition);
+ }
+ else if (Match(rDescriptor.mnEventCode, BUTTON_UP | LEFT_BUTTON))
{
// The following Process() call may lead to the desctruction
// of pHitDescriptor so release our reference to it.
pHitDescriptor.reset();
+ mpSubstitutionHandler->End();
mpSubstitutionHandler->Process();
}
- else
- if (pHitDescriptor != NULL)
- SetCurrentPage(pHitDescriptor);
- mpSubstitutionHandler->End();
- break;
-
- // Rectangle selection.
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE | NO_MODIFIER:
- DeselectAllPages();
- StartRectangleSelection(rDescriptor.maMouseModelPosition);
- break;
-
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE | SHIFT_MODIFIER:
- case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE | CONTROL_MODIFIER:
- StartRectangleSelection(rDescriptor.maMouseModelPosition);
- break;
-
- case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE):
- case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE):
- case ANY_PAGE_AND_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | RECTANGLE_VISIBLE):
- mrController.GetScrollBarManager().AutoScroll(rDescriptor.maMousePosition);
- UpdateRectangleSelection(rDescriptor.maMouseModelPosition);
break;
- case ANY_PAGE(BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | RECTANGLE_VISIBLE | NO_MODIFIER):
- ProcessRectangleSelection(false);
- break;
-
- case ANY_PAGE(BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | RECTANGLE_VISIBLE | SHIFT_MODIFIER):
- case ANY_PAGE(BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | RECTANGLE_VISIBLE | CONTROL_MODIFIER):
- ProcessRectangleSelection(true);
+ case RECTANGLE_VISIBLE:
+ OSL_ASSERT(mpRectangleSelector);
+ // The selection rectangle is visible. Handle events accordingly.
+ if (Match(rDescriptor.mnEventCode, MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK))
+ {
+ if (mpRectangleSelector)
+ {
+ mpRectangleSelector->SetSelectionModeFromModifier(rDescriptor.mnEventCode);
+ mpRectangleSelector->UpdatePosition(rDescriptor.maMousePosition);
+ }
+ bMakeSelectionVisible = false;
+ }
+ else if (Match(rDescriptor.mnEventCode, BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK))
+ {
+ mpRectangleSelector.reset();
+ }
+ // Anything else stops the rectangle selection and the event is
+ // processed again.
+ else
+ {
+ mpRectangleSelector.reset();
+ EventDescriptor aModifiedDescriptor (rDescriptor);
+ aModifiedDescriptor.mnEventCode &= ~RECTANGLE_VISIBLE;
+ EventProcessing(aModifiedDescriptor);
+ }
break;
default:
- bResult = false;
- break;
+ OSL_ASSERT(!mpRectangleSelector);
+ switch (rDescriptor.mnEventCode & (BUTTON_DOWN | BUTTON_UP | MOUSE_MOTION))
+ {
+ case BUTTON_DOWN:
+ switch (rDescriptor.mnEventCode)
+ {
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE:
+ SetCurrentPage(pHitDescriptor);
+ StartDragTimer();
+ break;
+
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
+ StartDragTimer();
+ break;
+
+ case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_SELECTED_PAGE:
+ case BUTTON_DOWN | LEFT_BUTTON | DOUBLE_CLICK | OVER_UNSELECTED_PAGE:
+ // A double click allways shows the selected slide in the center
+ // pane in an edit view.
+ SetCurrentPage(pHitDescriptor);
+ SwitchView(pHitDescriptor);
+ break;
+
+ // Range selection with the shift modifier.
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | SHIFT_MODIFIER:
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | SHIFT_MODIFIER:
+ RangeSelect(pHitDescriptor);
+ break;
+
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | OVER_BUTTON:
+ case BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | OVER_BUTTON:
+ // Remember page and button index. When mouse button is
+ // released over same page and button then invoke action of that
+ // button.
+ mnButtonDownButtonIndex = rDescriptor.mnButtonIndex;
+ OSL_ASSERT(pHitDescriptor);
+ mnButtonDownPageIndex = pHitDescriptor->GetPageIndex();
+ pHitDescriptor->GetVisualState().SetActiveButtonState(
+ mnButtonDownButtonIndex,
+ model::VisualState::BS_Pressed);
+ mrSlideSorter.GetView().RequestRepaint(pHitDescriptor);
+ break;
+
+ // Right button for context menu.
+ case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE:
+ // Single right click and shift+F10 select as preparation to
+ // show the context menu. Change the selection only when the
+ // page under the mouse is not selected. In this case the
+ // selection is set to this single page. Otherwise the
+ // selection is not modified.
+ DeselectAllPages();
+ SetCurrentPage(pHitDescriptor);
+ bMakeSelectionVisible = false;
+ break;
+
+ case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
+ // Do not change the selection. Just adjust the insertion indicator.
+ bMakeSelectionVisible = false;
+ break;
+ case BUTTON_DOWN | RIGHT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE:
+
+ // Rectangle selection.
+ case ANY_MODIFIER(BUTTON_DOWN | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE):
+ mbIsDeselectionPending = true;
+ OSL_ASSERT(!mpRectangleSelector);
+ break;
+ }
+ break;
+
+ case BUTTON_UP:
+ switch (rDescriptor.mnEventCode)
+ {
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE:
+ SetCurrentPage(pHitDescriptor);
+ break;
+
+ // Multi selection with the control modifier.
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | CONTROL_MODIFIER:
+ mrController.GetPageSelector().DeselectPage(pHitDescriptor);
+ break;
+
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | CONTROL_MODIFIER:
+ mrController.GetPageSelector().SelectPage(pHitDescriptor);
+ // fallthrough
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE | OVER_BUTTON:
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE | OVER_BUTTON:
+ if (mnButtonDownButtonIndex == rDescriptor.mnButtonIndex
+ && mnButtonDownPageIndex == pHitDescriptor->GetPageIndex())
+ {
+ ProcessButtonClick(pHitDescriptor, mnButtonDownButtonIndex);
+ }
+ break;
+ case BUTTON_UP | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE:
+ if (mbIsDeselectionPending)
+ DeselectAllPages();
+ break;
+ }
+ break;
+
+ case MOUSE_MOTION:
+ switch (rDescriptor.mnEventCode)
+ {
+ // A mouse motion without visible substitution starts that.
+ case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_SELECTED_PAGE):
+ mpSubstitutionHandler->SetHitDescriptor(pHitDescriptor);
+ mpSubstitutionHandler->Start(rDescriptor.maMouseModelPosition);
+ break;
+
+ // A mouse motion not over a page starts a rectangle selection.
+ case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | NOT_OVER_PAGE):
+ OSL_ASSERT(!mpRectangleSelector);
+ mpRectangleSelector.reset(
+ new RectangleSelector(mrSlideSorter, rDescriptor.maMouseModelPosition));
+ mpRectangleSelector->SetSelectionModeFromModifier(rDescriptor.mnEventCode);
+ break;
+ }
+ break;
+ }
}
+
mrController.GetPageSelector().EnableBroadcasting(bMakeSelectionVisible);
return bResult;
@@ -1070,20 +1162,23 @@ void SelectionFunction::EventPostprocessing (const EventDescriptor& rDescriptor)
// case that the context menu is visible.
DBG_ASSERT(
mrController.IsContextMenuOpen()
- || !rOverlay.GetInsertionIndicatorOverlay().isVisible(),
+ || !rOverlay.GetInsertionIndicatorOverlay()->IsVisible(),
"slidesorter::SelectionFunction: insertion indicator still visible");
DBG_ASSERT(
- !rOverlay.GetSubstitutionOverlay().isVisible(),
+ !rOverlay.GetSubstitutionOverlay()->IsVisible(),
"slidesorter::SelectionFunction: substitution still visible");
DBG_ASSERT(
- !rOverlay.GetSelectionRectangleOverlay().isVisible(),
+ !rOverlay.GetSelectionRectangleOverlay()->IsVisible(),
"slidesorter::SelectionFunction: selection rectangle still visible");
// Now turn them off.
if ( ! mrController.IsContextMenuOpen())
- rOverlay.GetInsertionIndicatorOverlay().setVisible(false);
- rOverlay.GetSubstitutionOverlay().setVisible(false);
- rOverlay.GetSelectionRectangleOverlay().setVisible(false);
+ rOverlay.GetInsertionIndicatorOverlay()->SetIsVisible(false);
+ rOverlay.GetSubstitutionOverlay()->SetIsVisible(false);
+ rOverlay.GetSelectionRectangleOverlay()->SetIsVisible(false);
+
+ mnButtonDownPageIndex = -1;
+ mnButtonDownButtonIndex = -1;
}
}
@@ -1097,6 +1192,9 @@ void SelectionFunction::SetCurrentPage (const model::SharedPageDescriptor& rpDes
rSelector.SelectPage(rpDescriptor);
mrController.GetCurrentSlideManager()->SwitchCurrentSlide(rpDescriptor);
+ mrController.GetFocusManager().SetFocusedPage(rpDescriptor);
+
+ mnShiftKeySelectionAnchor = -1;
}
@@ -1125,6 +1223,83 @@ void SelectionFunction::SwitchView (const model::SharedPageDescriptor& rpDescrip
+void SelectionFunction::UpdatePageUnderMouse (
+ const Point& rMousePosition,
+ const bool bIsMouseButtonDown)
+{
+ // Determine page under mouse and show the mouse over effect.
+ model::SharedPageDescriptor pHitDescriptor (
+ mrController.GetPageAt(rMousePosition));
+ mrSlideSorter.GetView().SetPageUnderMouse(pHitDescriptor);
+
+ // Handle the mouse being over any buttons.
+ if (pHitDescriptor)
+ {
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
+ const sal_Int32 nButtonIndex (
+ mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetButtonIndexAt (
+ pHitDescriptor,
+ aMouseModelPosition));
+ mrSlideSorter.GetView().SetButtonUnderMouse(nButtonIndex);
+ if (bIsMouseButtonDown)
+ {
+ pHitDescriptor->GetVisualState().SetActiveButtonState(
+ nButtonIndex,
+ model::VisualState::BS_Pressed);
+ }
+ }
+}
+
+
+
+
+void SelectionFunction::ProcessButtonClick (
+ const model::SharedPageDescriptor& rpDescriptor,
+ const sal_Int32 nButtonIndex)
+{
+ OSL_ASSERT(rpDescriptor);
+
+ PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
+ switch (nButtonIndex)
+ {
+ case 2:
+ // Start slide show at current slide.
+ mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
+ rpDescriptor);
+ if (mrSlideSorter.GetViewShell() != NULL)
+ mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
+ SID_PRESENTATION,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ break;
+
+ case 1:
+ // Toggle exclusion state.
+ rSelector.DeselectAllPages();
+ rSelector.SelectPage(rpDescriptor);
+ if (mrSlideSorter.GetViewShell() != NULL)
+ mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
+ rpDescriptor->HasState(model::PageDescriptor::ST_Excluded)
+ ? SID_SHOW_SLIDE
+ : SID_HIDE_SLIDE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ break;
+
+ case 0:
+ // Insert page after current page.
+ rSelector.DeselectAllPages();
+ rSelector.SelectPage(rpDescriptor);
+ if (mrSlideSorter.GetViewShell() != NULL)
+ mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
+ SID_INSERTPAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ break;
+ }
+}
+
+
+
+
//===== EventDescriptor =======================================================
SelectionFunction::EventDescriptor::EventDescriptor (
@@ -1135,9 +1310,10 @@ SelectionFunction::EventDescriptor::EventDescriptor (
maMouseModelPosition(),
mpHitDescriptor(),
mpHitPage(),
- mnEventCode(nEventType)
+ mnEventCode(nEventType),
+ mnButtonIndex(-1)
{
- ::Window* pWindow = rSlideSorter.GetActiveWindow();
+ ::boost::shared_ptr<sd::Window> pWindow (rSlideSorter.GetContentWindow());
maMousePosition = rEvent.GetPosPixel();
maMouseModelPosition = pWindow->PixelToLogic(maMousePosition);
@@ -1147,6 +1323,11 @@ SelectionFunction::EventDescriptor::EventDescriptor (
{
mpHitDescriptor = pHitDescriptor;
mpHitPage = pHitDescriptor->GetPage();
+
+ mnButtonIndex = rSlideSorter.GetView().GetLayouter()
+ .GetPageObjectLayouter()->GetButtonIndexAt(
+ pHitDescriptor,
+ maMouseModelPosition);
}
}
@@ -1161,9 +1342,9 @@ SelectionFunction::EventDescriptor::EventDescriptor (
maMouseModelPosition(),
mpHitDescriptor(),
mpHitPage(),
- mnEventCode(0)
+ mnEventCode(0),
+ mnButtonIndex(-1)
{
- mpHitDescriptor = rSlideSorter.GetController().GetFocusManager().GetFocusedPageDescriptor();
model::SharedPageDescriptor pHitDescriptor (
rSlideSorter.GetController().GetFocusManager().GetFocusedPageDescriptor());
if (pHitDescriptor.get() != NULL)
@@ -1177,11 +1358,51 @@ SelectionFunction::EventDescriptor::EventDescriptor (
+SelectionFunction::EventDescriptor::EventDescriptor (
+ const AcceptDropEvent& rEvent,
+ SlideSorter& rSlideSorter)
+ : maMousePosition(rEvent.maPosPixel),
+ maMouseModelPosition(),
+ mpHitDescriptor(),
+ mpHitPage(),
+ mnEventCode(MOUSE_DRAG),
+ mnButtonIndex(-1)
+{
+ ::boost::shared_ptr<sd::Window> pWindow (rSlideSorter.GetContentWindow());
+
+ maMouseModelPosition = pWindow->PixelToLogic(maMousePosition);
+ model::SharedPageDescriptor pHitDescriptor (
+ rSlideSorter.GetController().GetPageAt(maMousePosition));
+ if (pHitDescriptor.get() != NULL)
+ {
+ mpHitDescriptor = pHitDescriptor;
+ mpHitPage = pHitDescriptor->GetPage();
+ }
+}
+
+
+
+
+SelectionFunction::EventDescriptor::EventDescriptor (const EventDescriptor& rDescriptor)
+ : maMousePosition(rDescriptor.maMousePosition),
+ maMouseModelPosition(rDescriptor.maMouseModelPosition),
+ mpHitDescriptor(rDescriptor.mpHitDescriptor),
+ mpHitPage(rDescriptor.mpHitPage),
+ mnEventCode(rDescriptor.mnEventCode),
+ mnButtonIndex(rDescriptor.mnButtonIndex)
+{
+}
+
+
+
+
//===== SubstitutionHandler ===================================================
SelectionFunction::SubstitutionHandler::SubstitutionHandler (SlideSorter& rSlideSorter)
: mrSlideSorter(rSlideSorter),
- mbHasBeenMoved(false)
+ mpHitDescriptor(),
+ mbIsActive(false),
+ mnInsertionIndex(-1)
{
}
@@ -1190,59 +1411,98 @@ SelectionFunction::SubstitutionHandler::SubstitutionHandler (SlideSorter& rSlide
SelectionFunction::SubstitutionHandler::~SubstitutionHandler (void)
{
+ OSL_ASSERT(!mbIsActive);
if (mrSlideSorter.IsValid())
{
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetSubstitutionOverlay().setVisible(false);
- rOverlay.GetSubstitutionOverlay().Clear();
+ rOverlay.GetSubstitutionOverlay()->SetIsVisible(false);
+ rOverlay.GetSubstitutionOverlay()->Clear();
}
}
+void SelectionFunction::SubstitutionHandler::SetHitDescriptor (
+ const model::SharedPageDescriptor& rpHitDescriptor)
+{
+ mpHitDescriptor = rpHitDescriptor;
+}
+
+
+
+
void SelectionFunction::SubstitutionHandler::Start (const Point& rMouseModelPosition)
{
+ OSL_ASSERT(!mbIsActive);
+ mbIsActive = true;
+ mnInsertionIndex = -1;
+
// No Drag-and-Drop for master pages.
if (mrSlideSorter.GetModel().GetEditMode() != EM_PAGE)
return;
- if (mrSlideSorter.GetController().GetProperties()->IsUIReadOnly())
+ if (mrSlideSorter.GetProperties()->IsUIReadOnly())
return;
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- if ( ! rOverlay.GetSubstitutionOverlay().isVisible())
+ if ( ! rOverlay.GetSubstitutionOverlay()->IsVisible())
{
// Show a new substitution for the selected page objects.
model::PageEnumeration aSelectedPages(
model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
mrSlideSorter.GetModel()));
- rOverlay.GetSubstitutionOverlay().Create(aSelectedPages, rMouseModelPosition);
- rOverlay.GetSubstitutionOverlay().setVisible(true);
- mbHasBeenMoved = false;
+ rOverlay.GetSubstitutionOverlay()->Create(
+ aSelectedPages,
+ rMouseModelPosition,
+ mpHitDescriptor);
+ rOverlay.GetSubstitutionOverlay()->SetIsVisible(true);
+ mrSlideSorter.GetController().GetInsertionIndicatorHandler()->Start(rMouseModelPosition);
}
- else
- UpdatePosition(rMouseModelPosition);
}
-void SelectionFunction::SubstitutionHandler::UpdatePosition (const Point& rMouseModelPosition)
+void SelectionFunction::SubstitutionHandler::UpdatePosition (
+ const Point& rMousePosition,
+ const bool bAllowAutoScroll)
{
- if (mrSlideSorter.GetController().GetProperties()->IsUIReadOnly())
+ OSL_ASSERT(mbIsActive);
+
+ if (mrSlideSorter.GetProperties()->IsUIReadOnly())
return;
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
+ // Convert window coordinates into model coordinates (we need the
+ // window coordinates for auto-scrolling because that remains
+ // constant while scrolling.)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
+
+ if ( ! (bAllowAutoScroll && mrSlideSorter.GetController().GetScrollBarManager().AutoScroll(
+ rMousePosition,
+ ::boost::bind(
+ &SelectionFunction::SubstitutionHandler::UpdatePosition,
+ this,
+ rMousePosition,
+ false))))
+ {
+ view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- // Move the existing substitution to the new position.
- rOverlay.GetSubstitutionOverlay().SetPosition(rMouseModelPosition);
+ // Move the existing substitution to the new position.
+ rOverlay.GetSubstitutionOverlay()->SetPosition(aMouseModelPosition);
- rOverlay.GetInsertionIndicatorOverlay().SetPosition(rMouseModelPosition);
- rOverlay.GetInsertionIndicatorOverlay().setVisible(true);
+ mrSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdatePosition(
+ aMouseModelPosition);
- mbHasBeenMoved = true;
+ // Remember the new insertion index.
+ if (mrSlideSorter.GetController().GetInsertionIndicatorHandler()->IsInsertionTrivial())
+ mnInsertionIndex = -1;
+ else
+ mnInsertionIndex = mrSlideSorter.GetController().GetInsertionIndicatorHandler()
+ ->GetInsertionPageIndex();
+ }
}
@@ -1250,22 +1510,16 @@ void SelectionFunction::SubstitutionHandler::UpdatePosition (const Point& rMouse
void SelectionFunction::SubstitutionHandler::Process (void)
{
- if (mrSlideSorter.GetController().GetProperties()->IsUIReadOnly())
+ if (mrSlideSorter.GetProperties()->IsUIReadOnly())
return;
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
-
- if (IsSubstitutionInsertionNonTrivial())
+ if (mnInsertionIndex >= 0)
{
// Tell the model to move the selected pages behind the one with the
// index mnInsertionIndex which first has to transformed into an index
// understandable by the document.
- sal_Int32 nInsertionIndex = rOverlay.GetInsertionIndicatorOverlay().GetInsertionPageIndex();
- if (nInsertionIndex >= 0)
- {
- USHORT nDocumentIndex = (USHORT)nInsertionIndex-1;
- mrSlideSorter.GetController().GetSelectionManager()->MoveSelectedPages(nDocumentIndex);
- }
+ USHORT nDocumentIndex = (USHORT)mnInsertionIndex-1;
+ mrSlideSorter.GetController().GetSelectionManager()->MoveSelectedPages(nDocumentIndex);
ViewShell* pViewShell = mrSlideSorter.GetViewShell();
if (pViewShell != NULL)
@@ -1278,130 +1532,223 @@ void SelectionFunction::SubstitutionHandler::Process (void)
void SelectionFunction::SubstitutionHandler::End (void)
{
+ OSL_ASSERT(mbIsActive);
+ mbIsActive = false;
+
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetSubstitutionOverlay().setVisible(false);
- rOverlay.GetSubstitutionOverlay().Clear();
- rOverlay.GetInsertionIndicatorOverlay().setVisible(false);
+ rOverlay.GetSubstitutionOverlay()->SetIsVisible(false);
+ rOverlay.GetSubstitutionOverlay()->Clear();
+ mrSlideSorter.GetController().GetInsertionIndicatorHandler()->End();
+ mpHitDescriptor.reset();
}
-bool SelectionFunction::SubstitutionHandler::HasBeenMoved (void) const
+bool SelectionFunction::SubstitutionHandler::IsActive (void) const
{
- return mbHasBeenMoved;
+ return mbIsActive;
}
-bool SelectionFunction::SubstitutionHandler::IsSubstitutionInsertionNonTrivial (void) const
+//===== SelectionFunction::RectangleSelector ==================================
+
+SelectionFunction::RectangleSelector::RectangleSelector (
+ SlideSorter& rSlideSorter,
+ const Point& rMouseModelPosition)
+ : mrSlideSorter(rSlideSorter),
+ meSelectionMode(SM_Normal),
+ maInitialSelection()
{
- bool bIsNonTrivial = false;
+ if (mrSlideSorter.GetProperties()->IsShowSelection())
+ {
+ mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay()
+ ->Start(rMouseModelPosition);
+ }
- do
+ // Remember the current selection.
+ model::PageEnumeration aPages (
+ model::PageEnumerationProvider::CreateAllPagesEnumeration(
+ mrSlideSorter.GetModel()));
+ while (aPages.HasMoreElements())
{
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
+ model::SharedPageDescriptor pDescriptor (aPages.GetNextElement());
+ pDescriptor->SetState(
+ model::PageDescriptor::ST_WasSelected,
+ pDescriptor->HasState(model::PageDescriptor::ST_Selected));
+ }
+}
- // Make sure that the substitution and the insertion indicator are visible.
- if ( ! rOverlay.GetSubstitutionOverlay().isVisible())
- break;
- if ( ! rOverlay.GetInsertionIndicatorOverlay().isVisible())
- break;
- // 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() && ! bIsNonTrivial)
- {
- model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
- SdPage* pPage = pDescriptor->GetPage();
- if (pPage != NULL)
- {
- // Get the page number and compare it to the last one.
- sal_Int32 nPageNumber = (pPage->GetPageNum()-1)/2;
- if (nCurrentIndex>=0 && nPageNumber>(nCurrentIndex+1))
- bIsNonTrivial = true;
- else
- nCurrentIndex = nPageNumber;
- // Remember indices of the first and last page of the selection.
- if (nFirstIndex == -1)
- nFirstIndex = nPageNumber;
- nLastIndex = nPageNumber;
- }
- }
- if (bIsNonTrivial)
- break;
- // When we come here then the selection is consecutive. 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.
- sal_Int32 nInsertionIndex = rOverlay.GetInsertionIndicatorOverlay().GetInsertionPageIndex();
- if (nInsertionIndex<nFirstIndex || nInsertionIndex>(nLastIndex+1))
- bIsNonTrivial = true;
+SelectionFunction::RectangleSelector::~RectangleSelector (void)
+{
+ if (mrSlideSorter.GetProperties()->IsShowSelection())
+ {
+ mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay()->SetIsVisible(false);
}
- while (false);
-
- return bIsNonTrivial;
}
-//===== InsertionIndicatorHandler =============================================
-
-SelectionFunction::InsertionIndicatorHandler::InsertionIndicatorHandler (
- SlideSorter& rSlideSorter)
- : mrSlideSorter(rSlideSorter)
+void SelectionFunction::RectangleSelector::RestoreInitialSelection (void)
{
+ // Remember the current selection.
+ model::PageEnumeration aPages (
+ model::PageEnumerationProvider::CreateAllPagesEnumeration(
+ mrSlideSorter.GetModel()));
+ view::SlideSorterView& rView (mrSlideSorter.GetView());
+ while (aPages.HasMoreElements())
+ {
+ model::SharedPageDescriptor pDescriptor (aPages.GetNextElement());
+ pDescriptor->SetState(
+ model::PageDescriptor::ST_Selected,
+ pDescriptor->HasState(model::PageDescriptor::ST_WasSelected));
+ rView.RequestRepaint(pDescriptor);
+ }
}
-SelectionFunction::InsertionIndicatorHandler::~InsertionIndicatorHandler (void)
+void SelectionFunction::RectangleSelector::UpdatePosition (
+ const Point& rMousePosition,
+ const bool bAllowAutoScroll)
{
+ // Convert window coordinates into model coordinates (we need the
+ // window coordinates for auto-scrolling because that remains
+ // constant while scrolling.)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
+
+ if ( ! (bAllowAutoScroll && mrSlideSorter.GetController().GetScrollBarManager().AutoScroll(
+ rMousePosition,
+ ::boost::bind(
+ &SelectionFunction::RectangleSelector::UpdatePosition,
+ this,
+ rMousePosition,
+ false))))
+ {
+ if (mrSlideSorter.GetProperties()->IsShowSelection())
+ {
+ mrSlideSorter.GetView().GetOverlay().GetSelectionRectangleOverlay()
+ ->Update(aMouseModelPosition);
+ ProcessRectangleSelection();
+ }
+ }
}
-void SelectionFunction::InsertionIndicatorHandler::Start (const Point& rMouseModelPosition)
+void SelectionFunction::RectangleSelector::SetSelectionModeFromModifier (
+ const sal_uInt32 nEventCode)
{
- if (mrSlideSorter.GetController().GetProperties()->IsUIReadOnly())
- return;
+ switch (nEventCode & MODIFIER_MASK)
+ {
+ case NO_MODIFIER:
+ SetSelectionMode(RectangleSelector::SM_Normal);
+ break;
- view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetInsertionIndicatorOverlay().SetPosition(rMouseModelPosition);
- rOverlay.GetInsertionIndicatorOverlay().setVisible(true);
+ case SHIFT_MODIFIER:
+ SetSelectionMode(RectangleSelector::SM_Add);
+ break;
+
+ case CONTROL_MODIFIER:
+ SetSelectionMode(RectangleSelector::SM_Toggle);
+ break;
+ }
}
-void SelectionFunction::InsertionIndicatorHandler::UpdatePosition (const Point& rMouseModelPosition)
+void SelectionFunction::RectangleSelector::SetSelectionMode (const SelectionMode eSelectionMode)
{
- if (mrSlideSorter.GetController().GetProperties()->IsUIReadOnly())
+ if (meSelectionMode != eSelectionMode)
+ {
+ meSelectionMode = eSelectionMode;
+ ProcessRectangleSelection();
+ }
+}
+
+
+
+
+void SelectionFunction::RectangleSelector::ProcessRectangleSelection (void)
+{
+ if ( ! mrSlideSorter.GetProperties()->IsShowSelection())
return;
view::ViewOverlay& rOverlay (mrSlideSorter.GetView().GetOverlay());
- rOverlay.GetInsertionIndicatorOverlay().SetPosition(rMouseModelPosition);
-}
+ if (rOverlay.GetSelectionRectangleOverlay()->IsVisible())
+ {
+ mrSlideSorter.GetView().LockRedraw(true);
+ PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
+ // Select all pages whose page object lies completly or partially
+ // inside the selection rectangle.
+ const Rectangle& rSelectionRectangle (
+ rOverlay.GetSelectionRectangleOverlay()->GetSelectionRectangle());
+ model::PageEnumeration aPages (
+ model::PageEnumerationProvider::CreateAllPagesEnumeration(
+ mrSlideSorter.GetModel()));
+ while (aPages.HasMoreElements())
+ {
+ model::SharedPageDescriptor pDescriptor (aPages.GetNextElement());
+ // Determine whether the page object is inside the selection rectangle.
+ Rectangle aPageBox (
+ mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
+ pDescriptor,
+ view::PageObjectLayouter::Preview,
+ view::PageObjectLayouter::WindowCoordinateSystem));
+ const bool bIsPageInSelectionRectangle (rSelectionRectangle.IsOver(aPageBox));
+
+ // Determine whether the page was selected before the rectangle
+ // selection was started.
+ const bool bWasSelected (pDescriptor->HasState(model::PageDescriptor::ST_WasSelected));
+
+ // Combine the two selection states depending on the selection mode.
+ bool bSelect (false);
+ switch(meSelectionMode)
+ {
+ case SM_Normal:
+ bSelect = bIsPageInSelectionRectangle;
+ break;
+
+ case SM_Add:
+ bSelect = bIsPageInSelectionRectangle || bWasSelected;
+ break;
+
+ case SM_Toggle:
+ if (bIsPageInSelectionRectangle)
+ bSelect = !bWasSelected;
+ else
+ bSelect = bWasSelected;
+ break;
+ }
-void SelectionFunction::InsertionIndicatorHandler::End (void)
-{
- mrSlideSorter.GetView().GetOverlay().GetInsertionIndicatorOverlay().setVisible(false);
+ // Set the new selection state.
+ if (bSelect)
+ rSelector.SelectPage(pDescriptor);
+ else
+ rSelector.DeselectPage(pDescriptor);
+ }
+
+ // Rely on auto scrolling to make page objects visible.
+ mrSlideSorter.GetController().GetSelectionManager()->ResetMakeSelectionVisiblePending();
+
+ mrSlideSorter.GetView().LockRedraw(false);
+ }
}
+
+
+
} } } // end of namespace ::sd::slidesorter::controller
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
index 2eac8b757780..83ce65981bce 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx
index d12b485b8d87..e58966079e0c 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlideFunction.cxx
@@ -49,7 +49,7 @@ SlideFunction::SlideFunction (
SfxRequest& rRequest)
: FuPoor (
rSlideSorter.GetViewShell(),
- rSlideSorter.GetView().GetWindow(),
+ rSlideSorter.GetContentWindow().get(),
&rSlideSorter.GetView(),
rSlideSorter.GetModel().GetDocument(),
rRequest)
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index 4aa35f91292f..2dde82c121e1 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/controller/makefile.mk b/sd/source/ui/slidesorter/controller/makefile.mk
index 0eda7ccba22d..be1e56464d59 100644
--- a/sd/source/ui/slidesorter/controller/makefile.mk
+++ b/sd/source/ui/slidesorter/controller/makefile.mk
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
index 8191a18df54e..b4e91acd0dca 100644
--- a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
+++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
index 06dc252f7b96..d1266efae992 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx
new file mode 100644
index 000000000000..7cd27573e72c
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx b/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx
index d96d200d2476..ffcfabcb925f 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsAnimator.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx
new file mode 100644
index 000000000000..514b0ca056a5
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/controller/SlsInsertionIndicatorHandler.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
index e3ae4ef60175..0e1edb0576d7 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
@@ -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);
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx
index 4646726ed9ff..bc5f49b12c8b 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionFunction.hxx
@@ -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;
+
+ /** Remember where the left mouse button was pressed.
+ */
+ sal_Int32 mnButtonDownPageIndex;
+ sal_Int32 mnButtonDownButtonIndex;
+
+ bool mbIsDeselectionPending;
- ::std::auto_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
+ /** 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
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx
index 10b3167af563..665d01a89987 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsSelectionManager.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
index 9922787c42bc..e9c76e68fd35 100644
--- a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
+++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
@@ -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.
diff --git a/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx b/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx
index e04e5c6e6afb..34c092e4b3f8 100644
--- a/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx
+++ b/sd/source/ui/slidesorter/inc/model/SlsPageDescriptor.hxx
@@ -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);
-
- /** Return <TRUE/> when the page object is fully or parially visible. */
- bool IsVisible (void) 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);
+ enum State { ST_Visible, ST_Selected, ST_WasSelected,
+ ST_Focused, ST_MouseOver, ST_Current, ST_Excluded };
- /** 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);
+ bool HasState (const State eState) const;
- /** 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);
-
- view::PageObjectViewObjectContact* GetViewObjectContact (void) const;
-
- void SetViewObjectContact (
- view::PageObjectViewObjectContact* pViewObjectContact);
+ VisualState& GetVisualState (void);
- /** 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;
-
- /** The page object will be destroyed by the page into which it has
- been inserted.
- */
- view::PageObject* mpPageObject;
-
- bool mbIsSelected;
- bool mbIsVisible;
- bool mbIsFocused;
- bool mbIsCurrent;
-
- view::PageObjectViewObjectContact* mpViewObjectContact;
+ bool mbIsSelected : 1;
+ bool mbWasSelected : 1;
+ bool mbIsVisible : 1;
+ bool mbIsFocused : 1;
+ bool mbIsCurrent : 1;
+ bool mbIsMouseOver : 1;
- /// The borders in model coordinates arround the page object.
- SvBorder maModelBorder;
+ Rectangle maBoundingBox;
- /// 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);
diff --git a/sd/source/ui/slidesorter/inc/model/SlsVisualState.hxx b/sd/source/ui/slidesorter/inc/model/SlsVisualState.hxx
new file mode 100644
index 000000000000..b8df8a6688f8
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/model/SlsVisualState.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
index 360ecaba703c..8b927d0c630e 100644
--- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
@@ -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;
};
diff --git a/sd/source/ui/slidesorter/inc/view/SlsILayerPainter.hxx b/sd/source/ui/slidesorter/inc/view/SlsILayerPainter.hxx
new file mode 100644
index 000000000000..2489068ad470
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/view/SlsILayerPainter.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx b/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx
new file mode 100644
index 000000000000..7d5a8e5f21f5
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/view/SlsInsertAnimator.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
index 194f83680f06..b697b157017d 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
@@ -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;
};
diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx
new file mode 100644
index 000000000000..fcd398377b01
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx
new file mode 100644
index 000000000000..b67e6cb3969f
--- /dev/null
+++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx b/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx
index 93798e095871..2e141ad6b9be 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsViewOverlay.hxx
@@ -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,59 +212,34 @@ 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;
-
- 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.
+ // 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.
*/
- 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;
+ bool mbIsBeforePage;
+ ImageList maIcons;
+ Image maIconWithBorder;
+ Image maIcon;
+ Image maMask;
+ void SetPositionAndSize (const Rectangle& rBoundingBox);
};
@@ -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;
};
diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
index 4f21e48cce93..4d449b5c330f 100644
--- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
+++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
@@ -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,50 +373,8 @@ void SlideSorterModel::SynchronizeModelSelection (void)
while (aAllPages.HasMoreElements())
{
SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
- if (pDescriptor->GetPage()->IsSelected())
- pDescriptor->Select ();
- else
- pDescriptor->Deselect ();
- }
-}
-
-
-
-
-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()));
+ pDescriptor->SetState(PageDescriptor::ST_Selected, pDescriptor->GetPage()->IsSelected());
}
- return *mpPageObjectFactory.get();
}
diff --git a/sd/source/ui/slidesorter/model/SlsPageDescriptor.cxx b/sd/source/ui/slidesorter/model/SlsPageDescriptor.cxx
index 5061d44a88a4..2e5e9b08f905 100644
--- a/sd/source/ui/slidesorter/model/SlsPageDescriptor.cxx
+++ b/sd/source/ui/slidesorter/model/SlsPageDescriptor.cxx
@@ -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());
- }
-
- return mpPageObject;
-}
-
-
-
-
-void PageDescriptor::ReleasePageObject (void)
-{
- mpPageObject = NULL;
-}
-
-
+ case ST_Visible:
+ return mbIsVisible;
+ case ST_Selected:
+ return mbIsSelected;
-bool PageDescriptor::IsVisible (void) const
-{
- return mbIsVisible;
-}
-
+ case ST_WasSelected:
+ return mbWasSelected;
+ case ST_Focused:
+ return mbIsFocused;
+ case ST_MouseOver:
+ return mbIsMouseOver;
-void PageDescriptor::SetVisible (bool bIsVisible)
-{
- mbIsVisible = bIsVisible;
-}
-
+ case ST_Current:
+ return mbIsCurrent;
+ case ST_Excluded:
+ return mpPage!=NULL && mpPage->IsExcluded();
-
-bool PageDescriptor::Select (void)
-{
- if ( ! IsSelected())
- {
- mbIsSelected = true;
- return true;
+ default:
+ OSL_ASSERT(false);
+ return false;
}
- else
- return false;
}
-bool PageDescriptor::Deselect (void)
+bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
{
- if (IsSelected())
+ bool bModified (false);
+ switch (eState)
{
- mbIsSelected = false;
- return true;
+ 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;
}
- else
- return false;
+
+ if (bModified)
+ maVisualState.UpdateVisualState(*this);
+ return bModified;
}
-bool PageDescriptor::IsSelected (void) const
+VisualState& PageDescriptor::GetVisualState (void)
{
- 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
-{
- return mbIsFocused;
-}
-
-
-
-
-void PageDescriptor::SetFocus (void)
-{
- mbIsFocused = true;
-}
-
-
-
-
-void PageDescriptor::RemoveFocus (void)
-{
- 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
+Rectangle PageDescriptor::GetBoundingBox (void) const
{
- return maPageNumberAreaModelSize;
+ Rectangle aBox (maBoundingBox);
+ const Point aOffset (maVisualState.GetLocationOffset());
+ aBox.Move(aOffset.X(), aOffset.Y());
+ return aBox;
}
-bool PageDescriptor::IsCurrentPage (void) const
+Point PageDescriptor::GetLocation (void) const
{
- return mbIsCurrent;
+ return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
}
-void PageDescriptor::SetIsCurrentPage (const bool bIsCurrent)
+void PageDescriptor::SetBoundingBox (const Rectangle& rBoundingBox)
{
- mbIsCurrent = bIsCurrent;
+ maBoundingBox = rBoundingBox;
}
diff --git a/sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx b/sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx
index e6e3b89b12d5..e860beeb6c23 100644
--- a/sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx
+++ b/sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx
@@ -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);
}
};
diff --git a/sd/source/ui/slidesorter/model/SlsVisualState.cxx b/sd/source/ui/slidesorter/model/SlsVisualState.cxx
new file mode 100644
index 000000000000..d6b3deecea5b
--- /dev/null
+++ b/sd/source/ui/slidesorter/model/SlsVisualState.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/model/makefile.mk b/sd/source/ui/slidesorter/model/makefile.mk
index 653e437be91b..bff5d8aeaddf 100644
--- a/sd/source/ui/slidesorter/model/makefile.mk
+++ b/sd/source/ui/slidesorter/model/makefile.mk
@@ -50,6 +50,7 @@ SLOFILES = \
$(SLO)$/SlsPageDescriptor.obj \
$(SLO)$/SlsPageEnumeration.obj \
$(SLO)$/SlsPageEnumerationProvider.obj \
+ $(SLO)$/SlsVisualState.obj \
$(SLO)$/SlideSorterModel.obj
EXCEPTIONSFILES=
diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
index 9d0dbae862fa..4d8943ddd7e3 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
@@ -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 {
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
index 75b7d23db43f..272a85b3f391 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
@@ -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);
}
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index 0a04a236511c..194cf0f0ab83 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -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);
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index e877b41d3738..f21063a1057c 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -37,20 +37,22 @@
#include "SlideSorterViewShell.hxx"
#include "ViewShell.hxx"
#include "SlsViewCacheContext.hxx"
+#include "SlsLayeredDevice.hxx"
#include "view/SlsLayouter.hxx"
+#include "view/SlsPageObjectLayouter.hxx"
+#include "view/SlsPageObjectPainter.hxx"
#include "view/SlsViewOverlay.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
+#include "view/SlsILayerPainter.hxx"
#include "controller/SlideSorterController.hxx"
-#include "controller/SlsPageObjectFactory.hxx"
#include "controller/SlsProperties.hxx"
+#include "controller/SlsAnimator.hxx"
+#include "controller/SlsAnimationFunction.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageEnumerationProvider.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "cache/SlsPageCache.hxx"
#include "cache/SlsPageCacheManager.hxx"
#include "cache/SlsCacheContext.hxx"
-#include "view/SlsPageObject.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
#include "taskpane/SlideSorterCacheDisplay.hxx"
#include "DrawDocShell.hxx"
@@ -70,21 +72,243 @@
#include <tools/poly.hxx>
#include <vcl/lineinfo.hxx>
#include <algorithm>
-#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
#include <svx/sdrpagewindow.hxx>
+#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx>
#include <svl/itempool.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
+#include <boost/bind.hpp>
-#ifndef _SFXITEMPOOL_HXX
-#include <svl/itempool.hxx>
-#endif
using namespace std;
using namespace ::sd::slidesorter::model;
+using namespace ::drawinglayer::primitive2d;
+
+using ::sd::slidesorter::controller::Animator;
+using ::sd::slidesorter::controller::AnimationFunction;
+
+//#define VERBOSE
namespace sd { namespace slidesorter { namespace view {
-TYPEINIT1(SlideSorterView, ::sd::View);
+/** Wrapper around the SlideSorterView that supports the IPainter interface
+ and that allows the LayeredDevice to hold the SlideSorterView (held as
+ scoped_ptr by the SlideSorter) as shared_ptr.
+*/
+class Painter : public ILayerPainter
+{
+public:
+ Painter (SlideSorterView& rView) : mrView(rView) {}
+ virtual ~Painter (void) {}
+
+ virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea)
+ {
+ mrView.Paint(rDevice,rRepaintArea);
+ }
+ virtual void SetLayerInvalidator (const SharedILayerInvalidator&)
+ {
+ }
+
+private:
+ SlideSorterView& mrView;
+};
+
+class AnimatedSphere
+{
+public:
+ AnimatedSphere (
+ const Size& rWindowSize,
+ const double nStartTime)
+ : mnCenterX(rand() * rWindowSize.Width() / RAND_MAX),
+ mnCenterY(rand() * rWindowSize.Height() / RAND_MAX),
+ mnStartRadius(10),
+ mnEndRadius(rand() * 150 / RAND_MAX),
+ maColor(GetColor()),
+ mnLocalTime(-nStartTime),
+ mnValue(0),
+ mnStartTime(nStartTime)
+ {
+ }
+
+ void SetTime (const double nTime)
+ {
+ mnLocalTime = nTime - mnStartTime;
+ if (mnLocalTime >= 0 && mnLocalTime <= 1)
+ mnValue = controller::AnimationFunction::SlowInSlowOut_0to0_Sine(mnLocalTime);
+ else
+ mnValue = 0;
+ }
+
+ bool IsExpired (void)
+ {
+ return mnLocalTime >= 1.0;
+ }
+
+ Rectangle GetBoundingBox (void)
+ {
+ if (mnLocalTime < 0)
+ return Rectangle();
+
+ const double nRadius (mnStartRadius*(1-mnValue) + mnEndRadius*mnValue);
+ const sal_Int32 nIntRadius (ceil(nRadius)+1);
+ return Rectangle(
+ mnCenterX-nIntRadius,
+ mnCenterY-nIntRadius,
+ mnCenterX+nIntRadius,
+ mnCenterY+nIntRadius);
+ }
+
+ void Paint (OutputDevice& rDevice)
+ {
+ if (mnLocalTime < 0)
+ return;
+
+ rDevice.SetFillColor(maColor);
+ rDevice.SetLineColor();
+
+ const Rectangle aBox (GetBoundingBox());
+ const USHORT nSavedAntialiasingMode (rDevice.GetAntialiasing());
+ rDevice.SetAntialiasing(nSavedAntialiasingMode | ANTIALIASING_ENABLE_B2DDRAW);
+ rDevice.DrawPolygon(
+ ::basegfx::tools::createPolygonFromRect(
+ ::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right(), aBox.Bottom()),
+ 1.0,
+ 1.0));
+ rDevice.SetAntialiasing(nSavedAntialiasingMode);
+ }
+
+private:
+ const sal_Int32 mnCenterX;
+ const sal_Int32 mnCenterY;
+ const double mnStartRadius;
+ const double mnEndRadius;
+ const Color maColor;
+ double mnLocalTime;
+ double mnValue;
+ const double mnStartTime;
+
+ static Color GetColor (void)
+ {
+ Color aColor;
+ do
+ {
+ aColor.SetRed(rand() * 255 / RAND_MAX);
+ aColor.SetGreen(rand() * 255 / RAND_MAX);
+ aColor.SetBlue(rand() * 255 / RAND_MAX);
+ }
+ while (aColor.GetGreen()<=aColor.GetRed() || aColor.GetGreen()<=aColor.GetBlue());
+ return aColor;
+ }
+};
+
+class BackgroundPainter
+ : public ILayerPainter,
+ public ::boost::noncopyable
+{
+public:
+ BackgroundPainter (
+ const ::boost::shared_ptr<controller::Animator>& rpAnimator,
+ const ::boost::shared_ptr< ::Window>& rpWindow,
+ const Color aBackgroundColor,
+ const bool bIsAnimated)
+ : mpAnimator(rpAnimator),
+ mnAnimationId(controller::Animator::NotAnAnimationId),
+ maBackgroundColor(aBackgroundColor),
+ maSpheres(),
+ mpInvalidator(),
+ mpWindow(rpWindow)
+ {
+ if (bIsAnimated)
+ {
+ mnAnimationId = mpAnimator->AddInfiniteAnimation(::boost::ref(*this), 0.01);
+
+ for (sal_Int32 nIndex=0; nIndex<10; ++nIndex)
+ maSpheres.push_back(::boost::shared_ptr<AnimatedSphere>(
+ new AnimatedSphere(rpWindow->GetSizePixel(), nIndex*0.3)));
+ }
+ }
+
+ ~BackgroundPainter (void)
+ {
+ mpAnimator->RemoveAnimation(mnAnimationId);
+ }
+
+ virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea)
+ {
+ rDevice.SetFillColor(maBackgroundColor);
+ rDevice.SetLineColor();
+ rDevice.DrawRect(rRepaintArea);
+
+ for (SphereVector::const_iterator
+ iSphere(maSpheres.begin()),
+ iEnd(maSpheres.end());
+ iSphere!=iEnd;
+ ++iSphere)
+ {
+ if (rRepaintArea.IsOver((*iSphere)->GetBoundingBox()))
+ (*iSphere)->Paint(rDevice);
+ }
+ }
+
+ virtual void SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator)
+ {
+ Invalidate();
+ mpInvalidator = rpInvalidator;
+ Invalidate();
+ }
+
+ void operator () (const double nTime)
+ {
+ Invalidate();
+
+ for (SphereVector::iterator
+ iSphere(maSpheres.begin()),
+ iEnd(maSpheres.end());
+ iSphere!=iEnd;
+ ++iSphere)
+ {
+ if ((*iSphere)->IsExpired())
+ (*iSphere).reset(
+ new AnimatedSphere(mpWindow->GetSizePixel(), nTime));
+ else
+ (*iSphere)->SetTime(nTime);
+ }
+
+ Invalidate();
+ }
+
+private:
+ const ::boost::shared_ptr<controller::Animator> mpAnimator;
+ const Color maBackgroundColor;
+ typedef ::std::vector< ::boost::shared_ptr<AnimatedSphere> > SphereVector;
+ SphereVector maSpheres;
+ SharedILayerInvalidator mpInvalidator;
+ ::boost::shared_ptr< ::Window> mpWindow;
+ controller::Animator::AnimationId mnAnimationId;
+
+ void Invalidate (void)
+ {
+ if (mpInvalidator)
+ for (SphereVector::const_iterator
+ iSphere(maSpheres.begin()),
+ iEnd(maSpheres.end());
+ iSphere!=iEnd;
+ ++iSphere)
+ {
+ mpInvalidator->Invalidate((*iSphere)->GetBoundingBox());
+ }
+ }
+};
+
+
+
+TYPEINIT1(SlideSorterView, ::sd::View);
SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
: ::sd::View (
@@ -93,33 +317,31 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
rSlideSorter.GetViewShell()),
mrSlideSorter(rSlideSorter),
mrModel(rSlideSorter.GetModel()),
- maPageModel(),
- mpPage(new SdrPage(maPageModel)),
- mpLayouter (new Layouter ()),
+ mpLayouter (new Layouter (rSlideSorter.GetContentWindow())),
mbPageObjectVisibilitiesValid (false),
mpPreviewCache(),
- mpViewOverlay (new ViewOverlay(rSlideSorter)),
+ mpLayeredDevice(new LayeredDevice(rSlideSorter.GetContentWindow())),
+ mpViewOverlay (new ViewOverlay(rSlideSorter, mpLayeredDevice)),
mnFirstVisiblePageIndex(0),
mnLastVisiblePageIndex(-1),
mbModelChangedWhileModifyEnabled(true),
maPreviewSize(0,0),
mbPreciousFlagUpdatePending(true),
- maPageNumberAreaModelSize(0,0),
- maModelBorder(),
- meOrientation(VERTICAL)
+ meOrientation(VERTICAL),
+ mpProperties(rSlideSorter.GetProperties()),
+ mpPageUnderMouse(),
+ mnButtonUnderMouse(-1),
+ mpPageObjectPainter()
{
// Hide the page that contains the page objects.
SetPageVisible (FALSE);
- // call FreezeIdRanges() at the pool from the newly constructed SdrModel,
- // else creating SfxItemSets on it will complain
- maPageModel.GetItemPool().FreezeIdRanges();
-
- // add the page to the model (no, this is NOT done by the constructor :-( )
- maPageModel.InsertPage(mpPage);
-
- // show page
- LocalModelHasChanged();
+ // Wrap a shared_ptr held wrapper around this view and register it as
+ // painter at the layered device. There is no explicit destruction: in
+ // the SlideSorterView destructor the layered device is destroyed and
+ // with it the only reference to the wrapper which therefore is also
+ // destroyed.
+ mpLayeredDevice->RegisterPainter(SharedILayerPainter(new Painter(*this)), 1);
}
@@ -127,20 +349,8 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
SlideSorterView::~SlideSorterView (void)
{
- // Inform the contact objects to disconnect from the preview cache.
- // Otherwise each dying contact object invalidates its preview. When
- // the previews are kept for a later re-use than this invalidation is
- // not wanted.
- ::boost::shared_ptr<cache::PageCache> pEmptyCache;
- model::PageEnumeration aPageEnumeration (
- model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
- while (aPageEnumeration.HasMoreElements())
- {
- view::PageObjectViewObjectContact* pContact
- = aPageEnumeration.GetNextElement()->GetViewObjectContact();
- if (pContact != NULL)
- pContact->SetCache(pEmptyCache);
- }
+ mpLayeredDevice->Dispose();
+
mpPreviewCache.reset();
// hide the page to avoid problems in the view when deleting
@@ -149,6 +359,19 @@ SlideSorterView::~SlideSorterView (void)
// Deletion of the objects and the page will be done in SdrModel
// destructor (as long as objects and pages are added)
+
+ OSL_ASSERT(mpViewOverlay.unique());
+ mpViewOverlay.reset();
+
+ OSL_ASSERT(mpLayeredDevice.unique());
+ mpLayeredDevice.reset();
+}
+
+
+
+
+void SlideSorterView::Dispose (void)
+{
}
@@ -158,8 +381,8 @@ sal_Int32 SlideSorterView::GetPageIndexAtPoint (const Point& rPosition) const
{
sal_Int32 nIndex (-1);
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
{
nIndex = mpLayouter->GetIndexAtPoint (pWindow->PixelToLogic (rPosition));
@@ -179,8 +402,8 @@ sal_Int32 SlideSorterView::GetFadePageIndexAtPoint (
{
sal_Int32 nIndex (-1);
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
{
Point aModelPosition (pWindow->PixelToLogic (rPosition));
nIndex = mpLayouter->GetIndexAtPoint(
@@ -196,20 +419,13 @@ sal_Int32 SlideSorterView::GetFadePageIndexAtPoint (
{
// Now test whether the given position is inside the area of the
// fade effect indicator.
- view::PageObjectViewObjectContact* pContact
- = mrModel.GetPageDescriptor(nIndex)->GetViewObjectContact();
- if (pContact != NULL)
- {
- if ( ! pContact->GetBoundingBox(
- *pWindow,
- PageObjectViewObjectContact::FadeEffectIndicatorBoundingBox,
- PageObjectViewObjectContact::ModelCoordinateSystem).IsInside (
- aModelPosition))
- {
- nIndex = -1;
- }
- }
- else
+ const Rectangle aBox (
+ mpLayouter->GetPageObjectLayouter()->GetBoundingBox(
+ mrModel.GetPageDescriptor(nIndex),
+ PageObjectLayouter::TransitionEffectIndicator,
+ PageObjectLayouter::WindowCoordinateSystem));
+ const Point aPoint (aModelPosition.getX(), aModelPosition.getY());
+ if ( ! aBox.IsInside(aPoint))
nIndex = -1;
}
}
@@ -230,12 +446,16 @@ Layouter& SlideSorterView::GetLayouter (void)
void SlideSorterView::ModelHasChanged (void)
{
+ // Ignore this call. Rely on hints sent by the model to get informed of
+ // model changes.
+ /*
if (mbModelChangedWhileModifyEnabled)
{
controller::SlideSorterController::ModelChangeLock alock( mrSlideSorter.GetController() );
mrSlideSorter.GetController().HandleModelChange();
LocalModelHasChanged();
}
+ */
}
@@ -248,15 +468,10 @@ void SlideSorterView::LocalModelHasChanged(void)
// First call our base class.
View::ModelHasChanged ();
- // Then re-set the page as current page that contains the page objects.
- ShowSdrPage(mpPage);
-
// Initialize everything that depends on a page view, now that we have
// one.
// SetApplicationDocumentColor(
// Application::GetSettings().GetStyleSettings().GetWindowColor());
-
- UpdatePageBorders();
}
@@ -266,17 +481,7 @@ void SlideSorterView::PreModelChange (void)
{
// Reset the slide under the mouse. It will be set to the correct slide
// on the next mouse motion.
- GetOverlay().GetMouseOverIndicatorOverlay().SetSlideUnderMouse(SharedPageDescriptor());
-
- // Tell the page descriptors of the model that the page objects do not
- // exist anymore.
- model::PageEnumeration aPageEnumeration (
- model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
- while (aPageEnumeration.HasMoreElements())
- aPageEnumeration.GetNextElement()->ReleasePageObject();
-
- // Remove all page objects from the page.
- mpPage->Clear();
+ SetPageUnderMouse(SharedPageDescriptor());
}
@@ -290,13 +495,6 @@ void SlideSorterView::PostModelChange (void)
model::PageEnumeration aPageEnumeration (
model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
- UpdatePageBorders();
- while (aPageEnumeration.HasMoreElements())
- {
- SdrPageObj* pPageObject = aPageEnumeration.GetNextElement()->GetPageObject();
- if (pPageObject != NULL)
- AddSdrObject(*pPageObject);
- }
// The new page objects have to be scaled and positioned.
Layout ();
@@ -321,18 +519,11 @@ void SlideSorterView::HandleModelChange (void)
void SlideSorterView::HandleDrawModeChange (void)
{
- UpdatePageBorders();
-
// Replace the preview cache with a new and empty one. The
// PreviewRenderer that is used by the cache is replaced by this as
// well.
mpPreviewCache.reset();
GetPreviewCache()->InvalidateCache(true);
- mrModel.SetPageObjectFactory(
- ::std::auto_ptr<controller::PageObjectFactory>(
- new controller::PageObjectFactory(
- GetPreviewCache(),
- mrSlideSorter.GetController().GetProperties())));
RequestRepaint();
}
@@ -342,17 +533,25 @@ void SlideSorterView::HandleDrawModeChange (void)
void SlideSorterView::Resize (void)
{
- ::sd::Window* pWindow = GetWindow();
- if (mrModel.GetPageCount()>0 && pWindow != NULL)
+ if ( ! mpLayeredDevice->HasPainter(0))
+ mpLayeredDevice->RegisterPainter(
+ SharedILayerPainter(new BackgroundPainter(
+ mrSlideSorter.GetController().GetAnimator(),
+ mrSlideSorter.GetContentWindow(),
+ Color(0xf9fafa),//mpProperties->GetBackgroundColor(),
+ false)),
+ 0);
+
+ mpLayeredDevice->Resize();
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (mrModel.GetPageCount()>0 && pWindow)
{
- UpdatePageBorders();
bool bRearrangeSuccess (false);
if (meOrientation == HORIZONTAL)
{
bRearrangeSuccess = mpLayouter->RearrangeHorizontal (
pWindow->GetSizePixel(),
mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- pWindow,
mrModel.GetPageCount());
}
else
@@ -360,13 +559,12 @@ void SlideSorterView::Resize (void)
bRearrangeSuccess = mpLayouter->RearrangeVertical (
pWindow->GetSizePixel(),
mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- pWindow);
+ mrModel.GetPageCount());
}
if (bRearrangeSuccess)
{
Layout();
- pWindow->Invalidate();
}
}
}
@@ -376,38 +574,36 @@ void SlideSorterView::Resize (void)
void SlideSorterView::Layout ()
{
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ const ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
{
// Set the model area, i.e. the smallest rectangle that includes all
// page objects.
- Rectangle aViewBox (mpLayouter->GetPageBox(mrModel.GetPageCount()));
+ const Rectangle aViewBox (mpLayouter->GetPageBox(mrModel.GetPageCount()));
pWindow->SetViewOrigin (aViewBox.TopLeft());
pWindow->SetViewSize (aViewBox.GetSize());
- Size aPageObjectPixelSize (pWindow->LogicToPixel(mpLayouter->GetPageObjectSize()));
- if (maPreviewSize != aPageObjectPixelSize && mpPreviewCache.get()!=NULL)
+ ::boost::shared_ptr<PageObjectLayouter> pPageObjectLayouter(
+ mpLayouter->GetPageObjectLayouter());
+ if (pPageObjectLayouter)
{
- mpPreviewCache->ChangeSize(aPageObjectPixelSize);
- maPreviewSize = aPageObjectPixelSize;
+ const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetPreviewSize());
+ if (maPreviewSize != aNewPreviewSize && GetPreviewCache())
+ {
+ mpPreviewCache->ChangeSize(aNewPreviewSize, false);
+ maPreviewSize = aNewPreviewSize;
+ }
}
// Iterate over all page objects and place them relative to the
// containing page.
model::PageEnumeration aPageEnumeration (
model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
- int nIndex = 0;
while (aPageEnumeration.HasMoreElements())
{
model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
- SdrPageObj* pPageObject = pDescriptor->GetPageObject();
- Rectangle aPageObjectBox (mpLayouter->GetPageObjectBox (nIndex));
- pPageObject->SetSnapRect(aPageObjectBox);
-
- nIndex += 1;
+ pDescriptor->SetBoundingBox(mpLayouter->GetPageObjectBox(pDescriptor->GetPageIndex()));
}
- // Set the page so that it encloses all page objects.
- mpPage->SetSize (aViewBox.GetSize());
}
InvalidatePageObjectVisibilities ();
@@ -426,52 +622,33 @@ void SlideSorterView::InvalidatePageObjectVisibilities (void)
void SlideSorterView::DeterminePageObjectVisibilities (void)
{
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
{
// Set this flag to true here so that an invalidate during the
// visibility calculation can correctly invalidate it again.
mbPageObjectVisibilitiesValid = true;
- Rectangle aViewArea (
- Point(0,0),
- pWindow->GetSizePixel());
- aViewArea = pWindow->PixelToLogic (aViewArea);
- int nFirstIndex =
- mpLayouter->GetIndexOfFirstVisiblePageObject (aViewArea);
- int nLastIndex =
- mpLayouter->GetIndexOfLastVisiblePageObject (aViewArea);
+ Rectangle aViewArea (pWindow->PixelToLogic(Rectangle(Point(0,0),pWindow->GetSizePixel())));
+ const int nFirstIndex (mpLayouter->GetIndexOfFirstVisiblePageObject(aViewArea));
+ const int nLastIndex (mpLayouter->GetIndexOfLastVisiblePageObject(aViewArea));
+ const int nMinIndex (::std::min (mnFirstVisiblePageIndex, nFirstIndex));
+ const int nMaxIndex (::std::max (mnLastVisiblePageIndex, nLastIndex));
// For page objects that just dropped off the visible area we
// decrease the priority of pending requests for preview bitmaps.
-
- int nMinIndex = ::std::min (mnFirstVisiblePageIndex, nFirstIndex);
- int nMaxIndex = ::std::max (mnLastVisiblePageIndex, nLastIndex);
if (mnFirstVisiblePageIndex!=nFirstIndex || mnLastVisiblePageIndex!=nLastIndex)
mbPreciousFlagUpdatePending |= true;
+
model::SharedPageDescriptor pDescriptor;
- view::PageObjectViewObjectContact* pContact;
for (int nIndex=nMinIndex; nIndex<=nMaxIndex; nIndex++)
{
- // Determine the visibility before and after the change so that
- // we can handle the page objects for which the visibility has
- // changed.
- bool bWasVisible = nIndex>=mnFirstVisiblePageIndex
- && nIndex<=mnLastVisiblePageIndex;
- bool bIsVisible = nIndex>=nFirstIndex && nIndex<=nLastIndex;
-
- // Get the view-object-contact.
- if (bWasVisible != bIsVisible)
- {
- pContact = NULL;
- pDescriptor = mrModel.GetPageDescriptor(nIndex);
- if (pDescriptor.get() != NULL)
- pContact = pDescriptor->GetViewObjectContact();
-
- if (pDescriptor.get() != NULL)
- pDescriptor->SetVisible (bIsVisible);
- }
-
+ pDescriptor = mrModel.GetPageDescriptor(nIndex);
+ if (pDescriptor.get() != NULL)
+ SetState(
+ pDescriptor,
+ PageDescriptor::ST_Visible,
+ nIndex>=nFirstIndex && nIndex<=nLastIndex);
}
mnFirstVisiblePageIndex = nFirstIndex;
mnLastVisiblePageIndex = nLastIndex;
@@ -535,9 +712,15 @@ SlideSorterView::Orientation SlideSorterView::GetOrientation (void) const
void SlideSorterView::RequestRepaint (void)
{
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
+ {
pWindow->Invalidate();
+ mpLayeredDevice->InvalidateAllLayers(
+ Rectangle(
+ pWindow->PixelToLogic(Point(0,0)),
+ pWindow->PixelToLogic(pWindow->GetSizePixel())));
+ }
}
@@ -545,157 +728,106 @@ void SlideSorterView::RequestRepaint (void)
void SlideSorterView::RequestRepaint (const model::SharedPageDescriptor& rpDescriptor)
{
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
- pWindow->Invalidate(
- GetPageBoundingBox (
- rpDescriptor,
- CS_MODEL,
- BBT_INFO));
-}
-
-
-
-
-Rectangle SlideSorterView::GetModelArea (void)
-{
- return Rectangle (
- Point (0,0),
- Size (mpPage->GetSize().Width(),mpPage->GetSize().Height()));
+ RequestRepaint(rpDescriptor->GetBoundingBox());
}
-Rectangle SlideSorterView::GetPageBoundingBox (
- const model::SharedPageDescriptor& rpDescriptor,
- CoordinateSystem eCoordinateSystem,
- BoundingBoxType eBoundingBoxType) const
+void SlideSorterView::RequestRepaint (const Rectangle& rRepaintBox)
{
- Rectangle aBBox;
- SdrObject* pPageObject = rpDescriptor->GetPageObject();
- if (pPageObject != NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow)
{
- aBBox = pPageObject->GetCurrentBoundRect();
- AdaptBoundingBox (aBBox, eCoordinateSystem, eBoundingBoxType);
+ pWindow->Invalidate(rRepaintBox);
+ mpLayeredDevice->InvalidateAllLayers(rRepaintBox);
}
-
- return aBBox;
}
-Rectangle SlideSorterView::GetPageBoundingBox (
- sal_Int32 nIndex,
- CoordinateSystem eCoordinateSystem,
- BoundingBoxType eBoundingBoxType) const
+Rectangle SlideSorterView::GetModelArea (void)
{
- Rectangle aBBox;
- if (nIndex >= 0 && nIndex<mrModel.GetPageCount())
- {
- aBBox = mpLayouter->GetPageObjectBox(nIndex);
- AdaptBoundingBox (aBBox, eCoordinateSystem, eBoundingBoxType);
- }
-
- return aBBox;
+ return mpLayouter->GetPageBox(mrModel.GetPageCount());
}
+static sal_Int32 nPaintIndex = 0;
-
-void SlideSorterView::CompleteRedraw(OutputDevice* pDevice, const Region& rPaintArea, sdr::contact::ViewObjectContactRedirector* pRedirector)
+void SlideSorterView::CompleteRedraw (
+ OutputDevice* pDevice,
+ const Region& rPaintArea,
+ sdr::contact::ViewObjectContactRedirector* pRedirector)
{
+ if (pDevice == NULL || pDevice!=mrSlideSorter.GetContentWindow().get())
+ return;
+
+ // The parent implementation of CompleteRedraw is called only when
+ // painting is locked. We do all the painting ourself. When painting
+ // is locked the parent implementation keeps track of the repaint
+ // requests and later, when painting is unlocked, calls CompleteRedraw
+ // for all missed repaints.
+
if (mnLockRedrawSmph == 0)
{
- // Update the page visibilities when they have been invalidated.
- if ( ! mbPageObjectVisibilitiesValid)
- DeterminePageObjectVisibilities();
+#ifdef VERBOSE
+ OSL_TRACE("%5d CompleteRedraw %d %d %d %d",
+ nPaintIndex++,
+ rPaintArea.GetBoundRect().Left(),
+ rPaintArea.GetBoundRect().Top(),
+ rPaintArea.GetBoundRect().GetWidth(),
+ rPaintArea.GetBoundRect().GetHeight());
+#endif
- if (mbPreciousFlagUpdatePending)
- UpdatePreciousFlags();
+ mrSlideSorter.GetContentWindow()->IncrementLockCount();
+ mpLayeredDevice->Repaint(rPaintArea);
+ mrSlideSorter.GetContentWindow()->DecrementLockCount();
- // Call the base class InitRedraw even when re-drawing is locked to
- // let it remember the request for a redraw.
- View::CompleteRedraw (pDevice, rPaintArea, pRedirector);
+#ifdef VERBOSE
+ OSL_TRACE("CompleteRedraw done");
+#endif
}
else
{
- // In sd::View::CompleteRedraw() this call is recorded and given
- // region is painted when the view is unlocked.
- View::CompleteRedraw (pDevice, rPaintArea, pRedirector);
+#ifdef VERBOSE
+ OSL_TRACE("%5d CompleteRedraw while locked", nPaintIndex++);
+#endif
+ View::CompleteRedraw(pDevice, rPaintArea, pRedirector);
}
}
-void SlideSorterView::InvalidateOneWin (::Window& rWindow)
+void SlideSorterView::Paint (
+ OutputDevice& rDevice,
+ const Rectangle& rRepaintArea)
{
- // if ( IsInvalidateAllowed() )
- View::InvalidateOneWin (rWindow);
-}
-
-
-
-
-void SlideSorterView::InvalidateOneWin (
- ::Window& rWindow,
- const Rectangle& rPaintArea)
-{
- // if( IsInvalidateAllowed() )
- View::InvalidateOneWin (rWindow, rPaintArea);
-}
-
-
-
-
-::sd::Window* SlideSorterView::GetWindow (void) const
-{
- return static_cast< ::sd::Window*>(GetFirstOutputDevice());
-}
-
-
+ if ( ! mpPageObjectPainter)
+ if ( ! GetPageObjectPainter())
+ return;
+ // Update the page visibilities when they have been invalidated.
+ if ( ! mbPageObjectVisibilitiesValid)
+ DeterminePageObjectVisibilities();
-void SlideSorterView::AdaptBoundingBox (
- Rectangle& rModelPageObjectBoundingBox,
- CoordinateSystem eCoordinateSystem,
- BoundingBoxType eBoundingBoxType) const
-{
- CoordinateSystem aCurrentCoordinateSystem = CS_MODEL;
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL)
+ if (mbPreciousFlagUpdatePending)
+ UpdatePreciousFlags();
+
+ // Paint all page objects that are fully or partially inside the
+ // repaint region.
+ sal_Int32 nFirst (mpLayouter->GetIndexOfFirstVisiblePageObject(rRepaintArea));
+ sal_Int32 nLast (std::min(
+ mpLayouter->GetIndexOfLastVisiblePageObject(rRepaintArea),
+ mrModel.GetPageCount()));
+ for (sal_Int32 nIndex=nFirst; nIndex<=nLast; ++nIndex)
{
- if (eBoundingBoxType == BBT_INFO)
- {
- // Make the box larger so that it encloses all relevant
- // displayed information.
- if (aCurrentCoordinateSystem == CS_MODEL)
- {
- // The relevant offsets are given in pixel values. Therefore
- // transform the box first into screen coordinates.
- rModelPageObjectBoundingBox
- = pWindow->LogicToPixel (rModelPageObjectBoundingBox);
- aCurrentCoordinateSystem = CS_SCREEN;
- }
- rModelPageObjectBoundingBox.Left() -= maPagePixelBorder.Left();
- rModelPageObjectBoundingBox.Right() += maPagePixelBorder.Right();
- rModelPageObjectBoundingBox.Top() -= maPagePixelBorder.Top();
- rModelPageObjectBoundingBox.Bottom() += maPagePixelBorder.Bottom();
- }
+ model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex));
+ if (!pDescriptor || ! pDescriptor->HasState(PageDescriptor::ST_Visible))
+ continue;
- // Make sure that the bounding box is given in the correct coordinate
- // system.
- if (eCoordinateSystem != aCurrentCoordinateSystem)
- {
- if (eCoordinateSystem == CS_MODEL)
- rModelPageObjectBoundingBox
- = pWindow->PixelToLogic (rModelPageObjectBoundingBox);
- else
- rModelPageObjectBoundingBox
- = pWindow->LogicToPixel (rModelPageObjectBoundingBox);
- }
+ mpPageObjectPainter->PaintPageObject(rDevice, pDescriptor);
}
}
@@ -704,14 +836,14 @@ void SlideSorterView::AdaptBoundingBox (
::boost::shared_ptr<cache::PageCache> SlideSorterView::GetPreviewCache (void)
{
- ::sd::Window* pWindow = GetWindow();
- if (pWindow != NULL && mpPreviewCache.get() == NULL)
+ ::boost::shared_ptr<sd::Window> pWindow (mrSlideSorter.GetContentWindow());
+ if (pWindow && mpPreviewCache.get() == NULL)
{
- maPreviewSize = pWindow->LogicToPixel(mpLayouter->GetPageObjectSize());
mpPreviewCache.reset(
new cache::PageCache(
- maPreviewSize,
- cache::SharedCacheContext(new ViewCacheContext(mrSlideSorter.GetModel(), *this))));
+ mpLayouter->GetPageObjectSize(),
+ false,
+ cache::SharedCacheContext(new ViewCacheContext(mrSlideSorter))));
}
return mpPreviewCache;
@@ -728,14 +860,6 @@ ViewOverlay& SlideSorterView::GetOverlay (void)
-::sdr::contact::ObjectContact& SlideSorterView::GetObjectContact (void) const
-{
- return GetSdrPageView()->GetPageWindow(0)->GetObjectContact();
-}
-
-
-
-
SlideSorterView::PageRange SlideSorterView::GetVisiblePageRange (void)
{
const int nMaxPageIndex (mrModel.GetPageCount() - 1);
@@ -761,89 +885,151 @@ void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint
-void SlideSorterView::UpdatePageBorders (void)
+void SlideSorterView::LockRedraw (const bool bLock)
{
- maPagePixelBorder = SvBorder();
- ::sd::Window* pWindow = GetWindow();
- if (mrModel.GetPageCount()>0 && pWindow!=NULL)
- {
- // Calculate the border in model coordinates.
- maPageNumberAreaModelSize = PageObjectViewObjectContact::CalculatePageNumberAreaModelSize (
- pWindow,
- mrModel.GetPageCount());
- maModelBorder = PageObjectViewObjectContact::CalculatePageModelBorder (
- pWindow,
- mrModel.GetPageCount());
+ ::sd::View::LockRedraw(bLock ? TRUE : FALSE);
+}
- // Depending on values in the global properties the border has to be
- // extended a little bit.
- ::boost::shared_ptr<controller::Properties> pProperties(
- mrSlideSorter.GetController().GetProperties());
- if (pProperties.get()!=NULL && pProperties->IsHighlightCurrentSlide())
- {
- Size aBorderSize (pWindow->PixelToLogic (Size(3,3)));
- maModelBorder.Left() += aBorderSize.Width();
- maModelBorder.Right() += aBorderSize.Width();
- maModelBorder.Top() += aBorderSize.Height();
- maModelBorder.Bottom() += aBorderSize.Height();
- }
- // Set the border at all page descriptors so that the contact
- // objects have access to them.
- model::PageEnumeration aPageEnumeration (
- model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
- while (aPageEnumeration.HasMoreElements())
+
+
+void SlideSorterView::SetPageUnderMouse (const model::SharedPageDescriptor& rpDescriptor)
+{
+ if (mpPageUnderMouse != rpDescriptor)
+ {
+ if (mpPageUnderMouse)
{
- model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
- pDescriptor->SetModelBorder(maModelBorder);
- pDescriptor->SetPageNumberAreaModelSize(maPageNumberAreaModelSize);
+ mpPageUnderMouse->GetVisualState().SetActiveButtonState(
+ -1,
+ model::VisualState::BS_Normal);
+ SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false);
}
- // Convert the borders to pixel coordinates and store them for later
- // use.
- Size aTopLeftBorders(pWindow->LogicToPixel(
- Size (maModelBorder.Left(), maModelBorder.Top())));
- Size aBottomRightBorders(pWindow->LogicToPixel(
- Size (maModelBorder.Right(), maModelBorder.Bottom())));
- maPagePixelBorder = SvBorder (
- aTopLeftBorders.Width(),
- aTopLeftBorders.Height(),
- aBottomRightBorders.Width(),
- aBottomRightBorders.Height());
+ mpPageUnderMouse = rpDescriptor;
+ SetButtonUnderMouse(-1);
+
+ if (mpPageUnderMouse)
+ SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true);
}
+}
+
+
+
- // Finally tell the layouter about the borders.
- mpLayouter->SetBorders (2,5,4,5);
- mpLayouter->SetPageBorders (
- maPagePixelBorder.Left(),
- maPagePixelBorder.Right(),
- maPagePixelBorder.Top(),
- maPagePixelBorder.Bottom());
+void SlideSorterView::SetButtonUnderMouse (const sal_Int32 nButtonIndex)
+{
+ if (mnButtonUnderMouse != nButtonIndex)
+ {
+ if (mpPageUnderMouse)
+ {
+ mnButtonUnderMouse = nButtonIndex;
+ mpPageUnderMouse->GetVisualState().SetActiveButtonState(
+ mnButtonUnderMouse,
+ model::VisualState::BS_MouseOver);
+ RequestRepaint(mpPageUnderMouse);
+ }
+ }
}
-Size SlideSorterView::GetPageNumberAreaModelSize (void) const
+void SlideSorterView::AddVisualStateAnimation (const model::SharedPageDescriptor& rpDescriptor)
{
- return maPageNumberAreaModelSize;
+ // Stop a state animation for the given descriptor that is still running.
+ const Animator::AnimationId nId (rpDescriptor->GetVisualState().GetStateAnimationId());
+ if (nId != Animator::NotAnAnimationId)
+ {
+ mrSlideSorter.GetController().GetAnimator()->RemoveAnimation(nId);
+ }
+
+ rpDescriptor->GetVisualState().SetStateAnimationId(
+ mrSlideSorter.GetController().GetAnimator()->AddAnimation(
+ ::boost::bind(
+ controller::AnimationFunction::ApplyVisualStateChange,
+ rpDescriptor,
+ ::boost::ref(*this),
+ ::boost::bind(AnimationFunction::FastInSlowOut_Sine, _1)),
+ 350,
+ ::boost::bind(
+ &VisualState::SetStateAnimationId,
+ ::boost::ref(rpDescriptor->GetVisualState()),
+ controller::Animator::NotAnAnimationId)));
}
-SvBorder SlideSorterView::GetModelBorder (void) const
+bool SlideSorterView::SetState (
+ const model::SharedPageDescriptor& rpDescriptor,
+ const PageDescriptor::State eState,
+ const bool bStateValue)
{
- return maModelBorder;
+ const bool bModified (rpDescriptor->SetState(eState, bStateValue));
+ if ( ! bModified)
+ return false;
+
+ switch(eState)
+ {
+ case PageDescriptor::ST_Visible:
+ RequestRepaint(rpDescriptor);
+ break;
+
+ case PageDescriptor::ST_Selected:
+ case PageDescriptor::ST_Focused:
+ case PageDescriptor::ST_MouseOver:
+ case PageDescriptor::ST_Current:
+ case PageDescriptor::ST_Excluded:
+ AddVisualStateAnimation(rpDescriptor);
+ break;
+ }
+
+ // Fade in or out the buttons.
+ if (eState == PageDescriptor::ST_MouseOver)
+ {
+ // Stop a running animation.
+ const Animator::AnimationId nId (
+ rpDescriptor->GetVisualState().GetButtonAlphaAnimationId());
+ if (nId != Animator::NotAnAnimationId)
+ {
+ mrSlideSorter.GetController().GetAnimator()->RemoveAnimation(nId);
+ }
+
+ const double nStartAlpha (rpDescriptor->GetVisualState().GetButtonAlpha());
+ const double nEndAlpha (bStateValue ? 0.2 : 1.0);
+ const ::boost::function<double(double)> aBlendFunctor (
+ ::boost::bind(
+ AnimationFunction::Blend,
+ nStartAlpha,
+ nEndAlpha,
+ ::boost::bind(AnimationFunction::FastInSlowOut_Root, _1)));
+ rpDescriptor->GetVisualState().SetButtonAlphaAnimationId(
+ mrSlideSorter.GetController().GetAnimator()->AddAnimation(
+ ::boost::bind(
+ AnimationFunction::ApplyButtonAlphaChange,
+ rpDescriptor,
+ ::boost::ref(*this),
+ ::boost::bind(aBlendFunctor, _1)),
+ 400,
+ ::boost::bind(
+ &VisualState::SetButtonAlphaAnimationId,
+ ::boost::ref(rpDescriptor->GetVisualState()),
+ controller::Animator::NotAnAnimationId)
+ ));
+ }
+
+ return bModified;
}
-void SlideSorterView::AddSdrObject (SdrObject& rObject)
+::boost::shared_ptr<PageObjectPainter> SlideSorterView::GetPageObjectPainter (void)
{
- mpPage->InsertObject(&rObject);
- rObject.SetModel(&maPageModel);
+ if ( ! mpPageObjectPainter)
+ mpPageObjectPainter.reset(new PageObjectPainter(mrSlideSorter));
+ return mpPageObjectPainter;
}
+
} } } // end of namespace ::sd::slidesorter::view
diff --git a/sd/source/ui/slidesorter/view/SlsIcons.hrc b/sd/source/ui/slidesorter/view/SlsIcons.hrc
new file mode 100644
index 000000000000..c174252aa7ce
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsIcons.hrc
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsIcons.hxx b/sd/source/ui/slidesorter/view/SlsIcons.hxx
new file mode 100644
index 000000000000..63c4de22584a
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsIcons.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsIcons.src b/sd/source/ui/slidesorter/view/SlsIcons.src
new file mode 100644
index 000000000000..c3f68cde7436
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsIcons.src
@@ -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" ; };
+ };
+
+};
diff --git a/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
new file mode 100644
index 000000000000..3376fc9e0c6c
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx
new file mode 100644
index 000000000000..6b6231fcad69
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
new file mode 100644
index 000000000000..522355ca303e
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsLayouter.cxx b/sd/source/ui/slidesorter/view/SlsLayouter.cxx
index f3d91fff96dd..c2a54b63e8bf 100644
--- a/sd/source/ui/slidesorter/view/SlsLayouter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsLayouter.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx
new file mode 100644
index 000000000000..a517584cea40
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
new file mode 100644
index 000000000000..eae033b817e8
--- /dev/null
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -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
diff --git a/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx b/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx
index b2f4f5874a56..7389887efe1e 100644
--- a/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx
+++ b/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx
@@ -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);
}
diff --git a/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx b/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx
index f6dab2ec8d29..cea0dfadd706 100644
--- a/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx
+++ b/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx
@@ -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);
};
diff --git a/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx b/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx
index 0cad1985ce35..8a82c58111c5 100644
--- a/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx
+++ b/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx
@@ -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,72 +128,84 @@ 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;
+ return mpSubstitutionOverlay;
}
-SubstitutionOverlay& ViewOverlay::GetSubstitutionOverlay (void)
+SlideSorter& ViewOverlay::GetSlideSorter (void) const
{
- return maSubstitutionOverlay;
+ return mrSlideSorter;
}
-SlideSorter& ViewOverlay::GetSlideSorter (void) const
+::boost::shared_ptr<LayeredDevice> ViewOverlay::GetLayeredDevice (void) const
{
- return mrSlideSorter;
+ return mpLayeredDevice;
}
-OverlayManager* ViewOverlay::GetOverlayManager (void) const
+//===== OverlayBase::Invalidator ==============================================
+
+class OverlayBase::Invalidator
{
- OverlayManager* pOverlayManager = NULL;
+public:
+ Invalidator (OverlayBase& rOverlayObject)
+ : mrOverlayObject(rOverlayObject),
+ maOldBoundingBox(rOverlayObject.IsVisible()
+ ? rOverlayObject.GetBoundingBox()
+ : Rectangle())
+ {
+ }
- SlideSorterView& rView (mrSlideSorter.GetView());
- SdrPageView* pPageView = rView.GetSdrPageView();
- if (pPageView != NULL && pPageView->PageWindowCount()>0)
+ ~Invalidator (void)
{
- SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0);
- if (pPageWindow != NULL)
- pOverlayManager = pPageWindow->GetOverlayManager();
+ if ( ! maOldBoundingBox.IsEmpty())
+ mrOverlayObject.Invalidate(maOldBoundingBox);
+ if (mrOverlayObject.IsVisible())
+ mrOverlayObject.Invalidate(mrOverlayObject.GetBoundingBox());
}
- return pOverlayManager;
-}
+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::Invalidate (const Rectangle& rInvalidationBox)
+{
+ if (mpLayerInvalidator)
+ mpLayerInvalidator->Invalidate(rInvalidationBox);
}
-void OverlayBase::RemoveRegistration()
+sal_Int32 OverlayBase::GetLayerIndex (void) const
{
- OverlayManager* pOverlayManager = getOverlayManager();
- if (pOverlayManager != NULL)
- pOverlayManager->remove(*this);
+ 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;
-
- maShapes.clear();
+ maTranslation = Point(0,0);
+
+ ::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,57 +422,58 @@ 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())
- {
- aRetval.realloc(nCount);
- const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
- const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ if ( ! IsVisible())
+ return;
- for(sal_uInt32 a(0); a < nCount; a++)
- {
- aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
- new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
- maShapes.getB2DPolygon(a),
- aRGBColorA,
- aRGBColorB,
- gnSubstitutionStripeLength));
- }
- }
+ basegfx::B2DHomMatrix aTranslation;
+ aTranslation.translate(maTranslation.X(), maTranslation.Y());
- return aRetval;
-}
+ rDevice.SetFillColor(Color(AirForceBlue));
+ rDevice.SetLineColor();
-void SubstitutionOverlay::stripeDefinitionHasChanged()
-{
- // react on OverlayManager's stripe definition change
- objectChange();
+ for (::std::vector<ItemDescriptor>::const_iterator
+ iItem(maItems.begin()),
+ iEnd(maItems.end());
+ iItem!=iEnd;
+ ++iItem)
+ {
+ ::basegfx::B2DPolyPolygon aPolygon (iItem->maShape);
+ aPolygon.transform(aTranslation);
+ rDevice.DrawTransparent(aPolygon, iItem->mnTransparency);
+ rDevice.DrawBitmapEx(iItem->maLocation+maTranslation, iItem->maImage);
+ }
}
-//===== SelectionRectangleOverlay ===========================================
-SelectionRectangleOverlay::SelectionRectangleOverlay (ViewOverlay& rViewOverlay)
- : OverlayBase (rViewOverlay),
- maAnchor(0,0),
- maSecondCorner(0,0)
+
+Rectangle SubstitutionOverlay::GetBoundingBox (void) const
{
+ return maBoundingBox;
}
-SelectionRectangleOverlay::~SelectionRectangleOverlay()
+
+//===== SelectionRectangleOverlay ===========================================
+
+SelectionRectangleOverlay::SelectionRectangleOverlay (
+ ViewOverlay& rViewOverlay,
+ const sal_Int32 nLayerIndex)
+ : OverlayBase (rViewOverlay, nLayerIndex),
+ maAnchor(0,0),
+ maSecondCorner(0,0)
{
- 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,252 +494,111 @@ void SelectionRectangleOverlay::Start (const Point& rAnchor)
void SelectionRectangleOverlay::Update (const Point& rSecondCorner)
{
- maSecondCorner = rSecondCorner;
- setVisible(true);
- // The selection rectangle may have been visible already so call
- // objectChange() to enforce an update.
- objectChange();
-}
-
-
-
-
-drawinglayer::primitive2d::Primitive2DSequence SelectionRectangleOverlay::createOverlayObjectPrimitive2DSequence()
-{
- 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(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));
-
- aRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
- }
+ Invalidator aInvalidator (*this);
- return aRetval;
-}
-
-void SelectionRectangleOverlay::stripeDefinitionHasChanged()
-{
- // react on OverlayManager's stripe definition change
- objectChange();
-}
-
-
-
-
-//===== InsertionIndicatorOverlay ===========================================
-
-InsertionIndicatorOverlay::InsertionIndicatorOverlay (ViewOverlay& rViewOverlay)
- : OverlayBase (rViewOverlay),
- mnInsertionIndex(-1),
- maBoundingBox()
-{
-}
-
-
-
-
-InsertionIndicatorOverlay::~InsertionIndicatorOverlay()
-{
- 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();
+ maSecondCorner = rSecondCorner;
+ SetIsVisible(true);
}
-void InsertionIndicatorOverlay::SetPosition (const Point& rPoint)
+void SelectionRectangleOverlay::Paint (
+ OutputDevice& rDevice,
+ const Rectangle& rRepaintArea)
{
- 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)
- {
- // 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());
- }
+ if ( ! IsVisible())
+ return;
- // Add one when the mark was painted below or to the right of the
- // page object.
- if ( ! bLeftOrTop)
- nInsertionIndex += 1;
- }
-
- mnInsertionIndex = nInsertionIndex;
+ rDevice.SetFillColor(Color(Amber));
+ rDevice.SetLineColor(Color(Amber));
- Rectangle aBox;
- if (mnInsertionIndex >= 0)
- aBox = rLayouter.GetInsertionMarkerBox (
- nDrawIndex,
- bVertical,
- bLeftOrTop);
- SetPositionAndSize (aBox);
+ 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);
}
-sal_Int32 InsertionIndicatorOverlay::GetInsertionPageIndex (void) const
+Rectangle SelectionRectangleOverlay::GetBoundingBox (void) const
{
- return mnInsertionIndex;
+ 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);
}
-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()
-{
-}
-
-
-
+//===== InsertionIndicatorOverlay ===========================================
-MouseOverIndicatorOverlay::~MouseOverIndicatorOverlay (void)
+InsertionIndicatorOverlay::InsertionIndicatorOverlay (
+ ViewOverlay& rViewOverlay,
+ const sal_Int32 nLayerIndex)
+ : OverlayBase (rViewOverlay, nLayerIndex),
+ maLocation(),
+ maIconWithBorder(),
+ maIcon(),
+ maMask()
{
- RemoveRegistration();
+ 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));
}
-void MouseOverIndicatorOverlay::SetSlideUnderMouse (
- const model::SharedPageDescriptor& rpDescriptor)
+void InsertionIndicatorOverlay::SetLocation (const Point& rLocation)
{
- ViewShellBase* pBase = mrViewOverlay.GetSlideSorter().GetViewShellBase();
- if (pBase==NULL || ! pBase->GetUpdateLockManager()->IsLocked())
+ const Point aTopLeft (
+ rLocation - Point(
+ maIconWithBorder.GetSizePixel().Width()/2,
+ maIconWithBorder.GetSizePixel().Height()/2));
+ if (maLocation != aTopLeft)
{
- 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());
}
diff --git a/sd/source/ui/slidesorter/view/makefile.mk b/sd/source/ui/slidesorter/view/makefile.mk
index ebde1e7fe02d..0741b9e9551f 100644
--- a/sd/source/ui/slidesorter/view/makefile.mk
+++ b/sd/source/ui/slidesorter/view/makefile.mk
@@ -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)$/SlideSorterView.obj \
$(SLO)$/SlsFontProvider.obj \
- $(SLO)$/SlsPageObject.obj \
- $(SLO)$/SlsPageObjectViewContact.obj \
- $(SLO)$/SlsPageObjectViewObjectContact.obj \
+ $(SLO)$/SlsInsertAnimator.obj \
+ $(SLO)$/SlsLayeredDevice.obj \
$(SLO)$/SlsLayouter.obj \
- $(SLO)$/SlideSorterView.obj \
+ $(SLO)$/SlsPageObjectLayouter.obj \
+ $(SLO)$/SlsPageObjectPainter.obj \
$(SLO)$/SlsViewCacheContext.obj \
$(SLO)$/SlsViewOverlay.obj
-EXCEPTIONSFILES= \
- $(SLO)$/SlsPageObjectViewObjectContact.obj
-
# --- Tagets -------------------------------------------------------
.INCLUDE : target.mk
diff --git a/sd/source/ui/view/ViewShellManager.cxx b/sd/source/ui/view/ViewShellManager.cxx
index e8337c97dfb3..528969bcbf4d 100755
--- a/sd/source/ui/view/ViewShellManager.cxx
+++ b/sd/source/ui/view/ViewShellManager.cxx
@@ -45,7 +45,7 @@
#include <hash_map>
#undef VERBOSE
-#define VERBOSE 2
+//#define VERBOSE 2
namespace sd {
diff --git a/sd/util/makefile.mk b/sd/util/makefile.mk
index d74700307291..5c0c16e4a71e 100644
--- a/sd/util/makefile.mk
+++ b/sd/util/makefile.mk
@@ -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 \