Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "view/SlsButtonBar.hxx"
31 : :
32 : : #include "SlideSorter.hxx"
33 : : #include "SlsResource.hxx"
34 : : #include "model/SlsPageDescriptor.hxx"
35 : : #include "model/SlideSorterModel.hxx"
36 : : #include "view/SlsTheme.hxx"
37 : : #include "view/SlideSorterView.hxx"
38 : : #include "view/SlsToolTip.hxx"
39 : : #include "controller/SlideSorterController.hxx"
40 : : #include "controller/SlsSlotManager.hxx"
41 : : #include "controller/SlsCurrentSlideManager.hxx"
42 : : #include "controller/SlsPageSelector.hxx"
43 : : #include "controller/SlsAnimator.hxx"
44 : : #include "controller/SlsAnimationFunction.hxx"
45 : : #include "app.hrc"
46 : : #include "strings.hrc"
47 : : #include "drawdoc.hxx"
48 : : #include "sdmod.hxx"
49 : : #include "optsitem.hxx"
50 : : #include <svx/svxids.hrc>
51 : : #include <sfx2/dispatch.hxx>
52 : : #include <vcl/bmpacc.hxx>
53 : : #include <vcl/virdev.hxx>
54 : : #include <basegfx/polygon/b2dpolygontools.hxx>
55 : : #include <basegfx/polygon/b2dpolygon.hxx>
56 : : #include <com/sun/star/presentation/XPresentation2.hpp>
57 : : #include <boost/bind.hpp>
58 : :
59 : : using ::com::sun::star::uno::Any;
60 : : using ::com::sun::star::uno::Reference;
61 : : using ::com::sun::star::uno::Sequence;
62 : : using ::com::sun::star::beans::PropertyValue;
63 : : using ::com::sun::star::presentation::XPresentation2;
64 : :
65 : : namespace sd { namespace slidesorter { namespace view {
66 : :
67 : : /** Base class for the painter of the background bar onto which the buttons
68 : : are painted. It also provides some size information.
69 : : */
70 : : class ButtonBar::BackgroundTheme
71 : : {
72 : : public:
73 : : BackgroundTheme(
74 : : const ::boost::shared_ptr<Theme>& rpTheme,
75 : : const ::std::vector<SharedButton>& rButtons);
76 [ - + ]: 260 : virtual ~BackgroundTheme() { }
77 : : /** Set the preview bounding box, the maximal area in which to display
78 : : buttons. A call to this method triggers a call to Layout().
79 : : */
80 : : void SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox);
81 : : Button::IconSize GetIconSize (void) const;
82 : :
83 : : virtual BitmapEx CreateBackground () const;
84 : : virtual Point GetBackgroundLocation (void);
85 : : virtual Rectangle GetButtonArea (void);
86 : :
87 : : protected:
88 : : ::boost::shared_ptr<Theme> mpTheme;
89 : : Rectangle maPreviewBoundingBox;
90 : : Size maMinimumLargeButtonAreaSize;
91 : : Size maMinimumMediumButtonAreaSize;
92 : : Size maMinimumSmallButtonAreaSize;
93 : : Button::IconSize meIconSize;
94 : : Rectangle maButtonArea;
95 : : Point maBackgroundLocation;
96 : :
97 : : virtual void Layout (void);
98 : :
99 : : private:
100 : : /// Compute the size of the are for the given button size.
101 : : static Size MinimumSize( Button::IconSize eSize, const ::std::vector<SharedButton>& rButtons );
102 : : void UpdateMinimumIconSizes(const ::std::vector<SharedButton>& rButtons);
103 : : };
104 : :
105 : :
106 : : namespace {
107 : : /** The source mask is essentially multiplied with the given alpha value.
108 : : The result is writen to the result mask.
109 : : */
110 : 0 : void AdaptTransparency (AlphaMask& rMask, const AlphaMask& rSourceMask, const double nAlpha)
111 : : {
112 : 0 : BitmapWriteAccess* pBitmap = rMask.AcquireWriteAccess();
113 : 0 : const BitmapReadAccess* pSourceBitmap = const_cast<AlphaMask&>(rSourceMask).AcquireReadAccess();
114 : :
115 [ # # ][ # # ]: 0 : if (pBitmap!=NULL && pSourceBitmap!=NULL)
116 : : {
117 : 0 : const sal_Int32 nWidth (pBitmap->Width());
118 : 0 : const sal_Int32 nHeight (pBitmap->Height());
119 : :
120 [ # # ]: 0 : for (sal_Int32 nY = 0; nY<nHeight; ++nY)
121 [ # # ]: 0 : for (sal_Int32 nX = 0; nX<nWidth; ++nX)
122 : : {
123 : 0 : const sal_uInt8 nValue (255 - pSourceBitmap->GetPixel(nY, nX).GetBlueOrIndex());
124 : 0 : const sal_uInt8 nNewValue (static_cast<sal_uInt8>(nValue * (1-nAlpha)));
125 [ # # ]: 0 : pBitmap->SetPixel(nY, nX, 255-nNewValue);
126 : : }
127 : : }
128 : 0 : }
129 : :
130 : : } // end of anonymous namespace
131 : :
132 : :
133 : : //===== ButtonBar::Lock =======================================================
134 : :
135 : 0 : ButtonBar::Lock::Lock (SlideSorter& rSlideSorter)
136 : 0 : : mrButtonBar(rSlideSorter.GetView().GetButtonBar())
137 : : {
138 : 0 : mrButtonBar.AcquireLock();
139 : 0 : }
140 : :
141 : :
142 : :
143 : :
144 : 0 : ButtonBar::Lock::~Lock (void)
145 : : {
146 : 0 : mrButtonBar.ReleaseLock();
147 : 0 : }
148 : :
149 : :
150 : :
151 : :
152 : : //===== ButtonBar =============================================================
153 : :
154 : 130 : ButtonBar::ButtonBar (SlideSorter& rSlideSorter)
155 : : : mrSlideSorter(rSlideSorter),
156 : : maPageObjectSize(0,0),
157 : : maButtonBoundingBox(),
158 : : maBackgroundLocation(),
159 : : mpDescriptor(),
160 : : mbIsExcluded(false),
161 : : mpButtonUnderMouse(),
162 : : mpDownButton(),
163 : : maRegularButtons(),
164 : : maExcludedButtons(),
165 : : maNormalBackground(),
166 : : mbIsMouseOverBar(false),
167 : : mpBackgroundTheme(),
168 [ + - ][ + - ]: 130 : mnLockCount(0)
[ + - ][ + - ]
[ + - ]
169 : : {
170 [ + - ]: 130 : HandleDataChangeEvent();
171 : 130 : }
172 : :
173 : :
174 : :
175 : :
176 [ + - ][ + - ]: 130 : ButtonBar::~ButtonBar (void)
[ + - ][ + - ]
177 : : {
178 : 130 : }
179 : :
180 : :
181 : :
182 : :
183 : 0 : void ButtonBar::ProcessButtonDownEvent (
184 : : const model::SharedPageDescriptor& rpDescriptor,
185 : : const Point aMouseModelLocation)
186 : : {
187 [ # # ]: 0 : SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
188 [ # # ]: 0 : if (mpButtonUnderMouse)
189 : 0 : mpButtonUnderMouse->SetState(Button::State_Down);
190 : 0 : mpDownButton = mpButtonUnderMouse;
191 : :
192 : 0 : mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
193 : 0 : }
194 : :
195 : :
196 : :
197 : :
198 : 0 : void ButtonBar::ProcessButtonUpEvent (
199 : : const model::SharedPageDescriptor& rpDescriptor,
200 : : const Point aMouseModelLocation)
201 : : {
202 [ # # ]: 0 : SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
203 [ # # ]: 0 : if (mpButtonUnderMouse)
204 : : {
205 : 0 : mpButtonUnderMouse->SetState(Button::State_Hover);
206 [ # # ]: 0 : if (mpButtonUnderMouse == mpDownButton)
207 : : {
208 : : // This is done only when the buttons are sufficiently visible.
209 [ # # ]: 0 : if (mpDescriptor->GetVisualState().GetButtonAlpha()<0.7)
210 : : {
211 : 0 : mpButtonUnderMouse->ProcessClick(mpDescriptor);
212 : 0 : mbIsExcluded = mpDescriptor->HasState(model::PageDescriptor::ST_Excluded);
213 : 0 : ProcessMouseMotionEvent (rpDescriptor, aMouseModelLocation, false);
214 : : }
215 : : }
216 : : }
217 : 0 : mpDownButton.reset();
218 : 0 : mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
219 : 0 : }
220 : :
221 : :
222 : :
223 : :
224 : 0 : void ButtonBar::ProcessMouseMotionEvent (
225 : : const model::SharedPageDescriptor& rpDescriptor,
226 : : const Point aMouseModelLocation,
227 : : const bool bIsMouseButtonDown)
228 : : {
229 [ # # ]: 0 : model::SharedPageDescriptor pOldDescriptor (mpDescriptor);
230 : 0 : bool bPageHasChanged (false);
231 : 0 : bool bButtonHasChanged (false);
232 : 0 : bool bButtonStateHasChanged (false);
233 : :
234 : : // Update the page object for which to manage the buttons.
235 [ # # ]: 0 : bPageHasChanged = SetPage(rpDescriptor);
236 [ # # ]: 0 : mbIsMouseOverBar = IsMouseOverBar(aMouseModelLocation);
237 : :
238 : : // Update button under mouse.
239 [ # # ]: 0 : if (rpDescriptor)
240 : : {
241 [ # # ][ # # ]: 0 : bButtonHasChanged = SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
[ # # ]
242 : :
243 [ # # ]: 0 : if (mpButtonUnderMouse)
244 : : {
245 : : // When the mouse button is down, mark the button under the
246 : : // mouse only as pressed when it is the same button the mouse
247 : : // button was pressed over, and where the button release would
248 : : // lead to a click action.
249 [ # # ]: 0 : if (bIsMouseButtonDown)
250 : : {
251 [ # # ][ # # ]: 0 : if (mpButtonUnderMouse==mpDownButton)
252 : 0 : bButtonStateHasChanged = mpButtonUnderMouse->SetState(Button::State_Down);
253 : : }
254 : : else
255 : 0 : bButtonStateHasChanged = mpButtonUnderMouse->SetState(Button::State_Hover);
256 : : }
257 : : }
258 : :
259 : : // Show a quick help text when the mouse is over a button.
260 [ # # ]: 0 : if (bButtonHasChanged)
261 : : {
262 [ # # ]: 0 : SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
263 [ # # ]: 0 : if (pWindow)
264 : : {
265 [ # # ]: 0 : if (mpButtonUnderMouse)
266 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().GetToolTip().ShowHelpText(mpButtonUnderMouse->GetHelpText());
[ # # ]
267 : : else
268 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().GetToolTip().ShowDefaultHelpText();
[ # # ]
269 [ # # ]: 0 : }
270 : : }
271 : :
272 [ # # ][ # # ]: 0 : if (bPageHasChanged || bButtonHasChanged || bButtonStateHasChanged)
[ # # ]
273 : : {
274 [ # # ]: 0 : if (pOldDescriptor)
275 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().RequestRepaint(pOldDescriptor);
276 [ # # ][ # # ]: 0 : if (mpDescriptor && pOldDescriptor!=mpDescriptor)
[ # # ][ # # ]
277 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().RequestRepaint(mpDescriptor);
278 [ # # ]: 0 : }
279 : 0 : }
280 : :
281 : :
282 : :
283 : :
284 : 0 : void ButtonBar::ResetPage (void)
285 : : {
286 [ # # ]: 0 : SetPage(model::SharedPageDescriptor());
287 : 0 : }
288 : :
289 : :
290 : :
291 : :
292 : 0 : bool ButtonBar::SetPage (const model::SharedPageDescriptor& rpDescriptor)
293 : : {
294 [ # # ]: 0 : if (mpDescriptor != rpDescriptor)
295 : : {
296 : 0 : mpDescriptor = rpDescriptor;
297 : :
298 [ # # ]: 0 : if (mpDescriptor)
299 : 0 : mbIsExcluded = mpDescriptor->HasState(model::PageDescriptor::ST_Excluded);
300 : : else
301 : 0 : mbIsExcluded = false;
302 [ # # ]: 0 : SetButtonUnderMouse();
303 : 0 : mpDownButton.reset();
304 : :
305 : 0 : return true;
306 : : }
307 : : else
308 : 0 : return false;
309 : : }
310 : :
311 : :
312 : :
313 : :
314 : 0 : SharedButton ButtonBar::GetButtonAt (const Point aModelLocation)
315 : : {
316 [ # # ]: 0 : if (IsMouseOverBar(aModelLocation))
317 : : {
318 [ # # ]: 0 : const Point aLocalLocation (aModelLocation - mpDescriptor->GetBoundingBox().TopLeft());
319 : : ::std::vector<SharedButton>& rButtons (
320 [ # # ]: 0 : mbIsExcluded ? maExcludedButtons : maRegularButtons);
321 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<rButtons.size(); ++nIndex)
322 : : {
323 [ # # ][ # # ]: 0 : if (rButtons[sal_uInt32(nIndex)]->GetBoundingBox().IsInside(aLocalLocation))
[ # # ]
324 : : {
325 [ # # ][ # # ]: 0 : if (rButtons[sal_uInt32(nIndex)]->IsEnabled())
326 [ # # ]: 0 : return rButtons[sal_uInt32(nIndex)];
327 : : else
328 [ # # ]: 0 : return SharedButton();
329 : : }
330 : : }
331 : : }
332 : :
333 : 0 : return SharedButton();
334 : : }
335 : :
336 : :
337 : :
338 : :
339 : 0 : bool ButtonBar::IsMouseOverBar (void) const
340 : : {
341 : 0 : return mbIsMouseOverBar;
342 : : }
343 : :
344 : :
345 : :
346 : :
347 : 0 : bool ButtonBar::SetButtonUnderMouse (const SharedButton& rButton)
348 : : {
349 [ # # ]: 0 : if (mpButtonUnderMouse != rButton)
350 : : {
351 [ # # ]: 0 : if (mpButtonUnderMouse)
352 : 0 : mpButtonUnderMouse->SetState(Button::State_Normal);
353 : :
354 : 0 : mpButtonUnderMouse = rButton;
355 : :
356 : 0 : return true;
357 : : }
358 : : else
359 : 0 : return false;
360 : : }
361 : :
362 : :
363 : :
364 : :
365 : 677 : void ButtonBar::Paint (
366 : : OutputDevice& rDevice,
367 : : const model::SharedPageDescriptor& rpDescriptor)
368 : : {
369 [ + - ]: 677 : if ( ! rpDescriptor)
370 : : return;
371 : :
372 [ + - ][ + - ]: 677 : const double nButtonBarAlpha (rpDescriptor->GetVisualState().GetButtonBarAlpha());
373 [ - + ]: 677 : if (nButtonBarAlpha >= 1)
374 : : return;
375 : :
376 [ # # ][ # # ]: 0 : LayoutButtons(rpDescriptor->GetBoundingBox().GetSize());
[ # # ]
377 : :
378 [ # # ]: 0 : const Point aOffset (rpDescriptor->GetBoundingBox().TopLeft());
379 : :
380 : : // Paint the background.
381 [ # # ]: 0 : PaintButtonBackground(rDevice, rpDescriptor, aOffset);
382 : :
383 : : // Paint the buttons.
384 : : const ::std::vector<SharedButton>& rButtons (
385 [ # # ]: 0 : rpDescriptor->HasState(model::PageDescriptor::ST_Excluded)
386 : : ? maExcludedButtons
387 [ # # ]: 0 : : maRegularButtons);
388 : :
389 : :
390 [ # # ][ # # ]: 0 : const double nButtonAlpha (rpDescriptor->GetVisualState().GetButtonAlpha());
391 [ # # ]: 677 : for (sal_uInt32 nIndex=0; nIndex<rButtons.size(); ++nIndex)
392 : 0 : rButtons[nIndex]->Paint(
393 : : rDevice,
394 : : aOffset,
395 : : nButtonAlpha,
396 [ # # ][ # # ]: 0 : mrSlideSorter.GetTheme());
[ # # ]
397 : : }
398 : :
399 : :
400 : :
401 : :
402 : 0 : bool ButtonBar::IsMouseOverButton (void) const
403 : : {
404 : 0 : return mpButtonUnderMouse;
405 : : }
406 : :
407 : :
408 : :
409 : :
410 : 0 : void ButtonBar::PaintButtonBackground (
411 : : OutputDevice& rDevice,
412 : : const model::SharedPageDescriptor& rpDescriptor,
413 : : const Point aOffset)
414 : : {
415 [ # # ]: 0 : if (maNormalBackground.IsEmpty())
416 : : {
417 [ # # ]: 0 : if (mpBackgroundTheme)
418 [ # # ]: 0 : maNormalBackground = mpBackgroundTheme->CreateBackground();
419 : : }
420 [ # # ]: 0 : if (!maNormalBackground.IsEmpty())
421 : : {
422 [ # # ]: 0 : AlphaMask aMask (maNormalBackground.GetSizePixel());
423 : : AdaptTransparency(
424 : : aMask,
425 : : maNormalBackground.GetAlpha(),
426 [ # # ][ # # ]: 0 : rpDescriptor->GetVisualState().GetButtonBarAlpha());
[ # # ][ # # ]
[ # # ]
427 [ # # ][ # # ]: 0 : rDevice.DrawBitmapEx(maBackgroundLocation+aOffset, BitmapEx(maNormalBackground.GetBitmap(), aMask));
[ # # ][ # # ]
[ # # ][ # # ]
428 : : }
429 : 0 : }
430 : :
431 : :
432 : :
433 : :
434 : 0 : bool ButtonBar::IsMouseOverBar (const Point aModelLocation) const
435 : : {
436 [ # # ][ # # ]: 0 : if ( ! mpDescriptor || ! mpDescriptor->GetBoundingBox().IsInside(aModelLocation))
[ # # ][ # # ]
[ # # ]
[ # # # # ]
437 : 0 : return false;
438 : :
439 [ # # ][ # # ]: 0 : if ( ! maButtonBoundingBox.IsInside(aModelLocation - mpDescriptor->GetBoundingBox().TopLeft()))
440 : 0 : return false;
441 : :
442 : 0 : return true;
443 : : }
444 : :
445 : :
446 : :
447 : :
448 : 0 : void ButtonBar::LayoutButtons (const Size aPageObjectSize)
449 : : {
450 [ # # ]: 0 : if (maPageObjectSize != aPageObjectSize)
451 : : {
452 : 0 : maPageObjectSize = aPageObjectSize;
453 : :
454 [ # # ]: 0 : if (mpBackgroundTheme)
455 : : {
456 : : mpBackgroundTheme->SetPreviewBoundingBox(
457 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
458 : : Point(0,0),
459 : : PageObjectLayouter::Preview,
460 [ # # ][ # # ]: 0 : PageObjectLayouter::ModelCoordinateSystem));
[ # # ][ # # ]
461 : 0 : LayoutButtons();
462 : : }
463 : :
464 : : // Release the background bitmaps so that on the next paint
465 : : // they are created anew in the right size.
466 : 0 : maNormalBackground.SetEmpty();
467 : : }
468 : 0 : }
469 : :
470 : :
471 : :
472 : :
473 : 0 : bool ButtonBar::LayoutButtons (void)
474 : : {
475 : 0 : const sal_Int32 nGap = Theme_ButtonGap;
476 : 0 : const sal_Int32 nBorder = Theme_ButtonBorder;
477 : :
478 : 0 : const Button::IconSize eIconSize (mpBackgroundTheme->GetIconSize());
479 : :
480 : : // Tell buttons which size they are.
481 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
482 : 0 : maExcludedButtons[nIndex]->SetIconSize(eIconSize);
483 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
484 : 0 : maRegularButtons[nIndex]->SetIconSize(eIconSize);
485 : :
486 : : // Determine maximal height and total width of the buttons.
487 : : // Start with the buttons used for the excluded state.
488 : 0 : sal_Int32 nMaximumHeight (0);
489 : 0 : sal_Int32 nExcludedTotalWidth ((maExcludedButtons.size()-1) * nGap + 2*nBorder);
490 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
491 : : {
492 [ # # ]: 0 : const Size aSize (maExcludedButtons[nIndex]->GetSize());
493 [ # # ]: 0 : if (aSize.Height() > nMaximumHeight)
494 : 0 : nMaximumHeight = aSize.Height();
495 : 0 : nExcludedTotalWidth += aSize.Width();
496 : : }
497 : :
498 : : // Do the same for the regular buttons.
499 : 0 : sal_Int32 nRegularTotalWidth ((maRegularButtons.size()-1) * nGap + 2*nBorder);
500 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
501 : : {
502 [ # # ]: 0 : const Size aSize (maRegularButtons[nIndex]->GetSize());
503 [ # # ]: 0 : if (aSize.Height() > nMaximumHeight)
504 : 0 : nMaximumHeight = aSize.Height();
505 : 0 : nRegularTotalWidth += aSize.Width();
506 : : }
507 : 0 : nMaximumHeight += 2*nBorder;
508 : :
509 : : // Set up the bounding box of the button bar.
510 [ # # ]: 0 : maButtonBoundingBox = mpBackgroundTheme->GetButtonArea();
511 [ # # ]: 0 : maBackgroundLocation = mpBackgroundTheme->GetBackgroundLocation();
512 : : if (Theme_ButtonPaintType == 1)
513 : : {
514 : : // Center the buttons.
515 [ # # ]: 0 : maButtonBoundingBox.Left() += (maButtonBoundingBox.GetWidth() - nRegularTotalWidth)/2;
516 : 0 : maButtonBoundingBox.Right() = maButtonBoundingBox.Left() + nRegularTotalWidth - 1;
517 : : }
518 : :
519 : : // Place the buttons.
520 : 0 : Rectangle aBox (maButtonBoundingBox);
521 : 0 : aBox.Right() -= nBorder;
522 [ # # ]: 0 : for (sal_Int32 nIndex=maRegularButtons.size()-1; nIndex>=0; --nIndex)
523 : : {
524 [ # # ]: 0 : maRegularButtons[nIndex]->Place(aBox);
525 [ # # ]: 0 : aBox.Right() = maRegularButtons[nIndex]->GetBoundingBox().Left() - nGap;
526 : : }
527 : :
528 : : // For slides excluded from the show there is only one icon placed
529 : : // exactly like the second of the regular icons.
530 [ # # ][ # # ]: 0 : if (maRegularButtons.size()>=2 && maExcludedButtons.size()>=1)
[ # # ]
531 : : {
532 [ # # ]: 0 : aBox = maRegularButtons[1]->GetBoundingBox();
533 [ # # ]: 0 : maExcludedButtons[0]->Place(aBox);
534 : : }
535 : :
536 : : // We return true only when there is no inactive button.
537 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
538 [ # # ]: 0 : if ( ! maExcludedButtons[nIndex]->IsActive())
539 : 0 : return false;
540 [ # # ]: 0 : for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
541 [ # # ]: 0 : if ( ! maRegularButtons[nIndex]->IsActive())
542 : 0 : return false;
543 : :
544 : 0 : return true;
545 : : }
546 : :
547 : :
548 : :
549 : :
550 : 0 : void ButtonBar::RequestFadeIn (
551 : : const model::SharedPageDescriptor& rpDescriptor,
552 : : const bool bAnimate)
553 : : {
554 [ # # ]: 0 : if ( ! rpDescriptor)
555 : 0 : return;
556 [ # # ]: 0 : if (mnLockCount > 0)
557 : 0 : return;
558 : :
559 : 0 : const double nMinAlpha (0);
560 [ # # ]: 0 : if ( ! bAnimate)
561 : : {
562 : 0 : rpDescriptor->GetVisualState().SetButtonAlpha(nMinAlpha);
563 : 0 : rpDescriptor->GetVisualState().SetButtonBarAlpha(nMinAlpha);
564 : : }
565 : : else
566 : 0 : StartFadeAnimation(rpDescriptor, nMinAlpha, true);
567 : : }
568 : :
569 : :
570 : :
571 : :
572 : 0 : void ButtonBar::RequestFadeOut (
573 : : const model::SharedPageDescriptor& rpDescriptor,
574 : : const bool bAnimate)
575 : : {
576 [ # # ]: 0 : if ( ! rpDescriptor)
577 : 0 : return;
578 [ # # ]: 0 : if (mnLockCount > 0)
579 : 0 : return;
580 : :
581 : 0 : const double nMaxAlpha (1);
582 [ # # ]: 0 : if ( ! bAnimate)
583 : : {
584 : 0 : rpDescriptor->GetVisualState().SetButtonAlpha(nMaxAlpha);
585 : 0 : rpDescriptor->GetVisualState().SetButtonBarAlpha(nMaxAlpha);
586 : : }
587 : : else
588 : 0 : StartFadeAnimation(rpDescriptor, nMaxAlpha, false);
589 : : }
590 : :
591 : :
592 : :
593 : :
594 : 0 : bool ButtonBar::IsVisible (const model::SharedPageDescriptor& rpDescriptor)
595 : : {
596 : 0 : const double nMaxAlpha (1);
597 [ # # ][ # # ]: 0 : return rpDescriptor && rpDescriptor->GetVisualState().GetButtonBarAlpha() < nMaxAlpha;
598 : : }
599 : :
600 : :
601 : :
602 : :
603 : 130 : void ButtonBar::HandleDataChangeEvent (void)
604 : : {
605 : 130 : maExcludedButtons.clear();
606 [ + - ][ + - ]: 130 : maExcludedButtons.push_back(::boost::shared_ptr<Button>(new UnhideButton(mrSlideSorter)));
607 : :
608 : 130 : maRegularButtons.clear();
609 [ + - ][ + - ]: 130 : maRegularButtons.push_back(::boost::shared_ptr<Button>(new StartShowButton(mrSlideSorter)));
610 [ + - ][ + - ]: 130 : maRegularButtons.push_back(::boost::shared_ptr<Button>(new HideButton(mrSlideSorter)));
611 [ + - ][ + - ]: 130 : maRegularButtons.push_back(::boost::shared_ptr<Button>(new DuplicateButton(mrSlideSorter)));
612 : :
613 : : mpBackgroundTheme.reset(
614 : : new BackgroundTheme(
615 : : mrSlideSorter.GetTheme(),
616 [ + - ][ + - ]: 130 : maRegularButtons));
[ + - ]
617 : :
618 : : // Force layout on next Paint().
619 : 130 : maPageObjectSize = Size(0,0);
620 : 130 : }
621 : :
622 : :
623 : :
624 : :
625 : 0 : void ButtonBar::StartFadeAnimation (
626 : : const model::SharedPageDescriptor& rpDescriptor,
627 : : const double nTargetAlpha,
628 : : const bool bFadeIn)
629 : : {
630 [ # # ]: 0 : model::SharedPageDescriptor pDescriptor (rpDescriptor);
631 : :
632 [ # # ][ # # ]: 0 : const double nCurrentButtonAlpha (pDescriptor->GetVisualState().GetButtonAlpha());
633 [ # # ][ # # ]: 0 : const double nCurrentButtonBarAlpha (pDescriptor->GetVisualState().GetButtonBarAlpha());
634 : :
635 : : // Stop a running animation.
636 : : const controller::Animator::AnimationId nId (
637 [ # # ][ # # ]: 0 : pDescriptor->GetVisualState().GetButtonAlphaAnimationId());
638 [ # # ]: 0 : if (nId != controller::Animator::NotAnAnimationId)
639 [ # # ][ # # ]: 0 : mrSlideSorter.GetController().GetAnimator()->RemoveAnimation(nId);
[ # # ][ # # ]
640 : :
641 : : // Prepare the blending functors that translate [0,1] animation
642 : : // times into alpha values of buttons and button bar.
643 : : const ::boost::function<double(double)> aButtonBlendFunctor (
644 : : ::boost::bind(
645 : : controller::AnimationFunction::Blend,
646 : : nCurrentButtonAlpha,
647 : : nTargetAlpha,
648 [ # # ][ # # ]: 0 : ::boost::bind(controller::AnimationFunction::Linear, _1)));
[ # # ]
649 : : const ::boost::function<double(double)> aButtonBarBlendFunctor (
650 : : ::boost::bind(
651 : : controller::AnimationFunction::Blend,
652 : : nCurrentButtonBarAlpha,
653 : : nTargetAlpha,
654 [ # # ][ # # ]: 0 : ::boost::bind(controller::AnimationFunction::Linear, _1)));
[ # # ]
655 : :
656 : : // Delay the fade in a little bit when the buttons are not visible at
657 : : // all so that we do not leave a trail of half-visible buttons when the
658 : : // mouse is moved across the screen. No delay on fade out or when the
659 : : // buttons are already showing. Fade out is faster than fade in.
660 : : const double nDelay (nCurrentButtonBarAlpha>0 && nCurrentButtonBarAlpha<1
661 : : ? 0
662 [ # # ][ # # ]: 0 : : (bFadeIn ? Theme_ButtonFadeInDelay : Theme_ButtonFadeOutDelay));
[ # # ]
663 [ # # ]: 0 : const double nDuration (bFadeIn ? Theme_ButtonFadeInDuration : Theme_ButtonFadeOutDuration);
664 [ # # ]: 0 : pDescriptor->GetVisualState().SetButtonAlphaAnimationId(
665 [ # # ]: 0 : mrSlideSorter.GetController().GetAnimator()->AddAnimation(
666 : : ::boost::bind(
667 : : controller::AnimationFunction::ApplyButtonAlphaChange,
668 : : pDescriptor,
669 [ # # ]: 0 : ::boost::ref(mrSlideSorter.GetView()),
670 : : ::boost::bind(aButtonBlendFunctor, _1),
671 : : ::boost::bind(aButtonBarBlendFunctor, _1)),
672 : : static_cast<sal_Int32>(nDelay),
673 : : static_cast<sal_Int32>(nDuration),
674 : : ::boost::bind(
675 : : &model::VisualState::SetButtonAlphaAnimationId,
676 [ # # ]: 0 : ::boost::ref(pDescriptor->GetVisualState()),
677 : : controller::Animator::NotAnAnimationId)
678 [ # # ][ # # ]: 0 : ));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
679 : 0 : }
680 : :
681 : :
682 : :
683 : :
684 : 0 : void ButtonBar::AcquireLock (void)
685 : : {
686 [ # # ][ # # ]: 0 : if (mnLockCount == 0 && mpDescriptor)
[ # # ]
687 : 0 : RequestFadeOut(mpDescriptor, true);
688 : :
689 : 0 : ++mnLockCount;
690 : 0 : }
691 : :
692 : :
693 : :
694 : :
695 : 0 : void ButtonBar::ReleaseLock (void)
696 : : {
697 : 0 : --mnLockCount;
698 : :
699 [ # # ][ # # ]: 0 : if (mnLockCount == 0 && mpDescriptor)
[ # # ]
700 : 0 : RequestFadeIn(mpDescriptor, true);
701 : 0 : }
702 : :
703 : :
704 : :
705 : :
706 : : //===== BackgroundTheme =====================================================
707 : :
708 : 130 : ButtonBar::BackgroundTheme::BackgroundTheme (
709 : : const ::boost::shared_ptr<Theme>& rpTheme,
710 : : const ::std::vector<SharedButton>& rButtons)
711 : : : mpTheme(rpTheme),
712 : : meIconSize( Button::IconSize_Large ),
713 : : maButtonArea(),
714 [ + - ][ + - ]: 130 : maBackgroundLocation()
715 : : {
716 [ + - ]: 130 : UpdateMinimumIconSizes(rButtons);
717 : 130 : }
718 : :
719 : :
720 : :
721 : :
722 : 0 : void ButtonBar::BackgroundTheme::SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox)
723 : : {
724 : 0 : maPreviewBoundingBox = rPreviewBoundingBox;
725 : 0 : Layout();
726 : 0 : }
727 : :
728 : :
729 : 390 : Size ButtonBar::BackgroundTheme::MinimumSize( Button::IconSize eSize,
730 : : const ::std::vector<SharedButton>& rButtons )
731 : : {
732 : 390 : int nMaximumHeight = 0;
733 : 390 : const int nGap = Theme_ButtonGap;
734 : 390 : const int nBorder = Theme_ButtonBorder;
735 : :
736 : 390 : int nTotalWidth = (rButtons.size()-1) * nGap + 2*nBorder;
737 [ + + ]: 1560 : for ( int nIndex = 0; nIndex < int( rButtons.size() ); ++nIndex )
738 : : {
739 : : // Update large size.
740 [ + - ]: 1170 : Size aSize( rButtons[nIndex]->GetSize(eSize) );
741 [ + + ]: 1170 : if ( aSize.Height() > nMaximumHeight )
742 : 390 : nMaximumHeight = aSize.Height();
743 : 1170 : nTotalWidth += aSize.Width();
744 : : }
745 : 390 : return Size( nTotalWidth, nMaximumHeight + 2*nBorder );
746 : : }
747 : :
748 : :
749 : 130 : void ButtonBar::BackgroundTheme::UpdateMinimumIconSizes (
750 : : const ::std::vector<SharedButton>& rButtons)
751 : : {
752 : 130 : maMinimumLargeButtonAreaSize = MinimumSize( Button::IconSize_Large, rButtons );
753 : 130 : maMinimumMediumButtonAreaSize = MinimumSize( Button::IconSize_Medium, rButtons );
754 : 130 : maMinimumSmallButtonAreaSize = MinimumSize( Button::IconSize_Small, rButtons );
755 : 130 : }
756 : :
757 : :
758 : 0 : Button::IconSize ButtonBar::BackgroundTheme::GetIconSize (void) const
759 : : {
760 : 0 : return meIconSize;
761 : : }
762 : :
763 : :
764 : :
765 : 0 : BitmapEx ButtonBar::BackgroundTheme::CreateBackground () const
766 : : {
767 : : OSL_ASSERT(mpTheme);
768 : :
769 : : // Get images.
770 [ # # # ]: 0 : switch (meIconSize)
771 : : {
772 : : case Button::IconSize_Large:
773 : : default:
774 : 0 : return mpTheme->GetIcon(Theme::Icon_ButtonBarLarge);
775 : :
776 : : case Button::IconSize_Medium:
777 : 0 : return mpTheme->GetIcon(Theme::Icon_ButtonBarMedium);
778 : :
779 : : case Button::IconSize_Small:
780 : 0 : return mpTheme->GetIcon(Theme::Icon_ButtonBarSmall);
781 : : }
782 : : }
783 : :
784 : :
785 : :
786 : :
787 : 0 : Point ButtonBar::BackgroundTheme::GetBackgroundLocation (void)
788 : : {
789 : 0 : return maBackgroundLocation;
790 : : }
791 : :
792 : :
793 : :
794 : :
795 : 0 : Rectangle ButtonBar::BackgroundTheme::GetButtonArea (void)
796 : : {
797 : 0 : return maButtonArea;
798 : : }
799 : :
800 : :
801 : :
802 : :
803 : 0 : void ButtonBar::BackgroundTheme::Layout (void)
804 : : {
805 [ # # ]: 0 : Size aImageSize (mpTheme->GetIcon(Theme::Icon_ButtonBarLarge).GetSizePixel());
806 [ # # ][ # # ]: 0 : if (aImageSize.Width() >= maPreviewBoundingBox.GetWidth())
807 : : {
808 [ # # ]: 0 : aImageSize = mpTheme->GetIcon(Theme::Icon_ButtonBarMedium).GetSizePixel();
809 [ # # ][ # # ]: 0 : if (aImageSize.Width() >= maPreviewBoundingBox.GetWidth())
810 : : {
811 : 0 : meIconSize = Button::IconSize_Small;
812 [ # # ]: 0 : aImageSize = mpTheme->GetIcon(Theme::Icon_ButtonBarSmall).GetSizePixel();
813 : : }
814 : : else
815 : 0 : meIconSize = Button::IconSize_Medium;
816 : : }
817 : : else
818 : : {
819 : 0 : meIconSize = Button::IconSize_Large;
820 : : }
821 : :
822 : : maBackgroundLocation = Point(
823 : 0 : maPreviewBoundingBox.Left()
824 [ # # ]: 0 : + (maPreviewBoundingBox.GetWidth()-aImageSize.Width())/2,
825 : 0 : maPreviewBoundingBox.Bottom() - aImageSize.Height());
826 [ # # ]: 0 : maButtonArea = Rectangle(maBackgroundLocation, aImageSize);
827 : 0 : }
828 : :
829 : :
830 : :
831 : :
832 : : //===== Button ================================================================
833 : :
834 : 520 : Button::Button (
835 : : SlideSorter& rSlideSorter,
836 : : const BitmapEx& rLargeIcon,
837 : : const BitmapEx& rLargeHoverIcon,
838 : : const BitmapEx& rMediumIcon,
839 : : const BitmapEx& rMediumHoverIcon,
840 : : const BitmapEx& rSmallIcon,
841 : : const BitmapEx& rSmallHoverIcon,
842 : : const ::rtl::OUString& rsHelpText)
843 : : : mrSlideSorter(rSlideSorter),
844 : : meState(State_Normal),
845 : : maBoundingBox(),
846 : : msHelpText(rsHelpText),
847 : : mbIsActive(false),
848 : : meIconSize(IconSize_Large),
849 : : maLargeIcon(rLargeIcon),
850 [ + - ]: 520 : maLargeHoverIcon(rLargeHoverIcon.IsEmpty() ? rLargeIcon : rLargeHoverIcon),
851 : : maMediumIcon(rMediumIcon),
852 [ + - ]: 520 : maMediumHoverIcon(rMediumHoverIcon.IsEmpty() ? rMediumIcon : rMediumHoverIcon),
853 : : maSmallIcon(rSmallIcon),
854 [ + - ][ - + ]: 1560 : maSmallHoverIcon(rSmallHoverIcon.IsEmpty() ? rSmallIcon : rSmallHoverIcon)
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
855 : : {
856 : 520 : }
857 : :
858 : :
859 [ + - ][ + - ]: 520 : Button::~Button (void)
[ + - ][ + - ]
[ + - ][ + - ]
860 : : {
861 [ - + ]: 520 : }
862 : :
863 : :
864 : :
865 : :
866 : 0 : bool Button::SetState (const State eState)
867 : : {
868 [ # # ]: 0 : if (meState != eState)
869 : : {
870 : 0 : meState = eState;
871 : 0 : return true;
872 : : }
873 : : else
874 : 0 : return false;
875 : : }
876 : :
877 : :
878 : :
879 : :
880 : 0 : Rectangle Button::GetBoundingBox (void) const
881 : : {
882 [ # # ]: 0 : if (mbIsActive)
883 : 0 : return maBoundingBox;
884 : : else
885 : 0 : return Rectangle();
886 : : }
887 : :
888 : :
889 : :
890 : :
891 : 0 : ::rtl::OUString Button::GetHelpText (void) const
892 : : {
893 [ # # ]: 0 : if (mbIsActive)
894 : 0 : return msHelpText;
895 : : else
896 : 0 : return ::rtl::OUString();
897 : : }
898 : :
899 : :
900 : :
901 : :
902 : 0 : void Button::SetActiveState (const bool bIsActive)
903 : : {
904 : 0 : mbIsActive = bIsActive;
905 : 0 : }
906 : :
907 : :
908 : :
909 : :
910 : 0 : bool Button::IsActive (void) const
911 : : {
912 : 0 : return mbIsActive;
913 : : }
914 : :
915 : :
916 : :
917 : :
918 : 0 : void Button::SetIconSize (const IconSize eIconSize)
919 : : {
920 : 0 : meIconSize = eIconSize;
921 : 0 : }
922 : :
923 : :
924 : :
925 : :
926 : 0 : bool Button::IsEnabled (void) const
927 : : {
928 : 0 : return true;
929 : : }
930 : :
931 : :
932 : 0 : void Button::Place (const Rectangle aButtonBarBox)
933 : : {
934 : 0 : const sal_Int32 nWidth (GetSize().Width());
935 : : maBoundingBox = Rectangle(
936 : 0 : aButtonBarBox.Right() - nWidth,
937 : : aButtonBarBox.Top(),
938 : : aButtonBarBox.Right(),
939 : 0 : aButtonBarBox.Bottom());
940 : 0 : SetActiveState(aButtonBarBox.IsInside(maBoundingBox));
941 : 0 : }
942 : :
943 : :
944 : 0 : void Button::Paint (
945 : : OutputDevice& rDevice,
946 : : const Point aOffset,
947 : : const double nAlpha,
948 : : const ::boost::shared_ptr<Theme>&) const
949 : : {
950 [ # # ]: 0 : if ( ! mbIsActive)
951 : 0 : return;
952 : :
953 : 0 : const sal_uInt16 nSavedAntialiasingMode (rDevice.GetAntialiasing());
954 [ # # ]: 0 : rDevice.SetAntialiasing(nSavedAntialiasingMode | ANTIALIASING_ENABLE_B2DDRAW);
955 : :
956 [ # # ]: 0 : rDevice.SetLineColor();
957 : :
958 : : // Choose icon.
959 [ # # ]: 0 : BitmapEx aIcon;
960 [ # # # ]: 0 : switch (meIconSize)
961 : : {
962 : : case IconSize_Large:
963 : : default:
964 [ # # ]: 0 : if (meState == State_Normal)
965 [ # # ]: 0 : aIcon = maLargeIcon;
966 : : else
967 [ # # ]: 0 : aIcon = maLargeHoverIcon;
968 : 0 : break;
969 : :
970 : : case IconSize_Medium:
971 [ # # ]: 0 : if (meState == State_Normal)
972 [ # # ]: 0 : aIcon = maMediumIcon;
973 : : else
974 [ # # ]: 0 : aIcon = maMediumHoverIcon;
975 : 0 : break;
976 : :
977 : : case IconSize_Small:
978 [ # # ]: 0 : if (meState == State_Normal)
979 [ # # ]: 0 : aIcon = maSmallIcon;
980 : : else
981 [ # # ]: 0 : aIcon = maSmallHoverIcon;
982 : 0 : break;
983 : : }
984 : :
985 : : // Paint icon.
986 [ # # ][ # # ]: 0 : if ( ! aIcon.IsEmpty())
987 : : {
988 [ # # ]: 0 : AlphaMask aMask (aIcon.GetSizePixel());
989 [ # # ][ # # ]: 0 : AdaptTransparency(aMask, aIcon.GetAlpha(), nAlpha);
[ # # ]
990 : : rDevice.DrawBitmapEx(
991 : : Point(
992 : 0 : maBoundingBox.Left()
993 : 0 : + aOffset.X()
994 [ # # ]: 0 : + (maBoundingBox.GetWidth()-aIcon.GetSizePixel().Width())/2,
995 : 0 : maBoundingBox.Top()
996 : 0 : + aOffset.Y()
997 [ # # ]: 0 : + (maBoundingBox.GetHeight()-aIcon.GetSizePixel().Height())/2),
998 [ # # ]: 0 : BitmapEx(aIcon.GetBitmap(), aMask));
[ # # # # ]
[ # # ][ # # ]
[ # # ]
999 : : }
1000 : :
1001 [ # # ][ # # ]: 0 : rDevice.SetAntialiasing(nSavedAntialiasingMode);
1002 : : }
1003 : :
1004 : :
1005 : 0 : Size Button::GetSize (void) const
1006 : : {
1007 : 0 : return GetSize(meIconSize);
1008 : : }
1009 : :
1010 : :
1011 : 1170 : Size Button::GetSize (const Button::IconSize eIconSize) const
1012 : : {
1013 [ + + + ]: 1170 : switch (eIconSize)
1014 : : {
1015 : : case IconSize_Large:
1016 : : default:
1017 : 390 : return maLargeIcon.GetSizePixel();
1018 : :
1019 : : case IconSize_Medium:
1020 : 390 : return maMediumIcon.GetSizePixel();
1021 : :
1022 : : case IconSize_Small:
1023 : 1170 : return maSmallIcon.GetSizePixel();
1024 : : }
1025 : : }
1026 : :
1027 : :
1028 : :
1029 : :
1030 : : //===== UnhideButton ==========================================================
1031 : :
1032 : 130 : UnhideButton::UnhideButton (SlideSorter& rSlideSorter)
1033 : : : Button(
1034 : : rSlideSorter,
1035 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BLarge),
[ + - ]
1036 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BLargeHover),
[ + - ]
1037 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BMedium),
[ + - ]
1038 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BMediumHover),
[ + - ]
1039 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BSmall),
[ + - ]
1040 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BSmallHover),
[ + - ]
1041 [ + - ][ + - ]: 390 : String(SdResId(STRING_SHOW_SLIDE)))
[ + - ][ + - ]
1042 : : {
1043 : 130 : }
1044 : :
1045 : :
1046 : :
1047 : :
1048 : 0 : void UnhideButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1049 : : {
1050 [ # # ]: 0 : if ( ! rpDescriptor)
1051 : 0 : return;
1052 [ # # ]: 0 : mrSlideSorter.GetController().GetSlotManager()->ChangeSlideExclusionState(
1053 : 0 : (rpDescriptor->HasState(model::PageDescriptor::ST_Selected)
1054 : : ? model::SharedPageDescriptor()
1055 : : : rpDescriptor),
1056 [ # # ][ # # ]: 0 : false);
[ # # ][ # # ]
1057 : : }
1058 : :
1059 : :
1060 : :
1061 : :
1062 : : //===== StartSlideShowButton ==================================================
1063 : :
1064 : 130 : StartShowButton::StartShowButton (SlideSorter& rSlideSorter)
1065 : : : Button(
1066 : : rSlideSorter,
1067 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Large),
[ + - ]
1068 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1LargeHover),
[ + - ]
1069 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Medium),
[ + - ]
1070 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1MediumHover),
[ + - ]
1071 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Small),
[ + - ]
1072 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1SmallHover),
[ + - ]
1073 [ + - ][ + - ]: 390 : String(SdResId(STRING_START_SLIDESHOW)))
[ + - ][ + - ]
1074 : : {
1075 : 130 : }
1076 : :
1077 : :
1078 : :
1079 : :
1080 : 0 : bool StartShowButton::IsEnabled (void) const
1081 : : {
1082 [ # # ]: 0 : ViewShell* pViewShell = mrSlideSorter.GetViewShell();
1083 [ # # ]: 0 : if (pViewShell == NULL)
1084 : 0 : return false;
1085 [ # # ]: 0 : SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
1086 [ # # ]: 0 : if (pDispatcher == NULL)
1087 : 0 : return false;
1088 : :
1089 : 0 : const SfxPoolItem* pState = NULL;
1090 [ # # ]: 0 : const SfxItemState eState (pDispatcher->QueryState(SID_PRESENTATION, pState));
1091 : 0 : return (eState & SFX_ITEM_DISABLED) == 0;
1092 : : }
1093 : :
1094 : :
1095 : :
1096 : :
1097 : 0 : void StartShowButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1098 : : {
1099 : : // Hide the tool tip early, while the slide show still intializes.
1100 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().GetToolTip().SetPage(model::SharedPageDescriptor());
[ # # ][ # # ]
[ # # ]
1101 : :
1102 : : Reference< XPresentation2 > xPresentation(
1103 [ # # ][ # # ]: 0 : mrSlideSorter.GetModel().GetDocument()->getPresentation());
[ # # ]
1104 [ # # ]: 0 : if (xPresentation.is())
1105 : : {
1106 [ # # ]: 0 : Sequence<PropertyValue> aProperties (1);
1107 [ # # ]: 0 : aProperties[0].Name = ::rtl::OUString("FirstPage");
1108 [ # # ][ # # ]: 0 : const ::rtl::OUString sName (rpDescriptor->GetPage()->GetName());
[ # # ]
1109 [ # # ][ # # ]: 0 : aProperties[0].Value = Any(sName);
1110 : :
1111 : : // We have to temporarily change the options value
1112 : : // StartWithActualPage to make the slide show use the
1113 : : // specified first page.
1114 [ # # ][ # # ]: 0 : const DocumentType eType (mrSlideSorter.GetModel().GetDocument()->GetDocumentType());
1115 [ # # ][ # # ]: 0 : const sal_Bool bSavedState (SD_MOD()->GetSdOptions(eType)->IsStartWithActualPage());
[ # # ]
1116 [ # # ][ # # ]: 0 : SD_MOD()->GetSdOptions(eType)->SetStartWithActualPage(sal_False);
[ # # ]
1117 : :
1118 [ # # ][ # # ]: 0 : xPresentation->startWithArguments(aProperties);
1119 : :
1120 : : // Restore previous StartWithActualPage value.
1121 [ # # ][ # # ]: 0 : SD_MOD()->GetSdOptions(eType)->SetStartWithActualPage(bSavedState);
[ # # ][ # # ]
1122 : 0 : }
1123 : 0 : }
1124 : :
1125 : :
1126 : :
1127 : :
1128 : : //===== HideButton ============================================================
1129 : :
1130 : 130 : HideButton::HideButton (SlideSorter& rSlideSorter)
1131 : : : Button(
1132 : : rSlideSorter,
1133 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Large),
[ + - ]
1134 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2LargeHover),
[ + - ]
1135 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Medium),
[ + - ]
1136 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2MediumHover),
[ + - ]
1137 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Small),
[ + - ]
1138 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2SmallHover),
[ + - ]
1139 [ + - ][ + - ]: 390 : String(SdResId(STRING_HIDE_SLIDE)))
[ + - ][ + - ]
1140 : : {
1141 : 130 : }
1142 : :
1143 : :
1144 : :
1145 : :
1146 : 0 : void HideButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1147 : : {
1148 [ # # ]: 0 : if ( ! rpDescriptor)
1149 : 0 : return;
1150 [ # # ]: 0 : mrSlideSorter.GetController().GetSlotManager()->ChangeSlideExclusionState(
1151 : 0 : (rpDescriptor->HasState(model::PageDescriptor::ST_Selected)
1152 : : ? model::SharedPageDescriptor()
1153 : : : rpDescriptor),
1154 [ # # ][ # # ]: 0 : true);
[ # # ][ # # ]
1155 : : }
1156 : :
1157 : :
1158 : :
1159 : :
1160 : : //===== DuplicateButton =======================================================
1161 : :
1162 : 130 : DuplicateButton::DuplicateButton (SlideSorter& rSlideSorter)
1163 : : : Button(
1164 : : rSlideSorter,
1165 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Large),
[ + - ]
1166 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3LargeHover),
[ + - ]
1167 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Medium),
[ + - ]
1168 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3MediumHover),
[ + - ]
1169 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Small),
[ + - ]
1170 [ + - ][ + - ]: 260 : rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3SmallHover),
[ + - ]
1171 [ + - ][ + - ]: 390 : String(SdResId(STRING_DUPLICATE_SLIDE)))
[ + - ][ + - ]
1172 : : {
1173 : 130 : }
1174 : :
1175 : :
1176 : :
1177 : :
1178 : 0 : bool DuplicateButton::IsEnabled (void) const
1179 : : {
1180 [ # # ]: 0 : ViewShell* pViewShell = mrSlideSorter.GetViewShell();
1181 [ # # ]: 0 : if (pViewShell == NULL)
1182 : 0 : return false;
1183 [ # # ]: 0 : SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
1184 [ # # ]: 0 : if (pDispatcher == NULL)
1185 : 0 : return false;
1186 : :
1187 : 0 : const SfxPoolItem* pState = NULL;
1188 : : const SfxItemState eState (pDispatcher->QueryState(
1189 : : SID_DUPLICATE_PAGE,
1190 [ # # ]: 0 : pState));
1191 : 0 : return (eState & SFX_ITEM_DISABLED) == 0;
1192 : : }
1193 : :
1194 : :
1195 : :
1196 : :
1197 : 0 : void DuplicateButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1198 : : {
1199 [ # # ]: 0 : if ( ! rpDescriptor)
1200 : 0 : return;
1201 : :
1202 [ # # ][ # # ]: 0 : mrSlideSorter.GetView().SetPageUnderMouse(model::SharedPageDescriptor(),false);
1203 : :
1204 : : // When the page under the button is not selected then set the
1205 : : // selection to just this page.
1206 [ # # ]: 0 : if ( ! rpDescriptor->HasState(model::PageDescriptor::ST_Selected))
1207 : : {
1208 : 0 : mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
1209 : 0 : mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor);
1210 : : }
1211 : : // Duplicate the selected pages. Insert the new pages right
1212 : : // after the current selection and select them
1213 [ # # # # ]: 0 : if (mrSlideSorter.GetViewShell() != NULL
[ # # ]
1214 : 0 : && mrSlideSorter.GetViewShell()->GetDispatcher() != NULL)
1215 : : {
1216 : 0 : mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
1217 : : SID_DUPLICATE_PAGE,
1218 : 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1219 : : }
1220 : : }
1221 : :
1222 : :
1223 : :
1224 [ + - ][ + - ]: 75 : } } } // end of namespace ::sd::slidesorter::view
1225 : :
1226 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|