This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push: new a02f915 Fixed typos, removed whitespace a02f915 is described below commit a02f915e57f23a2fb054057f8432f1b267040505 Author: mseidel <msei...@apache.org> AuthorDate: Tue Sep 21 18:08:08 2021 +0200 Fixed typos, removed whitespace (cherry picked from commit f36d4cdc7a803b3544aac6219cff04e0eaf450db) --- .../source/ui/slidesorter/view/SlideSorterView.cxx | 1282 ++++++++++---------- .../source/ui/slidesorter/view/SlsFontProvider.cxx | 120 +- .../source/ui/slidesorter/view/SlsFramePainter.cxx | 350 +++--- .../source/ui/slidesorter/view/SlsFramePainter.hxx | 158 +-- .../view/SlsInsertionIndicatorOverlay.cxx | 543 +++++---- .../ui/slidesorter/view/SlsLayeredDevice.hxx | 66 +- main/sd/source/ui/slidesorter/view/SlsResource.hxx | 12 +- main/sd/source/ui/slidesorter/view/SlsToolTip.cxx | 236 ++-- .../ui/slidesorter/view/SlsViewCacheContext.cxx | 92 +- .../ui/slidesorter/view/SlsViewCacheContext.hxx | 38 +- 10 files changed, 1448 insertions(+), 1449 deletions(-) diff --git a/main/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/main/sd/source/ui/slidesorter/view/SlideSorterView.cxx index b88e3fb..0f8e4a6 100644 --- a/main/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/main/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -90,52 +90,52 @@ using namespace ::drawinglayer::primitive2d; namespace sd { namespace slidesorter { namespace view { namespace { - /** Wrapper around the SlideSorterView that supports the IPainter - interface and that allows the LayeredDevice to hold the - SlideSorterView (held as scoped_ptr by the SlideSorter) as - shared_ptr. - */ - class Painter : public ILayerPainter - { - public: - Painter (SlideSorterView& rView) : mrView(rView) {} - virtual ~Painter (void) {} - - virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea) - { - mrView.Paint(rDevice,rRepaintArea); - } - - virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {} - - private: - SlideSorterView& mrView; - }; + /** Wrapper around the SlideSorterView that supports the IPainter + interface and that allows the LayeredDevice to hold the + SlideSorterView (held as scoped_ptr by the SlideSorter) as + shared_ptr. + */ + class Painter : public ILayerPainter + { + public: + Painter (SlideSorterView& rView) : mrView(rView) {} + virtual ~Painter (void) {} + + virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea) + { + mrView.Paint(rDevice,rRepaintArea); + } + + virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {} + + private: + SlideSorterView& mrView; + }; } class BackgroundPainter - : public ILayerPainter, - public ::boost::noncopyable + : public ILayerPainter, + public ::boost::noncopyable { public: - BackgroundPainter (const Color aBackgroundColor) : maBackgroundColor(aBackgroundColor) {} - virtual ~BackgroundPainter (void) {} - - virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea) - { - rDevice.SetFillColor(maBackgroundColor); - rDevice.SetLineColor(); - rDevice.DrawRect(rRepaintArea); - } + BackgroundPainter (const Color aBackgroundColor) : maBackgroundColor(aBackgroundColor) {} + virtual ~BackgroundPainter (void) {} + + virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea) + { + rDevice.SetFillColor(maBackgroundColor); + rDevice.SetLineColor(); + rDevice.DrawRect(rRepaintArea); + } - virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {} + virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {} - void SetColor (const Color aColor) { maBackgroundColor = aColor; } + void SetColor (const Color aColor) { maBackgroundColor = aColor; } private: - Color maBackgroundColor; + Color maBackgroundColor; }; @@ -143,52 +143,52 @@ private: TYPEINIT1(SlideSorterView, ::sd::View); SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter) - : ::sd::View ( - rSlideSorter.GetModel().GetDocument(), - rSlideSorter.GetContentWindow().get(), - rSlideSorter.GetViewShell()), - mrSlideSorter(rSlideSorter), - mrModel(rSlideSorter.GetModel()), - mbIsDisposed(false), - mpLayouter (new Layouter(rSlideSorter.GetContentWindow(), rSlideSorter.GetTheme())), - mbPageObjectVisibilitiesValid (false), - mpPreviewCache(), - mpLayeredDevice(new LayeredDevice(rSlideSorter.GetContentWindow())), - maVisiblePageRange(-1,-1), - mbModelChangedWhileModifyEnabled(true), - maPreviewSize(0,0), - mbPreciousFlagUpdatePending(true), - meOrientation(Layouter::GRID), - mpProperties(rSlideSorter.GetProperties()), - mpPageUnderMouse(), - mnButtonUnderMouse(-1), - mpPageObjectPainter(), - mpSelectionPainter(), - mpBackgroundPainter( - new BackgroundPainter(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background))), - mpButtonBar(new ButtonBar(mrSlideSorter)), - mpToolTip(new ToolTip(mrSlideSorter)), - mbIsRearrangePending(true), - maVisibilityChangeListeners() + : ::sd::View ( + rSlideSorter.GetModel().GetDocument(), + rSlideSorter.GetContentWindow().get(), + rSlideSorter.GetViewShell()), + mrSlideSorter(rSlideSorter), + mrModel(rSlideSorter.GetModel()), + mbIsDisposed(false), + mpLayouter (new Layouter(rSlideSorter.GetContentWindow(), rSlideSorter.GetTheme())), + mbPageObjectVisibilitiesValid (false), + mpPreviewCache(), + mpLayeredDevice(new LayeredDevice(rSlideSorter.GetContentWindow())), + maVisiblePageRange(-1,-1), + mbModelChangedWhileModifyEnabled(true), + maPreviewSize(0,0), + mbPreciousFlagUpdatePending(true), + meOrientation(Layouter::GRID), + mpProperties(rSlideSorter.GetProperties()), + mpPageUnderMouse(), + mnButtonUnderMouse(-1), + mpPageObjectPainter(), + mpSelectionPainter(), + mpBackgroundPainter( + new BackgroundPainter(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background))), + mpButtonBar(new ButtonBar(mrSlideSorter)), + mpToolTip(new ToolTip(mrSlideSorter)), + mbIsRearrangePending(true), + maVisibilityChangeListeners() { // Hide the page that contains the page objects. - SetPageVisible (sal_False); - - // Register the background painter on level 1 to avoid the creation of a - // background buffer. - mpLayeredDevice->RegisterPainter(mpBackgroundPainter, 1); - - // Wrap a shared_ptr-held-wrapper around this view and register it as - // painter at the layered device. There is no explicit destruction: in - // the SlideSorterView destructor the layered device is destroyed and - // with it the only reference to the wrapper which therefore is also - // destroyed. - SharedILayerPainter pPainter (new Painter(*this)); - - // The painter is placed on level 1 to avoid buffering. This should be - // a little faster during animations because the previews are painted - // directly into the window, not via the buffer. - mpLayeredDevice->RegisterPainter(pPainter, 1); + SetPageVisible (sal_False); + + // Register the background painter on level 1 to avoid the creation of a + // background buffer. + mpLayeredDevice->RegisterPainter(mpBackgroundPainter, 1); + + // Wrap a shared_ptr-held-wrapper around this view and register it as + // painter at the layered device. There is no explicit destruction: in + // the SlideSorterView destructor the layered device is destroyed and + // with it the only reference to the wrapper which therefore is also + // destroyed. + SharedILayerPainter pPainter (new Painter(*this)); + + // The painter is placed on level 1 to avoid buffering. This should be + // a little faster during animations because the previews are painted + // directly into the window, not via the buffer. + mpLayeredDevice->RegisterPainter(pPainter, 1); } @@ -196,11 +196,11 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter) SlideSorterView::~SlideSorterView (void) { - if ( ! mbIsDisposed) - { - OSL_ASSERT(mbIsDisposed); - Dispose(); - } + if ( ! mbIsDisposed) + { + OSL_ASSERT(mbIsDisposed); + Dispose(); + } } @@ -208,7 +208,7 @@ SlideSorterView::~SlideSorterView (void) void SlideSorterView::Init (void) { - HandleModelChange(); + HandleModelChange(); } @@ -216,24 +216,24 @@ void SlideSorterView::Init (void) void SlideSorterView::Dispose (void) { - mpSelectionPainter.reset(); + mpSelectionPainter.reset(); - mpLayeredDevice->Dispose(); - mpPreviewCache.reset(); + mpLayeredDevice->Dispose(); + mpPreviewCache.reset(); - SetPageUnderMouse(SharedPageDescriptor(),false); + SetPageUnderMouse(SharedPageDescriptor(),false); - // 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(); - // Deletion of the objects and the page will be done in SdrModel + // Deletion of the objects and the page will be done in SdrModel // destructor (as long as objects and pages are added) - OSL_ASSERT(mpLayeredDevice.unique()); - mpLayeredDevice.reset(); + OSL_ASSERT(mpLayeredDevice.unique()); + mpLayeredDevice.reset(); - mbIsDisposed = true; + mbIsDisposed = true; } @@ -241,19 +241,19 @@ void SlideSorterView::Dispose (void) sal_Int32 SlideSorterView::GetPageIndexAtPoint (const Point& rWindowPosition) const { - sal_Int32 nIndex (-1); - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - nIndex = mpLayouter->GetIndexAtPoint(pWindow->PixelToLogic(rWindowPosition), false, false); - - // Clip the page index against the page count. - if (nIndex >= mrModel.GetPageCount()) - nIndex = -1; - } - - return nIndex; + sal_Int32 nIndex (-1); + + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + nIndex = mpLayouter->GetIndexAtPoint(pWindow->PixelToLogic(rWindowPosition), false, false); + + // Clip the page index against the page count. + if (nIndex >= mrModel.GetPageCount()) + nIndex = -1; + } + + return nIndex; } @@ -261,7 +261,7 @@ sal_Int32 SlideSorterView::GetPageIndexAtPoint (const Point& rWindowPosition) co Layouter& SlideSorterView::GetLayouter (void) { - return *mpLayouter.get(); + return *mpLayouter.get(); } @@ -269,8 +269,8 @@ Layouter& SlideSorterView::GetLayouter (void) void SlideSorterView::ModelHasChanged (void) { - // Ignore this call. Rely on hints sent by the model to get informed of - // model changes. + // Ignore this call. Rely on hints sent by the model to get informed of + // model changes. } @@ -278,10 +278,10 @@ void SlideSorterView::ModelHasChanged (void) void SlideSorterView::LocalModelHasChanged(void) { - mbModelChangedWhileModifyEnabled = false; - - // First call our base class. - View::ModelHasChanged (); + mbModelChangedWhileModifyEnabled = false; + + // First call our base class. + View::ModelHasChanged (); } @@ -289,8 +289,8 @@ void SlideSorterView::LocalModelHasChanged(void) void SlideSorterView::PreModelChange (void) { - // Reset the slide under the mouse. It will be re-set in PostModelChange(). - SetPageUnderMouse(SharedPageDescriptor()); + // Reset the slide under the mouse. It will be re-set in PostModelChange(). + SetPageUnderMouse(SharedPageDescriptor()); } @@ -298,30 +298,30 @@ void SlideSorterView::PreModelChange (void) void SlideSorterView::PostModelChange (void) { - // In PreModelChange() the page objects have been released. Here we - // create new ones. - ::osl::MutexGuard aGuard (mrModel.GetMutex()); + // In PreModelChange() the page objects have been released. Here we + // create new ones. + ::osl::MutexGuard aGuard (mrModel.GetMutex()); - model::PageEnumeration aPageEnumeration ( - model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); + model::PageEnumeration aPageEnumeration ( + model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - // The new page objects have to be scaled and positioned. - RequestRearrange(); - RequestRepaint(); + // The new page objects have to be scaled and positioned. + RequestRearrange(); + RequestRepaint(); } /** At the moment for every model change all page objects are destroyed and - re-created again. This can be optimized by accepting hints that - describe the type of change so that existing page objects can be - reused. + re-created again. This can be optimized by accepting hints that + describe the type of change so that existing page objects can be + reused. */ void SlideSorterView::HandleModelChange (void) { - PreModelChange (); - PostModelChange(); + PreModelChange (); + PostModelChange(); } @@ -329,13 +329,13 @@ void SlideSorterView::HandleModelChange (void) void SlideSorterView::HandleDrawModeChange (void) { - // Replace the preview cache with a new and empty one. The - // PreviewRenderer that is used by the cache is replaced by this as - // well. - mpPreviewCache.reset(); - GetPreviewCache()->InvalidateCache(true); - - RequestRepaint(); + // Replace the preview cache with a new and empty one. The + // PreviewRenderer that is used by the cache is replaced by this as + // well. + mpPreviewCache.reset(); + GetPreviewCache()->InvalidateCache(true); + + RequestRepaint(); } @@ -343,18 +343,18 @@ void SlideSorterView::HandleDrawModeChange (void) void SlideSorterView::HandleDataChangeEvent (void) { - GetPageObjectPainter()->SetTheme(mrSlideSorter.GetTheme()); + GetPageObjectPainter()->SetTheme(mrSlideSorter.GetTheme()); - // Update the color used by the background painter. - ::boost::shared_ptr<BackgroundPainter> pPainter ( - ::boost::dynamic_pointer_cast<BackgroundPainter>(mpBackgroundPainter)); - if (pPainter) - pPainter->SetColor(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background)); + // Update the color used by the background painter. + ::boost::shared_ptr<BackgroundPainter> pPainter ( + ::boost::dynamic_pointer_cast<BackgroundPainter>(mpBackgroundPainter)); + if (pPainter) + pPainter->SetColor(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background)); - if (mpButtonBar) - mpButtonBar->HandleDataChangeEvent(); + if (mpButtonBar) + mpButtonBar->HandleDataChangeEvent(); - RequestRepaint(); + RequestRepaint(); } @@ -362,10 +362,10 @@ void SlideSorterView::HandleDataChangeEvent (void) void SlideSorterView::Resize (void) { - UpdateOrientation(); + UpdateOrientation(); - mpLayeredDevice->Resize(); - RequestRearrange(); + mpLayeredDevice->Resize(); + RequestRearrange(); } @@ -373,8 +373,8 @@ void SlideSorterView::Resize (void) void SlideSorterView::RequestRearrange (void) { - mbIsRearrangePending = true; - Rearrange(); + mbIsRearrangePending = true; + Rearrange(); } @@ -382,30 +382,30 @@ void SlideSorterView::RequestRearrange (void) void SlideSorterView::Rearrange (void) { - if ( ! mbIsRearrangePending) - return; + if ( ! mbIsRearrangePending) + return; if (mrModel.GetPageCount() <= 0) - return; - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + return; + + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); if ( ! pWindow) - return; - const Size aWindowSize (pWindow->GetSizePixel()); - if (aWindowSize.Width()<=0 || aWindowSize.Height()<=0) - return; - - const bool bRearrangeSuccess ( - mpLayouter->Rearrange ( - meOrientation, - aWindowSize, - mrModel.GetPageDescriptor(0)->GetPage()->GetSize(), - mrModel.GetPageCount())); - if (bRearrangeSuccess) - { - mbIsRearrangePending = false; - Layout(); - UpdatePageUnderMouse(false); - // RequestRepaint(); + return; + const Size aWindowSize (pWindow->GetSizePixel()); + if (aWindowSize.Width()<=0 || aWindowSize.Height()<=0) + return; + + const bool bRearrangeSuccess ( + mpLayouter->Rearrange ( + meOrientation, + aWindowSize, + mrModel.GetPageDescriptor(0)->GetPage()->GetSize(), + mrModel.GetPageCount())); + if (bRearrangeSuccess) + { + mbIsRearrangePending = false; + Layout(); + UpdatePageUnderMouse(false); + // RequestRepaint(); } } @@ -414,70 +414,70 @@ void SlideSorterView::Rearrange (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 - { - // We are not placed in a docking window. One possible reason - // is that the slide sorter is temporarily into a cache and was - // reparented to a non-docking window. - SetOrientation(Layouter::GRID); - } - } + // 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 + { + // We are not placed in a docking window. One possible reason + // is that the slide sorter is temporarily into a cache and was + // reparented to a non-docking window. + SetOrientation(Layouter::GRID); + } + } } @@ -485,43 +485,43 @@ void SlideSorterView::UpdateOrientation (void) void SlideSorterView::Layout () { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - // Set the model area, i.e. the smallest rectangle that includes all - // page objects. - const Rectangle aViewBox (mpLayouter->GetTotalBoundingBox()); - pWindow->SetViewOrigin (aViewBox.TopLeft()); - pWindow->SetViewSize (aViewBox.GetSize()); - - ::boost::shared_ptr<PageObjectLayouter> pPageObjectLayouter( - mpLayouter->GetPageObjectLayouter()); - if (pPageObjectLayouter) - { - const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetSize( - PageObjectLayouter::Preview, - PageObjectLayouter::WindowCoordinateSystem)); - if (maPreviewSize != aNewPreviewSize && GetPreviewCache()) - { - mpPreviewCache->ChangeSize(aNewPreviewSize, true); - maPreviewSize = aNewPreviewSize; - } - } - - // Iterate over all page objects and place them relative to the - // containing page. - model::PageEnumeration aPageEnumeration ( - model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - while (aPageEnumeration.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); - pDescriptor->SetBoundingBox(mpLayouter->GetPageObjectBox(pDescriptor->GetPageIndex())); - } - - GetPageObjectPainter()->NotifyResize(); - } - - InvalidatePageObjectVisibilities (); + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + // Set the model area, i.e. the smallest rectangle that includes all + // page objects. + const Rectangle aViewBox (mpLayouter->GetTotalBoundingBox()); + pWindow->SetViewOrigin (aViewBox.TopLeft()); + pWindow->SetViewSize (aViewBox.GetSize()); + + ::boost::shared_ptr<PageObjectLayouter> pPageObjectLayouter( + mpLayouter->GetPageObjectLayouter()); + if (pPageObjectLayouter) + { + const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetSize( + PageObjectLayouter::Preview, + PageObjectLayouter::WindowCoordinateSystem)); + if (maPreviewSize != aNewPreviewSize && GetPreviewCache()) + { + mpPreviewCache->ChangeSize(aNewPreviewSize, true); + maPreviewSize = aNewPreviewSize; + } + } + + // Iterate over all page objects and place them relative to the + // containing page. + model::PageEnumeration aPageEnumeration ( + model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); + while (aPageEnumeration.HasMoreElements()) + { + model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); + pDescriptor->SetBoundingBox(mpLayouter->GetPageObjectBox(pDescriptor->GetPageIndex())); + } + + GetPageObjectPainter()->NotifyResize(); + } + + InvalidatePageObjectVisibilities (); } @@ -529,7 +529,7 @@ void SlideSorterView::Layout () void SlideSorterView::InvalidatePageObjectVisibilities (void) { - mbPageObjectVisibilitiesValid = false; + mbPageObjectVisibilitiesValid = false; } @@ -537,57 +537,57 @@ void SlideSorterView::InvalidatePageObjectVisibilities (void) void SlideSorterView::DeterminePageObjectVisibilities (void) { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - // Set this flag to true here so that an invalidate during the - // visibility calculation can correctly invalidate it again. - mbPageObjectVisibilitiesValid = true; - - Rectangle aViewArea (pWindow->PixelToLogic(Rectangle(Point(0,0),pWindow->GetSizePixel()))); - const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(aViewArea)); - const Range aUnion( - ::std::min(maVisiblePageRange.Min(), aRange.Min()), - ::std::max(maVisiblePageRange.Max(), aRange.Max())); - - // For page objects that just dropped off the visible area we - // decrease the priority of pending requests for preview bitmaps. - if (maVisiblePageRange != aRange) - mbPreciousFlagUpdatePending |= true; - - model::SharedPageDescriptor pDescriptor; - for (int nIndex=aUnion.Min(); nIndex<=aUnion.Max(); nIndex++) - { - pDescriptor = mrModel.GetPageDescriptor(nIndex); - if (pDescriptor.get() != NULL) - SetState( - pDescriptor, - PageDescriptor::ST_Visible, - aRange.IsInside(nIndex)); - } - - // Broadcast a change of the set of visible page objects. - if (maVisiblePageRange != aRange) - { - maVisiblePageRange = aRange; - - // Tell the listeners that the visibility of some objects has - // changed. - ::std::vector<Link>& aChangeListeners (maVisibilityChangeListeners); - for (::std::vector<Link>::const_iterator - iLink(aChangeListeners.begin()), - iEnd(aChangeListeners.end()); - iLink!=iEnd; - ++iLink) - { - iLink->Call(NULL); - } - } - - - // Restore the mouse over state. - UpdatePageUnderMouse(true); - } + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + // Set this flag to true here so that an invalidate during the + // visibility calculation can correctly invalidate it again. + mbPageObjectVisibilitiesValid = true; + + Rectangle aViewArea (pWindow->PixelToLogic(Rectangle(Point(0,0),pWindow->GetSizePixel()))); + const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(aViewArea)); + const Range aUnion( + ::std::min(maVisiblePageRange.Min(), aRange.Min()), + ::std::max(maVisiblePageRange.Max(), aRange.Max())); + + // For page objects that just dropped off the visible area we + // decrease the priority of pending requests for preview bitmaps. + if (maVisiblePageRange != aRange) + mbPreciousFlagUpdatePending |= true; + + model::SharedPageDescriptor pDescriptor; + for (int nIndex=aUnion.Min(); nIndex<=aUnion.Max(); nIndex++) + { + pDescriptor = mrModel.GetPageDescriptor(nIndex); + if (pDescriptor.get() != NULL) + SetState( + pDescriptor, + PageDescriptor::ST_Visible, + aRange.IsInside(nIndex)); + } + + // Broadcast a change of the set of visible page objects. + if (maVisiblePageRange != aRange) + { + maVisiblePageRange = aRange; + + // Tell the listeners that the visibility of some objects has + // changed. + ::std::vector<Link>& aChangeListeners (maVisibilityChangeListeners); + for (::std::vector<Link>::const_iterator + iLink(aChangeListeners.begin()), + iEnd(aChangeListeners.end()); + iLink!=iEnd; + ++iLink) + { + iLink->Call(NULL); + } + } + + + // Restore the mouse over state. + UpdatePageUnderMouse(true); + } } @@ -595,34 +595,34 @@ void SlideSorterView::DeterminePageObjectVisibilities (void) void SlideSorterView::UpdatePreciousFlags (void) { - if (mbPreciousFlagUpdatePending) - { - mbPreciousFlagUpdatePending = false; - - model::SharedPageDescriptor pDescriptor; - ::boost::shared_ptr<cache::PageCache> pCache = GetPreviewCache(); - sal_Int32 nPageCount (mrModel.GetPageCount()); - - for (int nIndex=0; nIndex<=nPageCount; ++nIndex) - { - pDescriptor = mrModel.GetPageDescriptor(nIndex); - if (pDescriptor.get() != NULL) - { - pCache->SetPreciousFlag( - pDescriptor->GetPage(), - maVisiblePageRange.IsInside(nIndex)); - SSCD_SET_VISIBILITY(mrModel.GetDocument(), nIndex, - maVisiblePageRange.IsInside(nIndex)); - } - else - { - // At least one cache entry can not be updated. Remember to - // repeat the whole updating later and leave the loop now. - mbPreciousFlagUpdatePending = true; - break; - } - } - } + if (mbPreciousFlagUpdatePending) + { + mbPreciousFlagUpdatePending = false; + + model::SharedPageDescriptor pDescriptor; + ::boost::shared_ptr<cache::PageCache> pCache = GetPreviewCache(); + sal_Int32 nPageCount (mrModel.GetPageCount()); + + for (int nIndex=0; nIndex<=nPageCount; ++nIndex) + { + pDescriptor = mrModel.GetPageDescriptor(nIndex); + if (pDescriptor.get() != NULL) + { + pCache->SetPreciousFlag( + pDescriptor->GetPage(), + maVisiblePageRange.IsInside(nIndex)); + SSCD_SET_VISIBILITY(mrModel.GetDocument(), nIndex, + maVisiblePageRange.IsInside(nIndex)); + } + else + { + // At least one cache entry can not be updated. Remember to + // repeat the whole updating later and leave the loop now. + mbPreciousFlagUpdatePending = true; + break; + } + } + } } @@ -630,13 +630,13 @@ void SlideSorterView::UpdatePreciousFlags (void) bool SlideSorterView::SetOrientation (const Layouter::Orientation eOrientation) { - if (meOrientation != eOrientation) - { - meOrientation = eOrientation; - return true; - } - else - return false; + if (meOrientation != eOrientation) + { + meOrientation = eOrientation; + return true; + } + else + return false; } @@ -644,7 +644,7 @@ bool SlideSorterView::SetOrientation (const Layouter::Orientation eOrientation) Layouter::Orientation SlideSorterView::GetOrientation (void) const { - return meOrientation; + return meOrientation; } @@ -652,15 +652,15 @@ Layouter::Orientation SlideSorterView::GetOrientation (void) const void SlideSorterView::RequestRepaint (void) { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - mpLayeredDevice->InvalidateAllLayers( - Rectangle( - pWindow->PixelToLogic(Point(0,0)), - pWindow->PixelToLogic(pWindow->GetSizePixel()))); - pWindow->Invalidate(); - } + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + mpLayeredDevice->InvalidateAllLayers( + Rectangle( + pWindow->PixelToLogic(Point(0,0)), + pWindow->PixelToLogic(pWindow->GetSizePixel()))); + pWindow->Invalidate(); + } } @@ -668,8 +668,8 @@ void SlideSorterView::RequestRepaint (void) void SlideSorterView::RequestRepaint (const model::SharedPageDescriptor& rpDescriptor) { - if (rpDescriptor) - RequestRepaint(rpDescriptor->GetBoundingBox()); + if (rpDescriptor) + RequestRepaint(rpDescriptor->GetBoundingBox()); } @@ -677,24 +677,24 @@ void SlideSorterView::RequestRepaint (const model::SharedPageDescriptor& rpDescr void SlideSorterView::RequestRepaint (const Rectangle& rRepaintBox) { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - mpLayeredDevice->InvalidateAllLayers(rRepaintBox); - pWindow->Invalidate(rRepaintBox); - } + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + mpLayeredDevice->InvalidateAllLayers(rRepaintBox); + pWindow->Invalidate(rRepaintBox); + } } void SlideSorterView::RequestRepaint (const Region& rRepaintRegion) { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow) - { - mpLayeredDevice->InvalidateAllLayers(rRepaintRegion); - pWindow->Invalidate(rRepaintRegion); - } + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow) + { + mpLayeredDevice->InvalidateAllLayers(rRepaintRegion); + pWindow->Invalidate(rRepaintRegion); + } } @@ -702,7 +702,7 @@ void SlideSorterView::RequestRepaint (const Region& rRepaintRegion) Rectangle SlideSorterView::GetModelArea (void) { - return mpLayouter->GetTotalBoundingBox(); + return mpLayouter->GetTotalBoundingBox(); } @@ -717,58 +717,58 @@ static double gnLastFrameStart = 0; #endif void SlideSorterView::CompleteRedraw ( - OutputDevice* pDevice, - const Region& rPaintArea, - sdr::contact::ViewObjectContactRedirector* pRedirector) + OutputDevice* pDevice, + const Region& rPaintArea, + sdr::contact::ViewObjectContactRedirector* pRedirector) { - (void)pRedirector; + (void)pRedirector; #ifdef DEBUG_TIMING - const double nStartTime (gaTimer.getElapsedTime()); - OSL_TRACE("SlideSorterView::CompleteRedraw start at %f, %s", - nStartTime, - mnLockRedrawSmph ? "locked" : ""); + const double nStartTime (gaTimer.getElapsedTime()); + OSL_TRACE("SlideSorterView::CompleteRedraw start at %f, %s", + nStartTime, + mnLockRedrawSmph ? "locked" : ""); #endif - if (pDevice == NULL || pDevice!=mrSlideSorter.GetContentWindow().get()) - return; - - // The parent implementation of CompleteRedraw is called only when - // painting is locked. We do all the painting ourself. When painting - // is locked the parent implementation keeps track of the repaint - // requests and later, when painting is unlocked, calls CompleteRedraw - // for all missed repaints. - - if (mnLockRedrawSmph == 0) - { - mrSlideSorter.GetContentWindow()->IncrementLockCount(); - if (mpLayeredDevice->HandleMapModeChange()) - DeterminePageObjectVisibilities(); - mpLayeredDevice->Repaint(rPaintArea); - mrSlideSorter.GetContentWindow()->DecrementLockCount(); - } - else - { - maRedrawRegion.Union(rPaintArea); - } + if (pDevice == NULL || pDevice!=mrSlideSorter.GetContentWindow().get()) + return; + + // The parent implementation of CompleteRedraw is called only when + // painting is locked. We do all the painting ourself. When painting + // is locked the parent implementation keeps track of the repaint + // requests and later, when painting is unlocked, calls CompleteRedraw + // for all missed repaints. + + if (mnLockRedrawSmph == 0) + { + mrSlideSorter.GetContentWindow()->IncrementLockCount(); + if (mpLayeredDevice->HandleMapModeChange()) + DeterminePageObjectVisibilities(); + mpLayeredDevice->Repaint(rPaintArea); + mrSlideSorter.GetContentWindow()->DecrementLockCount(); + } + else + { + maRedrawRegion.Union(rPaintArea); + } #ifdef DEBUG_TIMING - const double nEndTime (gaTimer.getElapsedTime()); - OSL_TRACE("SlideSorterView::CompleteRedraw end at %f after %fms", nEndTime, (nEndTime-nStartTime)*1000); - gFrameTimeSum -= gFrameTimes[gFrameTimeIndex]; - gFrameTimes[gFrameTimeIndex] = nStartTime - gnLastFrameStart; - gnLastFrameStart = nStartTime; - gFrameTimeSum += gFrameTimes[gFrameTimeIndex]; - gFrameTimeIndex = (gFrameTimeIndex+1) % gFrameTimeCount; - - - mrSlideSorter.GetContentWindow()->SetFillColor(COL_BLUE); - mrSlideSorter.GetContentWindow()->DrawRect(gFrameTimeBox); - mrSlideSorter.GetContentWindow()->SetTextColor(COL_WHITE); - mrSlideSorter.GetContentWindow()->DrawText( - gFrameTimeBox, - ::rtl::OUString::valueOf(1 / (gFrameTimeSum / gFrameTimeCount)), - TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER); - // mrSlideSorter.GetContentWindow()->Invalidate(gFrameTimeBox); + const double nEndTime (gaTimer.getElapsedTime()); + OSL_TRACE("SlideSorterView::CompleteRedraw end at %f after %fms", nEndTime, (nEndTime-nStartTime)*1000); + gFrameTimeSum -= gFrameTimes[gFrameTimeIndex]; + gFrameTimes[gFrameTimeIndex] = nStartTime - gnLastFrameStart; + gnLastFrameStart = nStartTime; + gFrameTimeSum += gFrameTimes[gFrameTimeIndex]; + gFrameTimeIndex = (gFrameTimeIndex+1) % gFrameTimeCount; + + + mrSlideSorter.GetContentWindow()->SetFillColor(COL_BLUE); + mrSlideSorter.GetContentWindow()->DrawRect(gFrameTimeBox); + mrSlideSorter.GetContentWindow()->SetTextColor(COL_WHITE); + mrSlideSorter.GetContentWindow()->DrawText( + gFrameTimeBox, + ::rtl::OUString::valueOf(1 / (gFrameTimeSum / gFrameTimeCount)), + TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER); + // mrSlideSorter.GetContentWindow()->Invalidate(gFrameTimeBox); #endif } @@ -776,49 +776,49 @@ void SlideSorterView::CompleteRedraw ( void SlideSorterView::Paint ( - OutputDevice& rDevice, - const Rectangle& rRepaintArea) + OutputDevice& rDevice, + const Rectangle& rRepaintArea) { - if ( ! mpPageObjectPainter) - if ( ! GetPageObjectPainter()) - return; - - // Update the page visibilities when they have been invalidated. - if ( ! mbPageObjectVisibilitiesValid) - DeterminePageObjectVisibilities(); - - if (mbPreciousFlagUpdatePending) - UpdatePreciousFlags(); - - if (mbIsRearrangePending) - Rearrange(); - - // Paint all page objects that are fully or partially inside the - // repaint region. - const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(rRepaintArea)); - for (sal_Int32 nIndex=aRange.Min(); nIndex<=aRange.Max(); ++nIndex) - { - model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex)); - if (!pDescriptor || ! pDescriptor->HasState(PageDescriptor::ST_Visible)) - continue; - - mpPageObjectPainter->PaintPageObject(rDevice, pDescriptor); - } + if ( ! mpPageObjectPainter) + if ( ! GetPageObjectPainter()) + return; + + // Update the page visibilities when they have been invalidated. + if ( ! mbPageObjectVisibilitiesValid) + DeterminePageObjectVisibilities(); + + if (mbPreciousFlagUpdatePending) + UpdatePreciousFlags(); + + if (mbIsRearrangePending) + Rearrange(); + + // Paint all page objects that are fully or partially inside the + // repaint region. + const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(rRepaintArea)); + for (sal_Int32 nIndex=aRange.Min(); nIndex<=aRange.Max(); ++nIndex) + { + model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex)); + if (!pDescriptor || ! pDescriptor->HasState(PageDescriptor::ST_Visible)) + continue; + + mpPageObjectPainter->PaintPageObject(rDevice, pDescriptor); + } } void SlideSorterView::ConfigurationChanged ( - utl::ConfigurationBroadcaster* pBroadcaster, - sal_uInt32 nHint) + utl::ConfigurationBroadcaster* pBroadcaster, + sal_uInt32 nHint) { - // Some changes of the configuration (some of the colors for example) - // may affect the previews. Throw away the old ones and create new ones. - cache::PageCacheManager::Instance()->InvalidateAllCaches(); - - ::sd::View::ConfigurationChanged(pBroadcaster, nHint); - RequestRepaint(); + // Some changes of the configuration (some of the colors for example) + // may affect the previews. Throw away the old ones and create new ones. + cache::PageCacheManager::Instance()->InvalidateAllCaches(); + + ::sd::View::ConfigurationChanged(pBroadcaster, nHint); + RequestRepaint(); } @@ -827,17 +827,17 @@ void SlideSorterView::ConfigurationChanged ( ::boost::shared_ptr<cache::PageCache> SlideSorterView::GetPreviewCache (void) { - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow && mpPreviewCache.get() == NULL) - { - mpPreviewCache.reset( - new cache::PageCache( - mpLayouter->GetPageObjectSize(), - false, - cache::SharedCacheContext(new ViewCacheContext(mrSlideSorter)))); - } - - return mpPreviewCache; + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow && mpPreviewCache.get() == NULL) + { + mpPreviewCache.reset( + new cache::PageCache( + mpLayouter->GetPageObjectSize(), + false, + cache::SharedCacheContext(new ViewCacheContext(mrSlideSorter)))); + } + + return mpPreviewCache; } @@ -845,9 +845,9 @@ void SlideSorterView::ConfigurationChanged ( Pair SlideSorterView::GetVisiblePageRange (void) { - if ( ! mbPageObjectVisibilitiesValid) - DeterminePageObjectVisibilities(); - return maVisiblePageRange; + if ( ! mbPageObjectVisibilitiesValid) + DeterminePageObjectVisibilities(); + return maVisiblePageRange; } @@ -855,13 +855,13 @@ Pair SlideSorterView::GetVisiblePageRange (void) void SlideSorterView::AddVisibilityChangeListener (const Link& rListener) { - if (::std::find ( - maVisibilityChangeListeners.begin(), - maVisibilityChangeListeners.end(), - rListener) == maVisibilityChangeListeners.end()) - { - maVisibilityChangeListeners.push_back(rListener); - } + if (::std::find ( + maVisibilityChangeListeners.begin(), + maVisibilityChangeListeners.end(), + rListener) == maVisibilityChangeListeners.end()) + { + maVisibilityChangeListeners.push_back(rListener); + } } @@ -869,11 +869,11 @@ void SlideSorterView::AddVisibilityChangeListener (const Link& rListener) void SlideSorterView::RemoveVisibilityChangeListener(const Link&rListener) { - maVisibilityChangeListeners.erase ( - ::std::find ( - maVisibilityChangeListeners.begin(), - maVisibilityChangeListeners.end(), - rListener)); + maVisibilityChangeListeners.erase ( + ::std::find ( + maVisibilityChangeListeners.begin(), + maVisibilityChangeListeners.end(), + rListener)); } @@ -881,8 +881,8 @@ void SlideSorterView::RemoveVisibilityChangeListener(const Link&rListener) ButtonBar& SlideSorterView::GetButtonBar (void) const { - OSL_ASSERT(mpButtonBar); - return *mpButtonBar; + OSL_ASSERT(mpButtonBar); + return *mpButtonBar; } @@ -890,8 +890,8 @@ ButtonBar& SlideSorterView::GetButtonBar (void) const ToolTip& SlideSorterView::GetToolTip (void) const { - OSL_ASSERT(mpToolTip); - return *mpToolTip; + OSL_ASSERT(mpToolTip); + return *mpToolTip; } @@ -899,9 +899,9 @@ ToolTip& SlideSorterView::GetToolTip (void) const void SlideSorterView::DragFinished (sal_Int8 nDropAction) { - mrSlideSorter.GetController().GetClipboard().DragFinished(nDropAction); + mrSlideSorter.GetController().GetClipboard().DragFinished(nDropAction); - View::DragFinished(nDropAction); + View::DragFinished(nDropAction); } @@ -910,10 +910,10 @@ void SlideSorterView::DragFinished (sal_Int8 nDropAction) void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) { ::sd::DrawDocShell* pDocShell = mrModel.GetDocument()->GetDocSh(); - if (pDocShell!=NULL && pDocShell->IsEnableSetModified()) - mbModelChangedWhileModifyEnabled = true; + if (pDocShell!=NULL && pDocShell->IsEnableSetModified()) + mbModelChangedWhileModifyEnabled = true; - ::sd::View::Notify(rBroadcaster, rHint); + ::sd::View::Notify(rBroadcaster, rHint); } @@ -921,148 +921,148 @@ void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint void SlideSorterView::UpdatePageUnderMouse (bool bAnimate) { - ::boost::shared_ptr<ScrollBar> pVScrollBar (mrSlideSorter.GetVerticalScrollBar()); - ::boost::shared_ptr<ScrollBar> pHScrollBar (mrSlideSorter.GetHorizontalScrollBar()); - if ((pVScrollBar && pVScrollBar->IsVisible() && pVScrollBar->IsTracking()) - || (pHScrollBar && pHScrollBar->IsVisible() && pHScrollBar->IsTracking())) - { - // One of the scroll bars is tracking mouse movement. Do not - // highlight the slide under the mouse in this case. - SetPageUnderMouse(SharedPageDescriptor(),false); - return; - } - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (pWindow && pWindow->IsVisible() && ! pWindow->IsMouseCaptured()) - { - const Window::PointerState aPointerState (pWindow->GetPointerState()); - const Rectangle aWindowBox (pWindow->GetPosPixel(), pWindow->GetSizePixel()); - if (aWindowBox.IsInside(aPointerState.maPos)) - { - UpdatePageUnderMouse ( - aPointerState.maPos, - (aPointerState.mnState & MOUSE_LEFT)!=0, - bAnimate); - return; - } - } - - SetPageUnderMouse(SharedPageDescriptor(),false); + ::boost::shared_ptr<ScrollBar> pVScrollBar (mrSlideSorter.GetVerticalScrollBar()); + ::boost::shared_ptr<ScrollBar> pHScrollBar (mrSlideSorter.GetHorizontalScrollBar()); + if ((pVScrollBar && pVScrollBar->IsVisible() && pVScrollBar->IsTracking()) + || (pHScrollBar && pHScrollBar->IsVisible() && pHScrollBar->IsTracking())) + { + // One of the scroll bars is tracking mouse movement. Do not + // highlight the slide under the mouse in this case. + SetPageUnderMouse(SharedPageDescriptor(),false); + return; + } + + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (pWindow && pWindow->IsVisible() && ! pWindow->IsMouseCaptured()) + { + const Window::PointerState aPointerState (pWindow->GetPointerState()); + const Rectangle aWindowBox (pWindow->GetPosPixel(), pWindow->GetSizePixel()); + if (aWindowBox.IsInside(aPointerState.maPos)) + { + UpdatePageUnderMouse ( + aPointerState.maPos, + (aPointerState.mnState & MOUSE_LEFT)!=0, + bAnimate); + return; + } + } + + SetPageUnderMouse(SharedPageDescriptor(),false); } void SlideSorterView::UpdatePageUnderMouse ( - const Point& rMousePosition, - const bool bIsMouseButtonDown, - const bool bAnimate) + const Point& rMousePosition, + const bool bIsMouseButtonDown, + const bool bAnimate) { - UpdatePageUnderMouse( - mrSlideSorter.GetController().GetPageAt(rMousePosition), - rMousePosition, - bIsMouseButtonDown, - bAnimate); + UpdatePageUnderMouse( + mrSlideSorter.GetController().GetPageAt(rMousePosition), + rMousePosition, + bIsMouseButtonDown, + bAnimate); } void SlideSorterView::UpdatePageUnderMouse ( - const model::SharedPageDescriptor& rpDescriptor, - const Point& rMousePosition, - const bool bIsMouseButtonDown, - const bool bAnimate) + const model::SharedPageDescriptor& rpDescriptor, + const Point& rMousePosition, + const bool bIsMouseButtonDown, + const bool bAnimate) { - // Update the page under the mouse. - SetPageUnderMouse(rpDescriptor, bAnimate); - - // Tell the button bar about the new mouse position. - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); - - ::boost::shared_ptr<ViewShell> pMainViewShell (mrSlideSorter.GetViewShellBase()->GetMainViewShell()); - if (pMainViewShell - && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW) - { - const bool bIsMouseOverButtonBar (GetButtonBar().IsMouseOverBar()); - GetButtonBar().ProcessMouseMotionEvent(rpDescriptor, aMouseModelPosition, bIsMouseButtonDown); - // Set the help text of the slide when the mouse was moved from the - // button bar back over the preview. - if (rpDescriptor - && GetButtonBar().IsMouseOverBar() != bIsMouseOverButtonBar - && bIsMouseOverButtonBar) - { - mpToolTip->ShowDefaultHelpText(); - } - } + // Update the page under the mouse. + SetPageUnderMouse(rpDescriptor, bAnimate); + + // Tell the button bar about the new mouse position. + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); + + ::boost::shared_ptr<ViewShell> pMainViewShell (mrSlideSorter.GetViewShellBase()->GetMainViewShell()); + if (pMainViewShell + && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW) + { + const bool bIsMouseOverButtonBar (GetButtonBar().IsMouseOverBar()); + GetButtonBar().ProcessMouseMotionEvent(rpDescriptor, aMouseModelPosition, bIsMouseButtonDown); + // Set the help text of the slide when the mouse was moved from the + // button bar back over the preview. + if (rpDescriptor + && GetButtonBar().IsMouseOverBar() != bIsMouseOverButtonBar + && bIsMouseOverButtonBar) + { + mpToolTip->ShowDefaultHelpText(); + } + } } void SlideSorterView::SetPageUnderMouse ( - const model::SharedPageDescriptor& rpDescriptor, - const bool bAnimate) + const model::SharedPageDescriptor& rpDescriptor, + const bool bAnimate) { - if (mpPageUnderMouse != rpDescriptor) - { - if (mpPageUnderMouse) - SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false, bAnimate); + if (mpPageUnderMouse != rpDescriptor) + { + if (mpPageUnderMouse) + SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false, bAnimate); - mpPageUnderMouse = rpDescriptor; + mpPageUnderMouse = rpDescriptor; - if (mpPageUnderMouse) - SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true, bAnimate); + if (mpPageUnderMouse) + SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true, bAnimate); - // Change the quick help text to display the name of the page under - // the mouse. - mpToolTip->SetPage(rpDescriptor); - } + // Change the quick help text to display the name of the page under + // the mouse. + mpToolTip->SetPage(rpDescriptor); + } } bool SlideSorterView::SetState ( - const model::SharedPageDescriptor& rpDescriptor, - const PageDescriptor::State eState, - const bool bStateValue, - const bool bAnimate) + const model::SharedPageDescriptor& rpDescriptor, + const PageDescriptor::State eState, + const bool bStateValue, + const bool bAnimate) { - model::SharedPageDescriptor pDescriptor (rpDescriptor); - if ( ! pDescriptor) - return false; - - const bool bModified (pDescriptor->SetState(eState, bStateValue)); - if ( ! bModified) - return false; - - // When the page object is not visible (i.e. not on the screen then - // nothing has to be painted. - if (pDescriptor->HasState(PageDescriptor::ST_Visible)) - { - // For most states a change of that state leads to visible - // difference and we have to request a repaint. - if (eState != PageDescriptor::ST_WasSelected) - RequestRepaint(pDescriptor); - } - - ::boost::shared_ptr<ViewShell> pMainViewShell(mrSlideSorter.GetViewShellBase()->GetMainViewShell()); - if (pMainViewShell - && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW) - { - // Fade in or out the buttons. - if (eState == PageDescriptor::ST_MouseOver) - { - if (bStateValue) - GetButtonBar().RequestFadeIn(rpDescriptor, bAnimate); - else - GetButtonBar().RequestFadeOut(rpDescriptor, bAnimate); - } - } - - return bModified; + model::SharedPageDescriptor pDescriptor (rpDescriptor); + if ( ! pDescriptor) + return false; + + const bool bModified (pDescriptor->SetState(eState, bStateValue)); + if ( ! bModified) + return false; + + // When the page object is not visible (i.e. not on the screen then + // nothing has to be painted. + if (pDescriptor->HasState(PageDescriptor::ST_Visible)) + { + // For most states a change of that state leads to visible + // difference and we have to request a repaint. + if (eState != PageDescriptor::ST_WasSelected) + RequestRepaint(pDescriptor); + } + + ::boost::shared_ptr<ViewShell> pMainViewShell(mrSlideSorter.GetViewShellBase()->GetMainViewShell()); + if (pMainViewShell + && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW) + { + // Fade in or out the buttons. + if (eState == PageDescriptor::ST_MouseOver) + { + if (bStateValue) + GetButtonBar().RequestFadeIn(rpDescriptor, bAnimate); + else + GetButtonBar().RequestFadeOut(rpDescriptor, bAnimate); + } + } + + return bModified; } @@ -1070,9 +1070,9 @@ bool SlideSorterView::SetState ( ::boost::shared_ptr<PageObjectPainter> SlideSorterView::GetPageObjectPainter (void) { - if ( ! mpPageObjectPainter) - mpPageObjectPainter.reset(new PageObjectPainter(mrSlideSorter)); - return mpPageObjectPainter; + if ( ! mpPageObjectPainter) + mpPageObjectPainter.reset(new PageObjectPainter(mrSlideSorter)); + return mpPageObjectPainter; } @@ -1080,7 +1080,7 @@ bool SlideSorterView::SetState ( ::boost::shared_ptr<LayeredDevice> SlideSorterView::GetLayeredDevice (void) const { - return mpLayeredDevice; + return mpLayeredDevice; } @@ -1089,26 +1089,26 @@ bool SlideSorterView::SetState ( //===== SlideSorterView::DrawLock ============================================= SlideSorterView::DrawLock::DrawLock ( - view::SlideSorterView& rView, - const SharedSdWindow& rpWindow) - : mrView(rView), - mpWindow(rpWindow) + view::SlideSorterView& rView, + const SharedSdWindow& rpWindow) + : mrView(rView), + mpWindow(rpWindow) { - if (mrView.mnLockRedrawSmph == 0) - mrView.maRedrawRegion.SetEmpty(); - ++mrView.mnLockRedrawSmph; + if (mrView.mnLockRedrawSmph == 0) + mrView.maRedrawRegion.SetEmpty(); + ++mrView.mnLockRedrawSmph; } SlideSorterView::DrawLock::DrawLock (SlideSorter& rSlideSorter) - : mrView(rSlideSorter.GetView()), - mpWindow(rSlideSorter.GetContentWindow()) + : mrView(rSlideSorter.GetView()), + mpWindow(rSlideSorter.GetContentWindow()) { - if (mrView.mnLockRedrawSmph == 0) - mrView.maRedrawRegion.SetEmpty(); - ++mrView.mnLockRedrawSmph; + if (mrView.mnLockRedrawSmph == 0) + mrView.maRedrawRegion.SetEmpty(); + ++mrView.mnLockRedrawSmph; } @@ -1116,14 +1116,14 @@ SlideSorterView::DrawLock::DrawLock (SlideSorter& rSlideSorter) SlideSorterView::DrawLock::~DrawLock (void) { - OSL_ASSERT(mrView.mnLockRedrawSmph>0); - --mrView.mnLockRedrawSmph; - if (mrView.mnLockRedrawSmph == 0) - if (mpWindow) - { - mpWindow->Invalidate(mrView.maRedrawRegion); - mpWindow->Update(); - } + OSL_ASSERT(mrView.mnLockRedrawSmph>0); + --mrView.mnLockRedrawSmph; + if (mrView.mnLockRedrawSmph == 0) + if (mpWindow) + { + mpWindow->Invalidate(mrView.maRedrawRegion); + mpWindow->Update(); + } } @@ -1131,7 +1131,7 @@ SlideSorterView::DrawLock::~DrawLock (void) void SlideSorterView::DrawLock::Dispose (void) { - mpWindow.reset(); + mpWindow.reset(); } diff --git a/main/sd/source/ui/slidesorter/view/SlsFontProvider.cxx b/main/sd/source/ui/slidesorter/view/SlsFontProvider.cxx index ddc6232..adb55825 100644 --- a/main/sd/source/ui/slidesorter/view/SlsFontProvider.cxx +++ b/main/sd/source/ui/slidesorter/view/SlsFontProvider.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -40,42 +40,42 @@ FontProvider* FontProvider::mpInstance = NULL; FontProvider& FontProvider::Instance (void) { - if (mpInstance == NULL) - { - ::osl::GetGlobalMutex aMutexFunctor; - ::osl::MutexGuard aGuard (aMutexFunctor()); - if (mpInstance == NULL) - { - // Create an instance of the class and register it at the - // SdGlobalResourceContainer so that it is eventually released. - FontProvider* pInstance = new FontProvider(); - SdGlobalResourceContainer::Instance().AddResource ( - ::std::auto_ptr<SdGlobalResource>(pInstance)); - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - mpInstance = pInstance; - } - } - else - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } - - // We throw an exception when for some strange reason no instance of - // this class exists. - if (mpInstance == NULL) - throw ::com::sun::star::uno::RuntimeException(::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")), - NULL); - - return *mpInstance; + if (mpInstance == NULL) + { + ::osl::GetGlobalMutex aMutexFunctor; + ::osl::MutexGuard aGuard (aMutexFunctor()); + if (mpInstance == NULL) + { + // Create an instance of the class and register it at the + // SdGlobalResourceContainer so that it is eventually released. + FontProvider* pInstance = new FontProvider(); + SdGlobalResourceContainer::Instance().AddResource ( + ::std::auto_ptr<SdGlobalResource>(pInstance)); + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + mpInstance = pInstance; + } + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } + + // We throw an exception when for some strange reason no instance of + // this class exists. + if (mpInstance == NULL) + throw ::com::sun::star::uno::RuntimeException(::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")), + NULL); + + return *mpInstance; } FontProvider::FontProvider (void) - : maFont(), - maMapMode() + : maFont(), + maMapMode() { } @@ -91,7 +91,7 @@ FontProvider::~FontProvider (void) void FontProvider::Invalidate (void) { - maFont.reset(); + maFont.reset(); } @@ -99,30 +99,30 @@ void FontProvider::Invalidate (void) FontProvider::SharedFontPointer FontProvider::GetFont (const OutputDevice& rDevice) { - // Reset the font when the map mode has changed since its creation. - if (maMapMode != rDevice.GetMapMode()) - maFont.reset(); - - if (maFont.get() == NULL) - { - // Initialize the font from the application style settings. - maFont.reset(new Font (Application::GetSettings().GetStyleSettings().GetAppFont())); - maFont->SetTransparent(sal_True); - maFont->SetWeight(WEIGHT_NORMAL); - - // Transform the point size to pixel size. - MapMode aFontMapMode (MAP_POINT); - Size aFontSize (rDevice.LogicToPixel(maFont->GetSize(), aFontMapMode)); - - // Transform the font size to the logical coordinates of the device. - maFont->SetSize (rDevice.PixelToLogic(aFontSize)); - - // Remember the map mode of the given device to detect different - // devices or modified zoom scales on future calls. - maMapMode = rDevice.GetMapMode(); - } - - return maFont; + // Reset the font when the map mode has changed since its creation. + if (maMapMode != rDevice.GetMapMode()) + maFont.reset(); + + if (maFont.get() == NULL) + { + // Initialize the font from the application style settings. + maFont.reset(new Font (Application::GetSettings().GetStyleSettings().GetAppFont())); + maFont->SetTransparent(sal_True); + maFont->SetWeight(WEIGHT_NORMAL); + + // Transform the point size to pixel size. + MapMode aFontMapMode (MAP_POINT); + Size aFontSize (rDevice.LogicToPixel(maFont->GetSize(), aFontMapMode)); + + // Transform the font size to the logical coordinates of the device. + maFont->SetSize (rDevice.PixelToLogic(aFontSize)); + + // Remember the map mode of the given device to detect different + // devices or modified zoom scales on future calls. + maMapMode = rDevice.GetMapMode(); + } + + return maFont; } -} } } // end of namespace ::sd::slidesorter::view +} } } // end of namespace ::sd::slidesorter::view diff --git a/main/sd/source/ui/slidesorter/view/SlsFramePainter.cxx b/main/sd/source/ui/slidesorter/view/SlsFramePainter.cxx index 13b5052..1e2ff92 100644 --- a/main/sd/source/ui/slidesorter/view/SlsFramePainter.cxx +++ b/main/sd/source/ui/slidesorter/view/SlsFramePainter.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -31,29 +31,29 @@ namespace sd { namespace slidesorter { namespace view { FramePainter::FramePainter (const BitmapEx& rShadowBitmap) - : maTopLeft(rShadowBitmap,-1,-1), - maTop(rShadowBitmap,0,-1), - maTopRight(rShadowBitmap,+1,-1), - maLeft(rShadowBitmap,-1,0), - maRight(rShadowBitmap,+1,0), - maBottomLeft(rShadowBitmap,-1,+1), - maBottom(rShadowBitmap,0,+1), - maBottomRight(rShadowBitmap,+1,+1), - maCenter(rShadowBitmap,0,0), - mbIsValid(false) + : maTopLeft(rShadowBitmap,-1,-1), + maTop(rShadowBitmap,0,-1), + maTopRight(rShadowBitmap,+1,-1), + maLeft(rShadowBitmap,-1,0), + maRight(rShadowBitmap,+1,0), + maBottomLeft(rShadowBitmap,-1,+1), + maBottom(rShadowBitmap,0,+1), + maBottomRight(rShadowBitmap,+1,+1), + maCenter(rShadowBitmap,0,0), + mbIsValid(false) { - if (rShadowBitmap.GetSizePixel().Width() == rShadowBitmap.GetSizePixel().Height() - && (rShadowBitmap.GetSizePixel().Width()-1)%2 == 0 - && ((rShadowBitmap.GetSizePixel().Width()-1)/2)%2 == 1) - { - mbIsValid = true; - } - else - { - OSL_ASSERT(rShadowBitmap.GetSizePixel().Width() == rShadowBitmap.GetSizePixel().Height()); - OSL_ASSERT((rShadowBitmap.GetSizePixel().Width()-1)%2 == 0); - OSL_ASSERT(((rShadowBitmap.GetSizePixel().Width()-1)/2)%2 == 1); - } + if (rShadowBitmap.GetSizePixel().Width() == rShadowBitmap.GetSizePixel().Height() + && (rShadowBitmap.GetSizePixel().Width()-1)%2 == 0 + && ((rShadowBitmap.GetSizePixel().Width()-1)/2)%2 == 1) + { + mbIsValid = true; + } + else + { + OSL_ASSERT(rShadowBitmap.GetSizePixel().Width() == rShadowBitmap.GetSizePixel().Height()); + OSL_ASSERT((rShadowBitmap.GetSizePixel().Width()-1)%2 == 0); + OSL_ASSERT(((rShadowBitmap.GetSizePixel().Width()-1)/2)%2 == 1); + } } @@ -67,54 +67,54 @@ FramePainter::~FramePainter (void) void FramePainter::PaintFrame ( - OutputDevice& rDevice, - const Rectangle aBox) const + OutputDevice& rDevice, + const Rectangle aBox) const { - if ( ! mbIsValid) - return; - - // Paint the shadow. - maTopLeft.PaintCorner(rDevice, aBox.TopLeft()); - maTopRight.PaintCorner(rDevice, aBox.TopRight()); - maBottomLeft.PaintCorner(rDevice, aBox.BottomLeft()); - maBottomRight.PaintCorner(rDevice, aBox.BottomRight()); - maLeft.PaintSide(rDevice, aBox.TopLeft(), aBox.BottomLeft(), maTopLeft, maBottomLeft); - maRight.PaintSide(rDevice, aBox.TopRight(), aBox.BottomRight(), maTopRight, maBottomRight); - maTop.PaintSide(rDevice, aBox.TopLeft(), aBox.TopRight(), maTopLeft, maTopRight); - maBottom.PaintSide(rDevice, aBox.BottomLeft(), aBox.BottomRight(), maBottomLeft, maBottomRight); - maCenter.PaintCenter(rDevice,aBox); + if ( ! mbIsValid) + return; + + // Paint the shadow. + maTopLeft.PaintCorner(rDevice, aBox.TopLeft()); + maTopRight.PaintCorner(rDevice, aBox.TopRight()); + maBottomLeft.PaintCorner(rDevice, aBox.BottomLeft()); + maBottomRight.PaintCorner(rDevice, aBox.BottomRight()); + maLeft.PaintSide(rDevice, aBox.TopLeft(), aBox.BottomLeft(), maTopLeft, maBottomLeft); + maRight.PaintSide(rDevice, aBox.TopRight(), aBox.BottomRight(), maTopRight, maBottomRight); + maTop.PaintSide(rDevice, aBox.TopLeft(), aBox.TopRight(), maTopLeft, maTopRight); + maBottom.PaintSide(rDevice, aBox.BottomLeft(), aBox.BottomRight(), maBottomLeft, maBottomRight); + maCenter.PaintCenter(rDevice,aBox); } void FramePainter::AdaptColor ( - const Color aNewColor, - const bool bEraseCenter) + const Color aNewColor, + const bool bEraseCenter) { - // Get the source color. - if (maCenter.maBitmap.IsEmpty()) - return; - BitmapReadAccess* pReadAccess = maCenter.maBitmap.GetBitmap().AcquireReadAccess(); - if (pReadAccess == NULL) - return; - const Color aSourceColor = pReadAccess->GetColor(0,0); - maCenter.maBitmap.GetBitmap().ReleaseAccess(pReadAccess); - - // Erase the center bitmap. - if (bEraseCenter) - maCenter.maBitmap.SetEmpty(); - - // Replace the color in all bitmaps. - maTopLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); - maTop.maBitmap.Replace(aSourceColor, aNewColor, 0); - maTopRight.maBitmap.Replace(aSourceColor, aNewColor, 0); - maLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); - maCenter.maBitmap.Replace(aSourceColor, aNewColor, 0); - maRight.maBitmap.Replace(aSourceColor, aNewColor, 0); - maBottomLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); - maBottom.maBitmap.Replace(aSourceColor, aNewColor, 0); - maBottomRight.maBitmap.Replace(aSourceColor, aNewColor, 0); + // Get the source color. + if (maCenter.maBitmap.IsEmpty()) + return; + BitmapReadAccess* pReadAccess = maCenter.maBitmap.GetBitmap().AcquireReadAccess(); + if (pReadAccess == NULL) + return; + const Color aSourceColor = pReadAccess->GetColor(0,0); + maCenter.maBitmap.GetBitmap().ReleaseAccess(pReadAccess); + + // Erase the center bitmap. + if (bEraseCenter) + maCenter.maBitmap.SetEmpty(); + + // Replace the color in all bitmaps. + maTopLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); + maTop.maBitmap.Replace(aSourceColor, aNewColor, 0); + maTopRight.maBitmap.Replace(aSourceColor, aNewColor, 0); + maLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); + maCenter.maBitmap.Replace(aSourceColor, aNewColor, 0); + maRight.maBitmap.Replace(aSourceColor, aNewColor, 0); + maBottomLeft.maBitmap.Replace(aSourceColor, aNewColor, 0); + maBottom.maBitmap.Replace(aSourceColor, aNewColor, 0); + maBottomRight.maBitmap.Replace(aSourceColor, aNewColor, 0); } @@ -123,137 +123,137 @@ void FramePainter::AdaptColor ( //===== FramePainter::OffsetBitmap ============================================ FramePainter::OffsetBitmap::OffsetBitmap ( - const BitmapEx& rBitmap, - const sal_Int32 nHorizontalPosition, - const sal_Int32 nVerticalPosition) - : maBitmap(), - maOffset() + const BitmapEx& rBitmap, + const sal_Int32 nHorizontalPosition, + const sal_Int32 nVerticalPosition) + : maBitmap(), + maOffset() { - OSL_ASSERT(nHorizontalPosition>=-1 && nHorizontalPosition<=+1); - OSL_ASSERT(nVerticalPosition>=-1 && nVerticalPosition<=+1); - - const sal_Int32 nS (1); - const sal_Int32 nC (::std::max<sal_Int32>(0,(rBitmap.GetSizePixel().Width()-nS)/2)); - const sal_Int32 nO (nC/2); - - const Point aOrigin( - nHorizontalPosition<0 ? 0 : (nHorizontalPosition == 0 ? nC : nC+nS), - nVerticalPosition<0 ? 0 : (nVerticalPosition == 0 ? nC : nC+nS)); - const Size aSize( - nHorizontalPosition==0 ? nS : nC, - nVerticalPosition==0 ? nS : nC); - maBitmap = BitmapEx(rBitmap, aOrigin, aSize); - if (maBitmap.IsEmpty()) - return; - maOffset = Point( - nHorizontalPosition<0 ? -nO : nHorizontalPosition>0 ? -nO : 0, - nVerticalPosition<0 ? -nO : nVerticalPosition>0 ? -nO : 0); - - // Enlarge the side bitmaps so that painting the frame requires less - // paint calls. - const sal_Int32 nSideBitmapSize (64); - if (nHorizontalPosition == 0 && nVerticalPosition == 0) - { - maBitmap.Scale(Size(nSideBitmapSize,nSideBitmapSize), BMP_SCALE_FASTESTINTERPOLATE); - } - else if (nHorizontalPosition == 0) - { - maBitmap.Scale(Size(nSideBitmapSize,aSize.Height()), BMP_SCALE_FASTESTINTERPOLATE); - } - else if (nVerticalPosition == 0) - { - maBitmap.Scale(Size(maBitmap.GetSizePixel().Width(), nSideBitmapSize), BMP_SCALE_FASTESTINTERPOLATE); - } + OSL_ASSERT(nHorizontalPosition>=-1 && nHorizontalPosition<=+1); + OSL_ASSERT(nVerticalPosition>=-1 && nVerticalPosition<=+1); + + const sal_Int32 nS (1); + const sal_Int32 nC (::std::max<sal_Int32>(0,(rBitmap.GetSizePixel().Width()-nS)/2)); + const sal_Int32 nO (nC/2); + + const Point aOrigin( + nHorizontalPosition<0 ? 0 : (nHorizontalPosition == 0 ? nC : nC+nS), + nVerticalPosition<0 ? 0 : (nVerticalPosition == 0 ? nC : nC+nS)); + const Size aSize( + nHorizontalPosition==0 ? nS : nC, + nVerticalPosition==0 ? nS : nC); + maBitmap = BitmapEx(rBitmap, aOrigin, aSize); + if (maBitmap.IsEmpty()) + return; + maOffset = Point( + nHorizontalPosition<0 ? -nO : nHorizontalPosition>0 ? -nO : 0, + nVerticalPosition<0 ? -nO : nVerticalPosition>0 ? -nO : 0); + + // Enlarge the side bitmaps so that painting the frame requires less + // paint calls. + const sal_Int32 nSideBitmapSize (64); + if (nHorizontalPosition == 0 && nVerticalPosition == 0) + { + maBitmap.Scale(Size(nSideBitmapSize,nSideBitmapSize), BMP_SCALE_FASTESTINTERPOLATE); + } + else if (nHorizontalPosition == 0) + { + maBitmap.Scale(Size(nSideBitmapSize,aSize.Height()), BMP_SCALE_FASTESTINTERPOLATE); + } + else if (nVerticalPosition == 0) + { + maBitmap.Scale(Size(maBitmap.GetSizePixel().Width(), nSideBitmapSize), BMP_SCALE_FASTESTINTERPOLATE); + } } void FramePainter::OffsetBitmap::PaintCorner ( - OutputDevice& rDevice, - const Point& rAnchor) const + OutputDevice& rDevice, + const Point& rAnchor) const { - if ( ! maBitmap.IsEmpty()) - rDevice.DrawBitmapEx(rAnchor+maOffset, maBitmap); + if ( ! maBitmap.IsEmpty()) + rDevice.DrawBitmapEx(rAnchor+maOffset, maBitmap); } void FramePainter::OffsetBitmap::PaintSide ( - OutputDevice& rDevice, - const Point& rAnchor1, - const Point& rAnchor2, - const OffsetBitmap& rCornerBitmap1, - const OffsetBitmap& rCornerBitmap2) const + OutputDevice& rDevice, + const Point& rAnchor1, + const Point& rAnchor2, + const OffsetBitmap& rCornerBitmap1, + const OffsetBitmap& rCornerBitmap2) const { - if (maBitmap.IsEmpty()) - return; - - const Size aBitmapSize (maBitmap.GetSizePixel()); - if (rAnchor1.Y() == rAnchor2.Y()) - { - // Side is horizontal. - const sal_Int32 nY (rAnchor1.Y() + maOffset.Y()); - const sal_Int32 nLeft ( - rAnchor1.X() - + rCornerBitmap1.maBitmap.GetSizePixel().Width() - + rCornerBitmap1.maOffset.X()); - const sal_Int32 nRight ( - rAnchor2.X() - + rCornerBitmap2.maOffset.X()\ - - 1); - for (sal_Int32 nX=nLeft; nX<=nRight; nX+=aBitmapSize.Width()) - { - rDevice.DrawBitmapEx( - Point(nX,nY), - Size(std::min(aBitmapSize.Width(),static_cast<long>(nRight-nX+1)),aBitmapSize.Height()), - maBitmap); - } - } - else if (rAnchor1.X() == rAnchor2.X()) - { - // Side is vertical. - const sal_Int32 nX (rAnchor1.X() + maOffset.X()); - const sal_Int32 nTop ( - rAnchor1.Y() - + rCornerBitmap1.maBitmap.GetSizePixel().Height() - + rCornerBitmap1.maOffset.Y()); - const sal_Int32 nBottom ( - rAnchor2.Y() - + rCornerBitmap2.maOffset.Y() - - 1); - for (sal_Int32 nY=nTop; nY<=nBottom; nY+=aBitmapSize.Height()) - { - rDevice.DrawBitmapEx( - Point(nX,nY), - Size(aBitmapSize.Width(), std::min(aBitmapSize.Height(), static_cast<long>(nBottom-nY+1))), - maBitmap); - } - } - else - { - // Diagonal sides indicatee an error. - OSL_ASSERT(false); - } + if (maBitmap.IsEmpty()) + return; + + const Size aBitmapSize (maBitmap.GetSizePixel()); + if (rAnchor1.Y() == rAnchor2.Y()) + { + // Side is horizontal. + const sal_Int32 nY (rAnchor1.Y() + maOffset.Y()); + const sal_Int32 nLeft ( + rAnchor1.X() + + rCornerBitmap1.maBitmap.GetSizePixel().Width() + + rCornerBitmap1.maOffset.X()); + const sal_Int32 nRight ( + rAnchor2.X() + + rCornerBitmap2.maOffset.X()\ + - 1); + for (sal_Int32 nX=nLeft; nX<=nRight; nX+=aBitmapSize.Width()) + { + rDevice.DrawBitmapEx( + Point(nX,nY), + Size(std::min(aBitmapSize.Width(),static_cast<long>(nRight-nX+1)),aBitmapSize.Height()), + maBitmap); + } + } + else if (rAnchor1.X() == rAnchor2.X()) + { + // Side is vertical. + const sal_Int32 nX (rAnchor1.X() + maOffset.X()); + const sal_Int32 nTop ( + rAnchor1.Y() + + rCornerBitmap1.maBitmap.GetSizePixel().Height() + + rCornerBitmap1.maOffset.Y()); + const sal_Int32 nBottom ( + rAnchor2.Y() + + rCornerBitmap2.maOffset.Y() + - 1); + for (sal_Int32 nY=nTop; nY<=nBottom; nY+=aBitmapSize.Height()) + { + rDevice.DrawBitmapEx( + Point(nX,nY), + Size(aBitmapSize.Width(), std::min(aBitmapSize.Height(), static_cast<long>(nBottom-nY+1))), + maBitmap); + } + } + else + { + // Diagonal sides indicates an error. + OSL_ASSERT(false); + } } void FramePainter::OffsetBitmap::PaintCenter ( - OutputDevice& rDevice, - const Rectangle& rBox) const + OutputDevice& rDevice, + const Rectangle& rBox) const { - const Size aBitmapSize (maBitmap.GetSizePixel()); - for (sal_Int32 nY=rBox.Top(); nY<=rBox.Bottom(); nY+=aBitmapSize.Height()) - for (sal_Int32 nX=rBox.Left(); nX<=rBox.Right(); nX+=aBitmapSize.Width()) - rDevice.DrawBitmapEx( - Point(nX,nY), - Size( - ::std::min(aBitmapSize.Width(), rBox.Right()-nX+1), - std::min(aBitmapSize.Height(), rBox.Bottom()-nY+1)), - maBitmap); + const Size aBitmapSize (maBitmap.GetSizePixel()); + for (sal_Int32 nY=rBox.Top(); nY<=rBox.Bottom(); nY+=aBitmapSize.Height()) + for (sal_Int32 nX=rBox.Left(); nX<=rBox.Right(); nX+=aBitmapSize.Width()) + rDevice.DrawBitmapEx( + Point(nX,nY), + Size( + ::std::min(aBitmapSize.Width(), rBox.Right()-nX+1), + std::min(aBitmapSize.Height(), rBox.Bottom()-nY+1)), + maBitmap); } diff --git a/main/sd/source/ui/slidesorter/view/SlsFramePainter.hxx b/main/sd/source/ui/slidesorter/view/SlsFramePainter.hxx index c0d641e..0e14bcb 100644 --- a/main/sd/source/ui/slidesorter/view/SlsFramePainter.hxx +++ b/main/sd/source/ui/slidesorter/view/SlsFramePainter.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -32,83 +32,83 @@ namespace sd { namespace slidesorter { namespace view { class FramePainter { public: - FramePainter (const BitmapEx& rBitmap); - ~FramePainter (void); - - /** Paint a border around the given box by using a set of bitmaps for - the corners and sides. - */ - void PaintFrame (OutputDevice&rDevice, const Rectangle aBox) const; - - /** Special functionality that takes the color from the center - bitmap and replaces that color in all bitmaps by the given new - color. Alpha values are not modified. - @param bClearCenterBitmap - When <TRUE/> then the center bitmap is erased. - */ - void AdaptColor (const Color aNewColor, const bool bClearCenterBitmap); + FramePainter (const BitmapEx& rBitmap); + ~FramePainter (void); + + /** Paint a border around the given box by using a set of bitmaps for + the corners and sides. + */ + void PaintFrame (OutputDevice&rDevice, const Rectangle aBox) const; + + /** Special functionality that takes the color from the center + bitmap and replaces that color in all bitmaps by the given new + color. Alpha values are not modified. + @param bClearCenterBitmap + When <TRUE/> then the center bitmap is erased. + */ + void AdaptColor (const Color aNewColor, const bool bClearCenterBitmap); private: - /** Bitmap with offset that is used when the bitmap is painted. The bitmap - */ - class OffsetBitmap { - public: - BitmapEx maBitmap; - Point maOffset; - - /** Create one of the eight shadow bitmaps from one that combines - them all. This larger bitmap is expected to have dimension NxN - with N=1+2*M. Of this larger bitmap there are created four - corner bitmaps of size 2*M x 2*M and four side bitmaps of sizes - 1xM (top and bottom) and Mx1 (left and right). The corner - bitmaps have each one quadrant of size MxM that is painted under - the interior of the frame. - @param rBitmap - The larger bitmap of which the eight shadow bitmaps are cut - out from. - @param nHorizontalPosition - Valid values are -1 (left), 0 (center), and +1 (right). - @param nVerticalPosition - Valid values are -1 (top), 0 (center), and +1 (bottom). - */ - OffsetBitmap ( - const BitmapEx& rBitmap, - const sal_Int32 nHorizontalPosition, - const sal_Int32 nVerticalPosition); - - /** Use the given device to paint the bitmap at the location that is - the sum of the given anchor and the internal offset. - */ - void PaintCorner (OutputDevice& rDevice, const Point& rAnchor) const; - - /** Use the given device to paint the bitmap stretched between the - two given locations. Offsets of the adjacent corner bitmaps and - the offset of the side bitmap are used to determine the area - that is to be filled with the side bitmap. - */ - void PaintSide ( - OutputDevice& rDevice, - const Point& rAnchor1, - const Point& rAnchor2, - const OffsetBitmap& rCornerBitmap1, - const OffsetBitmap& rCornerBitmap2) const; - - /** Fill the given rectangle with the bitmap. - */ - void PaintCenter ( - OutputDevice& rDevice, - const Rectangle& rBox) const; - }; - OffsetBitmap maTopLeft; - OffsetBitmap maTop; - OffsetBitmap maTopRight; - OffsetBitmap maLeft; - OffsetBitmap maRight; - OffsetBitmap maBottomLeft; - OffsetBitmap maBottom; - OffsetBitmap maBottomRight; - OffsetBitmap maCenter; - bool mbIsValid; + /** Bitmap with offset that is used when the bitmap is painted. The bitmap + */ + class OffsetBitmap { + public: + BitmapEx maBitmap; + Point maOffset; + + /** Create one of the eight shadow bitmaps from one that combines + them all. This larger bitmap is expected to have dimension NxN + with N=1+2*M. Of this larger bitmap there are created four + corner bitmaps of size 2*M x 2*M and four side bitmaps of sizes + 1xM (top and bottom) and Mx1 (left and right). The corner + bitmaps have each one quadrant of size MxM that is painted under + the interior of the frame. + @param rBitmap + The larger bitmap of which the eight shadow bitmaps are cut + out from. + @param nHorizontalPosition + Valid values are -1 (left), 0 (center), and +1 (right). + @param nVerticalPosition + Valid values are -1 (top), 0 (center), and +1 (bottom). + */ + OffsetBitmap ( + const BitmapEx& rBitmap, + const sal_Int32 nHorizontalPosition, + const sal_Int32 nVerticalPosition); + + /** Use the given device to paint the bitmap at the location that is + the sum of the given anchor and the internal offset. + */ + void PaintCorner (OutputDevice& rDevice, const Point& rAnchor) const; + + /** Use the given device to paint the bitmap stretched between the + two given locations. Offsets of the adjacent corner bitmaps and + the offset of the side bitmap are used to determine the area + that is to be filled with the side bitmap. + */ + void PaintSide ( + OutputDevice& rDevice, + const Point& rAnchor1, + const Point& rAnchor2, + const OffsetBitmap& rCornerBitmap1, + const OffsetBitmap& rCornerBitmap2) const; + + /** Fill the given rectangle with the bitmap. + */ + void PaintCenter ( + OutputDevice& rDevice, + const Rectangle& rBox) const; + }; + OffsetBitmap maTopLeft; + OffsetBitmap maTop; + OffsetBitmap maTopRight; + OffsetBitmap maLeft; + OffsetBitmap maRight; + OffsetBitmap maBottomLeft; + OffsetBitmap maBottom; + OffsetBitmap maBottomRight; + OffsetBitmap maCenter; + bool mbIsValid; }; diff --git a/main/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/main/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index 2b8c67d..fc93d17 100644 --- a/main/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx +++ b/main/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -55,11 +55,11 @@ static const double gnPreviewOffsetScale = 1.0 / 8.0; Rectangle GrowRectangle (const Rectangle& rBox, const sal_Int32 nOffset) { - return Rectangle ( - rBox.Left() - nOffset, - rBox.Top() - nOffset, - rBox.Right() + nOffset, - rBox.Bottom() + nOffset); + return Rectangle ( + rBox.Left() - nOffset, + rBox.Top() - nOffset, + rBox.Right() + nOffset, + rBox.Bottom() + nOffset); } sal_Int32 RoundToInt (const double nValue) { return sal_Int32(::rtl::math::round(nValue)); } @@ -70,21 +70,21 @@ sal_Int32 RoundToInt (const double nValue) { return sal_Int32(::rtl::math::round namespace sd { namespace slidesorter { namespace view { -//===== InsertionIndicatorOverlay =========================================== +//===== InsertionIndicatorOverlay ============================================= const static sal_Int32 gnShadowBorder = 3; const static sal_Int32 gnSuperScaleFactor = 1; InsertionIndicatorOverlay::InsertionIndicatorOverlay (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - mbIsVisible(false), - mnLayerIndex(2), - mpLayerInvalidator(), - maLocation(), - maIcon(), - maIconOffset(), - mpShadowPainter( - new FramePainter(mrSlideSorter.GetTheme()->GetIcon(Theme::Icon_RawInsertShadow))) + : mrSlideSorter(rSlideSorter), + mbIsVisible(false), + mnLayerIndex(2), + mpLayerInvalidator(), + maLocation(), + maIcon(), + maIconOffset(), + mpShadowPainter( + new FramePainter(mrSlideSorter.GetTheme()->GetIcon(Theme::Icon_RawInsertShadow))) { } @@ -93,7 +93,7 @@ InsertionIndicatorOverlay::InsertionIndicatorOverlay (SlideSorter& rSlideSorter) InsertionIndicatorOverlay::~InsertionIndicatorOverlay (void) { - Hide(); + Hide(); } @@ -101,230 +101,230 @@ InsertionIndicatorOverlay::~InsertionIndicatorOverlay (void) void InsertionIndicatorOverlay::Create (const SdTransferable* pTransferable) { - if (pTransferable == NULL) - return; - - ::boost::shared_ptr<controller::TransferableData> pData ( - controller::TransferableData::GetFromTransferable(pTransferable)); - if ( ! pData) - return; - sal_Int32 nSelectionCount (0); - if (pTransferable->HasPageBookmarks()) - nSelectionCount = pTransferable->GetPageBookmarks().Count(); - else - { - DrawDocShell* pDataDocShell = dynamic_cast<DrawDocShell*>(&pTransferable->GetDocShell()); - if (pDataDocShell != NULL) - { - SdDrawDocument* pDataDocument = pDataDocShell->GetDoc(); - if (pDataDocument != NULL) - nSelectionCount = pDataDocument->GetSdPageCount(PK_STANDARD); - } - } - Create(pData->GetRepresentatives(), nSelectionCount); + if (pTransferable == NULL) + return; + + ::boost::shared_ptr<controller::TransferableData> pData ( + controller::TransferableData::GetFromTransferable(pTransferable)); + if ( ! pData) + return; + sal_Int32 nSelectionCount (0); + if (pTransferable->HasPageBookmarks()) + nSelectionCount = pTransferable->GetPageBookmarks().Count(); + else + { + DrawDocShell* pDataDocShell = dynamic_cast<DrawDocShell*>(&pTransferable->GetDocShell()); + if (pDataDocShell != NULL) + { + SdDrawDocument* pDataDocument = pDataDocShell->GetDoc(); + if (pDataDocument != NULL) + nSelectionCount = pDataDocument->GetSdPageCount(PK_STANDARD); + } + } + Create(pData->GetRepresentatives(), nSelectionCount); } void InsertionIndicatorOverlay::Create ( - const ::std::vector<controller::TransferableData::Representative>& rRepresentatives, - const sal_Int32 nSelectionCount) + const ::std::vector<controller::TransferableData::Representative>& rRepresentatives, + const sal_Int32 nSelectionCount) { - view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); - ::boost::shared_ptr<view::PageObjectLayouter> pPageObjectLayouter ( - rLayouter.GetPageObjectLayouter()); - ::boost::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme()); - const Size aOriginalPreviewSize (pPageObjectLayouter->GetSize( - PageObjectLayouter::Preview, - PageObjectLayouter::WindowCoordinateSystem)); - - const double nPreviewScale (0.5); - const Size aPreviewSize ( - RoundToInt(aOriginalPreviewSize.Width()*nPreviewScale), - RoundToInt(aOriginalPreviewSize.Height()*nPreviewScale)); - const sal_Int32 nOffset ( - RoundToInt(Min(aPreviewSize.Width(),aPreviewSize.Height()) * gnPreviewOffsetScale)); - - // Determine size and offset depending on the number of previews. - sal_Int32 nCount (rRepresentatives.size()); - if (nCount > 0) - --nCount; - Size aIconSize( - aPreviewSize.Width() + 2 * gnShadowBorder + nCount*nOffset, - aPreviewSize.Height() + 2 * gnShadowBorder + nCount*nOffset); - maIconOffset = Point(gnShadowBorder, gnShadowBorder); - - // Create virtual devices for bitmap and mask whose bitmaps later be - // combined to form the BitmapEx of the icon. - VirtualDevice aContent ( - *mrSlideSorter.GetContentWindow(), - 0, - 0); - aContent.SetOutputSizePixel(aIconSize); - - aContent.SetFillColor(); - aContent.SetLineColor(pTheme->GetColor(Theme::Color_PreviewBorder)); - const Point aOffset = PaintRepresentatives(aContent, aPreviewSize, nOffset, rRepresentatives); - - PaintPageCount(aContent, nSelectionCount, aPreviewSize, aOffset); - - maIcon = aContent.GetBitmapEx(Point(0,0), aIconSize); - maIcon.Scale(aIconSize); + view::Layouter& rLayouter (mrSlideSorter.GetView().GetLayouter()); + ::boost::shared_ptr<view::PageObjectLayouter> pPageObjectLayouter ( + rLayouter.GetPageObjectLayouter()); + ::boost::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme()); + const Size aOriginalPreviewSize (pPageObjectLayouter->GetSize( + PageObjectLayouter::Preview, + PageObjectLayouter::WindowCoordinateSystem)); + + const double nPreviewScale (0.5); + const Size aPreviewSize ( + RoundToInt(aOriginalPreviewSize.Width()*nPreviewScale), + RoundToInt(aOriginalPreviewSize.Height()*nPreviewScale)); + const sal_Int32 nOffset ( + RoundToInt(Min(aPreviewSize.Width(),aPreviewSize.Height()) * gnPreviewOffsetScale)); + + // Determine size and offset depending on the number of previews. + sal_Int32 nCount (rRepresentatives.size()); + if (nCount > 0) + --nCount; + Size aIconSize( + aPreviewSize.Width() + 2 * gnShadowBorder + nCount*nOffset, + aPreviewSize.Height() + 2 * gnShadowBorder + nCount*nOffset); + maIconOffset = Point(gnShadowBorder, gnShadowBorder); + + // Create virtual devices for bitmap and mask whose bitmaps later be + // combined to form the BitmapEx of the icon. + VirtualDevice aContent ( + *mrSlideSorter.GetContentWindow(), + 0, + 0); + aContent.SetOutputSizePixel(aIconSize); + + aContent.SetFillColor(); + aContent.SetLineColor(pTheme->GetColor(Theme::Color_PreviewBorder)); + const Point aOffset = PaintRepresentatives(aContent, aPreviewSize, nOffset, rRepresentatives); + + PaintPageCount(aContent, nSelectionCount, aPreviewSize, aOffset); + + maIcon = aContent.GetBitmapEx(Point(0,0), aIconSize); + maIcon.Scale(aIconSize); } void InsertionIndicatorOverlay::SelectRepresentatives ( - model::PageEnumeration& rSelection, - ::std::vector<model::SharedPageDescriptor>& rDescriptors) const + model::PageEnumeration& rSelection, + ::std::vector<model::SharedPageDescriptor>& rDescriptors) const { - sal_Int32 nCount (0); - while (rSelection.HasMoreElements()) + sal_Int32 nCount (0); + while (rSelection.HasMoreElements()) { - if (nCount++ >= 3) - break; - rDescriptors.push_back(rSelection.GetNextElement()); - } + if (nCount++ >= 3) + break; + rDescriptors.push_back(rSelection.GetNextElement()); + } } Point InsertionIndicatorOverlay::PaintRepresentatives ( - OutputDevice& rContent, - const Size aPreviewSize, - const sal_Int32 nOffset, - const ::std::vector<controller::TransferableData::Representative>& rRepresentatives) const + OutputDevice& rContent, + const Size aPreviewSize, + const sal_Int32 nOffset, + const ::std::vector<controller::TransferableData::Representative>& rRepresentatives) const { - const Point aOffset (0,rRepresentatives.size()==1 ? -nOffset : 0); - - // Paint the pages. - Point aPageOffset (0,0); - double nTransparency (0); - const BitmapEx aExclusionOverlay (mrSlideSorter.GetTheme()->GetIcon(Theme::Icon_HideSlideOverlay)); - for (sal_Int32 nIndex=2; nIndex>=0; --nIndex) - { - if (rRepresentatives.size() <= sal_uInt32(nIndex)) - continue; - switch(nIndex) - { - case 0 : - aPageOffset = Point(0, nOffset); - nTransparency = 0.85; - break; - case 1: - aPageOffset = Point(nOffset, 0); - nTransparency = 0.75; - break; - case 2: - aPageOffset = Point(2*nOffset, 2*nOffset); - nTransparency = 0.65; - break; - } - aPageOffset += aOffset; - aPageOffset.X() += gnShadowBorder; - aPageOffset.Y() += gnShadowBorder; - - // Paint the preview. - Bitmap aPreview (rRepresentatives[nIndex].maBitmap); - const Size aSuperSampleSize( - aPreviewSize.Width()*gnSuperScaleFactor, - aPreviewSize.Height()*gnSuperScaleFactor); - aPreview.Scale(aPreviewSize, BMP_SCALE_INTERPOLATE); - rContent.DrawBitmapEx(aPageOffset, aPreview); - - // When the page is marked as excluded from the slide show then - // paint an overlay that visualizes this. - if (rRepresentatives[nIndex].mbIsExcluded) - { - const Region aSavedClipRegion (rContent.GetClipRegion()); - rContent.IntersectClipRegion(Rectangle(aPageOffset, aPreviewSize)); - // Paint bitmap tiled over the preview to mark it as excluded. - const sal_Int32 nIconWidth (aExclusionOverlay.GetSizePixel().Width()); - const sal_Int32 nIconHeight (aExclusionOverlay.GetSizePixel().Height()); - if (nIconWidth>0 && nIconHeight>0) - { - for (sal_Int32 nX=0; nX<aPreviewSize.Width(); nX+=nIconWidth) - for (sal_Int32 nY=0; nY<aPreviewSize.Height(); nY+=nIconHeight) - rContent.DrawBitmapEx(Point(nX,nY)+aPageOffset, aExclusionOverlay); - } - rContent.SetClipRegion(aSavedClipRegion); - } - - // Tone down the bitmap. The further back the darker it becomes. - Rectangle aBox ( - aPageOffset.X(), - aPageOffset.Y(), - aPageOffset.X()+aPreviewSize.Width()-1, - aPageOffset.Y()+aPreviewSize.Height()-1); - rContent.SetFillColor(COL_BLACK); - rContent.SetLineColor(); - rContent.DrawTransparent( - ::basegfx::B2DPolyPolygon(::basegfx::tools::createPolygonFromRect( - ::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right()+1, aBox.Bottom()+1), - 0, - 0)), - nTransparency); - - // Draw border around preview. - Rectangle aBorderBox (GrowRectangle(aBox, 1)); - rContent.SetLineColor(COL_GRAY); - rContent.SetFillColor(); - rContent.DrawRect(aBorderBox); - - // Draw shadow around preview. - mpShadowPainter->PaintFrame(rContent, aBorderBox); - } - - return aPageOffset; + const Point aOffset (0,rRepresentatives.size()==1 ? -nOffset : 0); + + // Paint the pages. + Point aPageOffset (0,0); + double nTransparency (0); + const BitmapEx aExclusionOverlay (mrSlideSorter.GetTheme()->GetIcon(Theme::Icon_HideSlideOverlay)); + for (sal_Int32 nIndex=2; nIndex>=0; --nIndex) + { + if (rRepresentatives.size() <= sal_uInt32(nIndex)) + continue; + switch(nIndex) + { + case 0 : + aPageOffset = Point(0, nOffset); + nTransparency = 0.85; + break; + case 1: + aPageOffset = Point(nOffset, 0); + nTransparency = 0.75; + break; + case 2: + aPageOffset = Point(2*nOffset, 2*nOffset); + nTransparency = 0.65; + break; + } + aPageOffset += aOffset; + aPageOffset.X() += gnShadowBorder; + aPageOffset.Y() += gnShadowBorder; + + // Paint the preview. + Bitmap aPreview (rRepresentatives[nIndex].maBitmap); + const Size aSuperSampleSize( + aPreviewSize.Width()*gnSuperScaleFactor, + aPreviewSize.Height()*gnSuperScaleFactor); + aPreview.Scale(aPreviewSize, BMP_SCALE_INTERPOLATE); + rContent.DrawBitmapEx(aPageOffset, aPreview); + + // When the page is marked as excluded from the slide show then + // paint an overlay that visualizes this. + if (rRepresentatives[nIndex].mbIsExcluded) + { + const Region aSavedClipRegion (rContent.GetClipRegion()); + rContent.IntersectClipRegion(Rectangle(aPageOffset, aPreviewSize)); + // Paint bitmap tiled over the preview to mark it as excluded. + const sal_Int32 nIconWidth (aExclusionOverlay.GetSizePixel().Width()); + const sal_Int32 nIconHeight (aExclusionOverlay.GetSizePixel().Height()); + if (nIconWidth>0 && nIconHeight>0) + { + for (sal_Int32 nX=0; nX<aPreviewSize.Width(); nX+=nIconWidth) + for (sal_Int32 nY=0; nY<aPreviewSize.Height(); nY+=nIconHeight) + rContent.DrawBitmapEx(Point(nX,nY)+aPageOffset, aExclusionOverlay); + } + rContent.SetClipRegion(aSavedClipRegion); + } + + // Tone down the bitmap. The further back the darker it becomes. + Rectangle aBox ( + aPageOffset.X(), + aPageOffset.Y(), + aPageOffset.X()+aPreviewSize.Width()-1, + aPageOffset.Y()+aPreviewSize.Height()-1); + rContent.SetFillColor(COL_BLACK); + rContent.SetLineColor(); + rContent.DrawTransparent( + ::basegfx::B2DPolyPolygon(::basegfx::tools::createPolygonFromRect( + ::basegfx::B2DRectangle(aBox.Left(), aBox.Top(), aBox.Right()+1, aBox.Bottom()+1), + 0, + 0)), + nTransparency); + + // Draw border around preview. + Rectangle aBorderBox (GrowRectangle(aBox, 1)); + rContent.SetLineColor(COL_GRAY); + rContent.SetFillColor(); + rContent.DrawRect(aBorderBox); + + // Draw shadow around preview. + mpShadowPainter->PaintFrame(rContent, aBorderBox); + } + + return aPageOffset; } void InsertionIndicatorOverlay::PaintPageCount ( - OutputDevice& rDevice, - const sal_Int32 nSelectionCount, - const Size aPreviewSize, - const Point aFirstPageOffset) const + OutputDevice& rDevice, + const sal_Int32 nSelectionCount, + const Size aPreviewSize, + const Point aFirstPageOffset) const { - // Paint the number of slides. - ::boost::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme()); - ::boost::shared_ptr<Font> pFont(Theme::GetFont(Theme::Font_PageCount, rDevice)); - if (pFont) - { - ::rtl::OUString sNumber (::rtl::OUString::valueOf(nSelectionCount)); - - // Determine the size of the (painted) text and create a bounding - // box that centers the text on the first preview. - rDevice.SetFont(*pFont); - Rectangle aTextBox; - rDevice.GetTextBoundRect(aTextBox, sNumber); - Point aTextOffset (aTextBox.TopLeft()); - Size aTextSize (aTextBox.GetSize()); - // Place text inside the first page preview. - Point aTextLocation(aFirstPageOffset); - // Center the text. - aTextLocation += Point( - (aPreviewSize.Width()-aTextBox.GetWidth())/2, - (aPreviewSize.Height()-aTextBox.GetHeight())/2); - aTextBox = Rectangle(aTextLocation, aTextSize); - - // Paint background, border and text. - static const sal_Int32 nBorder = 5; - rDevice.SetFillColor(pTheme->GetColor(Theme::Color_Selection)); - rDevice.SetLineColor(pTheme->GetColor(Theme::Color_Selection)); - rDevice.DrawRect(GrowRectangle(aTextBox, nBorder)); - - rDevice.SetFillColor(); - rDevice.SetLineColor(pTheme->GetColor(Theme::Color_PageCountFontColor)); - rDevice.DrawRect(GrowRectangle(aTextBox, nBorder-1)); - - rDevice.SetTextColor(pTheme->GetColor(Theme::Color_PageCountFontColor)); - rDevice.DrawText(aTextBox.TopLeft()-aTextOffset, sNumber); - } + // Paint the number of slides. + ::boost::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme()); + ::boost::shared_ptr<Font> pFont(Theme::GetFont(Theme::Font_PageCount, rDevice)); + if (pFont) + { + ::rtl::OUString sNumber (::rtl::OUString::valueOf(nSelectionCount)); + + // Determine the size of the (painted) text and create a bounding + // box that centers the text on the first preview. + rDevice.SetFont(*pFont); + Rectangle aTextBox; + rDevice.GetTextBoundRect(aTextBox, sNumber); + Point aTextOffset (aTextBox.TopLeft()); + Size aTextSize (aTextBox.GetSize()); + // Place text inside the first page preview. + Point aTextLocation(aFirstPageOffset); + // Center the text. + aTextLocation += Point( + (aPreviewSize.Width()-aTextBox.GetWidth())/2, + (aPreviewSize.Height()-aTextBox.GetHeight())/2); + aTextBox = Rectangle(aTextLocation, aTextSize); + + // Paint background, border and text. + static const sal_Int32 nBorder = 5; + rDevice.SetFillColor(pTheme->GetColor(Theme::Color_Selection)); + rDevice.SetLineColor(pTheme->GetColor(Theme::Color_Selection)); + rDevice.DrawRect(GrowRectangle(aTextBox, nBorder)); + + rDevice.SetFillColor(); + rDevice.SetLineColor(pTheme->GetColor(Theme::Color_PageCountFontColor)); + rDevice.DrawRect(GrowRectangle(aTextBox, nBorder-1)); + + rDevice.SetTextColor(pTheme->GetColor(Theme::Color_PageCountFontColor)); + rDevice.DrawText(aTextBox.TopLeft()-aTextOffset, sNumber); + } } @@ -332,37 +332,37 @@ void InsertionIndicatorOverlay::PaintPageCount ( void InsertionIndicatorOverlay::SetLocation (const Point& rLocation) { - const Point aTopLeft ( - rLocation - Point( - maIcon.GetSizePixel().Width()/2, - maIcon.GetSizePixel().Height()/2)); - if (maLocation != aTopLeft) - { - const Rectangle aOldBoundingBox (GetBoundingBox()); - - maLocation = aTopLeft; - - if (mpLayerInvalidator && IsVisible()) - { - mpLayerInvalidator->Invalidate(aOldBoundingBox); - mpLayerInvalidator->Invalidate(GetBoundingBox()); - } - } + const Point aTopLeft ( + rLocation - Point( + maIcon.GetSizePixel().Width()/2, + maIcon.GetSizePixel().Height()/2)); + if (maLocation != aTopLeft) + { + const Rectangle aOldBoundingBox (GetBoundingBox()); + + maLocation = aTopLeft; + + if (mpLayerInvalidator && IsVisible()) + { + mpLayerInvalidator->Invalidate(aOldBoundingBox); + mpLayerInvalidator->Invalidate(GetBoundingBox()); + } + } } void InsertionIndicatorOverlay::Paint ( - OutputDevice& rDevice, - const Rectangle& rRepaintArea) + OutputDevice& rDevice, + const Rectangle& rRepaintArea) { - (void)rRepaintArea; + (void)rRepaintArea; - if ( ! IsVisible()) - return; + if ( ! IsVisible()) + return; - rDevice.DrawImage(maLocation, maIcon); + rDevice.DrawImage(maLocation, maIcon); } @@ -370,10 +370,10 @@ void InsertionIndicatorOverlay::Paint ( void InsertionIndicatorOverlay::SetLayerInvalidator (const SharedILayerInvalidator& rpInvalidator) { - mpLayerInvalidator = rpInvalidator; + mpLayerInvalidator = rpInvalidator; - if (mbIsVisible && mpLayerInvalidator) - mpLayerInvalidator->Invalidate(GetBoundingBox()); + if (mbIsVisible && mpLayerInvalidator) + mpLayerInvalidator->Invalidate(GetBoundingBox()); } @@ -381,7 +381,7 @@ void InsertionIndicatorOverlay::SetLayerInvalidator (const SharedILayerInvalidat bool InsertionIndicatorOverlay::IsVisible (void) const { - return mbIsVisible; + return mbIsVisible; } @@ -389,19 +389,19 @@ bool InsertionIndicatorOverlay::IsVisible (void) const void InsertionIndicatorOverlay::Show (void) { - if ( ! mbIsVisible) - { - mbIsVisible = true; - - ::boost::shared_ptr<LayeredDevice> pLayeredDevice ( - mrSlideSorter.GetView().GetLayeredDevice()); - if (pLayeredDevice) - { - pLayeredDevice->RegisterPainter(shared_from_this(), mnLayerIndex); - if (mpLayerInvalidator) - mpLayerInvalidator->Invalidate(GetBoundingBox()); - } - } + if ( ! mbIsVisible) + { + mbIsVisible = true; + + ::boost::shared_ptr<LayeredDevice> pLayeredDevice ( + mrSlideSorter.GetView().GetLayeredDevice()); + if (pLayeredDevice) + { + pLayeredDevice->RegisterPainter(shared_from_this(), mnLayerIndex); + if (mpLayerInvalidator) + mpLayerInvalidator->Invalidate(GetBoundingBox()); + } + } } @@ -409,19 +409,19 @@ void InsertionIndicatorOverlay::Show (void) void InsertionIndicatorOverlay::Hide (void) { - if (mbIsVisible) - { - mbIsVisible = false; - - ::boost::shared_ptr<LayeredDevice> pLayeredDevice ( - mrSlideSorter.GetView().GetLayeredDevice()); - if (pLayeredDevice) - { - if (mpLayerInvalidator) - mpLayerInvalidator->Invalidate(GetBoundingBox()); - pLayeredDevice->RemovePainter(shared_from_this(), mnLayerIndex); - } - } + if (mbIsVisible) + { + mbIsVisible = false; + + ::boost::shared_ptr<LayeredDevice> pLayeredDevice ( + mrSlideSorter.GetView().GetLayeredDevice()); + if (pLayeredDevice) + { + if (mpLayerInvalidator) + mpLayerInvalidator->Invalidate(GetBoundingBox()); + pLayeredDevice->RemovePainter(shared_from_this(), mnLayerIndex); + } + } } @@ -429,7 +429,7 @@ void InsertionIndicatorOverlay::Hide (void) Rectangle InsertionIndicatorOverlay::GetBoundingBox (void) const { - return Rectangle(maLocation, maIcon.GetSizePixel()); + return Rectangle(maLocation, maIcon.GetSizePixel()); } @@ -437,12 +437,11 @@ Rectangle InsertionIndicatorOverlay::GetBoundingBox (void) const Size InsertionIndicatorOverlay::GetSize (void) const { - return Size( - maIcon.GetSizePixel().Width() + 10, - maIcon.GetSizePixel().Height() + 10); + return Size( + maIcon.GetSizePixel().Width() + 10, + maIcon.GetSizePixel().Height() + 10); } } } } // end of namespace ::sd::slidesorter::view - diff --git a/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx b/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx index acd42a2..f7b759f 100644 --- a/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx +++ b/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -42,50 +42,50 @@ class Window; namespace sd { namespace slidesorter { namespace view { /** A simple wrapper around an OutputDevice that provides support for - independent layers and buffering. - Each layer may contain any number of painters. + independent layers and buffering. + Each layer may contain any number of painters. */ class LayeredDevice - : public ::boost::enable_shared_from_this<LayeredDevice> + : public ::boost::enable_shared_from_this<LayeredDevice> { public: - LayeredDevice (const SharedSdWindow& rpTargetWindow); - ~LayeredDevice (void); + LayeredDevice (const SharedSdWindow& rpTargetWindow); + ~LayeredDevice (void); - void Invalidate ( - const Rectangle& rInvalidationBox, - const sal_Int32 nLayer); - void InvalidateAllLayers ( - const Rectangle& rInvalidationBox); - void InvalidateAllLayers ( - const Region& rInvalidationRegion); + void Invalidate ( + const Rectangle& rInvalidationBox, + const sal_Int32 nLayer); + void InvalidateAllLayers ( + const Rectangle& rInvalidationBox); + void InvalidateAllLayers ( + const Region& rInvalidationRegion); - void RegisterPainter ( - const SharedILayerPainter& rPainter, - const sal_Int32 nLayer); + void RegisterPainter ( + const SharedILayerPainter& rPainter, + const sal_Int32 nLayer); - void RemovePainter ( - const SharedILayerPainter& rPainter, - const sal_Int32 nLayer); + void RemovePainter ( + const SharedILayerPainter& rPainter, + const sal_Int32 nLayer); - bool HasPainter (const sal_Int32 nLayer); + bool HasPainter (const sal_Int32 nLayer); - bool HandleMapModeChange (void); - void Repaint (const Region& rRepaintRegion); + bool HandleMapModeChange (void); + void Repaint (const Region& rRepaintRegion); - void Resize (void); + void Resize (void); - void Dispose (void); + void Dispose (void); private: - SharedSdWindow mpTargetWindow; - class LayerContainer; - ::boost::scoped_ptr<LayerContainer> mpLayers; - ::boost::scoped_ptr<VirtualDevice> mpBackBuffer; - MapMode maSavedMapMode; + SharedSdWindow mpTargetWindow; + class LayerContainer; + ::boost::scoped_ptr<LayerContainer> mpLayers; + ::boost::scoped_ptr<VirtualDevice> mpBackBuffer; + MapMode maSavedMapMode; - void RepaintRectangle (const Rectangle& rRepaintRectangle); + void RepaintRectangle (const Rectangle& rRepaintRectangle); }; diff --git a/main/sd/source/ui/slidesorter/view/SlsResource.hxx b/main/sd/source/ui/slidesorter/view/SlsResource.hxx index ef15b9c..6721d7a 100644 --- a/main/sd/source/ui/slidesorter/view/SlsResource.hxx +++ b/main/sd/source/ui/slidesorter/view/SlsResource.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -33,8 +33,8 @@ namespace sd { namespace slidesorter { namespace view { class LocalResource : public Resource { public: - LocalResource (const sal_uInt16 nResourceId) : Resource(SdResId(nResourceId)){} - ~LocalResource (void) { FreeResource(); } + LocalResource (const sal_uInt16 nResourceId) : Resource(SdResId(nResourceId)){} + ~LocalResource (void) { FreeResource(); } }; diff --git a/main/sd/source/ui/slidesorter/view/SlsToolTip.cxx b/main/sd/source/ui/slidesorter/view/SlsToolTip.cxx index 2b946c4..6b23dd2 100644 --- a/main/sd/source/ui/slidesorter/view/SlsToolTip.cxx +++ b/main/sd/source/ui/slidesorter/view/SlsToolTip.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -37,14 +37,14 @@ using ::rtl::OUString; namespace sd { namespace slidesorter { namespace view { ToolTip::ToolTip (SlideSorter& rSlideSorter) - : mrSlideSorter(rSlideSorter), - msDefaultHelpText(), - msCurrentHelpText(), - mnHelpWindowHandle(0), - maTimer() + : mrSlideSorter(rSlideSorter), + msDefaultHelpText(), + msCurrentHelpText(), + mnHelpWindowHandle(0), + maTimer() { - maTimer.SetTimeout(rSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ToolTipDelay)); - maTimer.SetTimeoutHdl(LINK(this, ToolTip, DelayTrigger)); + maTimer.SetTimeout(rSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ToolTipDelay)); + maTimer.SetTimeoutHdl(LINK(this, ToolTip, DelayTrigger)); } @@ -52,8 +52,8 @@ ToolTip::ToolTip (SlideSorter& rSlideSorter) ToolTip::~ToolTip (void) { - maTimer.Stop(); - Hide(); + maTimer.Stop(); + Hide(); } @@ -61,39 +61,39 @@ ToolTip::~ToolTip (void) void ToolTip::SetPage (const model::SharedPageDescriptor& rpDescriptor) { - if (mpDescriptor != rpDescriptor) - { - maTimer.Stop(); - Hide(); - - mpDescriptor = rpDescriptor; - - if (mpDescriptor) - { - SdPage* pPage = mpDescriptor->GetPage(); - OUString sHelpText; - if (pPage != NULL) - sHelpText = pPage->GetName(); - else - { - OSL_ASSERT(mpDescriptor->GetPage() != NULL); - } - if (sHelpText.getLength() == 0) - { - sHelpText = String(SdResId(STR_PAGE)); - sHelpText += String::CreateFromInt32(mpDescriptor->GetPageIndex()+1); - } - - msDefaultHelpText = sHelpText; - msCurrentHelpText = sHelpText; - Show(false); - } - else - { - msDefaultHelpText = OUString(); - msCurrentHelpText = OUString(); - } - } + if (mpDescriptor != rpDescriptor) + { + maTimer.Stop(); + Hide(); + + mpDescriptor = rpDescriptor; + + if (mpDescriptor) + { + SdPage* pPage = mpDescriptor->GetPage(); + OUString sHelpText; + if (pPage != NULL) + sHelpText = pPage->GetName(); + else + { + OSL_ASSERT(mpDescriptor->GetPage() != NULL); + } + if (sHelpText.getLength() == 0) + { + sHelpText = String(SdResId(STR_PAGE)); + sHelpText += String::CreateFromInt32(mpDescriptor->GetPageIndex()+1); + } + + msDefaultHelpText = sHelpText; + msCurrentHelpText = sHelpText; + Show(false); + } + else + { + msDefaultHelpText = OUString(); + msCurrentHelpText = OUString(); + } + } } @@ -101,15 +101,15 @@ void ToolTip::SetPage (const model::SharedPageDescriptor& rpDescriptor) void ToolTip::ShowDefaultHelpText (const ::rtl::OUString& rsHelpText) { - if (msDefaultHelpText != rsHelpText) - { - const bool bIsVisible (Hide()); + if (msDefaultHelpText != rsHelpText) + { + const bool bIsVisible (Hide()); - msDefaultHelpText = rsHelpText; - msCurrentHelpText = rsHelpText; + msDefaultHelpText = rsHelpText; + msCurrentHelpText = rsHelpText; - Show(bIsVisible); - } + Show(bIsVisible); + } } @@ -117,14 +117,14 @@ void ToolTip::ShowDefaultHelpText (const ::rtl::OUString& rsHelpText) void ToolTip::ShowDefaultHelpText (void) { - if (msCurrentHelpText != msDefaultHelpText) - { - const bool bIsVisible (Hide()); + if (msCurrentHelpText != msDefaultHelpText) + { + const bool bIsVisible (Hide()); - msCurrentHelpText = msDefaultHelpText; + msCurrentHelpText = msDefaultHelpText; - Show(bIsVisible); - } + Show(bIsVisible); + } } @@ -132,14 +132,14 @@ void ToolTip::ShowDefaultHelpText (void) void ToolTip::ShowHelpText (const ::rtl::OUString& rsHelpText) { - if (msCurrentHelpText != rsHelpText) - { - const bool bIsVisible (Hide()); + if (msCurrentHelpText != rsHelpText) + { + const bool bIsVisible (Hide()); - msCurrentHelpText = rsHelpText; + msCurrentHelpText = rsHelpText; - Show(bIsVisible); - } + Show(bIsVisible); + } } @@ -147,10 +147,10 @@ void ToolTip::ShowHelpText (const ::rtl::OUString& rsHelpText) void ToolTip::Show (const bool bNoDelay) { - if (bNoDelay) - DoShow(); - else - maTimer.Start(); + if (bNoDelay) + DoShow(); + else + maTimer.Start(); } @@ -158,44 +158,44 @@ void ToolTip::Show (const bool bNoDelay) void ToolTip::DoShow (void) { - if (maTimer.IsActive()) - { - // The delay timer is active. Wait for it to trigger the showing of - // the tool tip. - return; - } - - SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); - if (msCurrentHelpText.getLength()>0 && pWindow) - { - Rectangle aBox ( - mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox( - mpDescriptor, - PageObjectLayouter::Preview, - PageObjectLayouter::WindowCoordinateSystem)); - - // Do not show the help text when the (lower edge of the ) preview - // is not visible. The tool tip itself may still be outside the - // window. - if (aBox.Bottom() >= pWindow->GetSizePixel().Height()) - return; - - ::Window* pParent (pWindow.get()); - while (pParent!=NULL && pParent->GetParent()!=NULL) - pParent = pParent->GetParent(); - const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft()); - - // We do not know how high the tool tip will be but want its top - // edge not its bottom to be at a specific position (a little below - // the preview). Therefore we use a little trick and place the tool - // tip at the top of a rectangle that is placed below the preview. - aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3); - mnHelpWindowHandle = Help::ShowTip( - pWindow.get(), - aBox, - msCurrentHelpText, - QUICKHELP_CENTER | QUICKHELP_TOP); - } + if (maTimer.IsActive()) + { + // The delay timer is active. Wait for it to trigger the showing of + // the tool tip. + return; + } + + SharedSdWindow pWindow (mrSlideSorter.GetContentWindow()); + if (msCurrentHelpText.getLength()>0 && pWindow) + { + Rectangle aBox ( + mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox( + mpDescriptor, + PageObjectLayouter::Preview, + PageObjectLayouter::WindowCoordinateSystem)); + + // Do not show the help text when the (lower edge of the ) preview + // is not visible. The tool tip itself may still be outside the + // window. + if (aBox.Bottom() >= pWindow->GetSizePixel().Height()) + return; + + ::Window* pParent (pWindow.get()); + while (pParent!=NULL && pParent->GetParent()!=NULL) + pParent = pParent->GetParent(); + const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft()); + + // We do not know how high the tool tip will be but want its top + // edge not its bottom to be at a specific position (a little below + // the preview). Therefore we use a little trick and place the tool + // tip at the top of a rectangle that is placed below the preview. + aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3); + mnHelpWindowHandle = Help::ShowTip( + pWindow.get(), + aBox, + msCurrentHelpText, + QUICKHELP_CENTER | QUICKHELP_TOP); + } } @@ -203,14 +203,14 @@ void ToolTip::DoShow (void) bool ToolTip::Hide (void) { - if (mnHelpWindowHandle>0) - { - Help::HideTip(mnHelpWindowHandle); - mnHelpWindowHandle = 0; - return true; - } - else - return false; + if (mnHelpWindowHandle>0) + { + Help::HideTip(mnHelpWindowHandle); + mnHelpWindowHandle = 0; + return true; + } + else + return false; } @@ -218,9 +218,9 @@ bool ToolTip::Hide (void) IMPL_LINK(ToolTip, DelayTrigger, void*, EMPTYARG) { - DoShow(); - - return 0; + DoShow(); + + return 0; } } } } // end of namespace ::sd::slidesorter::view diff --git a/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx b/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx index fb49545..1e9ab5b 100644 --- a/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx +++ b/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -43,8 +43,8 @@ namespace sd { namespace slidesorter { namespace view { ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter) - : mrModel(rSlideSorter.GetModel()), - mrSlideSorter(rSlideSorter) + : mrModel(rSlideSorter.GetModel()), + mrSlideSorter(rSlideSorter) { } @@ -59,21 +59,21 @@ ViewCacheContext::~ViewCacheContext (void) void ViewCacheContext::NotifyPreviewCreation ( - cache::CacheKey aKey, - const Bitmap&) + cache::CacheKey aKey, + const Bitmap&) { - const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); - if (pDescriptor.get() != NULL) - { - // Force a repaint that will trigger their re-creation. - mrSlideSorter.GetView().RequestRepaint(pDescriptor); - } - else - { - // It is OK when a preview was created for a page that is not - // currently displayed because both normal and master pages are - // kept in the same cache. - } + const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); + if (pDescriptor.get() != NULL) + { + // Force a repaint that will trigger their re-creation. + mrSlideSorter.GetView().RequestRepaint(pDescriptor); + } + else + { + // It is OK when a preview was created for a page that is not + // currently displayed because both normal and master pages are + // kept in the same cache. + } } @@ -81,11 +81,11 @@ void ViewCacheContext::NotifyPreviewCreation ( bool ViewCacheContext::IsIdle (void) { - sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get())); - if (nIdleState == tools::IdleDetection::IDET_IDLE) - return true; - else - return false; + sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get())); + if (nIdleState == tools::IdleDetection::IDET_IDLE) + return true; + else + return false; } @@ -93,8 +93,8 @@ bool ViewCacheContext::IsIdle (void) bool ViewCacheContext::IsVisible (cache::CacheKey aKey) { - const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); - return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible); + const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey)); + return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible); } @@ -102,7 +102,7 @@ bool ViewCacheContext::IsVisible (cache::CacheKey aKey) const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey) { - return static_cast<const SdrPage*>(aKey); + return static_cast<const SdrPage*>(aKey); } @@ -110,20 +110,20 @@ const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey) ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible) { - ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>()); + ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>()); - model::PageEnumeration aPageEnumeration ( - bVisible - ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel) - : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); + model::PageEnumeration aPageEnumeration ( + bVisible + ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel) + : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel)); - while (aPageEnumeration.HasMoreElements()) - { - model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); - pKeys->push_back(pDescriptor->GetPage()); - } + while (aPageEnumeration.HasMoreElements()) + { + model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement()); + pKeys->push_back(pDescriptor->GetPage()); + } - return pKeys; + return pKeys; } @@ -131,7 +131,7 @@ const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey) sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey) { - return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2; + return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2; } @@ -139,8 +139,8 @@ sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey) model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey) { - sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2); - return mrModel.GetPageDescriptor(nPageIndex); + sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2); + return mrModel.GetPageDescriptor(nPageIndex); } @@ -148,10 +148,10 @@ model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKe ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void) { - if (mrModel.GetDocument() == NULL) - return NULL; - else - return mrModel.GetDocument()->getUnoModel(); + if (mrModel.GetDocument() == NULL) + return NULL; + else + return mrModel.GetDocument()->getUnoModel(); } } } } // end of namespace ::sd::slidesorter::view diff --git a/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx b/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx index 377e3f6..21430c4 100644 --- a/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx +++ b/main/sd/source/ui/slidesorter/view/SlsViewCacheContext.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -37,27 +37,27 @@ class SlideSorter; namespace sd { namespace slidesorter { namespace view { -/** The cache context for the SlideSorter as used by Draw and Impress. See - the base class for documentation of the individual methods. +/** The cache context for the SlideSorter as used by Draw and Impress. See + the base class for documentation of the individual methods. */ class ViewCacheContext : public cache::CacheContext { public: - ViewCacheContext (SlideSorter& rSlideSorter); - virtual ~ViewCacheContext (void); - virtual void NotifyPreviewCreation (cache::CacheKey aKey, const Bitmap& rPreview); - virtual bool IsIdle (void); - virtual bool IsVisible (cache::CacheKey aKey); - virtual const SdrPage* GetPage (cache::CacheKey aKey); - virtual ::boost::shared_ptr<std::vector<cache::CacheKey> > GetEntryList (bool bVisible); - virtual sal_Int32 GetPriority (cache::CacheKey aKey); - virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void); - + ViewCacheContext (SlideSorter& rSlideSorter); + virtual ~ViewCacheContext (void); + virtual void NotifyPreviewCreation (cache::CacheKey aKey, const Bitmap& rPreview); + virtual bool IsIdle (void); + virtual bool IsVisible (cache::CacheKey aKey); + virtual const SdrPage* GetPage (cache::CacheKey aKey); + virtual ::boost::shared_ptr<std::vector<cache::CacheKey> > GetEntryList (bool bVisible); + virtual sal_Int32 GetPriority (cache::CacheKey aKey); + virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void); + private: - model::SlideSorterModel& mrModel; - SlideSorter& mrSlideSorter; + model::SlideSorterModel& mrModel; + SlideSorter& mrSlideSorter; - model::SharedPageDescriptor GetDescriptor (cache::CacheKey aKey); + model::SharedPageDescriptor GetDescriptor (cache::CacheKey aKey); };