summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAndre Fischer <af@openoffice.org>2010-03-19 15:06:39 +0100
committerAndre Fischer <af@openoffice.org>2010-03-19 15:06:39 +0100
commitb390fae1706b9c511158a03e4fd61f263be4e511 (patch)
tree644429f16c6834c397b10dee200a01aa7ed516ee /sd
parent8c23aba539c0f5764ec543e4cfa6bac2fc20e7ae (diff)
renaissance1: #i107215# Reorganized and improved layouting.
Diffstat (limited to 'sd')
-rw-r--r--sd/source/core/drawdoc2.cxx3
-rw-r--r--sd/source/ui/dlg/PaneDockingWindow.cxx70
-rw-r--r--sd/source/ui/inc/PaneDockingWindow.hxx18
-rw-r--r--sd/source/ui/inc/SlideSorter.hxx2
-rw-r--r--sd/source/ui/presenter/PresenterPreviewCache.cxx2
-rw-r--r--sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx29
-rw-r--r--sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx21
-rw-r--r--sd/source/ui/slidesorter/cache/SlsPageCache.cxx17
-rw-r--r--sd/source/ui/slidesorter/controller/SlideSorterController.cxx14
-rw-r--r--sd/source/ui/slidesorter/controller/SlsClipboard.cxx3
-rw-r--r--sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx156
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx12
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx6
-rw-r--r--sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx24
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx26
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx16
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx182
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorter.cxx18
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterService.cxx9
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx43
-rw-r--r--sd/source/ui/slidesorter/view/SlideSorterView.cxx290
-rw-r--r--sd/source/ui/slidesorter/view/SlsLayouter.cxx1512
-rw-r--r--sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx28
23 files changed, 1498 insertions, 1003 deletions
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index eb279d639ce8..6ccf50453e50 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -1469,8 +1469,7 @@ USHORT SdDrawDocument::CreatePage (
-USHORT SdDrawDocument::DuplicatePage (
- const USHORT nPageNum)
+USHORT SdDrawDocument::DuplicatePage (USHORT nPageNum)
{
PageKind ePageKind = PK_STANDARD;
diff --git a/sd/source/ui/dlg/PaneDockingWindow.cxx b/sd/source/ui/dlg/PaneDockingWindow.cxx
index b2f17bc0ab2a..0eb33468daf0 100644
--- a/sd/source/ui/dlg/PaneDockingWindow.cxx
+++ b/sd/source/ui/dlg/PaneDockingWindow.cxx
@@ -34,13 +34,16 @@
#include "PaneDockingWindow.hxx"
#include "Window.hxx"
#include "ViewShellBase.hxx"
+#include "framework/FrameworkHelper.hxx"
#include "sdresid.hxx"
#include "res_bmp.hrc"
#include <sfx2/dispatch.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/taskpanelist.hxx>
+#include <vcl/splitwin.hxx>
+#include <vcl/svapp.hxx>
#include <tools/wintypes.hxx>
-#include "framework/FrameworkHelper.hxx"
+#include <boost/bind.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -55,11 +58,7 @@ PaneDockingWindow::PaneDockingWindow (
const ResId& rResId,
const ::rtl::OUString& rsPaneURL,
const ::rtl::OUString& rsTitle)
- : SfxDockingWindow (
- _pBindings,
- pChildWindow,
- pParent,
- rResId),
+ : SfxDockingWindow (_pBindings, pChildWindow, pParent, rResId),
msPaneURL(rsPaneURL),
msTitle(rsTitle),
mpTitleToolBox(),
@@ -121,7 +120,7 @@ void PaneDockingWindow::Layout (void)
Size aWindowSize (GetOutputSizePixel());
Size aToolBoxSize (0,0);
- int nTitleBarHeight (GetSettings().GetStyleSettings().GetTitleHeight());
+ mnTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight();
// Place the title tool box.
if (mpTitleToolBox.get() != NULL)
@@ -132,20 +131,20 @@ void PaneDockingWindow::Layout (void)
mpTitleToolBox->ShowItem (1);
aToolBoxSize = mpTitleToolBox->CalcWindowSizePixel();
- if (aToolBoxSize.Height() > nTitleBarHeight)
- nTitleBarHeight = aToolBoxSize.Height();
+ if (aToolBoxSize.Height() > mnTitleBarHeight)
+ mnTitleBarHeight = aToolBoxSize.Height();
mpTitleToolBox->SetPosSizePixel (
Point(aWindowSize.Width()-aToolBoxSize.Width(),
- (nTitleBarHeight-aToolBoxSize.Height())/2),
+ (mnTitleBarHeight-aToolBoxSize.Height())/2),
aToolBoxSize);
}
// Place the content window.
- if (nTitleBarHeight < aToolBoxSize.Height())
- nTitleBarHeight = aToolBoxSize.Height();
- aWindowSize.Height() -= nTitleBarHeight;
+ if (mnTitleBarHeight < aToolBoxSize.Height())
+ mnTitleBarHeight = aToolBoxSize.Height();
+ aWindowSize.Height() -= mnTitleBarHeight;
mpContentWindow->SetPosSizePixel(
- Point(maBorder.Left(),nTitleBarHeight+maBorder.Top()),
+ Point(maBorder.Left(),mnTitleBarHeight+maBorder.Top()),
Size (aWindowSize.Width()-maBorder.Left()-maBorder.Right(),
aWindowSize.Height()-maBorder.Top()-maBorder.Bottom()));
}
@@ -159,10 +158,6 @@ void PaneDockingWindow::Paint (const Rectangle& rRectangle)
Layout();
SfxDockingWindow::Paint (rRectangle);
- int nTitleBarHeight (GetSettings().GetStyleSettings().GetTitleHeight());
- Size aToolBoxSize = mpTitleToolBox->CalcWindowSizePixel();
- if (aToolBoxSize.Height() > nTitleBarHeight)
- nTitleBarHeight = aToolBoxSize.Height();
Color aOriginalLineColor (GetLineColor());
Color aOriginalFillColor (GetFillColor());
SetFillColor (GetSettings().GetStyleSettings().GetDialogColor());
@@ -180,7 +175,7 @@ void PaneDockingWindow::Paint (const Rectangle& rRectangle)
int nInnerLeft = nOuterLeft + maBorder.Left() - 1;
int nOuterRight = aWindowSize.Width() - 1;
int nInnerRight = nOuterRight - maBorder.Right() + 1;
- int nInnerTop = nTitleBarHeight + maBorder.Top() - 1;
+ int nInnerTop = mnTitleBarHeight + maBorder.Top() - 1;
int nOuterBottom = aWindowSize.Height() - 1;
int nInnerBottom = nOuterBottom - maBorder.Bottom() + 1;
@@ -424,4 +419,41 @@ void PaneDockingWindow::MouseButtonDown (const MouseEvent& rEvent)
+
+void PaneDockingWindow::SetValidSizeRange (const Range aValidSizeRange)
+{
+ SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
+ if (pSplitWindow != NULL)
+ {
+ const USHORT nId (pSplitWindow->GetItemId(static_cast< ::Window*>(this)));
+ const USHORT nSetId (pSplitWindow->GetSet(nId));
+ // Because the PaneDockingWindow paints its own decoration, we have
+ // to compensate the valid size range for that.
+ sal_Int32 nCompensation (pSplitWindow->IsHorizontal()
+ ? mnTitleBarHeight + maBorder.Top() + maBorder.Bottom()
+ : maBorder.Left() + maBorder.Right());
+ pSplitWindow->SetItemSizeRange(
+ nSetId,
+ Range(
+ aValidSizeRange.Min() + nCompensation,
+ aValidSizeRange.Max() + nCompensation));
+ }
+}
+
+
+
+
+PaneDockingWindow::Orientation PaneDockingWindow::GetOrientation (void) const
+{
+ SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
+ if (pSplitWindow == NULL)
+ return UnknownOrientation;
+ else if (pSplitWindow->IsHorizontal())
+ return HorizontalOrientation;
+ else
+ return VerticalOrientation;
+}
+
+
+
} // end of namespace ::sd
diff --git a/sd/source/ui/inc/PaneDockingWindow.hxx b/sd/source/ui/inc/PaneDockingWindow.hxx
index c61f0e8d774c..e4516480124f 100644
--- a/sd/source/ui/inc/PaneDockingWindow.hxx
+++ b/sd/source/ui/inc/PaneDockingWindow.hxx
@@ -38,6 +38,7 @@
#include <boost/shared_ptr.hpp>
class ToolBox;
+class SplitWindow;
namespace sd {
@@ -107,6 +108,19 @@ public:
::boost::shared_ptr<ToolBox> GetTitleToolBox (void) const;
+ /** When docked the given range is passed to the parent SplitWindow.
+ */
+ void SetValidSizeRange (const Range aValidSizeRange);
+
+ enum Orientation { HorizontalOrientation, VerticalOrientation, UnknownOrientation };
+ /** When the PaneDockingWindow is docked and managed by a split window
+ it can derive its orientation from the orientation of the split
+ window and return either HorizontalOrientation or
+ VerticalOrientation.
+ Otherwise UnknownOrientation is returned.
+ */
+ Orientation GetOrientation (void) const;
+
private:
/** The pane which is represented by the docking window.
*/
@@ -127,6 +141,10 @@ private:
*/
SvBorder maBorder;
+ /** The current height of the title bar.
+ */
+ sal_Int32 mnTitleBarHeight;
+
sal_uInt16 mnChildWindowId;
::boost::scoped_ptr< ::Window> mpContentWindow;
diff --git a/sd/source/ui/inc/SlideSorter.hxx b/sd/source/ui/inc/SlideSorter.hxx
index 49869d807848..c1515ff0d4d4 100644
--- a/sd/source/ui/inc/SlideSorter.hxx
+++ b/sd/source/ui/inc/SlideSorter.hxx
@@ -200,6 +200,8 @@ public:
*/
::boost::shared_ptr<controller::Properties> GetProperties (void) const;
+ /** Return the active theme wich gives access to colors and fonts.
+ */
::boost::shared_ptr<view::Theme> GetTheme (void) const;
protected:
diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx
index 523097f53247..e8b04611b688 100644
--- a/sd/source/ui/presenter/PresenterPreviewCache.cxx
+++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx
@@ -213,7 +213,7 @@ Reference<rendering::XBitmap> SAL_CALL PresenterPreviewCache::getSlidePreview (
if (pPage == NULL)
throw RuntimeException();
- const BitmapEx aPreview (mpCache->GetPreviewBitmap(pPage));
+ const BitmapEx aPreview (mpCache->GetPreviewBitmap(pPage,true));
if (aPreview.IsEmpty())
return NULL;
else
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
index ba1eb21e9ca6..e8ae79047545 100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
@@ -43,6 +43,7 @@
#include "model/SlsPageDescriptor.hxx"
#include "controller/SlideSorterController.hxx"
+
namespace sd { namespace slidesorter { namespace cache {
GenericPageCache::GenericPageCache (
@@ -134,7 +135,9 @@ void GenericPageCache::ChangePreviewSize (
-BitmapEx GenericPageCache::GetPreviewBitmap (CacheKey aKey)
+BitmapEx GenericPageCache::GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
{
OSL_ASSERT(aKey != NULL);
@@ -147,13 +150,15 @@ BitmapEx GenericPageCache::GetPreviewBitmap (CacheKey aKey)
::boost::shared_ptr<BitmapEx> pPreview(mpBitmapCache->GetBitmap(pPage));
OSL_ASSERT(pPreview.get() != NULL);
aPreview = *pPreview;
- Size aBitmapSize (aPreview.GetSizePixel());
- if (aBitmapSize != maPreviewSize)
+ const Size aBitmapSize (aPreview.GetSizePixel());
+ if (bResize && aBitmapSize != maPreviewSize)
{
// 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 (maPreviewSize, BMP_SCALE_FAST);
+ {
+ aPreview.Scale(maPreviewSize, BMP_SCALE_FAST);
+ }
}
bMayBeUpToDate = true;
}
@@ -172,8 +177,8 @@ BitmapEx GenericPageCache::GetPreviewBitmap (CacheKey aKey)
void GenericPageCache::RequestPreviewBitmap (
- CacheKey aKey,
- bool bMayBeUpToDate)
+ const CacheKey aKey,
+ const bool bMayBeUpToDate)
{
OSL_ASSERT(aKey != NULL);
@@ -211,7 +216,7 @@ void GenericPageCache::RequestPreviewBitmap (
-void GenericPageCache::InvalidatePreviewBitmap (CacheKey aKey)
+void GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey)
{
if (mpBitmapCache.get() != NULL)
mpBitmapCache->InvalidateBitmap(mpCacheContext->GetPage(aKey));
@@ -220,7 +225,7 @@ void GenericPageCache::InvalidatePreviewBitmap (CacheKey aKey)
-void GenericPageCache::ReleasePreviewBitmap (CacheKey aKey)
+void GenericPageCache::ReleasePreviewBitmap (const CacheKey aKey)
{
if (mpBitmapCache.get() != NULL)
{
@@ -254,9 +259,9 @@ void GenericPageCache::ReleasePreviewBitmap (CacheKey aKey)
-void GenericPageCache::InvalidateCache (bool bUpdateCache)
+void GenericPageCache::InvalidateCache (const bool bUpdateCache)
{
- if (mpBitmapCache.get() != NULL)
+ if (mpBitmapCache)
{
// When the cache is being invalidated then it makes no sense to
// continue creating preview bitmaps. However, this may be
@@ -276,7 +281,9 @@ void GenericPageCache::InvalidateCache (bool bUpdateCache)
-void GenericPageCache::SetPreciousFlag (CacheKey aKey, bool bIsPrecious)
+void GenericPageCache::SetPreciousFlag (
+ const CacheKey aKey,
+ const bool bIsPrecious)
{
ProvideCacheAndProcessor();
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
index 7afa01a9b860..5196d688be96 100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
@@ -81,11 +81,18 @@ public:
receives the correctly sized preview bitmap.
@param rRequestData
This data is used to determine the preview.
+ @param bResize
+ When <TRUE/> then when the available bitmap has not the
+ requested size, it is scaled before it is returned. When
+ <FALSE/> then the bitmap is returned in the wrong size and it is
+ the task of the caller to scale it.
@return
Returns a bitmap that is either empty, contains a scaled (up or
down) version or is the requested bitmap.
*/
- BitmapEx GetPreviewBitmap (CacheKey aKey);
+ BitmapEx GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize);
/** When the requested preview bitmap does not yet exist or is not
up-to-date then the rendering of one is scheduled. Otherwise this
@@ -100,33 +107,33 @@ public:
unsure use <TRUE/>.
*/
void RequestPreviewBitmap (
- CacheKey aKey,
- bool bMayBeUpToDate = true);
+ const CacheKey aKey,
+ const bool bMayBeUpToDate = true);
/** Tell the cache to replace the bitmap associated with the given
request data with a new one that reflects recent changes in the
content of the page object.
*/
- void InvalidatePreviewBitmap (CacheKey aKey);
+ void InvalidatePreviewBitmap (const CacheKey aKey);
/** 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
requested a new bitmap.
*/
- void ReleasePreviewBitmap (CacheKey aKey);
+ void ReleasePreviewBitmap (const CacheKey aKey);
/** Call this method when all preview bitmaps have to be generated anew.
This is the case when the size of the page objects on the screen has
changed or when the model has changed.
*/
- void InvalidateCache (bool bUpdateCache);
+ void InvalidateCache (const bool bUpdateCache);
/** With the precious flag you can control whether a bitmap can be
removed from the cache or reduced in size to make room for other
bitmaps or is so precious that it will not be touched. A typical
use is to set the precious flag for the visible pages.
*/
- void SetPreciousFlag (CacheKey aKey, bool bIsPrecious);
+ void SetPreciousFlag (const CacheKey aKey, const bool bIsPrecious);
/** Return <TRUE/> when there is no preview bitmap in the cache.
*/
diff --git a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
index 0e0b7e2f01c4..c0ec8daaf3ca 100644
--- a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
@@ -78,15 +78,17 @@ void PageCache::ChangeSize (
-BitmapEx PageCache::GetPreviewBitmap (CacheKey aKey)
+BitmapEx PageCache::GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
{
- return mpImplementation->GetPreviewBitmap(aKey);
+ return mpImplementation->GetPreviewBitmap(aKey, bResize);
}
-void PageCache::RequestPreviewBitmap (CacheKey aKey)
+void PageCache::RequestPreviewBitmap (const CacheKey aKey)
{
return mpImplementation->RequestPreviewBitmap(aKey);
}
@@ -106,8 +108,7 @@ void PageCache::InvalidatePreviewBitmap (
-void PageCache::ReleasePreviewBitmap (
- CacheKey aKey)
+void PageCache::ReleasePreviewBitmap (const CacheKey aKey)
{
mpImplementation->ReleasePreviewBitmap(aKey);
}
@@ -115,7 +116,7 @@ void PageCache::ReleasePreviewBitmap (
-void PageCache::InvalidateCache (bool bUpdateCache)
+void PageCache::InvalidateCache (const bool bUpdateCache)
{
mpImplementation->InvalidateCache(bUpdateCache);
}
@@ -124,8 +125,8 @@ void PageCache::InvalidateCache (bool bUpdateCache)
void PageCache::SetPreciousFlag (
- CacheKey aKey,
- bool bIsPrecious)
+ const CacheKey aKey,
+ const bool bIsPrecious)
{
mpImplementation->SetPreciousFlag(aKey, bIsPrecious);
}
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
index 859b19246f05..7ff2397d5b84 100644
--- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
+++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
@@ -800,17 +800,21 @@ Rectangle SlideSorterController::Rearrange (bool bForce)
SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
if (pWindow)
{
+ if (bForce)
+ mrView.UpdateOrientation();
+
// Place the scroll bars.
- aNewContentArea = GetScrollBarManager().PlaceScrollBars(maTotalWindowArea);
+ aNewContentArea = GetScrollBarManager().PlaceScrollBars(
+ maTotalWindowArea,
+ mrView.GetOrientation() != view::Layouter::VERTICAL,
+ mrView.GetOrientation() != view::Layouter::HORIZONTAL);
bool bSizeHasChanged (false);
// Only when bForce is not true we have to test for a size change in
// order to determine whether the window and the view have to be resized.
if ( ! bForce)
{
- Rectangle aCurrentContentArea (
- pWindow->GetPosPixel(),
- pWindow->GetOutputSizePixel());
+ Rectangle aCurrentContentArea (pWindow->GetPosPixel(), pWindow->GetOutputSizePixel());
bSizeHasChanged = (aNewContentArea != aCurrentContentArea);
}
if (bForce || bSizeHasChanged)
@@ -860,7 +864,7 @@ void SlideSorterController::SetZoom (long int nZoom)
{
SlideSorterView::DrawLock aLock (mrSlideSorter);
- mrView.GetLayouter().SetZoom(nZoom/100.0);
+ mrView.GetLayouter()._SetZoom(nZoom/100.0);
mrView.Layout();
GetScrollBarManager().UpdateScrollBars (false);
mrView.GetPreviewCache()->InvalidateCache();
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 7f74b600640a..7596e9946be2 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -380,7 +380,8 @@ void Clipboard::CreateSlideTransferable (
model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
if ( ! pDescriptor || pDescriptor->GetPage()==NULL)
continue;
- Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage()).GetBitmap());
+ Bitmap aPreview (pPreviewCache->GetPreviewBitmap(pDescriptor->GetPage(), false)
+ .GetBitmap());
aRepresentatives.push_back(aPreview);
if (aRepresentatives.size() >= 3)
break;
diff --git a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
index 1537adec84b5..cb301c21d32d 100644
--- a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
@@ -136,12 +136,24 @@ void ScrollBarManager::Disconnect (void)
window changes and a second call to the layouter becomes necessary.
That call is made anyway after this method returns.
*/
-Rectangle ScrollBarManager::PlaceScrollBars (const Rectangle& rAvailableArea)
+Rectangle ScrollBarManager::PlaceScrollBars (
+ const Rectangle& rAvailableArea,
+ const bool bIsHorizontalScrollBarAllowed,
+ const bool bIsVerticalScrollBarAllowed)
{
- Rectangle aRemainingSpace (DetermineScrollBarVisibilities(rAvailableArea));
- PlaceHorizontalScrollBar (rAvailableArea);
- PlaceVerticalScrollBar (rAvailableArea);
- PlaceFiller (rAvailableArea);
+ Rectangle aRemainingSpace (DetermineScrollBarVisibilities(
+ rAvailableArea,
+ bIsHorizontalScrollBarAllowed,
+ bIsVerticalScrollBarAllowed));
+
+ if (mpHorizontalScrollBar!=NULL && mpHorizontalScrollBar->IsVisible())
+ PlaceHorizontalScrollBar (rAvailableArea);
+
+ if (mpVerticalScrollBar!=NULL && mpVerticalScrollBar->IsVisible())
+ PlaceVerticalScrollBar (rAvailableArea);
+
+ if (mpScrollBarFiller!=NULL && mpScrollBarFiller->IsVisible())
+ PlaceFiller (rAvailableArea);
return aRemainingSpace;
}
@@ -151,25 +163,21 @@ Rectangle ScrollBarManager::PlaceScrollBars (const Rectangle& rAvailableArea)
void ScrollBarManager::PlaceHorizontalScrollBar (const Rectangle& aAvailableArea)
{
- if (mpHorizontalScrollBar != NULL
- && mpHorizontalScrollBar->IsVisible())
- {
- // Save the current relative position.
- mnHorizontalPosition = double(mpHorizontalScrollBar->GetThumbPos())
- / double(mpHorizontalScrollBar->GetRange().Len());
-
- // Place the scroll bar.
- Size aScrollBarSize (mpHorizontalScrollBar->GetSizePixel());
- mpHorizontalScrollBar->SetPosSizePixel (
- Point(aAvailableArea.Left(),
- aAvailableArea.Bottom()-aScrollBarSize.Height()+1),
- Size (aAvailableArea.GetWidth() - GetVerticalScrollBarWidth(),
- aScrollBarSize.Height()));
-
- // Restore the relative position.
- mpHorizontalScrollBar->SetThumbPos(
- (long)(0.5 + mnHorizontalPosition * mpHorizontalScrollBar->GetRange().Len()));
- }
+ // Save the current relative position.
+ mnHorizontalPosition = double(mpHorizontalScrollBar->GetThumbPos())
+ / double(mpHorizontalScrollBar->GetRange().Len());
+
+ // Place the scroll bar.
+ Size aScrollBarSize (mpHorizontalScrollBar->GetSizePixel());
+ mpHorizontalScrollBar->SetPosSizePixel (
+ Point(aAvailableArea.Left(),
+ aAvailableArea.Bottom()-aScrollBarSize.Height()+1),
+ Size (aAvailableArea.GetWidth() - GetVerticalScrollBarWidth(),
+ aScrollBarSize.Height()));
+
+ // Restore the relative position.
+ mpHorizontalScrollBar->SetThumbPos(
+ (long)(0.5 + mnHorizontalPosition * mpHorizontalScrollBar->GetRange().Len()));
}
@@ -177,21 +185,17 @@ void ScrollBarManager::PlaceHorizontalScrollBar (const Rectangle& aAvailableArea
void ScrollBarManager::PlaceVerticalScrollBar (const Rectangle& aArea)
{
- if (mpVerticalScrollBar != NULL
- && mpVerticalScrollBar->IsVisible())
- {
- const double nThumbPosition (mpVerticalScrollBar->GetThumbPos());
+ const double nThumbPosition (mpVerticalScrollBar->GetThumbPos());
- // Place the scroll bar.
- Size aScrollBarSize (mpVerticalScrollBar->GetSizePixel());
- Point aPosition (aArea.Right()-aScrollBarSize.Width()+1, aArea.Top());
- Size aSize (aScrollBarSize.Width(), aArea.GetHeight() - GetHorizontalScrollBarHeight());
- mpVerticalScrollBar->SetPosSizePixel(aPosition, aSize);
+ // Place the scroll bar.
+ Size aScrollBarSize (mpVerticalScrollBar->GetSizePixel());
+ Point aPosition (aArea.Right()-aScrollBarSize.Width()+1, aArea.Top());
+ Size aSize (aScrollBarSize.Width(), aArea.GetHeight() - GetHorizontalScrollBarHeight());
+ mpVerticalScrollBar->SetPosSizePixel(aPosition, aSize);
- // Restore the position.
- mpVerticalScrollBar->SetThumbPos(nThumbPosition);
- mnVerticalPosition = nThumbPosition / double(mpVerticalScrollBar->GetRange().Len());
- }
+ // Restore the position.
+ mpVerticalScrollBar->SetThumbPos(nThumbPosition);
+ mnVerticalPosition = nThumbPosition / double(mpVerticalScrollBar->GetRange().Len());
}
@@ -199,23 +203,13 @@ void ScrollBarManager::PlaceVerticalScrollBar (const Rectangle& aArea)
void ScrollBarManager::PlaceFiller (const Rectangle& aArea)
{
- // Place the filler when both scroll bars are visible.
- if (mpHorizontalScrollBar != NULL
- && mpVerticalScrollBar != NULL
- && mpHorizontalScrollBar->IsVisible()
- && mpVerticalScrollBar->IsVisible())
- {
- mpScrollBarFiller->SetPosSizePixel(
- Point(
- aArea.Right()-mpVerticalScrollBar->GetSizePixel().Width()+1,
- aArea.Bottom()-mpHorizontalScrollBar->GetSizePixel().Height()+1),
- Size (
- mpVerticalScrollBar->GetSizePixel().Width(),
- mpHorizontalScrollBar->GetSizePixel().Height()));
- mpScrollBarFiller->Show();
- }
- else
- mpScrollBarFiller->Hide();
+ mpScrollBarFiller->SetPosSizePixel(
+ Point(
+ aArea.Right()-mpVerticalScrollBar->GetSizePixel().Width()+1,
+ aArea.Bottom()-mpHorizontalScrollBar->GetSizePixel().Height()+1),
+ Size (
+ mpVerticalScrollBar->GetSizePixel().Width(),
+ mpHorizontalScrollBar->GetSizePixel().Height()));
}
@@ -224,8 +218,7 @@ void ScrollBarManager::PlaceFiller (const Rectangle& aArea)
void ScrollBarManager::AdaptWindowSize (const Rectangle& rArea)
{
Size aPixelContentSize (mpContentWindow->LogicToPixel(
- mrSlideSorter.GetView().GetLayouter().GetPageBox (
- mrSlideSorter.GetModel().GetPageCount()).GetSize()));
+ mrSlideSorter.GetView().GetLayouter().GetTotalBoundingBox().GetSize()));
int nHeightDifference = aPixelContentSize.Height() - rArea.GetHeight();
::Window* pParentWindow = mpContentWindow->GetParent();
Size aNewWindowSize (pParentWindow->GetSizePixel());
@@ -391,7 +384,10 @@ void ScrollBarManager::SetWindowOrigin (
b) when not showing a scroll bar the area used by the page objects fits
into the available area in the scroll bars orientation.
*/
-Rectangle ScrollBarManager::DetermineScrollBarVisibilities (const Rectangle& rAvailableArea)
+Rectangle ScrollBarManager::DetermineScrollBarVisibilities (
+ const Rectangle& rAvailableArea,
+ const bool bIsHorizontalScrollBarAllowed,
+ const bool bIsVerticalScrollBarAllowed)
{
// Test which combination of scroll bars is the best.
bool bShowHorizontal = false;
@@ -402,20 +398,35 @@ Rectangle ScrollBarManager::DetermineScrollBarVisibilities (const Rectangle& rAv
// No pages => no scroll bars.
break;
- if (TestScrollBarVisibilities(bShowHorizontal=false, bShowVertical=false, rAvailableArea))
+ if (TestScrollBarVisibilities(false, false, rAvailableArea))
break;
- if (TestScrollBarVisibilities(bShowHorizontal=true, bShowVertical=false, rAvailableArea))
+ if (bIsHorizontalScrollBarAllowed
+ && TestScrollBarVisibilities(true, false, rAvailableArea))
+ {
+ bShowHorizontal = true;
break;
- if (TestScrollBarVisibilities(bShowHorizontal=false, bShowVertical=true, rAvailableArea))
+ }
+ if (bIsVerticalScrollBarAllowed
+ && TestScrollBarVisibilities(false, true, rAvailableArea))
+ {
+ bShowVertical = true;
break;
- if (TestScrollBarVisibilities(bShowHorizontal=true, bShowVertical=true, rAvailableArea))
+ }
+ if (bIsHorizontalScrollBarAllowed
+ && bIsVerticalScrollBarAllowed
+ && TestScrollBarVisibilities(true, true, rAvailableArea))
+ {
+ bShowHorizontal = true;
+ bShowVertical = true;
break;
+ }
}
while (false);
// Make the visibility of the scroll bars permanent.
mpVerticalScrollBar->Show(bShowVertical);
mpHorizontalScrollBar->Show(bShowHorizontal);
+ mpScrollBarFiller->Show(bShowVertical && bShowHorizontal);
// Adapt the remaining space accordingly.
Rectangle aRemainingSpace (rAvailableArea);
@@ -449,26 +460,15 @@ bool ScrollBarManager::TestScrollBarVisibilities (
// Tell the view to rearrange its page objects and check whether the
// page objects can be shown without clipping.
- bool bRearrangeSuccess (false);
- if (mrSlideSorter.GetView().GetOrientation() == view::SlideSorterView::HORIZONTAL)
- {
- bRearrangeSuccess = mrSlideSorter.GetView().GetLayouter().RearrangeHorizontal (
- aBrowserSize,
- rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- rModel.GetPageCount());
- }
- else
- {
- bRearrangeSuccess = mrSlideSorter.GetView().GetLayouter().RearrangeVertical (
- aBrowserSize,
- rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- rModel.GetPageCount());
- }
+ bool bRearrangeSuccess (mrSlideSorter.GetView().GetLayouter().Rearrange (
+ mrSlideSorter.GetView().GetOrientation(),
+ aBrowserSize,
+ rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
+ rModel.GetPageCount()));
if (bRearrangeSuccess)
{
- Size aPageSize = mrSlideSorter.GetView().GetLayouter().GetPageBox (
- rModel.GetPageCount()).GetSize();
+ Size aPageSize = mrSlideSorter.GetView().GetLayouter().GetTotalBoundingBox().GetSize();
Size aWindowModelSize = mpContentWindow->PixelToLogic(aBrowserSize);
bool bHorizontallyClipped = (aPageSize.Width() > aWindowModelSize.Width());
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
index ac155377c0df..9ddfbf481b7e 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
@@ -389,12 +389,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
case KEY_ESCAPE:
// When there is an active multiselection or drag-and-drop
- // operation then stop that. Otherwise transfer the focus to
- // the tool box.
-
- if ( ! (mpDragAndDropContext || mpMouseMultiSelector))
- rFocusManager.SetFocusToToolBox();
-
+ // operation then stop that.
StopDragAndDrop();
if (mpMouseMultiSelector)
{
@@ -1125,7 +1120,8 @@ void SelectionFunction::ProcessButtonUpEvent (const EventDescriptor& rDescriptor
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 == rDescriptor.mpHitDescriptor->GetPageIndex())
+ && mnButtonDownPageIndex == rDescriptor.mpHitDescriptor->GetPageIndex()
+ && rDescriptor.mpHitDescriptor->GetVisualState().GetButtonAlpha()<0.7)
{
ProcessButtonClick(rDescriptor.mpHitDescriptor, mnButtonDownButtonIndex);
}
@@ -1146,7 +1142,7 @@ void SelectionFunction::ProcessMouseMotionEvent (const EventDescriptor& rDescrip
switch (rDescriptor.mnEventCode)
{
case ANY_MODIFIER(MOUSE_MOTION | LEFT_BUTTON | SINGLE_CLICK | OVER_UNSELECTED_PAGE):
- SetCurrentPage(rDescriptor.mpHitDescriptor);
+ // SetCurrentPage(rDescriptor.mpHitDescriptor);
// Fallthrough
// A mouse motion without visible substitution starts that.
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
index e1d42b161053..0cec638ac82c 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
@@ -436,7 +436,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
sal_Int32 nNewTop (aVisibleArea.Top());
sal_Int32 nNewLeft (aVisibleArea.Left());
- if (mrSlideSorter.GetView().GetOrientation() != SlideSorterView::HORIZONTAL)
+ if (mrSlideSorter.GetView().GetOrientation() != Layouter::HORIZONTAL)
{
// Scroll the visible area to make aSelectionBox visible.
if (mrSlideSorter.GetProperties()->IsCenterSelection())
@@ -461,7 +461,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox)
}
- if (mrSlideSorter.GetView().GetOrientation() != SlideSorterView::VERTICAL)
+ if (mrSlideSorter.GetView().GetOrientation() != Layouter::VERTICAL)
{
// Scroll the visible area to make aSelectionBox visible.
if (mrSlideSorter.GetProperties()->IsCenterSelection())
@@ -547,7 +547,7 @@ bool SelectionManager::DoesSelectionExceedVisibleArea (const Rectangle& rSelecti
Rectangle(
Point(0,0),
pWindow->GetOutputSizePixel())));
- if (mrSlideSorter.GetView().GetOrientation() == SlideSorterView::VERTICAL)
+ if (mrSlideSorter.GetView().GetOrientation() != Layouter::HORIZONTAL)
return rSelectionBox.GetHeight() > aVisibleArea.GetHeight();
else
return rSelectionBox.GetWidth() > aVisibleArea.GetWidth();
diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
index b4e91acd0dca..d32b1a82aeef 100644
--- a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
+++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx
@@ -111,22 +111,30 @@ public:
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 queue. When the preview is available the page
- shape will be told to paint itself again. When it then calls this
- method again if receives the correctly sized preview bitmap.
+ into the request queue. When the preview is available in the right
+ size the page shape will be told to paint itself again. When it
+ then calls this method again if receives the correctly sized preview
+ bitmap.
@param rRequestData
This data is used to determine the preview.
+ @param bResize
+ When <TRUE/> then when the available bitmap has not the
+ requested size, it is scaled before it is returned. When
+ <FALSE/> then the bitmap is returned in the wrong size and it is
+ the task of the caller to scale it.
@return
Returns a bitmap that is either empty, contains a scaled (up or
down) version or is the requested bitmap.
*/
- BitmapEx GetPreviewBitmap (CacheKey aKey);
+ BitmapEx GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize);
/** 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);
+ void RequestPreviewBitmap (const CacheKey aKey);
/** Tell the cache that the bitmap associated with the given request
data is not up-to-date anymore.
@@ -142,7 +150,7 @@ public:
and does not need (a) its current bitmap in the cache and (b) a
requested new bitmap.
*/
- void ReleasePreviewBitmap (CacheKey aKey);
+ void ReleasePreviewBitmap (const CacheKey aKey);
/** Call this method when all preview bitmaps have to be generated anew.
This is the case when the size of the page objects on the screen has
@@ -152,14 +160,14 @@ public:
are created. When it is <FALSE/> the existing previews are only
marked as not being up-to-date anymore.
*/
- void InvalidateCache (bool bUpdateCache = true);
+ void InvalidateCache (const bool bUpdateCache = true);
/** With the precious flag you can control whether a bitmap can be
removed or reduced in size to make room for other bitmaps or is so
precious that it will not touched. A typical use is to set the
precious flag for exactly the visible pages.
*/
- void SetPreciousFlag (CacheKey aKey, bool bIsPrecious);
+ void SetPreciousFlag (const CacheKey aKey, const bool bIsPrecious);
void Pause (void);
void Resume (void);
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
index 4c3a71e578d7..7d23cd17b983 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsScrollBarManager.hxx
@@ -116,20 +116,25 @@ public:
bool bScrollToCurrentPosition = true);
/** Place the scroll bars inside the given area. When the available
- area is not large enough for the content to display the resulting
- behaviour depends on the mbUseVerticalScrollBar flag. When it is
- set to true then a vertical scroll bar is shown. Otherwise the
- height of the returned area is enlarged so that the content fits
- into it.
+ area is not large enough for the content to display the horizontal
+ and/or vertical scroll bar is enabled.
@param rAvailableArea
The scroll bars will be placed inside this rectangle. It is
expected to be given in pixel relative to its parent.
+ @param bIsHorizontalScrollBarAllowed
+ Only when this flag is <TRUE/> the horizontal scroll may be
+ displayed.
+ @param bIsVerticalScrollBarAllowed
+ Only when this flag is <TRUE/> the horizontal scroll may be
+ displayed.
@return
Returns the space that remains after the scroll bars are
- placed. When the mbUseVerticalScrollBar flag is false then the
- returned rectangle may be larger than the given one.
+ placed.
*/
- Rectangle PlaceScrollBars (const Rectangle& rAvailableArea);
+ Rectangle PlaceScrollBars (
+ const Rectangle& rAvailableArea,
+ const bool bIsHorizontalScrollBarAllowed,
+ const bool bIsVerticalScrollBarAllowed);
/** Update the vertical and horizontal scroll bars so that the visible
area has the given top and left values.
@@ -231,7 +236,10 @@ private:
The area that is enclosed by the scroll bars is returned. It
will be filled with the SlideSorterView.
*/
- Rectangle DetermineScrollBarVisibilities (const Rectangle& rAvailableArea);
+ Rectangle DetermineScrollBarVisibilities(
+ const Rectangle& rAvailableArea,
+ const bool bIsHorizontalScrollBarAllowed,
+ const bool bIsVerticalScrollBarAllowed);
/** Typically called by DetermineScrollBarVisibilities() this method
tests a specific configuration of the two scroll bars being visible
diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
index a9cad51af652..b5bdb91ade29 100644
--- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
@@ -34,6 +34,7 @@
#include "SlideSorter.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "model/SlsSharedPageDescriptor.hxx"
+#include "view/SlsLayouter.hxx"
#include "View.hxx"
#include <sfx2/viewfrm.hxx>
@@ -88,9 +89,11 @@ public:
virtual ~SlideSorterView (void);
void Dispose (void);
- enum Orientation { HORIZONTAL, VERTICAL, GRID };
- void SetOrientation (const Orientation eOrientation);
- Orientation GetOrientation (void) const;
+ /** Set the general way of layouting the page objects. Note that this
+ method does not trigger any repaints or layouts.
+ */
+ bool SetOrientation (const Layouter::Orientation eOrientation);
+ Layouter::Orientation GetOrientation (void) const;
void RequestRepaint (void);
void RequestRepaint (const model::SharedPageDescriptor& rDescriptor);
@@ -211,6 +214,8 @@ public:
const bool bStateValue,
const bool bAnimate = true);
+ void UpdateOrientation (void);
+
::boost::shared_ptr<PageObjectPainter> GetPageObjectPainter (void);
::boost::shared_ptr<LayeredDevice> GetLayeredDevice (void) const;
@@ -244,7 +249,7 @@ private:
bool mbModelChangedWhileModifyEnabled;
Size maPreviewSize;
bool mbPreciousFlagUpdatePending;
- Orientation meOrientation;
+ Layouter::Orientation meOrientation;
::boost::shared_ptr<controller::Properties> mpProperties;
model::SharedPageDescriptor mpPageUnderMouse;
bool mbIsMouseOverIndicationAllowed;
@@ -258,9 +263,6 @@ private:
void DeterminePageObjectVisibilities (void);
void UpdatePreciousFlags (void);
-
- ::drawinglayer::primitive2d::Primitive2DSequence GetPrimitive2DHierarchy (
- const Region& rPaintArea) const;
};
diff --git a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
index 12bc67aa5e4b..ee27cd9201c6 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx
@@ -77,21 +77,13 @@ class InsertPosition;
class Layouter
{
public:
+ enum Orientation { HORIZONTAL, VERTICAL, GRID };
+
Layouter (const SharedSdWindow& 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,
- sal_Int32 nPreferredWidth);
-
/** Set the horizontal and vertical borders in pixel coordinates between
the enclosing window and page objects. The borders may be painted
larger then the given values when the space for the insertion marker
@@ -133,6 +125,9 @@ public:
/** Central method of this class. It takes the input values and
calculates the output values. Both given sizes must not be 0 in any
dimension or the call is ignored.
+ @param eOrientation
+ This defines the generaly layout and specifies whether there may
+ be more than one row or more than one column.
@param rWindowSize
The size of the window in pixels that the slide sorter is
displayed in. This can differ from the size of mpWindow during
@@ -146,11 +141,8 @@ public:
The return value indicates whether the Get... methods can be
used to obtain valid values (<TRUE/>).
*/
- bool RearrangeHorizontal (
- const Size& rWindowSize,
- const Size& rPreviewModelSize,
- const sal_uInt32 nPageCount);
- bool RearrangeVertical (
+ bool Rearrange (
+ const Orientation eOrientation,
const Size& rWindowSize,
const Size& rPreviewModelSize,
const sal_uInt32 nPageCount);
@@ -158,8 +150,8 @@ public:
/** Change the zoom factor. This does not change the general layout
(number of columns).
*/
- void SetZoom (double nZoomFactor);
- void SetZoom (Fraction nZoomFactor);
+ void _SetZoom (double nZoomFactor);
+ void _SetZoom (Fraction nZoomFactor);
/** Return the number of columns.
*/
@@ -196,7 +188,7 @@ public:
/** Return the bounding box in model coordinates of the page that
contains the given amount of page objects.
*/
- Rectangle GetPageBox (const sal_Int32 nObjectCount = -1) const;
+ Rectangle GetTotalBoundingBox (void) const;
/** Return the index of the first fully or partially visible page
object. This takes into account only the vertical dimension.
@@ -247,143 +239,19 @@ public:
const Size& rIndicatorSize,
model::SlideSorterModel& rModel) const;
- /** Return whether the main orientation of the slides in the slide
- sorter is vertical, i.e. all slides are arranged in one column.
- */
- bool IsVertical (void) const;
+ Range GetValidHorizontalSizeRange (void) const;
+ Range GetValidVerticalSizeRange (void) const;
+ class Implementation;
private:
+ ::boost::scoped_ptr<Implementation> mpImplementation;
SharedSdWindow 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;
- sal_Int32 mnRowCount;
- /// The maximum number of columns. Can only be larger than the current
- /// number of columns when there are not enough pages to fill all
- /// available columns.
- sal_Int32 mnMaxColumnCount;
- /// The maximum number of rows. Can only be larger than the current
- /// number of rows when there are not enough pages to fill all available
- /// rows.
- sal_Int32 mnMaxRowCount;
- Size maPageObjectSize;
- bool mbIsVertical;
-
- ::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
-
- enum GapMembership { GM_NONE, GM_PREVIOUS, GM_BOTH, GM_NEXT,
- GM_PAGE_BORDER};
-
- /** Calculate the row that the point with the given vertical coordinate
- is over. The horizontal component is ignored.
- @param nYPosition
- Vertical position in model coordinates.
- @param bIncludeBordersAndGaps
- When this flag is <TRUE/> then the area of borders and gaps are
- interpreted as belonging to one of the rows.
- @param eGapMembership
- Specifies to what row the gap areas belong. Here GM_NONE
- corresponds to bIncludeBordersAndGaps being <FALSE/>. When
- GM_BOTH is given then the upper half is associated to the row
- above and the lower half to the row below. Values of
- GM_PREVIOUS and GM_NEXT associate the whole gap area with the
- row above or below respectively.
- */
- sal_Int32 GetRowAtPosition (
- sal_Int32 nYPosition,
- bool bIncludeBordersAndGaps,
- GapMembership eGapMembership = GM_NONE) const;
-
- /** Calculate the column that the point with the given horizontal
- coordinate is over. The verical component is ignored.
- @param nXPosition
- Horizontal position in model coordinates.
- @param bIncludeBordersAndGaps
- When this flag is <TRUE/> then the area of borders and gaps are
- interpreted as belonging to one of the columns.
- @param eGapMembership
- Specifies to what column the gap areas belong. Here GM_NONE
- corresponds to bIncludeBordersAndGaps being <FALSE/>. When
- GM_BOTH is given then the left half is associated with the
- column at the left and the right half with the column to the
- right. Values of GM_PREVIOUS and GM_NEXT associate the whole
- gap area with the column to the left or right respectively.
- */
- sal_Int32 GetColumnAtPosition (
- sal_Int32 nXPosition,
- bool bIncludeBordersAndGaps,
- GapMembership eGapMembership = GM_NONE) const;
-
- /** This method is typically called from GetRowAtPosition() and
- GetColumnAtPosition() to handle a position that lies inside the gap
- between two adjacent rows or columns.
- @param nDistanceIntoGap
- Vertical distance from the bottom of the upper row down into the
- gap or or horizontal distance from the right edge right into the
- gap.
- @param eGapMemberhship
- This value decides what areas in the gap belong to which (or no)
- row or column.
- @param nIndex
- The row index of the upper row or the column index of the left
- column.
- @param nGap
- Width or height of the gap in model coordiantes between the
- page borders.
- @return
- Returns either the index of the upper row (as given as nRow), the
- index of the lower row (nRow+1) or -1 to indicate that the
- position belongs to no row.
- */
- sal_Int32 ResolvePositionInGap (
- sal_Int32 nDistanceIntoGap,
- GapMembership eGapMembership,
- sal_Int32 nIndex,
- sal_Int32 nGap) const;
-
- /** Calculate the logical part of the insert position, i.e. the page
- after whicht to insert.
- */
- void CalculateLogicalInsertPosition (
- const Point& rModelPosition,
- InsertPosition& rPosition) const;
-
- /** Calculate the geometrical part of the insert position, i.e. the
- location of where to display the insertion indicator and the
- distances about which the leading and trailing pages have to be
- moved to make room for the indicator.
- */
- void CalculateGeometricPosition (
- InsertPosition& rPosition,
- const Size& rIndicatorSize,
- const bool bIsVertical,
- model::SlideSorterModel& rModel) const;
-
- /** Return the bounding box of the preview or, when selected, of the page
- object. Thus, it returns something like a visual bounding box.
- */
- Rectangle GetInnerBoundingBox (
- model::SlideSorterModel& rModel,
- const sal_Int32 nIndex) const;
};
+
/** Collect all values concerning the logical and visual properties of the
insertion position that is used for drag-and-drop and copy-and-past.
*/
@@ -395,6 +263,18 @@ public:
bool operator== (const InsertPosition& rInsertPosition) const;
bool operator!= (const InsertPosition& rInsertPosition) const;
+ void SetLogicalPosition (
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn,
+ const sal_Int32 nIndex,
+ const bool bIsAtRunStart,
+ const bool bIsAtRunEnd,
+ const bool bIsExtraSpaceNeeded);
+ void SetGeometricalPosition(
+ const Point aLocation,
+ const Point aLeadingOffset,
+ const Point aTrailingOffset);
+
sal_Int32 GetRow (void) const { return mnRow; }
sal_Int32 GetColumn (void) const { return mnColumn; }
sal_Int32 GetIndex (void) const { return mnIndex; }
@@ -409,14 +289,12 @@ private:
sal_Int32 mnRow;
sal_Int32 mnColumn;
sal_Int32 mnIndex;
- Point maLocation;
- Point maLeadingOffset;
- Point maTrailingOffset;
bool mbIsAtRunStart : 1;
bool mbIsAtRunEnd : 1;
bool mbIsExtraSpaceNeeded : 1;
-
- friend class Layouter;
+ Point maLocation;
+ Point maLeadingOffset;
+ Point maTrailingOffset;
};
diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
index 089d9b70f5fc..d3fb4857ae64 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
@@ -200,26 +200,25 @@ void SlideSorter::Init (void)
SetupListeners ();
// Initialize the window.
- SharedSdWindow pWindow (GetContentWindow());
- if (pWindow != NULL)
+ SharedSdWindow pContentWindow (GetContentWindow());
+ if (pContentWindow)
{
- ::Window* pParentWindow = pWindow->GetParent();
+ ::Window* pParentWindow = pContentWindow->GetParent();
if (pParentWindow != NULL)
pParentWindow->SetBackground(Wallpaper());
- pWindow->SetBackground(Wallpaper());
- pWindow->SetViewOrigin (Point(0,0));
+ pContentWindow->SetBackground(Wallpaper());
+ pContentWindow->SetViewOrigin (Point(0,0));
// We do our own scrolling while dragging a page selection.
- pWindow->SetUseDropScroll (false);
+ pContentWindow->SetUseDropScroll (false);
// Change the winbits so that the active window accepts the focus.
- pWindow->SetStyle ((pWindow->GetStyle() & ~WB_DIALOGCONTROL) | WB_TABSTOP);
- pWindow->Hide();
+ pContentWindow->SetStyle ((pContentWindow->GetStyle() & ~WB_DIALOGCONTROL) | WB_TABSTOP);
+ pContentWindow->Hide();
// Set view pointer of base class.
SetupControls(pParentWindow);
mbIsValid = true;
}
-
}
@@ -697,7 +696,6 @@ long ContentWindow::Notify (NotifyEvent& rEvent)
-
} // end of anonymous namespace
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
index c339f9004d60..283be95d915f 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
@@ -38,6 +38,7 @@
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
#include "view/SlideSorterView.hxx"
+#include "view/SlsLayouter.hxx"
#include "DrawController.hxx"
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -50,7 +51,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing::framework;
using ::rtl::OUString;
-using ::sd::slidesorter::view::SlideSorterView;
+using ::sd::slidesorter::view::Layouter;
namespace sd { namespace slidesorter {
@@ -448,7 +449,7 @@ sal_Bool SAL_CALL SlideSorterService::getIsOrientationVertical (void)
if (mpSlideSorter.get() == NULL || ! mpSlideSorter->IsValid())
return true;
else
- return mpSlideSorter->GetView().GetOrientation() == SlideSorterView::VERTICAL;
+ return mpSlideSorter->GetView().GetOrientation() != Layouter::HORIZONTAL;
}
@@ -460,8 +461,8 @@ void SAL_CALL SlideSorterService::setIsOrientationVertical (sal_Bool bValue)
ThrowIfDisposed();
if (mpSlideSorter.get() != NULL && mpSlideSorter->IsValid())
mpSlideSorter->GetView().SetOrientation(bValue
- ? SlideSorterView::VERTICAL
- : SlideSorterView::HORIZONTAL);
+ ? Layouter::GRID
+ : Layouter::HORIZONTAL);
}
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index 4e0fc3c66260..edd3e37dae20 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -112,13 +112,6 @@ TYPEINIT1(SlideSorterViewShell, ViewShell);
pViewShell->Initialize();
if (pViewShell->mpSlideSorter.get() == NULL)
pViewShell.reset();
-
- // The layout of slides depends on whether the slide sorter is
- // displayed in the center or the side pane.
- if (bIsCenterPane)
- pViewShell->mpSlideSorter->GetView().SetOrientation(view::SlideSorterView::GRID);
- else
- pViewShell->mpSlideSorter->GetView().SetOrientation(view::SlideSorterView::VERTICAL);
}
catch(Exception&)
{
@@ -571,7 +564,29 @@ void SlideSorterViewShell::ArrangeGUIElements (void)
bool SlideSorterViewShell::HandleScrollCommand (const CommandEvent& rEvent, ::sd::Window* pWindow)
{
- bool bDone = ViewShell::HandleScrollCommand(rEvent, pWindow);
+ bool bDone (false);
+
+ if (rEvent.GetCommand() == COMMAND_WHEEL
+ && mpSlideSorter->GetView().GetOrientation() == view::Layouter::HORIZONTAL)
+ {
+ // Make the wheel scroll the horizontal scroll bar. For this we
+ // change the IsHoriz() flag of the CommandWheelData structure.
+ CommandWheelData* pData = (CommandWheelData*)rEvent.GetData();
+ CommandEvent aEvent (
+ rEvent.GetMousePosPixel(),
+ COMMAND_WHEEL,
+ FALSE,
+ new CommandWheelData(
+ pData->GetDelta(),
+ pData->GetNotchDelta(),
+ pData->GetScrollLines(),
+ pData->GetMode(),
+ pData->GetModifier(),
+ TRUE));
+ bDone = ViewShell::HandleScrollCommand(aEvent, pWindow);
+ }
+ else
+ bDone = ViewShell::HandleScrollCommand(rEvent, pWindow);
if (bDone)
{
@@ -617,16 +632,12 @@ void SlideSorterViewShell::ReadFrameViewData (FrameView* pFrameView)
view::SlideSorterView& rView (mpSlideSorter->GetView());
USHORT nSlidesPerRow (pFrameView->GetSlidesPerRow());
- if (nSlidesPerRow == 0 || ! IsMainViewShell())
+ if (nSlidesPerRow > 0
+ && rView.GetOrientation() == view::Layouter::GRID
+ && IsMainViewShell())
{
- // When a value of 0 (automatic) is given or the the slide
- // sorter is displayed in a side pane then we ignore the value
- // of the frame view and adapt the number of columns
- // automatically to the window width.
- rView.GetLayouter().SetColumnCount(1,1);
- }
- else
rView.GetLayouter().SetColumnCount(nSlidesPerRow,nSlidesPerRow);
+ }
if (IsMainViewShell())
mpSlideSorter->GetController().GetCurrentSlideManager()->NotifyCurrentSlideChange(
mpFrameView->GetSelectedPage());
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 16da8620fb9b..fdfd9ec8f8f0 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -54,6 +54,7 @@
#include "cache/SlsCacheContext.hxx"
#include "taskpane/SlideSorterCacheDisplay.hxx"
#include "DrawDocShell.hxx"
+#include "PaneDockingWindow.hxx"
#include "drawdoc.hxx"
#include "sdpage.hxx"
@@ -122,97 +123,8 @@ 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),
- mbIsValid(rWindowSize.Width()>10 && rWindowSize.Height()>10),
- mnSpeedUp(0.5 + rand() * 1.0 / RAND_MAX)
- {
- }
- void SetTime (const double nTime)
- {
- mnLocalTime = (nTime - mnStartTime) * mnSpeedUp;
- if (mnLocalTime >= 0 && mnLocalTime <= mnSpeedUp)
- mnValue = controller::AnimationFunction::SlowInSlowOut_0to0_Sine(mnLocalTime/mnSpeedUp);
- else
- mnValue = 0;
- }
- bool IsExpired (void)
- {
- return mnLocalTime >= mnSpeedUp || ! mbIsValid;
- }
-
- 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 || ! mbIsValid)
- 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;
- const bool mbIsValid;
- const double mnSpeedUp;
-
- 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,
@@ -220,31 +132,15 @@ class BackgroundPainter
{
public:
BackgroundPainter (
- const ::boost::shared_ptr<controller::Animator>& rpAnimator,
const SharedSdWindow& rpWindow,
- const Color aBackgroundColor,
- const bool bIsAnimated)
- : mpAnimator(rpAnimator),
- maBackgroundColor(aBackgroundColor),
- maSpheres(),
- mpInvalidator(),
- mpWindow(rpWindow),
- mnAnimationId(controller::Animator::NotAnAnimationId)
+ const Color aBackgroundColor)
+ : maBackgroundColor(aBackgroundColor),
+ 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)
{
- if (mnAnimationId >= 0)
- mpAnimator->RemoveAnimation(mnAnimationId);
}
virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea)
@@ -252,66 +148,16 @@ public:
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();
+ (void)rpInvalidator;
}
private:
- const ::boost::shared_ptr<controller::Animator> mpAnimator;
const Color maBackgroundColor;
- typedef ::std::vector< ::boost::shared_ptr<AnimatedSphere> > SphereVector;
- SphereVector maSpheres;
- SharedILayerInvalidator mpInvalidator;
SharedSdWindow 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());
- }
- }
};
@@ -334,7 +180,7 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
mbModelChangedWhileModifyEnabled(true),
maPreviewSize(0,0),
mbPreciousFlagUpdatePending(true),
- meOrientation(VERTICAL),
+ meOrientation(Layouter::GRID),
mpProperties(rSlideSorter.GetProperties()),
mpPageUnderMouse(),
mbIsMouseOverIndicationAllowed(true),
@@ -342,8 +188,6 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
mpPageObjectPainter(),
mpSelectionPainter()
{
- OSL_TRACE("layered device at %x", mpLayeredDevice.get());
-
// Hide the page that contains the page objects.
SetPageVisible (FALSE);
@@ -352,7 +196,6 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
// the SlideSorterView destructor the layered device is destroyed and
// with it the only reference to the wrapper which therefore is also
// destroyed.
- OSL_TRACE("layered device at %x", mpLayeredDevice.get());
mpLayeredDevice->RegisterPainter(SharedILayerPainter(new Painter(*this)), 2);
}
@@ -374,9 +217,6 @@ SlideSorterView::~SlideSorterView (void)
void SlideSorterView::Init (void)
{
HandleModelChange();
-
- // mpSelectionPainter.reset(new SelectionPainter(mrSlideSorter));
- // mpLayeredDevice->RegisterPainter(mpSelectionPainter, 1);
}
@@ -389,7 +229,7 @@ void SlideSorterView::Dispose (void)
mpLayeredDevice->Dispose();
mpPreviewCache.reset();
- // hide the page to avoid problems in the view when deleting
+ // Hide the page to avoid problems in the view when deleting
// visualized objects
HideSdrPage();
@@ -448,11 +288,6 @@ void SlideSorterView::LocalModelHasChanged(void)
// First call our base class.
View::ModelHasChanged ();
-
- // Initialize everything that depends on a page view, now that we have
- // one.
- // SetApplicationDocumentColor(
- // Application::GetSettings().GetStyleSettings().GetWindowColor());
}
@@ -514,34 +349,25 @@ void SlideSorterView::HandleDrawModeChange (void)
void SlideSorterView::Resize (void)
{
+ UpdateOrientation();
+
if ( ! mpLayeredDevice->HasPainter(0))
mpLayeredDevice->RegisterPainter(
SharedILayerPainter(new BackgroundPainter(
- mrSlideSorter.GetController().GetAnimator(),
mrSlideSorter.GetContentWindow(),
- mrSlideSorter.GetTheme()->GetColor(Theme::Background),
- false)),
+ mrSlideSorter.GetTheme()->GetColor(Theme::Background))),
0);
mpLayeredDevice->Resize();
SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
if (mrModel.GetPageCount()>0 && pWindow)
{
- bool bRearrangeSuccess (false);
- if (meOrientation == HORIZONTAL)
- {
- bRearrangeSuccess = mpLayouter->RearrangeHorizontal (
- pWindow->GetSizePixel(),
- mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- mrModel.GetPageCount());
- }
- else
- {
- bRearrangeSuccess = mpLayouter->RearrangeVertical (
+ const bool bRearrangeSuccess (
+ mpLayouter->Rearrange (
+ meOrientation,
pWindow->GetSizePixel(),
mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
- mrModel.GetPageCount());
- }
+ mrModel.GetPageCount()));
if (bRearrangeSuccess)
{
@@ -554,6 +380,75 @@ void SlideSorterView::Resize (void)
+void SlideSorterView::UpdateOrientation (void)
+{
+ // The layout of slides depends on whether the slide sorter is
+ // displayed in the center or the side pane.
+ if (mrSlideSorter.GetViewShell()->IsMainViewShell())
+ SetOrientation(Layouter::GRID);
+ else
+ {
+ // Get access to the docking window.
+ ::Window* pWindow = mrSlideSorter.GetContentWindow().get();
+ PaneDockingWindow* pDockingWindow = NULL;
+ while (pWindow!=NULL && pDockingWindow==NULL)
+ {
+ pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
+ pWindow = pWindow->GetParent();
+ }
+
+ if (pDockingWindow != NULL)
+ {
+ const long nScrollBarSize (
+ Application::GetSettings().GetStyleSettings().GetScrollBarSize());
+ switch (pDockingWindow->GetOrientation())
+ {
+ case PaneDockingWindow::HorizontalOrientation:
+ if (SetOrientation(Layouter::HORIZONTAL))
+ {
+ const Range aRange (mpLayouter->GetValidVerticalSizeRange());
+ pDockingWindow->SetValidSizeRange(Range(
+ aRange.Min() + nScrollBarSize,
+ aRange.Max() + nScrollBarSize));
+ }
+ break;
+
+ case PaneDockingWindow::VerticalOrientation:
+ if (SetOrientation(Layouter::VERTICAL))
+ {
+ const Range aRange (mpLayouter->GetValidHorizontalSizeRange());
+ pDockingWindow->SetValidSizeRange(Range(
+ aRange.Min() + nScrollBarSize,
+ aRange.Max() + nScrollBarSize));
+ }
+ break;
+
+ case PaneDockingWindow::UnknownOrientation:
+ if (SetOrientation(Layouter::GRID))
+ {
+ const sal_Int32 nAdditionalSize (10);
+ pDockingWindow->SetMinOutputSizePixel(Size(
+ mpLayouter->GetValidHorizontalSizeRange().Min()
+ + nScrollBarSize
+ + nAdditionalSize,
+ mpLayouter->GetValidVerticalSizeRange().Min()
+ + nScrollBarSize
+ + nAdditionalSize));
+ }
+ return;
+ }
+ }
+ else
+ {
+ OSL_ASSERT(pDockingWindow!=NULL);
+ SetOrientation(Layouter::GRID);
+ }
+ }
+}
+
+
+
+
void SlideSorterView::Layout ()
{
SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
@@ -561,7 +456,7 @@ void SlideSorterView::Layout ()
{
// Set the model area, i.e. the smallest rectangle that includes all
// page objects.
- const Rectangle aViewBox (mpLayouter->GetPageBox(mrModel.GetPageCount()));
+ const Rectangle aViewBox (mpLayouter->GetTotalBoundingBox());
pWindow->SetViewOrigin (aViewBox.TopLeft());
pWindow->SetViewSize (aViewBox.GetSize());
@@ -679,16 +574,21 @@ void SlideSorterView::UpdatePreciousFlags (void)
-void SlideSorterView::SetOrientation (const Orientation eOrientation)
+bool SlideSorterView::SetOrientation (const Layouter::Orientation eOrientation)
{
- meOrientation = eOrientation;
- RequestRepaint();
+ if (meOrientation != eOrientation)
+ {
+ meOrientation = eOrientation;
+ return true;
+ }
+ else
+ return false;
}
-SlideSorterView::Orientation SlideSorterView::GetOrientation (void) const
+Layouter::Orientation SlideSorterView::GetOrientation (void) const
{
return meOrientation;
}
@@ -747,7 +647,7 @@ void SlideSorterView::RequestRepaint (const Region& rRepaintRegion)
Rectangle SlideSorterView::GetModelArea (void)
{
- return mpLayouter->GetPageBox(mrModel.GetPageCount());
+ return mpLayouter->GetTotalBoundingBox();
}
@@ -917,7 +817,7 @@ void SlideSorterView::SetIsMouseOverIndicationAllowed (const bool bIsAllowed)
void SlideSorterView::UpdatePageUnderMouse (bool bAnimate)
{
SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
- if (pWindow)
+ if (pWindow && ! pWindow->IsMouseCaptured())
{
const Window::PointerState aPointerState (pWindow->GetPointerState());
UpdatePageUnderMouse (
diff --git a/sd/source/ui/slidesorter/view/SlsLayouter.cxx b/sd/source/ui/slidesorter/view/SlsLayouter.cxx
index 156ebaac8b7d..cc43787972a8 100644
--- a/sd/source/ui/slidesorter/view/SlsLayouter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsLayouter.cxx
@@ -33,69 +33,301 @@
#include "view/SlsLayouter.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
-
#include "Window.hxx"
+#include <rtl/math.hxx>
#include <basegfx/numeric/ftools.hxx>
+namespace {
+ sal_Int32 RoundToInt (const double nValue)
+ {
+ return sal_Int32(::rtl::math::round(nValue));
+ }
+}
+
namespace sd { namespace slidesorter { namespace view {
-Layouter::Layouter (const SharedSdWindow& rpWindow)
- : mpWindow(rpWindow),
- mnRequestedLeftBorder(5),
- mnRequestedRightBorder(5),
- mnRequestedTopBorder(5),
- mnRequestedBottomBorder(5),
- mnLeftBorder(5),
- mnRightBorder(5),
- mnTopBorder(5),
- mnBottomBorder(5),
- mnVerticalGap (10),
- mnHorizontalGap(10),
- mnMinimalWidth(100),
- mnPreferredWidth(200),
- mnMaximalWidth(300),
- mnMinimalColumnCount(1),
- mnMaximalColumnCount(4),
- mnPageCount(0),
- mnColumnCount(1),
- mnRowCount(0),
- mnMaxColumnCount(0),
- mnMaxRowCount(0),
- maPageObjectSize(1,1),
- mbIsVertical(true)
+class Layouter::Implementation
{
-}
+public:
+ SharedSdWindow 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;
+ Size maMinimalSize;
+ Size maPreferredSize;
+ Size maMaximalSize;
+ sal_Int32 mnMinimalColumnCount;
+ sal_Int32 mnMaximalColumnCount;
+ sal_Int32 mnPageCount;
+ sal_Int32 mnColumnCount;
+ sal_Int32 mnRowCount;
+ /// The maximum number of columns. Can only be larger than the current
+ /// number of columns when there are not enough pages to fill all
+ /// available columns.
+ sal_Int32 mnMaxColumnCount;
+ /// The maximum number of rows. Can only be larger than the current
+ /// number of rows when there are not enough pages to fill all available
+ /// rows.
+ sal_Int32 mnMaxRowCount;
+ Size maPageObjectSize;
+
+ ::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
+
+ enum GapMembership {
+ GM_NONE,
+ GM_PREVIOUS,
+ GM_BOTH,
+ GM_NEXT,
+ GM_PAGE_BORDER
+ };
+
+ static Implementation* Create (
+ const Implementation& rImplementation,
+ const Layouter::Orientation eOrientation);
+
+ virtual Layouter::Orientation GetOrientation (void) const = 0;
+
+ bool Rearrange (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize,
+ const sal_uInt32 nPageCount);
+
+ /** Calculate the row that the point with the given vertical coordinate
+ is over. The horizontal component is ignored.
+ @param nYPosition
+ Vertical position in model coordinates.
+ @param bIncludeBordersAndGaps
+ When this flag is <TRUE/> then the area of borders and gaps are
+ interpreted as belonging to one of the rows.
+ @param eGapMembership
+ Specifies to what row the gap areas belong. Here GM_NONE
+ corresponds to bIncludeBordersAndGaps being <FALSE/>. When
+ GM_BOTH is given then the upper half is associated to the row
+ above and the lower half to the row below. Values of
+ GM_PREVIOUS and GM_NEXT associate the whole gap area with the
+ row above or below respectively.
+ */
+ sal_Int32 GetRowAtPosition (
+ sal_Int32 nYPosition,
+ bool bIncludeBordersAndGaps,
+ GapMembership eGapMembership = GM_NONE) const;
+
+ /** Calculate the column that the point with the given horizontal
+ coordinate is over. The verical component is ignored.
+ @param nXPosition
+ Horizontal position in model coordinates.
+ @param bIncludeBordersAndGaps
+ When this flag is <TRUE/> then the area of borders and gaps are
+ interpreted as belonging to one of the columns.
+ @param eGapMembership
+ Specifies to what column the gap areas belong. Here GM_NONE
+ corresponds to bIncludeBordersAndGaps being <FALSE/>. When
+ GM_BOTH is given then the left half is associated with the
+ column at the left and the right half with the column to the
+ right. Values of GM_PREVIOUS and GM_NEXT associate the whole
+ gap area with the column to the left or right respectively.
+ */
+ sal_Int32 GetColumnAtPosition (
+ sal_Int32 nXPosition,
+ bool bIncludeBordersAndGaps,
+ GapMembership eGapMembership = GM_NONE) const;
+
+ /** This method is typically called from GetRowAtPosition() and
+ GetColumnAtPosition() to handle a position that lies inside the gap
+ between two adjacent rows or columns.
+ @param nDistanceIntoGap
+ Vertical distance from the bottom of the upper row down into the
+ gap or or horizontal distance from the right edge right into the
+ gap.
+ @param eGapMemberhship
+ This value decides what areas in the gap belong to which (or no)
+ row or column.
+ @param nIndex
+ The row index of the upper row or the column index of the left
+ column.
+ @param nGap
+ Width or height of the gap in model coordiantes between the
+ page borders.
+ @return
+ Returns either the index of the upper row (as given as nRow), the
+ index of the lower row (nRow+1) or -1 to indicate that the
+ position belongs to no row.
+ */
+ sal_Int32 ResolvePositionInGap (
+ sal_Int32 nDistanceIntoGap,
+ GapMembership eGapMembership,
+ sal_Int32 nIndex,
+ sal_Int32 nGap) const;
+
+ /** Calculate the logical part of the insert position, i.e. the page
+ after whicht to insert.
+ */
+ virtual void CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const = 0;
+
+ /** Calculate the geometrical part of the insert position, i.e. the
+ location of where to display the insertion indicator and the
+ distances about which the leading and trailing pages have to be
+ moved to make room for the indicator.
+ */
+ void CalculateGeometricPosition (
+ InsertPosition& rPosition,
+ const Size& rIndicatorSize,
+ const bool bIsVertical,
+ model::SlideSorterModel& rModel) const;
+
+ /** Return the bounding box of the preview or, when selected, of the page
+ object. Thus, it returns something like a visual bounding box.
+ */
+ Rectangle GetInnerBoundingBox (
+ model::SlideSorterModel& rModel,
+ const sal_Int32 nIndex) const;
+
+ Range GetValidHorizontalSizeRange (void) const;
+ Range GetValidVerticalSizeRange (void) const;
+
+ Size CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize,
+ const bool bCalculateWidth,
+ const bool bCalculateHeight) const;
+
+ Rectangle GetPageObjectBox (
+ const sal_Int32 nIndex,
+ const bool bIncludeBorderAndGap = false) const;
+
+ Rectangle GetPageObjectBox (
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn) const;
+
+ Rectangle AddBorderAndGap (
+ const Rectangle& rBoundingBox,
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn) const;
+
+ Rectangle GetTotalBoundingBox (void) const;
+
+ virtual ~Implementation (void);
+protected:
+ Implementation (const SharedSdWindow& rpWindow);
+ Implementation (const Implementation& rImplementation);
+
+ virtual void CalculateRowAndColumnCount (const Size& rWindowSize) = 0;
+ virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize) = 0;
+ virtual Size CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const = 0;
+ void CalculateVerticalLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const;
+};
+
+
+/** The vertical layouter has one column and as many rows as there are
+ pages.
+*/
+class VerticalImplementation : public Layouter::Implementation
+{
+public:
+ VerticalImplementation (const SharedSdWindow& rpWindow);
+ VerticalImplementation (const Implementation& rImplementation);
+ virtual Layouter::Orientation GetOrientation (void) const;
+ void CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const;
+protected:
+ virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
+ virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
+ virtual Size CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const;
+};
-Layouter::~Layouter (void)
+
+/** The horizontal layouter has one row and as many columns as there are
+ pages.
+*/
+class HorizontalImplementation : public Layouter::Implementation
+{
+public:
+ HorizontalImplementation (const SharedSdWindow& rpWindow);
+ HorizontalImplementation (const Implementation& rImplementation);
+
+ virtual Layouter::Orientation GetOrientation (void) const;
+
+ void CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const;
+
+protected:
+ virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
+ virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
+ virtual Size CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const;
+};
+
+
+/** The number of columns of the grid layouter is defined via a control in
+ the slide sorter tool bar. The number of rows is calculated from the
+ number of columns and the number of pages.
+*/
+class GridImplementation : public Layouter::Implementation
+{
+public:
+ GridImplementation (const SharedSdWindow& rpWindow);
+ GridImplementation (const Implementation& rImplementation);
+
+ virtual Layouter::Orientation GetOrientation (void) const;
+
+ void CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const;
+
+protected:
+ virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
+ virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
+ virtual Size CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const;
+};
+
+
+
+
+//===== Layouter ==============================================================
+
+Layouter::Layouter (const SharedSdWindow& rpWindow)
+ : mpImplementation(new GridImplementation(rpWindow)),
+ mpWindow(rpWindow)
{
}
-::boost::shared_ptr<PageObjectLayouter> Layouter::GetPageObjectLayouter (void) const
+Layouter::~Layouter (void)
{
- return mpPageObjectLayouter;
}
-void Layouter::SetObjectWidth (
- sal_Int32 nMinimalWidth,
- sal_Int32 nMaximalWidth,
- sal_Int32 nPreferredWidth)
+::boost::shared_ptr<PageObjectLayouter> Layouter::GetPageObjectLayouter (void) const
{
- if (nMinimalWidth <= nPreferredWidth && nPreferredWidth <= nMaximalWidth)
- {
- mnMinimalWidth = nMinimalWidth;
- mnPreferredWidth = nMaximalWidth;
- mnMaximalWidth = nPreferredWidth;
- }
+ return mpImplementation->mpPageObjectLayouter;
}
@@ -108,13 +340,13 @@ void Layouter::SetBorders (
sal_Int32 nBottomBorder)
{
if (nLeftBorder >= 0)
- mnRequestedLeftBorder = nLeftBorder;
+ mpImplementation->mnRequestedLeftBorder = nLeftBorder;
if (nRightBorder >= 0)
- mnRequestedRightBorder = nRightBorder;
+ mpImplementation->mnRequestedRightBorder = nRightBorder;
if (nTopBorder >= 0)
- mnRequestedTopBorder = nTopBorder;
+ mpImplementation->mnRequestedTopBorder = nTopBorder;
if (nBottomBorder >= 0)
- mnRequestedBottomBorder = nBottomBorder;
+ mpImplementation->mnRequestedBottomBorder = nBottomBorder;
}
@@ -125,9 +357,9 @@ void Layouter::SetGaps (
sal_Int32 nVerticalGap)
{
if (nHorizontalGap >= 0)
- mnHorizontalGap = nHorizontalGap;
+ mpImplementation->mnHorizontalGap = nHorizontalGap;
if (nVerticalGap >= 0)
- mnVerticalGap = nVerticalGap;
+ mpImplementation->mnVerticalGap = nVerticalGap;
}
@@ -140,193 +372,46 @@ void Layouter::SetColumnCount (
{
if (nMinimalColumnCount <= nMaximalColumnCount)
{
- mnMinimalColumnCount = nMinimalColumnCount;
- mnMaximalColumnCount = nMaximalColumnCount;
+ mpImplementation->mnMinimalColumnCount = nMinimalColumnCount;
+ mpImplementation->mnMaximalColumnCount = nMaximalColumnCount;
}
}
-bool Layouter::RearrangeHorizontal (
+bool Layouter::Rearrange (
+ const Orientation eOrientation,
const Size& rWindowSize,
const Size& rPageSize,
const sal_uInt32 nPageCount)
{
OSL_ASSERT(mpWindow);
- mbIsVertical = false;
- mnPageCount = nPageCount;
-
- if (rWindowSize.Width() > 0
- && rWindowSize.Height() > 0
- && rPageSize.Width() > 0
- && rPageSize.Height() > 0)
- {
- // Calculate the column count.
- mnColumnCount = nPageCount;
- mnRowCount = 1;
-
- // Update the border values.
- mnLeftBorder = mnRequestedLeftBorder;
- mnTopBorder = mnRequestedTopBorder;
- mnRightBorder = mnRequestedRightBorder;
- mnBottomBorder = mnRequestedBottomBorder;
- if (mnColumnCount > 1)
- {
- int nMinimumBorderWidth = mnHorizontalGap/2;
- if (mnLeftBorder < nMinimumBorderWidth)
- mnLeftBorder = nMinimumBorderWidth;
- if (mnRightBorder < nMinimumBorderWidth)
- mnRightBorder = nMinimumBorderWidth;
- }
- else
- {
- int nMinimumBorderHeight = mnVerticalGap/2;
- if (mnTopBorder < nMinimumBorderHeight)
- mnTopBorder = nMinimumBorderHeight;
- if (mnBottomBorder < nMinimumBorderHeight)
- mnBottomBorder = nMinimumBorderHeight;
- }
-
- // Calculate the width of each page object.
- sal_uInt32 nTargetHeight = 0;
- sal_uInt32 nRowCount = 1;
- if (mnColumnCount > 0)
- nTargetHeight = (rWindowSize.Height()
- - mnTopBorder
- - mnBottomBorder
- - (nRowCount-1) * mnVerticalGap
- )
- / nRowCount;
- 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;
-
- // 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();
-
- mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
- / (maPageObjectSize.Width() + mnHorizontalGap);
- mnMaxRowCount = 1;
-
- return true;
- }
- else
- return false;
-}
-
-
-
-
-bool Layouter::RearrangeVertical (
- const Size& rWindowSize,
- const Size& rPreviewModelSize,
- const sal_uInt32 nPageCount)
-{
- OSL_ASSERT(mpWindow);
-
- mbIsVertical = true;
- mnPageCount = nPageCount;
+ if (eOrientation != mpImplementation->GetOrientation())
+ mpImplementation.reset(Implementation::Create(*mpImplementation, eOrientation));
- if (rWindowSize.Width() > 0
- && rWindowSize.Height() > 0
- && rPreviewModelSize.Width() > 0
- && rPreviewModelSize.Height() > 0)
- {
- // Calculate the column count.
- 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.
- mnLeftBorder = mnRequestedLeftBorder;
- mnTopBorder = mnRequestedTopBorder;
- mnRightBorder = mnRequestedRightBorder;
- mnBottomBorder = mnRequestedBottomBorder;
- if (mnColumnCount > 1)
- {
- int nMinimumBorderWidth = mnHorizontalGap/2;
- if (mnLeftBorder < nMinimumBorderWidth)
- mnLeftBorder = nMinimumBorderWidth;
- if (mnRightBorder < nMinimumBorderWidth)
- mnRightBorder = nMinimumBorderWidth;
- }
- else
- {
- 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
- - mnRightBorder
- - (mnColumnCount-1) * mnHorizontalGap
- )
- / mnColumnCount;
- if (nTargetWidth < mnMinimalWidth)
- nTargetWidth = mnMinimalWidth;
- if (nTargetWidth > mnMaximalWidth)
- nTargetWidth = mnMaximalWidth;
-
- // 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();
-
- mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
- / (maPageObjectSize.Width() + mnHorizontalGap);
- mnMaxRowCount = (rWindowSize.Height() - mnTopBorder - mnBottomBorder)
- / (maPageObjectSize.Height() + mnVerticalGap);
-
- return true;
- }
- else
- return false;
+ return mpImplementation->Rearrange(rWindowSize, rPageSize, nPageCount);
}
-void Layouter::SetZoom (double nZoomFactor)
+void Layouter::_SetZoom (double nZoomFactor)
{
- SetZoom(Fraction(nZoomFactor));
+ _SetZoom(Fraction(nZoomFactor));
}
-void Layouter::SetZoom (Fraction nZoomFactor)
+void Layouter::_SetZoom (Fraction nZoomFactor)
{
OSL_ASSERT(mpWindow);
MapMode aMapMode (mpWindow->GetMapMode());
aMapMode.SetScaleX (nZoomFactor);
aMapMode.SetScaleY (nZoomFactor);
- // maPageObjectPixelSize = mpWindow->LogicToPixel (maPageObjectModelSize);
mpWindow->SetMapMode (aMapMode);
}
@@ -335,7 +420,7 @@ void Layouter::SetZoom (Fraction nZoomFactor)
sal_Int32 Layouter::GetColumnCount (void) const
{
- return mnColumnCount;
+ return mpImplementation->mnColumnCount;
}
@@ -343,7 +428,7 @@ sal_Int32 Layouter::GetColumnCount (void) const
sal_Int32 Layouter::GetRowCount (void) const
{
- return mnRowCount;
+ return mpImplementation->mnRowCount;
}
@@ -351,7 +436,7 @@ sal_Int32 Layouter::GetRowCount (void) const
sal_Int32 Layouter::GetRow (const sal_Int32 nIndex) const
{
- return nIndex / mnColumnCount;
+ return nIndex / mpImplementation->mnColumnCount;
}
@@ -359,7 +444,7 @@ sal_Int32 Layouter::GetRow (const sal_Int32 nIndex) const
sal_Int32 Layouter::GetColumn (const sal_Int32 nIndex) const
{
- return nIndex % mnColumnCount;
+ return nIndex % mpImplementation->mnColumnCount;
}
@@ -367,9 +452,9 @@ sal_Int32 Layouter::GetColumn (const sal_Int32 nIndex) const
sal_Int32 Layouter::GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const
{
- const sal_Int32 nIndex (nRow * mnColumnCount + nColumn);
+ const sal_Int32 nIndex (nRow * mpImplementation->mnColumnCount + nColumn);
OSL_ASSERT(nIndex>=0);
- return ::std::min(nIndex, mnPageCount-1);
+ return ::std::min(nIndex, mpImplementation->mnPageCount-1);
}
@@ -377,7 +462,7 @@ sal_Int32 Layouter::GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) con
bool Layouter::IsColumnCountFixed (void) const
{
- return mnMinimalColumnCount == mnMaximalColumnCount;
+ return mpImplementation->mnMinimalColumnCount == mpImplementation->mnMaximalColumnCount;
}
@@ -385,7 +470,7 @@ bool Layouter::IsColumnCountFixed (void) const
Size Layouter::GetPageObjectSize (void) const
{
- return maPageObjectSize;
+ return mpImplementation->maPageObjectSize;
}
@@ -395,70 +480,15 @@ Rectangle Layouter::GetPageObjectBox (
const sal_Int32 nIndex,
const bool bIncludeBorderAndGap) const
{
- const sal_Int32 nRow (GetRow(nIndex));
- const sal_Int32 nColumn (GetColumn(nIndex));
- Rectangle aBoundingBox(
- Point (mnLeftBorder
- + nColumn * maPageObjectSize.Width()
- + (nColumn>0 ? nColumn : 0) * mnHorizontalGap,
- mnTopBorder
- + nRow * maPageObjectSize.Height()
- + (nRow>0 ? nRow : 0) * mnVerticalGap),
- maPageObjectSize);
- if (bIncludeBorderAndGap)
- {
- 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;
+ return mpImplementation->GetPageObjectBox(nIndex, bIncludeBorderAndGap);
}
-Rectangle Layouter::GetPageBox (const sal_Int32 nObjectCount) const
+Rectangle Layouter::GetTotalBoundingBox (void) const
{
- sal_Int32 nCount (nObjectCount);
- if (nCount < 0)
- nCount = mnPageCount;
-
- sal_Int32 nHorizontalSize = 0;
- sal_Int32 nVerticalSize = 0;
- if (mnColumnCount > 0)
- {
- sal_Int32 nRowCount = (nCount+mnColumnCount-1) / mnColumnCount;
- nHorizontalSize =
- mnLeftBorder
- + mnRightBorder
- + mnColumnCount * maPageObjectSize.Width();
- if (mnColumnCount > 1)
- nHorizontalSize += (mnColumnCount-1) * mnHorizontalGap;
- nVerticalSize =
- mnTopBorder
- + mnBottomBorder
- + nRowCount * maPageObjectSize.Height();
- if (nRowCount > 1)
- nVerticalSize += (nRowCount-1) * mnVerticalGap;
- }
-
- return Rectangle (
- Point(0,0),
- Size (nHorizontalSize, nVerticalSize)
- );
+ return mpImplementation->GetTotalBoundingBox();
}
@@ -470,59 +500,353 @@ InsertPosition Layouter::GetInsertPosition (
model::SlideSorterModel& rModel) const
{
InsertPosition aPosition;
- CalculateLogicalInsertPosition(rModelPosition, aPosition);
- CalculateGeometricPosition(aPosition, rIndicatorSize, GetColumnCount()==1, rModel);
+ mpImplementation->CalculateLogicalInsertPosition(
+ rModelPosition,
+ aPosition);
+ mpImplementation->CalculateGeometricPosition(
+ aPosition,
+ rIndicatorSize,
+ GetColumnCount()==1,
+ rModel);
return aPosition;
}
-void Layouter::CalculateLogicalInsertPosition (
- const Point& rModelPosition,
- InsertPosition& rPosition) const
+Range Layouter::GetValidHorizontalSizeRange (void) const
{
- // Determine logical position.
- if (mnColumnCount == 1)
+ return mpImplementation->GetValidHorizontalSizeRange();
+}
+
+
+
+
+Range Layouter::GetValidVerticalSizeRange (void) const
+{
+ return mpImplementation->GetValidVerticalSizeRange();
+}
+
+
+
+
+Range Layouter::GetRangeOfVisiblePageObjects (const Rectangle& aVisibleArea) const
+{
+ const sal_Int32 nRow0 (mpImplementation->GetRowAtPosition (
+ aVisibleArea.Top(),
+ true,
+ Implementation::GM_BOTH));
+ const sal_Int32 nRow1 (mpImplementation->GetRowAtPosition (
+ aVisibleArea.Bottom(),
+ true,
+ Implementation::GM_BOTH));
+ return Range(
+ ::std::min(nRow0*mpImplementation->mnColumnCount, mpImplementation->mnPageCount-1),
+ ::std::min((nRow1+1)*mpImplementation->mnColumnCount-1, mpImplementation->mnPageCount-1));
+}
+
+
+
+
+sal_Int32 Layouter::GetIndexAtPoint (
+ const Point& rPosition,
+ const bool bIncludePageBorders) const
+{
+ const sal_Int32 nRow (
+ mpImplementation->GetRowAtPosition (
+ rPosition.Y(),
+ bIncludePageBorders,
+ bIncludePageBorders ? Implementation::GM_PAGE_BORDER : Implementation::GM_NONE));
+ const sal_Int32 nColumn (
+ mpImplementation->GetColumnAtPosition (
+ rPosition.X(),
+ bIncludePageBorders,
+ bIncludePageBorders ? Implementation::GM_PAGE_BORDER : Implementation::GM_NONE));
+
+ if (nRow >= 0 && nColumn >= 0)
+ return nRow * mpImplementation->mnColumnCount + nColumn;
+ else
+ return -1;
+}
+
+
+
+
+//===== Layouter::Implementation ==============================================
+
+Layouter::Implementation* Layouter::Implementation::Create (
+ const Implementation& rImplementation,
+ const Layouter::Orientation eOrientation)
+{
+ switch (eOrientation)
+ {
+ case HORIZONTAL: return new HorizontalImplementation(rImplementation);
+ case VERTICAL: return new VerticalImplementation(rImplementation);
+ case GRID:
+ default: return new GridImplementation(rImplementation);
+ }
+}
+
+
+
+
+Layouter::Implementation::Implementation (const SharedSdWindow& rpWindow)
+ : mpWindow(rpWindow),
+ mnRequestedLeftBorder(5),
+ mnRequestedRightBorder(5),
+ mnRequestedTopBorder(5),
+ mnRequestedBottomBorder(5),
+ mnLeftBorder(5),
+ mnRightBorder(5),
+ mnTopBorder(5),
+ mnBottomBorder(5),
+ mnVerticalGap (10),
+ mnHorizontalGap(10),
+ maMinimalSize(100,75),
+ maPreferredSize(200,150),
+ maMaximalSize(300,200),
+ mnMinimalColumnCount(1),
+ mnMaximalColumnCount(15),
+ mnPageCount(0),
+ mnColumnCount(1),
+ mnRowCount(0),
+ mnMaxColumnCount(0),
+ mnMaxRowCount(0),
+ maPageObjectSize(1,1)
+{
+}
+
+
+
+
+Layouter::Implementation::Implementation (const Implementation& rImplementation)
+ : mpWindow(rImplementation.mpWindow),
+ mnRequestedLeftBorder(rImplementation.mnRequestedLeftBorder),
+ mnRequestedRightBorder(rImplementation.mnRequestedRightBorder),
+ mnRequestedTopBorder(rImplementation.mnRequestedTopBorder),
+ mnRequestedBottomBorder(rImplementation.mnRequestedBottomBorder),
+ mnLeftBorder(rImplementation.mnLeftBorder),
+ mnRightBorder(rImplementation.mnRightBorder),
+ mnTopBorder(rImplementation.mnTopBorder),
+ mnBottomBorder(rImplementation.mnBottomBorder),
+ mnVerticalGap(rImplementation.mnVerticalGap),
+ mnHorizontalGap(rImplementation.mnHorizontalGap),
+ maMinimalSize(rImplementation.maMinimalSize),
+ maPreferredSize(rImplementation.maPreferredSize),
+ maMaximalSize(rImplementation.maMaximalSize),
+ mnMinimalColumnCount(rImplementation.mnMinimalColumnCount),
+ mnMaximalColumnCount(rImplementation.mnMaximalColumnCount),
+ mnPageCount(rImplementation.mnPageCount),
+ mnColumnCount(rImplementation.mnColumnCount),
+ mnRowCount(rImplementation.mnRowCount),
+ mnMaxColumnCount(rImplementation.mnMaxColumnCount),
+ mnMaxRowCount(rImplementation.mnMaxRowCount),
+ maPageObjectSize(rImplementation.maPageObjectSize)
+{
+}
+
+
+
+
+Layouter::Implementation::~Implementation (void)
+{
+}
+
+
+
+
+bool Layouter::Implementation::Rearrange (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize,
+ const sal_uInt32 nPageCount)
+{
+ mnPageCount = nPageCount;
+
+ if (rWindowSize.Width()<=0 || rWindowSize.Height()<=0)
+ return false;
+ if (rPreviewModelSize.Width()<=0 || rPreviewModelSize.Height()<=0)
+ return false;
+
+ CalculateRowAndColumnCount(rWindowSize);
+
+ // Update the border values.
+ mnLeftBorder = mnRequestedLeftBorder;
+ mnTopBorder = mnRequestedTopBorder;
+ mnRightBorder = mnRequestedRightBorder;
+ mnBottomBorder = mnRequestedBottomBorder;
+ if (mnColumnCount > 1)
{
- const sal_Int32 nY = rModelPosition.Y() - mnTopBorder + maPageObjectSize.Height()/2;
- const sal_Int32 nRowHeight (maPageObjectSize.Height() + mnVerticalGap);
- rPosition.mnRow = ::std::min(mnPageCount, nY / nRowHeight);
- rPosition.mnColumn = 0;
- rPosition.mnIndex = rPosition.mnRow;
- rPosition.mbIsAtRunStart = (rPosition.mnRow == 0);
- rPosition.mbIsAtRunEnd = (rPosition.mnRow == mnRowCount);
- rPosition.mbIsExtraSpaceNeeded = (rPosition.mnRow >= mnMaxRowCount);
+ int nMinimumBorderWidth = mnHorizontalGap/2;
+ if (mnLeftBorder < nMinimumBorderWidth)
+ mnLeftBorder = nMinimumBorderWidth;
+ if (mnRightBorder < nMinimumBorderWidth)
+ mnRightBorder = nMinimumBorderWidth;
}
else
{
- rPosition.mnRow = ::std::min(
- mnRowCount-1,
- GetRowAtPosition (rModelPosition.Y(), true, GM_BOTH));
+ int nMinimumBorderHeight = mnVerticalGap/2;
+ if (mnTopBorder < nMinimumBorderHeight)
+ mnTopBorder = nMinimumBorderHeight;
+ if (mnBottomBorder < nMinimumBorderHeight)
+ mnBottomBorder = nMinimumBorderHeight;
+ }
- const sal_Int32 nX = rModelPosition.X() - mnLeftBorder + maPageObjectSize.Width()/2;
- const sal_Int32 nRowWidth (maPageObjectSize.Width() + mnHorizontalGap);
- rPosition.mnColumn = ::std::min(mnColumnCount, nX / nRowWidth);
- rPosition.mnIndex = rPosition.mnRow * mnColumnCount + rPosition.mnColumn;
+ mpPageObjectLayouter.reset(
+ new PageObjectLayouter(
+ CalculateTargetSize(rWindowSize, rPreviewModelSize),
+ rPreviewModelSize,
+ mpWindow,
+ mnPageCount));
+ maPageObjectSize = mpPageObjectLayouter->GetPageObjectSize();
+
+ CalculateMaxRowAndColumnCount(rWindowSize);
+
+ return true;
+}
- rPosition.mbIsAtRunStart = (rPosition.mnColumn == 0);
- rPosition.mbIsAtRunEnd = (rPosition.mnColumn == mnColumnCount);
- if (rPosition.mnIndex >= mnPageCount)
+
+
+sal_Int32 Layouter::Implementation::GetRowAtPosition (
+ sal_Int32 nYPosition,
+ bool bIncludeBordersAndGaps,
+ GapMembership eGapMembership) const
+{
+ sal_Int32 nRow = -1;
+
+ const sal_Int32 nY = nYPosition - mnTopBorder;
+ if (nY >= 0)
+ {
+ // Vertical distance from one row to the next.
+ 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) - maPageObjectSize.Height());
+ // When inside the gap below then nYPosition is not over a page
+ // object.
+ if (nDistanceIntoGap > 0)
+ nRow = ResolvePositionInGap (
+ nDistanceIntoGap,
+ eGapMembership,
+ nRow,
+ mnVerticalGap);
+ }
+ else if (bIncludeBordersAndGaps)
+ {
+ // We are in the top border area. Set nRow to the first row when
+ // the top border shall be considered to belong to the first row.
+ nRow = 0;
+ }
+
+ return nRow;
+}
+
+
+
+
+sal_Int32 Layouter::Implementation::GetColumnAtPosition (
+ sal_Int32 nXPosition,
+ bool bIncludeBordersAndGaps,
+ GapMembership eGapMembership) const
+{
+ sal_Int32 nColumn = -1;
+
+ sal_Int32 nX = nXPosition - mnLeftBorder;
+ if (nX >= 0)
+ {
+ // Horizontal distance from one column to the next.
+ const sal_Int32 nColumnOffset (maPageObjectSize.Width() + mnHorizontalGap);
+
+ // Calculate row consisting of page objects and gap below.
+ nColumn = nX / nColumnOffset;
+ if (nColumn < 0)
+ nColumn = 0;
+ else if (nColumn >= mnColumnCount)
+ nColumn = mnColumnCount-1;
+
+ 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)
+ nColumn = ResolvePositionInGap (
+ nDistanceIntoGap,
+ eGapMembership,
+ nColumn,
+ mnHorizontalGap);
+ }
+ else if (bIncludeBordersAndGaps)
+ {
+ // We are in the left border area. Set nColumn to the first column
+ // when the left border shall be considered to belong to the first
+ // column.
+ nColumn = 0;
+ }
+ return nColumn;
+}
+
+
+
+
+sal_Int32 Layouter::Implementation::ResolvePositionInGap (
+ sal_Int32 nDistanceIntoGap,
+ GapMembership eGapMembership,
+ sal_Int32 nIndex,
+ sal_Int32 nGap) const
+{
+ switch (eGapMembership)
+ {
+ case GM_NONE:
+ // The gap is no man's land.
+ nIndex = -1;
+ break;
+
+ case GM_BOTH:
{
- rPosition.mnIndex = mnPageCount;
- rPosition.mnRow = mnRowCount-1;
- rPosition.mnColumn = mnPageCount%mnColumnCount;
- rPosition.mbIsAtRunEnd = true;
+ // The lower half of the gap belongs to the next row or column.
+ sal_Int32 nFirstHalfGapWidth = nGap / 2;
+ if (nDistanceIntoGap > nFirstHalfGapWidth)
+ nIndex ++;
+ break;
}
- rPosition.mbIsExtraSpaceNeeded = (rPosition.mnColumn >= mnMaxColumnCount);
+
+ case GM_PREVIOUS:
+ // Row or column already at correct value.
+ break;
+
+ case GM_NEXT:
+ // The complete gap belongs to the next row or column.
+ nIndex ++;
+ break;
+
+ case GM_PAGE_BORDER:
+ if (nDistanceIntoGap > 0)
+ {
+ if (nDistanceIntoGap > nGap)
+ {
+ // Inside the border of the next row or column.
+ nIndex ++;
+ }
+ else
+ {
+ // Inside the gap between the page borders.
+ nIndex = -1;
+ }
+ }
+ break;
+
+ default:
+ nIndex = -1;
}
+
+ return nIndex;
}
-void Layouter::CalculateGeometricPosition (
+void Layouter::Implementation::CalculateGeometricPosition (
InsertPosition& rPosition,
const Size& rIndicatorSize,
const bool bIsVertical,
@@ -535,12 +859,13 @@ void Layouter::CalculateGeometricPosition (
bool bIsLeadingFixed (false);
bool bIsTrailingFixed (false);
sal_Int32 nSecondaryLocation (0);
+ const sal_Int32 nIndex (rPosition.GetIndex());
- if (rPosition.mbIsAtRunStart)
+ if (rPosition.IsAtRunStart())
{
// Place indicator at the top of the column.
- const Rectangle aOuterBox (GetPageObjectBox(rPosition.mnIndex));
- const Rectangle aInnerBox (GetInnerBoundingBox(rModel, rPosition.mnIndex));
+ const Rectangle aOuterBox (GetPageObjectBox(nIndex));
+ const Rectangle aInnerBox (GetInnerBoundingBox(rModel, nIndex));
if (bIsVertical)
{
nLeadingLocation = aOuterBox.Top();
@@ -555,12 +880,12 @@ void Layouter::CalculateGeometricPosition (
}
bIsLeadingFixed = true;
}
- else if (rPosition.mbIsAtRunEnd)
+ else if (rPosition.IsAtRunEnd())
{
// Place indicator at the bottom/right of the column/row.
- const Rectangle aOuterBox (GetPageObjectBox(rPosition.mnIndex-1));
- const Rectangle aInnerBox (GetInnerBoundingBox(rModel, rPosition.mnIndex-1));
+ const Rectangle aOuterBox (GetPageObjectBox(nIndex-1));
+ const Rectangle aInnerBox (GetInnerBoundingBox(rModel, nIndex-1));
if (bIsVertical)
{
nLeadingLocation = aInnerBox.Bottom();
@@ -574,14 +899,14 @@ void Layouter::CalculateGeometricPosition (
nSecondaryLocation = aInnerBox.Center().Y();
}
bIsTrailingFixed = true;
- if ( ! rPosition.mbIsExtraSpaceNeeded)
+ if ( ! rPosition.IsExtraSpaceNeeded())
bIsLeadingFixed = true;
}
else
{
// Place indicator between two rows/columns.
- const Rectangle aBox1 (GetInnerBoundingBox(rModel, rPosition.mnIndex-1));
- const Rectangle aBox2 (GetInnerBoundingBox(rModel, rPosition.mnIndex));
+ const Rectangle aBox1 (GetInnerBoundingBox(rModel, nIndex-1));
+ const Rectangle aBox2 (GetInnerBoundingBox(rModel, nIndex));
if (bIsVertical)
{
nLeadingLocation = aBox1.Bottom();
@@ -624,22 +949,24 @@ void Layouter::CalculateGeometricPosition (
if (bIsVertical)
{
- rPosition.maLocation = Point(nSecondaryLocation, nPrimaryLocation);
- rPosition.maLeadingOffset = Point(0, nLeadingOffset);
- rPosition.maTrailingOffset = Point(0, nTrailingOffset);
+ rPosition.SetGeometricalPosition(
+ Point(nSecondaryLocation, nPrimaryLocation),
+ Point(0, nLeadingOffset),
+ Point(0, nTrailingOffset));
}
else
{
- rPosition.maLocation = Point(nPrimaryLocation, nSecondaryLocation);
- rPosition.maLeadingOffset = Point(nLeadingOffset, 0);
- rPosition.maTrailingOffset = Point(nTrailingOffset, 0);
+ rPosition.SetGeometricalPosition(
+ Point(nPrimaryLocation, nSecondaryLocation),
+ Point(nLeadingOffset, 0),
+ Point(nTrailingOffset, 0));
}
}
-Rectangle Layouter::GetInnerBoundingBox (
+Rectangle Layouter::Implementation::GetInnerBoundingBox (
model::SlideSorterModel& rModel,
const sal_Int32 nIndex) const
{
@@ -649,12 +976,12 @@ Rectangle Layouter::GetInnerBoundingBox (
const Point aLocation (pDescriptor->GetLocation(true));
if (pDescriptor->HasState(model::PageDescriptor::ST_Selected))
- return GetPageObjectLayouter()->GetBoundingBox(
+ return mpPageObjectLayouter->GetBoundingBox(
aLocation,
PageObjectLayouter::PageObject,
PageObjectLayouter::ModelCoordinateSystem);
else
- return GetPageObjectLayouter()->GetBoundingBox(
+ return mpPageObjectLayouter->GetBoundingBox(
aLocation,
PageObjectLayouter::Preview,
PageObjectLayouter::ModelCoordinateSystem);
@@ -663,181 +990,436 @@ Rectangle Layouter::GetInnerBoundingBox (
-Range Layouter::GetRangeOfVisiblePageObjects (const Rectangle& aVisibleArea) const
+Range Layouter::Implementation::GetValidHorizontalSizeRange (void) const
{
- sal_Int32 nRow0 = GetRowAtPosition (aVisibleArea.Top(), true, GM_BOTH);
- sal_Int32 nRow1 = GetRowAtPosition (aVisibleArea.Bottom(),
- true, GM_BOTH);
return Range(
- ::std::min(nRow0 * mnColumnCount, mnPageCount-1),
- ::std::min((nRow1+1) * mnColumnCount - 1, mnPageCount-1));
+ mnLeftBorder + maMinimalSize.Width() + mnRightBorder,
+ mnLeftBorder + maMaximalSize.Width() + mnRightBorder);
}
-sal_Int32 Layouter::GetIndexAtPoint (
- const Point& rPosition,
- const bool bIncludePageBorders) const
+Range Layouter::Implementation::GetValidVerticalSizeRange (void) const
{
- sal_Int32 nRow = GetRowAtPosition (rPosition.Y(),
- bIncludePageBorders,
- bIncludePageBorders ? GM_PAGE_BORDER : GM_NONE);
- sal_Int32 nColumn = GetColumnAtPosition (rPosition.X(),
- bIncludePageBorders,
- bIncludePageBorders ? GM_PAGE_BORDER : GM_NONE);
+ return Range(
+ mnTopBorder + maMinimalSize.Height() + mnBottomBorder,
+ mnTopBorder + maMaximalSize.Height() + mnBottomBorder);
+}
- if (nRow >= 0 && nColumn >= 0)
- return nRow * mnColumnCount + nColumn;
+
+
+
+Size Layouter::Implementation::CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize,
+ const bool bCalculateWidth,
+ const bool bCalculateHeight) const
+{
+ if (mnColumnCount<=0 || mnRowCount<=0)
+ return maPreferredSize;
+ if ( ! (bCalculateWidth || bCalculateHeight))
+ {
+ OSL_ASSERT(bCalculateWidth || bCalculateHeight);
+ return maPreferredSize;
+ }
+
+ const double nPreviewAspectRatio (
+ double(rPreviewModelSize.Width())/double(rPreviewModelSize.Height()));
+
+ // Calculate the width of each page object.
+ Size aTargetSize (0,0);
+ if (bCalculateWidth)
+ aTargetSize.setWidth(
+ (rWindowSize.Width() - mnLeftBorder - mnRightBorder
+ - (mnColumnCount-1) * mnHorizontalGap)
+ / mnColumnCount);
+ else if (bCalculateHeight)
+ aTargetSize.setHeight(
+ (rWindowSize.Height() - mnTopBorder - mnBottomBorder
+ - (mnRowCount-1) * mnVerticalGap)
+ / mnRowCount);
+
+ if (bCalculateWidth)
+ {
+ if (aTargetSize.Width() < maMinimalSize.Width())
+ aTargetSize.setWidth(maMinimalSize.Width());
+ else if (aTargetSize.Width() > maMaximalSize.Width())
+ aTargetSize.setWidth(maMaximalSize.Width());
+ }
+ else if (bCalculateHeight)
+ {
+ if (aTargetSize.Height() < maMinimalSize.Height())
+ aTargetSize.setHeight(maMinimalSize.Height());
+ else if (aTargetSize.Height() > maMaximalSize.Height())
+ aTargetSize.setHeight(maMaximalSize.Height());
+ }
+
+ return aTargetSize;
+}
+
+
+
+
+Rectangle Layouter::Implementation::GetPageObjectBox (
+ const sal_Int32 nIndex,
+ const bool bIncludeBorderAndGap) const
+{
+ const sal_Int32 nRow (nIndex / mnColumnCount);
+ const sal_Int32 nColumn (nIndex % mnColumnCount);
+
+ const Rectangle aBoundingBox (GetPageObjectBox(nRow,nColumn));
+ if (bIncludeBorderAndGap)
+ return AddBorderAndGap(aBoundingBox, nRow, nColumn);
else
- return -1;
+ return aBoundingBox;
}
-bool Layouter::IsVertical (void) const
+Rectangle Layouter::Implementation::GetPageObjectBox (
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn) const
{
- return mbIsVertical;
+ return Rectangle(
+ Point (mnLeftBorder
+ + nColumn * maPageObjectSize.Width()
+ + (nColumn>0 ? nColumn : 0) * mnHorizontalGap,
+ mnTopBorder
+ + nRow * maPageObjectSize.Height()
+ + (nRow>0 ? nRow : 0) * mnVerticalGap),
+ maPageObjectSize);
}
-sal_Int32 Layouter::GetRowAtPosition (
- sal_Int32 nYPosition,
- bool bIncludeBordersAndGaps,
- GapMembership eGapMembership) const
+
+Rectangle Layouter::Implementation::AddBorderAndGap (
+ const Rectangle& rBoundingBox,
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn) const
{
- sal_Int32 nRow = -1;
+ Rectangle aBoundingBox (rBoundingBox);
- const sal_Int32 nY = nYPosition - mnTopBorder;
- if (nY >= 0)
- {
- // Vertical distance from one row to the next.
- const sal_Int32 nRowOffset (maPageObjectSize.Height() + mnVerticalGap);
+ 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;
+}
- // Calculate row consisting of page objects and gap below.
- nRow = nY / nRowOffset;
- 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)
- nRow = ResolvePositionInGap (
- nDistanceIntoGap,
- eGapMembership,
- nRow,
- mnVerticalGap);
- }
- else if (bIncludeBordersAndGaps)
+
+
+Rectangle Layouter::Implementation::GetTotalBoundingBox (void) const
+{
+ sal_Int32 nHorizontalSize = 0;
+ sal_Int32 nVerticalSize = 0;
+ if (mnColumnCount > 0)
{
- // We are in the top border area. Set nRow to the first row when
- // the top border shall be considered to belong to the first row.
- nRow = 0;
+ sal_Int32 nRowCount = (mnPageCount+mnColumnCount-1) / mnColumnCount;
+ nHorizontalSize =
+ mnLeftBorder
+ + mnRightBorder
+ + mnColumnCount * maPageObjectSize.Width();
+ if (mnColumnCount > 1)
+ nHorizontalSize += (mnColumnCount-1) * mnHorizontalGap;
+ nVerticalSize =
+ mnTopBorder
+ + mnBottomBorder
+ + nRowCount * maPageObjectSize.Height();
+ if (nRowCount > 1)
+ nVerticalSize += (nRowCount-1) * mnVerticalGap;
}
- return nRow;
+ return Rectangle (
+ Point(0,0),
+ Size (nHorizontalSize, nVerticalSize)
+ );
}
-sal_Int32 Layouter::GetColumnAtPosition (
- sal_Int32 nXPosition,
- bool bIncludeBordersAndGaps,
- GapMembership eGapMembership) const
+void Layouter::Implementation::CalculateVerticalLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const
{
- sal_Int32 nColumn = -1;
+ const sal_Int32 nY = rModelPosition.Y() - mnTopBorder + maPageObjectSize.Height()/2;
+ const sal_Int32 nRowHeight (maPageObjectSize.Height() + mnVerticalGap);
+ const sal_Int32 nRow (::std::min(mnPageCount, nY / nRowHeight));
+ rPosition.SetLogicalPosition (
+ nRow,
+ 0,
+ nRow,
+ (nRow == 0),
+ (nRow == mnRowCount),
+ (nRow >= mnMaxRowCount));
+}
- sal_Int32 nX = nXPosition - mnLeftBorder;
- if (nX >= 0)
- {
- // Horizontal distance from one column to the next.
- const sal_Int32 nColumnOffset (maPageObjectSize.Width() + mnHorizontalGap);
- // Calculate row consisting of page objects and gap below.
- nColumn = nX / nColumnOffset;
- if (nColumn < 0)
- nColumn = 0;
- else if (nColumn >= mnColumnCount)
- nColumn = mnColumnCount-1;
- 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)
- nColumn = ResolvePositionInGap (
- nDistanceIntoGap,
- eGapMembership,
- nColumn,
- mnHorizontalGap);
- }
- else if (bIncludeBordersAndGaps)
- {
- // We are in the left border area. Set nColumn to the first column
- // when the left border shall be considered to belong to the first
- // column.
- nColumn = 0;
- }
- return nColumn;
+
+//===== HorizontalImplementation ================================================
+
+HorizontalImplementation::HorizontalImplementation (const SharedSdWindow& rpWindow)
+ : Implementation(rpWindow)
+{
}
-sal_Int32 Layouter::ResolvePositionInGap (
- sal_Int32 nDistanceIntoGap,
- GapMembership eGapMembership,
- sal_Int32 nIndex,
- sal_Int32 nGap) const
+HorizontalImplementation::HorizontalImplementation (const Implementation& rImplementation)
+ : Implementation(rImplementation)
{
- switch (eGapMembership)
- {
- case GM_NONE:
- // The gap is no man's land.
- nIndex = -1;
- break;
+}
- case GM_BOTH:
- {
- // The lower half of the gap belongs to the next row or column.
- sal_Int32 nFirstHalfGapWidth = nGap / 2;
- if (nDistanceIntoGap > nFirstHalfGapWidth)
- nIndex ++;
- break;
- }
- case GM_PREVIOUS:
- // Row or column already at correct value.
- break;
- case GM_NEXT:
- // The complete gap belongs to the next row or column.
- nIndex ++;
- break;
- case GM_PAGE_BORDER:
- if (nDistanceIntoGap > 0)
- {
- if (nDistanceIntoGap > nGap)
- {
- // Inside the border of the next row or column.
- nIndex ++;
- }
- else
- {
- // Inside the gap between the page borders.
- nIndex = -1;
- }
- }
- break;
+Layouter::Orientation HorizontalImplementation::GetOrientation (void) const
+{
+ return Layouter::HORIZONTAL;
+}
- default:
- nIndex = -1;
+
+
+
+void HorizontalImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
+{
+ (void)rWindowSize;
+
+ // Row and column count are fixed (for a given page count.)
+ mnColumnCount = mnPageCount;
+ mnRowCount = 1;
+}
+
+
+
+
+void HorizontalImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
+{
+ mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
+ / (maPageObjectSize.Width() + mnHorizontalGap);
+ mnMaxRowCount = 1;
+}
+
+
+
+
+Size HorizontalImplementation::CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const
+{
+ return Implementation::CalculateTargetSize(rWindowSize, rPreviewModelSize, false, true);
+}
+
+
+
+
+void HorizontalImplementation::CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const
+{
+ const sal_Int32 nX = rModelPosition.X() - mnLeftBorder + maPageObjectSize.Width()/2;
+ const sal_Int32 nColumnWidth (maPageObjectSize.Width() + mnHorizontalGap);
+ const sal_Int32 nColumn (::std::min(mnPageCount, nX / nColumnWidth));
+ rPosition.SetLogicalPosition (
+ 0,
+ nColumn,
+ nColumn,
+ (nColumn == 0),
+ (nColumn == mnColumnCount),
+ (nColumn >= mnMaxColumnCount));
+}
+
+
+
+
+//===== VerticalImplementation ================================================
+
+VerticalImplementation::VerticalImplementation (const SharedSdWindow& rpWindow)
+ : Implementation(rpWindow)
+{
+}
+
+
+
+
+VerticalImplementation::VerticalImplementation (const Implementation& rImplementation)
+ : Implementation(rImplementation)
+{
+}
+
+
+
+
+Layouter::Orientation VerticalImplementation::GetOrientation (void) const
+{
+ return Layouter::VERTICAL;
+}
+
+
+
+
+void VerticalImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
+{
+ (void)rWindowSize;
+
+ // Row and column count are fixed (for a given page count.)
+ mnRowCount = mnPageCount;
+ mnColumnCount = 1;
+
+}
+
+
+
+
+void VerticalImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
+{
+ mnMaxRowCount = (rWindowSize.Height() - mnTopBorder - mnBottomBorder)
+ / (maPageObjectSize.Height() + mnVerticalGap);
+ mnMaxColumnCount = 1;
+}
+
+
+
+
+Size VerticalImplementation::CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const
+{
+ return Implementation::CalculateTargetSize(rWindowSize, rPreviewModelSize, true, false);
+}
+
+
+
+
+void VerticalImplementation::CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const
+{
+ return CalculateVerticalLogicalInsertPosition(rModelPosition, rPosition);
+}
+
+
+
+
+//===== GridImplementation ================================================
+
+GridImplementation::GridImplementation (const SharedSdWindow& rpWindow)
+ : Implementation(rpWindow)
+{
+}
+
+
+
+
+GridImplementation::GridImplementation (const Implementation& rImplementation)
+ : Implementation(rImplementation)
+{
+}
+
+
+
+
+Layouter::Orientation GridImplementation::GetOrientation (void) const
+{
+ return Layouter::GRID;
+}
+
+
+
+
+void GridImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
+{
+ // Calculate the column count.
+ mnColumnCount
+ = (rWindowSize.Width() - mnRequestedLeftBorder - mnRequestedRightBorder)
+ / (maPreferredSize.Width() + mnHorizontalGap);
+ if (mnColumnCount < mnMinimalColumnCount)
+ mnColumnCount = mnMinimalColumnCount;
+ if (mnColumnCount > mnMaximalColumnCount)
+ mnColumnCount = mnMaximalColumnCount;
+ mnRowCount = (mnPageCount + mnColumnCount-1)/mnColumnCount;
+}
+
+
+
+
+void GridImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
+{
+ mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
+ / (maPageObjectSize.Width() + mnHorizontalGap);
+ mnMaxRowCount = (rWindowSize.Height() - mnTopBorder - mnBottomBorder)
+ / (maPageObjectSize.Height() + mnVerticalGap);
+}
+
+
+
+
+
+Size GridImplementation::CalculateTargetSize (
+ const Size& rWindowSize,
+ const Size& rPreviewModelSize) const
+{
+ return Implementation::CalculateTargetSize(rWindowSize, rPreviewModelSize, true, true);
+}
+
+
+
+
+void GridImplementation::CalculateLogicalInsertPosition (
+ const Point& rModelPosition,
+ InsertPosition& rPosition) const
+{
+ if (mnColumnCount == 1)
+ {
+ CalculateVerticalLogicalInsertPosition(rModelPosition, rPosition);
}
+ else
+ {
+ // Handle the general case of more than one column.
+ sal_Int32 nRow (::std::min(
+ mnRowCount-1,
+ GetRowAtPosition (rModelPosition.Y(), true, GM_BOTH)));
+ const sal_Int32 nX = rModelPosition.X() - mnLeftBorder + maPageObjectSize.Width()/2;
+ const sal_Int32 nColumnWidth (maPageObjectSize.Width() + mnHorizontalGap);
+ sal_Int32 nColumn (::std::min(mnColumnCount, nX / nColumnWidth));
+ sal_Int32 nIndex (nRow * mnColumnCount + nColumn);
+ bool bIsAtRunEnd (nColumn == mnColumnCount);
- return nIndex;
+ if (nIndex >= mnPageCount)
+ {
+ nIndex = mnPageCount;
+ nRow = mnRowCount-1;
+ nColumn = mnPageCount%mnColumnCount;
+ bIsAtRunEnd = true;
+ }
+
+ rPosition.SetLogicalPosition (
+ nRow,
+ nColumn,
+ nIndex,
+ (nColumn == 0),
+ bIsAtRunEnd,
+ (nColumn >= mnMaxColumnCount));
+ }
}
@@ -849,12 +1431,12 @@ InsertPosition::InsertPosition (void)
: mnRow(-1),
mnColumn(-1),
mnIndex(-1),
- maLocation(0,0),
- maLeadingOffset(0,0),
- maTrailingOffset(0,0),
mbIsAtRunStart(false),
mbIsAtRunEnd(false),
- mbIsExtraSpaceNeeded(false)
+ mbIsExtraSpaceNeeded(false),
+ maLocation(0,0),
+ maLeadingOffset(0,0),
+ maTrailingOffset(0,0)
{
}
@@ -868,12 +1450,12 @@ InsertPosition& InsertPosition::operator= (const InsertPosition& rInsertPosition
mnRow = rInsertPosition.mnRow;
mnColumn = rInsertPosition.mnColumn;
mnIndex = rInsertPosition.mnIndex;
- maLocation = rInsertPosition.maLocation;
- maLeadingOffset = rInsertPosition.maLeadingOffset;
- maTrailingOffset = rInsertPosition.maTrailingOffset;
mbIsAtRunStart = rInsertPosition.mbIsAtRunStart;
mbIsAtRunEnd = rInsertPosition.mbIsAtRunEnd;
mbIsExtraSpaceNeeded = rInsertPosition.mbIsExtraSpaceNeeded;
+ maLocation = rInsertPosition.maLocation;
+ maLeadingOffset = rInsertPosition.maLeadingOffset;
+ maTrailingOffset = rInsertPosition.maTrailingOffset;
}
return *this;
}
@@ -902,4 +1484,36 @@ bool InsertPosition::operator!= (const InsertPosition& rInsertPosition) const
+
+void InsertPosition::SetLogicalPosition (
+ const sal_Int32 nRow,
+ const sal_Int32 nColumn,
+ const sal_Int32 nIndex,
+ const bool bIsAtRunStart,
+ const bool bIsAtRunEnd,
+ const bool bIsExtraSpaceNeeded)
+{
+ mnRow = nRow;
+ mnColumn = nColumn;
+ mnIndex = nIndex;
+ mbIsAtRunStart = bIsAtRunStart;
+ mbIsAtRunEnd = bIsAtRunEnd;
+ mbIsExtraSpaceNeeded = bIsExtraSpaceNeeded;
+}
+
+
+
+
+void InsertPosition::SetGeometricalPosition(
+ const Point aLocation,
+ const Point aLeadingOffset,
+ const Point aTrailingOffset)
+{
+ maLocation = aLocation;
+ maLeadingOffset = aLeadingOffset;
+ maTrailingOffset = aTrailingOffset;
+}
+
+
+
} } } // end of namespace ::sd::slidesorter::namespace
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
index 19f7bc14b664..ec0b274397b7 100644
--- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -59,7 +59,6 @@
#include <vcl/vclenum.hxx>
#include <vcl/bmpacc.hxx>
#include <vcl/virdev.hxx>
-#include <canvas/elapsedtime.hxx>
using namespace ::drawinglayer::primitive2d;
using namespace ::basegfx;
@@ -209,10 +208,14 @@ void PageObjectPainter::PaintPageObject (
void PageObjectPainter::NotifyResize (void)
{
- maNormalBackground.SetEmpty();
- maSelectionBackground.SetEmpty();
- maFocusedSelectionBackground.SetEmpty();
- maMouseOverBackground.SetEmpty();
+ if ( ! mpPageObjectLayouter
+ || mpPageObjectLayouter->GetPageObjectSize() != maNewSlideIcon.GetSizePixel())
+ {
+ maNormalBackground.SetEmpty();
+ maSelectionBackground.SetEmpty();
+ maFocusedSelectionBackground.SetEmpty();
+ maMouseOverBackground.SetEmpty();
+ }
}
@@ -270,7 +273,7 @@ void PageObjectPainter::PaintPreview (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const
{
- Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
+ const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::Preview,
PageObjectLayouter::ModelCoordinateSystem));
@@ -278,12 +281,17 @@ void PageObjectPainter::PaintPreview (
if (mpCache != NULL)
{
const SdrPage* pPage = rpDescriptor->GetPage();
- BitmapEx aBitmap (mpCache->GetPreviewBitmap(pPage));
- if (aBitmap.GetSizePixel() != aBox.GetSize())
- aBitmap.Scale(aBox.GetSize());
mpCache->SetPreciousFlag(pPage, true);
- rDevice.DrawBitmapEx(aBox.TopLeft(), aBitmap);
+ const Bitmap aBitmap (mpCache->GetPreviewBitmap(pPage,false).GetBitmap());
+ if (aBitmap.GetSizePixel() != aBox.GetSize())
+ {
+ rDevice.DrawBitmap(aBox.TopLeft(), aBox.GetSize(), aBitmap);
+ }
+ else
+ {
+ rDevice.DrawBitmap(aBox.TopLeft(), aBitmap);
+ }
}
if (rpDescriptor->GetVisualState().GetCurrentVisualState()