diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-13 16:06:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-13 16:51:47 +0100 |
commit | 747a4f30d2e6b44e31854849be30295cca25af5b (patch) | |
tree | 6ac7a41acafbe5ea93ee5e77bb3954760a30e2c4 /sd/source | |
parent | 13180e0c7cdfbaa86b8380fe7e8966f8ebaf1e00 (diff) |
convert slideshow context menu to .ui
Change-Id: I2e15f649ef628903899b5351bd52fc85b50fde8d
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/slideshow/slideshow.hrc | 50 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshow.src | 156 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.cxx | 298 |
3 files changed, 143 insertions, 361 deletions
diff --git a/sd/source/ui/slideshow/slideshow.hrc b/sd/source/ui/slideshow/slideshow.hrc deleted file mode 100644 index 4e6169f43b87..000000000000 --- a/sd/source/ui/slideshow/slideshow.hrc +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * 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 regarding copyright - * ownership. The ASF licenses this file 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 . - */ - -#ifndef SD_SLIDESHOW_HRC_ -#define SD_SLIDESHOW_HRC_ - -#define CM_PREV_SLIDE 1 -#define CM_NEXT_SLIDE 2 -#define CM_GOTO 3 -#define CM_SCREEN 4 -#define CM_SCREEN_BLACK 5 -#define CM_SCREEN_WHITE 6 -#define CM_ENDSHOW 7 -#define CM_FIRST_SLIDE 8 -#define CM_LAST_SLIDE 9 - -//CM for extra presenter UI -#define CM_ERASE_ALLINK 10 -#define CM_COLOR_PEN 11 -#define CM_WIDTH_PEN 12 -#define CM_WIDTH_PEN_VERY_THIN 13 -#define CM_WIDTH_PEN_THIN 14 -#define CM_WIDTH_PEN_NORMAL 15 -#define CM_WIDTH_PEN_THICK 16 -#define CM_WIDTH_PEN_VERY_THICK 17 -#define CM_PEN_MODE 18 - -#define CM_EDIT_PRESENTATION 19 - -#define CM_SLIDES 21 // this must be the last id! - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slideshow/slideshow.src b/sd/source/ui/slideshow/slideshow.src deleted file mode 100644 index 480cc096063a..000000000000 --- a/sd/source/ui/slideshow/slideshow.src +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * 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 regarding copyright - * ownership. The ASF licenses this file 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 . - */ - -#include "glob.hrc" -#include "slideshow.hrc" - -Menu RID_SLIDESHOW_CONTEXTMENU -{ - ItemList = - { - MenuItem - { - Identifier = CM_NEXT_SLIDE ; - Text [ en-US ] = "~Next" ; - }; - MenuItem - { - Identifier = CM_PREV_SLIDE ; - Text [ en-US ] = "~Previous" ; - }; - MenuItem - { - Identifier = CM_GOTO; - Text [ en-US ] = "~Go to Slide" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = CM_FIRST_SLIDE; - Text [ en-US ] = "~First Slide"; - }; - MenuItem - { - Identifier = CM_LAST_SLIDE; - Text [ en-US ] = "~Last Slide"; - }; - MenuItem - { - Separator = TRUE; - }; - }; - }; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = CM_PEN_MODE; - Text [ en-US ] = "Mouse pointer as ~Pen"; - }; - MenuItem - { - Identifier = CM_WIDTH_PEN; - Text [ en-US ] = "~Pen Width" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = CM_WIDTH_PEN_VERY_THIN; - Text [ en-US ] = "~Very thin"; - }; - MenuItem - { - Identifier = CM_WIDTH_PEN_THIN; - Text [ en-US ] = "~Thin"; - }; - MenuItem - { - Identifier = CM_WIDTH_PEN_NORMAL; - Text [ en-US ] = "~Normal"; - }; - MenuItem - { - Identifier = CM_WIDTH_PEN_THICK; - Text [ en-US ] = "~Thick"; - }; - MenuItem - { - Identifier = CM_WIDTH_PEN_VERY_THICK; - Text [ en-US ] = "~Very Thick"; - }; - }; - }; - }; - MenuItem - { - Identifier = CM_COLOR_PEN ; - Text [ en-US ] = "~Change pen Color..." ; - }; - MenuItem - { - Identifier = CM_ERASE_ALLINK ; - Text [ en-US ] = "~Erase all ink on Slide" ; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = CM_SCREEN; - Text [ en-US ] = "~Screen" ; - - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = CM_SCREEN_BLACK; - Text [ en-US ] = "~Black"; - }; - MenuItem - { - Identifier = CM_SCREEN_WHITE; - Text [ en-US ] = "~White"; - }; - }; - }; - }; - MenuItem - { - Identifier = CM_EDIT_PRESENTATION ; - Text [ en-US ] = "E~dit Presentation" ; - }; - MenuItem - { - Identifier = CM_ENDSHOW ; - Text [ en-US ] = "~End Show" ; - }; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 0a104ae0f69c..521e18f86ce3 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -70,7 +70,6 @@ #include "comphelper/anytostring.hxx" #include "cppuhelper/exc_hlp.hxx" #include "rtl/ref.hxx" -#include "slideshow.hrc" #include "canvas/elapsedtime.hxx" #include "avmedia/mediawindow.hxx" #include "svtools/colrdlg.hxx" @@ -78,6 +77,7 @@ #include "customshowlist.hxx" #include "unopage.hxx" +#define CM_SLIDES 21 using ::com::sun::star::animations::XAnimationNode; using ::com::sun::star::animations::XAnimationListener; @@ -1985,17 +1985,18 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) if( !mbWasPaused ) pause(); - VclPtrInstance<PopupMenu> pMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) ); + VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/simpress/ui/slidecontextmenu.ui", ""); + VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu")); // Adding button to display if in Pen mode - pMenu->CheckItem( CM_PEN_MODE, mbUsePen); + pMenu->CheckItem(pMenu->GetItemId("pen"), mbUsePen); const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode(); - pMenu->EnableItem( CM_NEXT_SLIDE, ( mpSlideController->getNextSlideIndex() != -1 ) ); - pMenu->EnableItem( CM_PREV_SLIDE, ( mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) ); - pMenu->EnableItem( CM_EDIT_PRESENTATION, mpViewShell->GetDoc()->IsStartWithPresentation()); + pMenu->EnableItem(pMenu->GetItemId("next"), mpSlideController->getNextSlideIndex() != -1); + pMenu->EnableItem(pMenu->GetItemId("prev"), (mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK)); + pMenu->EnableItem(pMenu->GetItemId("edit"), mpViewShell->GetDoc()->IsStartWithPresentation()); - PopupMenu* pPageMenu = pMenu->GetPopupMenu( CM_GOTO ); + PopupMenu* pPageMenu = pMenu->GetPopupMenu(pMenu->GetItemId("goto")); SfxViewFrame* pViewFrame = getViewFrame(); if( pViewFrame ) @@ -2003,13 +2004,13 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) Reference< css::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() ); if( xFrame.is() ) { - pMenu->SetItemImage( CM_NEXT_SLIDE, GetImage( xFrame, "slot:10617" , false ) ); - pMenu->SetItemImage( CM_PREV_SLIDE, GetImage( xFrame, "slot:10618" , false ) ); + pMenu->SetItemImage(pMenu->GetItemId("next"), GetImage(xFrame, "slot:10617" , false)); + pMenu->SetItemImage(pMenu->GetItemId("prev"), GetImage(xFrame, "slot:10618" , false)); if( pPageMenu ) { - pPageMenu->SetItemImage( CM_FIRST_SLIDE, GetImage( xFrame, "slot:10616" , false ) ); - pPageMenu->SetItemImage( CM_LAST_SLIDE, GetImage( xFrame, "slot:10619" , false ) ); + pPageMenu->SetItemImage(pPageMenu->GetItemId("first"), GetImage(xFrame, "slot:10616" , false)); + pPageMenu->SetItemImage(pPageMenu->GetItemId("last"), GetImage(xFrame, "slot:10619" , false)); } } } @@ -2020,7 +2021,7 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) const sal_Int32 nPageNumberCount = mpSlideController->getSlideNumberCount(); if( nPageNumberCount <= 1 ) { - pMenu->EnableItem( CM_GOTO, false ); + pMenu->EnableItem(pMenu->GetItemId("goto"), false); } else { @@ -2028,8 +2029,8 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) ) nCurrentSlideNumber = -1; - pPageMenu->EnableItem( CM_FIRST_SLIDE, ( mpSlideController->getSlideNumber(0) != nCurrentSlideNumber ) ); - pPageMenu->EnableItem( CM_LAST_SLIDE, ( mpSlideController->getSlideNumber( mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber ) ); + pPageMenu->EnableItem(pPageMenu->GetItemId("first"), mpSlideController->getSlideNumber(0) != nCurrentSlideNumber); + pPageMenu->EnableItem(pPageMenu->GetItemId("last"), mpSlideController->getSlideNumber(mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber); sal_Int32 nPageNumber; @@ -2051,14 +2052,14 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK ) { - PopupMenu* pBlankMenu = pMenu->GetPopupMenu( CM_SCREEN ); + PopupMenu* pBlankMenu = pMenu->GetPopupMenu(pMenu->GetItemId("screen")); if( pBlankMenu ) { - pBlankMenu->CheckItem( ( mpShowWindow->GetBlankColor() == Color( COL_WHITE ) ) ? CM_SCREEN_WHITE : CM_SCREEN_BLACK ); + pBlankMenu->CheckItem((mpShowWindow->GetBlankColor() == Color(COL_WHITE)) ? pBlankMenu->GetItemId("white") : pBlankMenu->GetItemId("black")); } } - PopupMenu* pWidthMenu = pMenu->GetPopupMenu( CM_WIDTH_PEN); + PopupMenu* pWidthMenu = pMenu->GetPopupMenu(pMenu->GetItemId("width")); // populate color width list if( pWidthMenu ) @@ -2090,15 +2091,13 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) break; } - pWidthMenu->EnableItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator)); - if( nWidth == mdUserPaintStrokeWidth) - pWidthMenu->CheckItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator) ); + if (nWidth == mdUserPaintStrokeWidth) + pWidthMenu->CheckItem(pWidthMenu->GetItemId(OString::number(nWidth))); } } pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl ) ); pMenu->Execute( mpShowWindow, maPopupMousePos ); - pMenu.disposeAndClear(); if( mxView.is() ) mxView->ignoreNextMouseReleased(); @@ -2109,153 +2108,142 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void) IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu, bool ) { - if( pMenu ) - { - sal_uInt16 nMenuId = pMenu->GetCurItemId(); + if (!pMenu) + return false; - switch( nMenuId ) - { - case CM_PREV_SLIDE: - gotoPreviousSlide(); - mbWasPaused = false; - break; - case CM_NEXT_SLIDE: - gotoNextSlide(); - mbWasPaused = false; - break; - case CM_FIRST_SLIDE: - gotoFirstSlide(); - mbWasPaused = false; - break; - case CM_LAST_SLIDE: - gotoLastSlide(); - mbWasPaused = false; - break; - case CM_SCREEN_BLACK: - case CM_SCREEN_WHITE: + OString sMenuId = pMenu->GetCurItemIdent(); + + if (sMenuId == "prev") + { + gotoPreviousSlide(); + mbWasPaused = false; + } + else if(sMenuId == "next") + { + gotoNextSlide(); + mbWasPaused = false; + } + else if (sMenuId == "first") + { + gotoFirstSlide(); + mbWasPaused = false; + } + else if (sMenuId == "last") + { + gotoLastSlide(); + mbWasPaused = false; + } + else if (sMenuId == "black" || sMenuId == "white") + { + const Color aBlankColor(sMenuId == "white" ? COL_WHITE : COL_BLACK); + if( mbWasPaused ) { - const Color aBlankColor( (nMenuId == CM_SCREEN_WHITE) ? COL_WHITE : COL_BLACK ); - if( mbWasPaused ) + if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK ) { - if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK ) + if( mpShowWindow->GetBlankColor() == aBlankColor ) { - if( mpShowWindow->GetBlankColor() == aBlankColor ) - { - mbWasPaused = false; - mpShowWindow->RestartShow(); - break; - } + mbWasPaused = false; + mpShowWindow->RestartShow(); + return false; } - mpShowWindow->RestartShow(); - } - if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) ) - { - pause(); - mbWasPaused = true; } + mpShowWindow->RestartShow(); } - break; - case CM_COLOR_PEN: - { - //Open a color picker based on SvColorDialog - ::Color aColor( mnUserPaintColor ); - SvColorDialog aColorDlg( mpShowWindow); - aColorDlg.SetColor( aColor ); - - if (aColorDlg.Execute() ) - { - aColor = aColorDlg.GetColor(); - setPenColor(aColor.GetColor()); - } - mbWasPaused = false; - } - break; - - case CM_WIDTH_PEN_VERY_THIN: - { - setPenWidth(4.0); - mbWasPaused = false; - } - break; - - case CM_WIDTH_PEN_THIN: - { - setPenWidth(100.0); - mbWasPaused = false; - } - break; - - case CM_WIDTH_PEN_NORMAL: - { - setPenWidth(150.0); - mbWasPaused = false; - } - break; - - case CM_WIDTH_PEN_THICK: - { - setPenWidth(200.0); - mbWasPaused = false; - } - break; + if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) ) + { + pause(); + mbWasPaused = true; + } + } + else if (sMenuId == "color") + { + //Open a color picker based on SvColorDialog + ::Color aColor( mnUserPaintColor ); + SvColorDialog aColorDlg( mpShowWindow); + aColorDlg.SetColor( aColor ); - case CM_WIDTH_PEN_VERY_THICK: - { - setPenWidth(400.0); - mbWasPaused = false; - } - break; - case CM_ERASE_ALLINK: - { - setEraseAllInk(true); - mbWasPaused = false; - } - break; - case CM_PEN_MODE: - { - setUsePen(!mbUsePen); - mbWasPaused = false; - } - break; - case CM_EDIT_PRESENTATION: - // When in autoplay mode (pps/ppsx), offer editing of the presentation - // Turn autostart off, else Impress will close when exiting the Presentation - mpViewShell->GetDoc()->SetExitAfterPresenting(false); - if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) ) - { - if( mpSlideController->getCurrentSlideNumber() != -1 ) - { - mnRestoreSlide = mpSlideController->getCurrentSlideNumber(); - } - } - endPresentation(); - break; - case CM_ENDSHOW: - // in case the user cancels the presentation, switch to current slide - // in edit mode - if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) ) - { - if( mpSlideController->getCurrentSlideNumber() != -1 ) - { - mnRestoreSlide = mpSlideController->getCurrentSlideNumber(); - } - } - endPresentation(); - break; - default: - sal_Int32 nPageNumber = nMenuId - CM_SLIDES; - const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode(); - if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) ) + if (aColorDlg.Execute() ) + { + aColor = aColorDlg.GetColor(); + setPenColor(aColor.GetColor()); + } + mbWasPaused = false; + } + else if (sMenuId == "4") + { + setPenWidth(4.0); + mbWasPaused = false; + } + else if (sMenuId == "100") + { + setPenWidth(100.0); + mbWasPaused = false; + } + else if (sMenuId == "150") + { + setPenWidth(150.0); + mbWasPaused = false; + } + else if (sMenuId == "200") + { + setPenWidth(200.0); + mbWasPaused = false; + } + else if (sMenuId == "400") + { + setPenWidth(400.0); + mbWasPaused = false; + } + else if (sMenuId == "erase") + { + setEraseAllInk(true); + mbWasPaused = false; + } + else if (sMenuId == "pen") + { + setUsePen(!mbUsePen); + mbWasPaused = false; + } + else if (sMenuId == "edit") + { + // When in autoplay mode (pps/ppsx), offer editing of the presentation + // Turn autostart off, else Impress will close when exiting the Presentation + mpViewShell->GetDoc()->SetExitAfterPresenting(false); + if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) ) + { + if( mpSlideController->getCurrentSlideNumber() != -1 ) { - mpShowWindow->RestartShow( nPageNumber ); + mnRestoreSlide = mpSlideController->getCurrentSlideNumber(); } - else if( nPageNumber != mpSlideController->getCurrentSlideNumber() ) + } + endPresentation(); + } + else if (sMenuId == "end") + { + // in case the user cancels the presentation, switch to current slide + // in edit mode + if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) ) + { + if( mpSlideController->getCurrentSlideNumber() != -1 ) { - displaySlideNumber( nPageNumber ); + mnRestoreSlide = mpSlideController->getCurrentSlideNumber(); } - mbWasPaused = false; - break; } + endPresentation(); + } + else + { + sal_Int32 nPageNumber = pMenu->GetCurItemId() - CM_SLIDES; + const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode(); + if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) ) + { + mpShowWindow->RestartShow( nPageNumber ); + } + else if( nPageNumber != mpSlideController->getCurrentSlideNumber() ) + { + displaySlideNumber( nPageNumber ); + } + mbWasPaused = false; } return false; |