diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sd/source/ui/controller | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sd/source/ui/controller')
-rw-r--r-- | sd/source/ui/controller/displaymodecontroller.cxx | 264 | ||||
-rw-r--r-- | sd/source/ui/controller/slidelayoutcontroller.cxx | 380 | ||||
-rw-r--r-- | sd/source/ui/controller/slidelayoutcontroller.hxx | 47 |
3 files changed, 691 insertions, 0 deletions
diff --git a/sd/source/ui/controller/displaymodecontroller.cxx b/sd/source/ui/controller/displaymodecontroller.cxx new file mode 100644 index 000000000..81ad2d19e --- /dev/null +++ b/sd/source/ui/controller/displaymodecontroller.cxx @@ -0,0 +1,264 @@ +/* -*- 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/. + */ + +#include <svtools/popupwindowcontroller.hxx> +#include <svtools/toolbarmenu.hxx> +#include <svtools/valueset.hxx> +#include <vcl/toolbox.hxx> + +#include <strings.hrc> + +#include <bitmaps.hlst> +#include <sdresid.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; + +namespace sd +{ + +// Component to select which display mode has to be used. +// Composed of a dropdown button in the toolbar and a +// popup menu to select the value + +namespace { + +class DisplayModeController : public svt::PopupWindowController +{ +public: + explicit DisplayModeController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; + virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + void setToolboxItemImage(const OUString& rImage); +}; + +class DisplayModeToolbarMenu final : public WeldToolbarPopup +{ +public: + DisplayModeToolbarMenu(DisplayModeController* pControl, weld::Widget* pParent); + virtual void GrabFocus() override + { + mxDisplayModeSet1->GrabFocus(); + } + +private: + rtl::Reference<DisplayModeController> mxControl; + std::unique_ptr<weld::Frame> mxFrame1; + std::unique_ptr<ValueSet> mxDisplayModeSet1; + std::unique_ptr<weld::CustomWeld> mxDisplayModeSetWin1; + std::unique_ptr<weld::Frame> mxFrame2; + std::unique_ptr<ValueSet> mxDisplayModeSet2; + std::unique_ptr<weld::CustomWeld> mxDisplayModeSetWin2; + + DECL_LINK(SelectValueSetHdl, ValueSet*, void); +}; + +struct snew_slide_value_info +{ + sal_uInt16 mnId; + OUString msBmpResId; + TranslateId mpStrResId; + const char* msUnoCommand; +}; + +} + +const snew_slide_value_info editmodes[] = +{ + {1, + BMP_DISPLAYMODE_SLIDE, + STR_NORMAL_MODE, + ".uno:NormalMultiPaneGUI" }, + {2, + BMP_DISPLAYMODE_OUTLINE, + STR_OUTLINE_MODE, + ".uno:OutlineMode" }, + {3, + BMP_DISPLAYMODE_NOTES, + STR_NOTES_MODE, + ".uno:NotesMode" }, + {4, + BMP_DISPLAYMODE_SLIDE_SORTER, + STR_SLIDE_SORTER_MODE, + ".uno:DiaMode" }, + {0, "", {}, "" } +}; + +const snew_slide_value_info mastermodes[] = +{ + {5, + BMP_DISPLAYMODE_SLIDE_MASTER, + STR_SLIDE_MASTER_MODE, + ".uno:SlideMasterPage" }, + {6, + BMP_DISPLAYMODE_NOTES_MASTER, + STR_NOTES_MASTER_MODE, + ".uno:NotesMasterPage" }, + {7, + BMP_DISPLAYMODE_HANDOUT_MASTER, + STR_HANDOUT_MASTER_MODE, + ".uno:HandoutMode" }, + {0, "", {}, "" } +}; + + +static void fillLayoutValueSet(ValueSet* pValue, const snew_slide_value_info* pInfo) +{ + Size aLayoutItemSize; + for( ; pInfo->mnId; pInfo++ ) + { + OUString aText(SdResId(pInfo->mpStrResId)); + BitmapEx aBmp(pInfo->msBmpResId); + + pValue->InsertItem(pInfo->mnId, Image(aBmp), aText); + + aLayoutItemSize.setWidth( std::max( aLayoutItemSize.Width(), aBmp.GetSizePixel().Width() ) ); + aLayoutItemSize.setHeight( std::max( aLayoutItemSize.Height(), aBmp.GetSizePixel().Height() ) ); + } + + aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize ); + Size aSize(pValue->CalcWindowSizePixel(aLayoutItemSize)); + + const sal_Int32 LAYOUT_BORDER_PIX = 7; + aSize.AdjustWidth((pValue->GetColCount() + 1) * LAYOUT_BORDER_PIX ); + aSize.AdjustHeight((pValue->GetLineCount() +1) * LAYOUT_BORDER_PIX ); + + pValue->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height()); + pValue->SetOutputSizePixel(aSize); +} + +DisplayModeToolbarMenu::DisplayModeToolbarMenu(DisplayModeController* pControl, weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/simpress/ui/displaywindow.ui", "DisplayWindow") + , mxControl(pControl) + , mxFrame1(m_xBuilder->weld_frame("editframe")) + , mxDisplayModeSet1(new ValueSet(nullptr)) + , mxDisplayModeSetWin1(new weld::CustomWeld(*m_xBuilder, "valueset1", *mxDisplayModeSet1)) + , mxFrame2(m_xBuilder->weld_frame("masterframe")) + , mxDisplayModeSet2(new ValueSet(nullptr)) + , mxDisplayModeSetWin2(new weld::CustomWeld(*m_xBuilder, "valueset2", *mxDisplayModeSet2)) +{ + mxDisplayModeSet1->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + mxDisplayModeSet1->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + + mxDisplayModeSet1->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) ); + mxDisplayModeSet2->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) ); + + sal_Int16 nColCount = 2; + + mxDisplayModeSet1->SetColCount( nColCount ); + fillLayoutValueSet( mxDisplayModeSet1.get(), &editmodes[0] ); + + mxDisplayModeSet2->SetColCount( nColCount ); + fillLayoutValueSet( mxDisplayModeSet2.get(), &mastermodes[0] ); +} + +IMPL_LINK( DisplayModeToolbarMenu, SelectValueSetHdl, ValueSet*, pControl, void ) +{ + OUString sCommandURL; + OUString sImage; + + if( pControl == mxDisplayModeSet1.get() ) { + sCommandURL = OUString::createFromAscii(editmodes[mxDisplayModeSet1->GetSelectedItemId() - 1 ].msUnoCommand); + sImage = editmodes[mxDisplayModeSet1->GetSelectedItemId() - 1 ].msBmpResId; + } + else if( pControl == mxDisplayModeSet2.get() ) { + sCommandURL = OUString::createFromAscii(mastermodes[mxDisplayModeSet2->GetSelectedItemId() - 5 ].msUnoCommand); + sImage = mastermodes[mxDisplayModeSet2->GetSelectedItemId() - 5 ].msBmpResId; + } + + if (!sCommandURL.isEmpty()) + mxControl->dispatchCommand( sCommandURL, Sequence< PropertyValue >() ); + + mxControl->setToolboxItemImage(sImage); + mxControl->EndPopupMode(); +} + +DisplayModeController::DisplayModeController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) +: svt::PopupWindowController( rxContext, Reference< frame::XFrame >(), OUString() ) +{ +} + +void SAL_CALL DisplayModeController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) +{ + svt::PopupWindowController::initialize( aArguments ); + ToolBox* pToolBox = nullptr; + ToolBoxItemId nId; + if ( getToolboxId( nId, &pToolBox ) ) + pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY ); + setToolboxItemImage(BMP_DISPLAYMODE_SLIDE); +} + +std::unique_ptr<WeldToolbarPopup> DisplayModeController::weldPopupWindow() +{ + return std::make_unique<sd::DisplayModeToolbarMenu>(this, m_pToolbar); +} + +VclPtr<vcl::Window> DisplayModeController::createVclPopupWindow( vcl::Window* pParent ) +{ + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, + std::make_unique<sd::DisplayModeToolbarMenu>(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; +} + +void DisplayModeController::setToolboxItemImage(const OUString& rImage) +{ + ToolBoxItemId nId; + ToolBox* pToolBox = nullptr; + if (!getToolboxId( nId, &pToolBox )) + return; + + BitmapEx aBmp(rImage); + int targetSize = (pToolBox->GetToolboxButtonSize() == ToolBoxButtonSize::Large) ? 32 : 16; + double scale = 1.0f; + Size size = aBmp.GetSizePixel(); + if (size.Width() > targetSize) + scale = static_cast<double>(targetSize) / static_cast<double>(size.Width()); + if (size.Height() > targetSize) + scale = ::std::min( scale, static_cast<double>(targetSize) / static_cast<double>(size.Height()) ); + aBmp.Scale( scale, scale ); + pToolBox->SetItemImage( nId, Image( aBmp ) ); +} + +// XServiceInfo + +OUString SAL_CALL DisplayModeController::getImplementationName() +{ + return "com.sun.star.comp.sd.DisplayModeController"; +} + +Sequence< OUString > SAL_CALL DisplayModeController::getSupportedServiceNames( ) +{ + css::uno::Sequence<OUString> aRet { "com.sun.star.frame.ToolbarController" }; + return aRet; +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* +com_sun_star_comp_sd_DisplayModeController_get_implementation( css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new sd::DisplayModeController(context)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/controller/slidelayoutcontroller.cxx b/sd/source/ui/controller/slidelayoutcontroller.cxx new file mode 100644 index 000000000..251548a22 --- /dev/null +++ b/sd/source/ui/controller/slidelayoutcontroller.cxx @@ -0,0 +1,380 @@ +/* -*- 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 <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/DrawViewMode.hpp> + +#include <comphelper/propertyvalue.hxx> +#include <vcl/commandinfoprovider.hxx> +#include <vcl/toolbox.hxx> + +#include <svl/cjkoptions.hxx> + +#include <svtools/toolbarmenu.hxx> +#include <svtools/valueset.hxx> + +#include <xmloff/autolayout.hxx> + +#include <strings.hrc> + +#include <bitmaps.hlst> +#include <sdresid.hxx> +#include "slidelayoutcontroller.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; + +namespace sd +{ + +namespace { + +class LayoutToolbarMenu : public WeldToolbarPopup +{ +public: + LayoutToolbarMenu(SlideLayoutController* pController, weld::Widget* pParent, const bool bInsertPage, const OUString& rCommand); + virtual void GrabFocus() override + { + mxLayoutSet1->GrabFocus(); + } + +protected: + DECL_LINK(SelectToolbarMenuHdl, weld::Button&, void); + DECL_LINK(SelectValueSetHdl, ValueSet*, void); + void SelectHdl(AutoLayout eLayout); +private: + rtl::Reference<SlideLayoutController> mxControl; + bool const mbInsertPage; + std::unique_ptr<weld::Frame> mxFrame1; + std::unique_ptr<ValueSet> mxLayoutSet1; + std::unique_ptr<weld::CustomWeld> mxLayoutSetWin1; + std::unique_ptr<weld::Frame> mxFrame2; + std::unique_ptr<ValueSet> mxLayoutSet2; + std::unique_ptr<weld::CustomWeld> mxLayoutSetWin2; + std::unique_ptr<weld::Button> mxMoreButton; +}; + +struct snew_slide_value_info_layout +{ + rtl::OUStringConstExpr msBmpResId; + TranslateId mpStrResId; + AutoLayout maAutoLayout; +}; + +} + +constexpr OUStringLiteral EMPTY = u""; + +const snew_slide_value_info_layout notes[] = +{ + {BMP_SLIDEN_01, STR_AUTOLAYOUT_NOTES, AUTOLAYOUT_NOTES}, + {EMPTY, {}, AUTOLAYOUT_NONE}, +}; + +const snew_slide_value_info_layout handout[] = +{ + {BMP_SLIDEH_01, STR_AUTOLAYOUT_HANDOUT1, AUTOLAYOUT_HANDOUT1}, + {BMP_SLIDEH_02, STR_AUTOLAYOUT_HANDOUT2, AUTOLAYOUT_HANDOUT2}, + {BMP_SLIDEH_03, STR_AUTOLAYOUT_HANDOUT3, AUTOLAYOUT_HANDOUT3}, + {BMP_SLIDEH_04, STR_AUTOLAYOUT_HANDOUT4, AUTOLAYOUT_HANDOUT4}, + {BMP_SLIDEH_06, STR_AUTOLAYOUT_HANDOUT6, AUTOLAYOUT_HANDOUT6}, + {BMP_SLIDEH_09, STR_AUTOLAYOUT_HANDOUT9, AUTOLAYOUT_HANDOUT9}, + {EMPTY, {}, AUTOLAYOUT_NONE}, +}; + +const snew_slide_value_info_layout standard[] = +{ + {BMP_LAYOUT_EMPTY, STR_AUTOLAYOUT_NONE, AUTOLAYOUT_NONE }, + {BMP_LAYOUT_HEAD03, STR_AUTOLAYOUT_TITLE, AUTOLAYOUT_TITLE }, + {BMP_LAYOUT_HEAD02, STR_AUTOLAYOUT_CONTENT, AUTOLAYOUT_TITLE_CONTENT }, + {BMP_LAYOUT_HEAD02A, STR_AUTOLAYOUT_2CONTENT, AUTOLAYOUT_TITLE_2CONTENT }, + {BMP_LAYOUT_HEAD01, STR_AUTOLAYOUT_ONLY_TITLE, AUTOLAYOUT_TITLE_ONLY }, + {BMP_LAYOUT_TEXTONLY, STR_AUTOLAYOUT_ONLY_TEXT, AUTOLAYOUT_ONLY_TEXT }, + {BMP_LAYOUT_HEAD03B, STR_AUTOLAYOUT_2CONTENT_CONTENT, AUTOLAYOUT_TITLE_2CONTENT_CONTENT }, + {BMP_LAYOUT_HEAD03C, STR_AUTOLAYOUT_CONTENT_2CONTENT, AUTOLAYOUT_TITLE_CONTENT_2CONTENT }, + {BMP_LAYOUT_HEAD03A, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT }, + {BMP_LAYOUT_HEAD02B, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT }, + {BMP_LAYOUT_HEAD04, STR_AUTOLAYOUT_4CONTENT, AUTOLAYOUT_TITLE_4CONTENT }, + {BMP_LAYOUT_HEAD06, STR_AUTOLAYOUT_6CONTENT, AUTOLAYOUT_TITLE_6CONTENT }, + {EMPTY, {}, AUTOLAYOUT_NONE} +}; + +const snew_slide_value_info_layout v_standard[] = +{ + // vertical + {BMP_LAYOUT_VERTICAL02, STR_AL_VERT_TITLE_TEXT_CHART, AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT }, + {BMP_LAYOUT_VERTICAL01, STR_AL_VERT_TITLE_VERT_OUTLINE, AUTOLAYOUT_VTITLE_VCONTENT }, + {BMP_LAYOUT_HEAD02, STR_AL_TITLE_VERT_OUTLINE, AUTOLAYOUT_TITLE_VCONTENT }, + {BMP_LAYOUT_HEAD02A, STR_AL_TITLE_VERT_OUTLINE_CLIPART, AUTOLAYOUT_TITLE_2VTEXT }, + {EMPTY, {}, AUTOLAYOUT_NONE} +}; + +static void fillLayoutValueSet( ValueSet* pValue, const snew_slide_value_info_layout* pInfo ) +{ + Size aLayoutItemSize; + for( ; pInfo->mpStrResId; pInfo++ ) + { + OUString aText(SdResId(pInfo->mpStrResId)); + Image aImg(StockImage::Yes, pInfo->msBmpResId); + pValue->InsertItem(static_cast<sal_uInt16>(pInfo->maAutoLayout)+1, aImg, aText); + aLayoutItemSize.setWidth( std::max( aLayoutItemSize.Width(), aImg.GetSizePixel().Width() ) ); + aLayoutItemSize.setHeight( std::max( aLayoutItemSize.Height(), aImg.GetSizePixel().Height() ) ); + } + + aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize ); + Size aSize(pValue->CalcWindowSizePixel(aLayoutItemSize)); + + const sal_Int32 LAYOUT_BORDER_PIX = 7; + + aSize.AdjustWidth((pValue->GetColCount() + 1) * LAYOUT_BORDER_PIX); + aSize.AdjustHeight((pValue->GetLineCount() +1) * LAYOUT_BORDER_PIX); + + pValue->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height()); + pValue->SetOutputSizePixel(aSize); +} + +LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widget* pParent, const bool bInsertPage, const OUString& rCommand) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/simpress/ui/layoutwindow.ui", "LayoutWindow") + , mxControl(pControl) + , mbInsertPage(bInsertPage) + , mxFrame1(m_xBuilder->weld_frame("horiframe")) + , mxLayoutSet1(new ValueSet(nullptr)) + , mxLayoutSetWin1(new weld::CustomWeld(*m_xBuilder, "valueset1", *mxLayoutSet1)) + , mxFrame2(m_xBuilder->weld_frame("vertframe")) + , mxLayoutSet2(new ValueSet(nullptr)) + , mxLayoutSetWin2(new weld::CustomWeld(*m_xBuilder, "valueset2", *mxLayoutSet2)) + , mxMoreButton(m_xBuilder->weld_button("more")) +{ + mxLayoutSet1->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + mxLayoutSet2->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + + DrawViewMode eMode = DrawViewMode_DRAW; + + // find out which view is running + if( m_xFrame.is() ) try + { + Reference< XPropertySet > xControllerSet( m_xFrame->getController(), UNO_QUERY_THROW ); + xControllerSet->getPropertyValue( "DrawViewMode" ) >>= eMode; + } + catch( Exception& ) + { + OSL_ASSERT(false); + } + + const bool bVerticalEnabled = SvtCJKOptions::IsVerticalTextEnabled(); + + mxLayoutSet1->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectValueSetHdl ) ); + + const snew_slide_value_info_layout* pInfo = nullptr; + sal_Int16 nColCount = 4; + switch( eMode ) + { + case DrawViewMode_DRAW: pInfo = &standard[0]; break; + case DrawViewMode_HANDOUT: pInfo = &handout[0]; nColCount = 2; break; + case DrawViewMode_NOTES: pInfo = ¬es[0]; nColCount = 1; break; + default: assert(false); // can't happen, will crash later otherwise + } + + mxLayoutSet1->SetColCount( nColCount ); + + fillLayoutValueSet( mxLayoutSet1.get(), pInfo ); + + bool bUseUILabel = (bVerticalEnabled && eMode == DrawViewMode_DRAW); + if (!bUseUILabel) + { + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rCommand, mxControl->getModuleName()); + mxFrame1->set_label(vcl::CommandInfoProvider::GetLabelForCommand(aProperties)); + } + + if (bVerticalEnabled && eMode == DrawViewMode_DRAW) + { + mxLayoutSet2->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectValueSetHdl ) ); + mxLayoutSet2->SetColCount( 4 ); + mxLayoutSet2->EnableFullItemMode( false ); + + fillLayoutValueSet( mxLayoutSet2.get(), &v_standard[0] ); + + mxFrame2->show(); + } + + if( eMode != DrawViewMode_DRAW ) + return; + + if( !m_xFrame.is() ) + return; + + OUString sSlotStr; + + if( bInsertPage ) + sSlotStr = ".uno:DuplicatePage"; + else + sSlotStr = ".uno:Undo"; + + css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, m_xFrame); + + OUString sSlotTitle; + if( bInsertPage ) + { + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sSlotStr, mxControl->getModuleName()); + sSlotTitle = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); + } + else + sSlotTitle = SdResId( STR_RESET_LAYOUT ); + + mxMoreButton->set_label(sSlotTitle); + mxMoreButton->set_image(xSlotImage); + mxMoreButton->connect_clicked(LINK(this, LayoutToolbarMenu, SelectToolbarMenuHdl)); + mxMoreButton->show(); +} + +IMPL_LINK(LayoutToolbarMenu, SelectValueSetHdl, ValueSet*, pLayoutSet, void) +{ + SelectHdl(static_cast<AutoLayout>(pLayoutSet->GetSelectedItemId()-1)); +} + +IMPL_LINK_NOARG(LayoutToolbarMenu, SelectToolbarMenuHdl, weld::Button&, void) +{ + SelectHdl(AUTOLAYOUT_END); +} + +void LayoutToolbarMenu::SelectHdl(AutoLayout eLayout) +{ + Sequence< PropertyValue > aArgs; + + OUString sCommandURL( mxControl->getCommandURL() ); + + if( eLayout != AUTOLAYOUT_END ) + { + aArgs = { comphelper::makePropertyValue("WhatLayout", static_cast<sal_Int32>(eLayout)) }; + } + else if( mbInsertPage ) + { + sCommandURL = ".uno:DuplicatePage"; + } + + mxControl->dispatchCommand( sCommandURL, aArgs ); + + mxControl->EndPopupMode(); +} + + +/// @throws css::uno::RuntimeException +static OUString SlideLayoutController_getImplementationName() +{ + return "com.sun.star.comp.sd.SlideLayoutController"; +} + +/// @throws RuntimeException +static Sequence< OUString > SlideLayoutController_getSupportedServiceNames() +{ + Sequence<OUString> aSNS { "com.sun.star.frame.ToolbarController" }; + return aSNS; +} + +/// @throws css::uno::RuntimeException +static OUString InsertSlideController_getImplementationName() +{ + return "com.sun.star.comp.sd.InsertSlideController"; +} + +/// @throws RuntimeException +static Sequence< OUString > InsertSlideController_getSupportedServiceNames() +{ + Sequence<OUString> aSNS { "com.sun.star.frame.ToolbarController" }; + return aSNS; +} + +SlideLayoutController::SlideLayoutController(const Reference< uno::XComponentContext >& rxContext, bool bInsertPage) + : svt::PopupWindowController(rxContext, nullptr, OUString()) + , mbInsertPage(bInsertPage) +{ +} + +void SAL_CALL SlideLayoutController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) +{ + svt::PopupWindowController::initialize( aArguments ); + + ToolBox* pToolBox = nullptr; + ToolBoxItemId nId; + if ( getToolboxId( nId, &pToolBox ) ) + { + if ( mbInsertPage ) + pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWN ); + else + pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY ); + } +} + +std::unique_ptr<WeldToolbarPopup> SlideLayoutController::weldPopupWindow() +{ + return std::make_unique<sd::LayoutToolbarMenu>(this, m_pToolbar, mbInsertPage, m_aCommandURL); +} + +VclPtr<vcl::Window> SlideLayoutController::createVclPopupWindow( vcl::Window* pParent ) +{ + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, + std::make_unique<sd::LayoutToolbarMenu>(this, pParent->GetFrameWeld(), mbInsertPage, m_aCommandURL)); + + mxInterimPopover->Show(); + + return mxInterimPopover; +} + +// XServiceInfo + +OUString SAL_CALL SlideLayoutController::getImplementationName() +{ + if( mbInsertPage ) + return InsertSlideController_getImplementationName(); + else + return SlideLayoutController_getImplementationName(); +} + +Sequence< OUString > SAL_CALL SlideLayoutController::getSupportedServiceNames( ) +{ + if( mbInsertPage ) + return InsertSlideController_getSupportedServiceNames(); + else + return SlideLayoutController_getSupportedServiceNames(); +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_sd_SlideLayoutController_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new sd::SlideLayoutController(context, false)); +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_sd_InsertSlideController_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new sd::SlideLayoutController(context, true)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/controller/slidelayoutcontroller.hxx b/sd/source/ui/controller/slidelayoutcontroller.hxx new file mode 100644 index 000000000..ae4a3a09f --- /dev/null +++ b/sd/source/ui/controller/slidelayoutcontroller.hxx @@ -0,0 +1,47 @@ +/* -*- 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 . + */ + +#pragma once + +#include <svtools/popupwindowcontroller.hxx> + +namespace sd +{ +class SlideLayoutController : public svt::PopupWindowController +{ +public: + SlideLayoutController(const css::uno::Reference<css::uno::XComponentContext>& rxContext, + bool bInsertPage); + + virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; + virtual VclPtr<vcl::Window> createVclPopupWindow(vcl::Window* pParent) override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + bool mbInsertPage; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |