diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-13 11:16:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-13 14:38:03 +0200 |
commit | 24d15ba86c00178238f3f8ef6c548a0d19338aa4 (patch) | |
tree | 104c371fde6f596638efdca0e6088b8439b5ac98 /sd | |
parent | 4f20da3b330a5aad88a51f454c0914789d9c2457 (diff) |
loplugin:mergeclasses sd::TitledDockingWindow with sd::PaneDockingWindow
Change-Id: I77314048173ebba0dc0e03f710607b74e73f0bde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135719
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/Library_sd.mk | 1 | ||||
-rw-r--r-- | sd/inc/pch/precompiled_sd.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/dlg/PaneChildWindows.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/dlg/PaneDockingWindow.cxx | 127 | ||||
-rw-r--r-- | sd/source/ui/dlg/titledockwin.cxx | 83 | ||||
-rw-r--r-- | sd/source/ui/framework/factories/ChildWindowPane.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/inc/PaneDockingWindow.hxx | 66 | ||||
-rw-r--r-- | sd/source/ui/inc/titledockwin.hxx | 44 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/view/SlideSorterView.cxx | 12 |
9 files changed, 117 insertions, 227 deletions
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 1ded5eadc8ba..8b441fe0542a 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -212,7 +212,6 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/dlg/LayerTabBar \ sd/source/ui/dlg/NavigatorChildWindow \ sd/source/ui/dlg/PaneChildWindows \ - sd/source/ui/dlg/PaneDockingWindow \ sd/source/ui/dlg/PaneShells \ sd/source/ui/dlg/SpellDialogChildWindow \ sd/source/ui/dlg/TemplateScanner \ diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx index f2ee62c48223..7654305cc1fc 100644 --- a/sd/inc/pch/precompiled_sd.hxx +++ b/sd/inc/pch/precompiled_sd.hxx @@ -514,7 +514,6 @@ #include <OutlineViewShell.hxx> #include <Outliner.hxx> #include <PaneChildWindows.hxx> -#include <PaneDockingWindow.hxx> #include <PresentationViewShell.hxx> #include <PreviewRenderer.hxx> #include <SdShapeTypes.hxx> diff --git a/sd/source/ui/dlg/PaneChildWindows.cxx b/sd/source/ui/dlg/PaneChildWindows.cxx index 7f73e005b4c5..320ce2a74b3d 100644 --- a/sd/source/ui/dlg/PaneChildWindows.cxx +++ b/sd/source/ui/dlg/PaneChildWindows.cxx @@ -18,7 +18,7 @@ */ #include <PaneChildWindows.hxx> -#include <PaneDockingWindow.hxx> +#include <titledockwin.hxx> #include <ViewShellBase.hxx> #include <framework/FrameworkHelper.hxx> #include <app.hrc> @@ -43,7 +43,7 @@ PaneChildWindow::PaneChildWindow ( TranslateId pTitleBarResId) : SfxChildWindow (pParentWindow, nId) { - SetWindow( VclPtr<PaneDockingWindow>::Create( + SetWindow( VclPtr<TitledDockingWindow>::Create( pBindings, this, pParentWindow, @@ -64,7 +64,7 @@ PaneChildWindow::PaneChildWindow ( PaneChildWindow::~PaneChildWindow() { ViewShellBase* pBase = nullptr; - PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(GetWindow()); + TitledDockingWindow* pDockingWindow = dynamic_cast<TitledDockingWindow*>(GetWindow()); if (pDockingWindow != nullptr) pBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame()); diff --git a/sd/source/ui/dlg/PaneDockingWindow.cxx b/sd/source/ui/dlg/PaneDockingWindow.cxx deleted file mode 100644 index 6f7332ad9b96..000000000000 --- a/sd/source/ui/dlg/PaneDockingWindow.cxx +++ /dev/null @@ -1,127 +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 <PaneDockingWindow.hxx> -#include <ViewShellBase.hxx> -#include <framework/FrameworkHelper.hxx> - -#include <sfx2/dispatch.hxx> -#include <vcl/splitwin.hxx> -#include <tools/wintypes.hxx> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::drawing::framework; -using ::sd::TitledDockingWindow; - -namespace sd { - -PaneDockingWindow::PaneDockingWindow( - SfxBindings *_pBindings, SfxChildWindow *pChildWindow, vcl::Window* pParent, - const OUString& rsTitle ) - : TitledDockingWindow(_pBindings, pChildWindow, pParent) -{ - SetTitle(rsTitle); - SetSizePixel(LogicToPixel(Size(80,200), MapMode(MapUnit::MapAppFont))); -} - -PaneDockingWindow::~PaneDockingWindow() -{ -} - -void PaneDockingWindow::StateChanged( StateChangedType nType ) -{ - switch (nType) - { - case StateChangedType::InitShow: - Resize(); - GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL); - break; - - case StateChangedType::Visible: - { - // The visibility of the docking window has changed. Tell the - // ConfigurationController so that it can activate or deactivate - // a/the view for the pane. - // Without this the side panes remain empty after closing an - // in-place slide show. - ViewShellBase* pBase = ViewShellBase::GetViewShellBase( - GetBindings().GetDispatcher()->GetFrame()); - if (pBase != nullptr) - { - framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration(); - } - } - break; - - default:; - } - SfxDockingWindow::StateChanged (nType); -} - -void PaneDockingWindow::MouseButtonDown (const MouseEvent& rEvent) -{ - if (rEvent.GetButtons() == MOUSE_LEFT) - { - // For some strange reason we have to set the WB_DIALOGCONTROL at - // the content window in order to have it pass focus to its content - // window. Without setting this flag here that works only on views - // that have not been taken from the cash and relocated to this pane - // docking window. - GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL); - GetContentWindow().GrabFocus(); - } - SfxDockingWindow::MouseButtonDown(rEvent); -} - -void PaneDockingWindow::SetValidSizeRange (const Range& rValidSizeRange) -{ - SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent()); - if (pSplitWindow == nullptr) - return; - - const sal_uInt16 nId (pSplitWindow->GetItemId(static_cast< vcl::Window*>(this))); - const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); - // Because the PaneDockingWindow paints its own decoration, we have - // to compensate the valid size range for that. - const SvBorder aBorder (GetDecorationBorder()); - sal_Int32 nCompensation (pSplitWindow->IsHorizontal() - ? aBorder.Top() + aBorder.Bottom() - : aBorder.Left() + aBorder.Right()); - pSplitWindow->SetItemSizeRange( - nSetId, - Range( - rValidSizeRange.Min() + nCompensation, - rValidSizeRange.Max() + nCompensation)); -} - -PaneDockingWindow::Orientation PaneDockingWindow::GetOrientation() const -{ - SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent()); - if (pSplitWindow == nullptr) - return UnknownOrientation; - else if (pSplitWindow->IsHorizontal()) - return HorizontalOrientation; - else - return VerticalOrientation; -} - -} // end of namespace ::sd - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/titledockwin.cxx b/sd/source/ui/dlg/titledockwin.cxx index f2aa744c200d..5a3f04c70f30 100644 --- a/sd/source/ui/dlg/titledockwin.cxx +++ b/sd/source/ui/dlg/titledockwin.cxx @@ -17,13 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <framework/FrameworkHelper.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <svl/eitem.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> +#include <vcl/splitwin.hxx> #include <vcl/toolbox.hxx> +#include <ViewShellBase.hxx> #include <bitmaps.hlst> #include <strings.hrc> #include <sdresid.hxx> @@ -32,7 +35,7 @@ namespace sd { //= TitledDockingWindow - TitledDockingWindow::TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, vcl::Window* i_pParent ) + TitledDockingWindow::TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, vcl::Window* i_pParent, const OUString& rsTitle ) :SfxDockingWindow( i_pBindings, i_pChildWindow, i_pParent, WB_MOVEABLE|WB_CLOSEABLE|WB_DOCKABLE|WB_HIDE|WB_3DLOOK ) ,m_aToolbox( VclPtr<ToolBox>::Create(this) ) ,m_aContentWindow( VclPtr<vcl::Window>::Create(this, WB_DIALOGCONTROL) ) @@ -47,6 +50,10 @@ namespace sd impl_resetToolBox(); m_aContentWindow->Show(); + + m_sTitle = rsTitle; + Invalidate(); + SetSizePixel(LogicToPixel(Size(80,200), MapMode(MapUnit::MapAppFont))); } TitledDockingWindow::~TitledDockingWindow() @@ -61,13 +68,6 @@ namespace sd SfxDockingWindow::dispose(); } - void TitledDockingWindow::SetTitle( const OUString& i_rTitle ) - { - m_sTitle = i_rTitle; - Invalidate(); - } - - void TitledDockingWindow::SetText( const OUString& i_rText ) { SfxDockingWindow::SetText( i_rText ); @@ -223,11 +223,30 @@ namespace sd void TitledDockingWindow::StateChanged( StateChangedType i_nType ) { - switch ( i_nType ) + switch (i_nType) { case StateChangedType::InitShow: + Resize(); + GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL); impl_layout(); break; + + case StateChangedType::Visible: + { + // The visibility of the docking window has changed. Tell the + // ConfigurationController so that it can activate or deactivate + // a/the view for the pane. + // Without this the side panes remain empty after closing an + // in-place slide show. + ViewShellBase* pBase = ViewShellBase::GetViewShellBase( + GetBindings().GetDispatcher()->GetFrame()); + if (pBase != nullptr) + { + framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration(); + } + } + break; + default:; } SfxDockingWindow::StateChanged( i_nType ); @@ -254,6 +273,52 @@ namespace sd } } + void TitledDockingWindow::MouseButtonDown (const MouseEvent& rEvent) + { + if (rEvent.GetButtons() == MOUSE_LEFT) + { + // For some strange reason we have to set the WB_DIALOGCONTROL at + // the content window in order to have it pass focus to its content + // window. Without setting this flag here that works only on views + // that have not been taken from the cash and relocated to this pane + // docking window. + GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL); + GetContentWindow().GrabFocus(); + } + SfxDockingWindow::MouseButtonDown(rEvent); + } + + void TitledDockingWindow::SetValidSizeRange (const Range& rValidSizeRange) + { + SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent()); + if (pSplitWindow == nullptr) + return; + + const sal_uInt16 nId (pSplitWindow->GetItemId(static_cast< vcl::Window*>(this))); + const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); + // Because the TitledDockingWindow paints its own decoration, we have + // to compensate the valid size range for that. + const SvBorder aBorder (GetDecorationBorder()); + sal_Int32 nCompensation (pSplitWindow->IsHorizontal() + ? aBorder.Top() + aBorder.Bottom() + : aBorder.Left() + aBorder.Right()); + pSplitWindow->SetItemSizeRange( + nSetId, + Range( + rValidSizeRange.Min() + nCompensation, + rValidSizeRange.Max() + nCompensation)); + } + + TitledDockingWindow::Orientation TitledDockingWindow::GetOrientation() const + { + SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent()); + if (pSplitWindow == nullptr) + return UnknownOrientation; + else if (pSplitWindow->IsHorizontal()) + return HorizontalOrientation; + else + return VerticalOrientation; + } } // namespace sfx2 diff --git a/sd/source/ui/framework/factories/ChildWindowPane.cxx b/sd/source/ui/framework/factories/ChildWindowPane.cxx index 136f6fcb78b2..8fc184c0578b 100644 --- a/sd/source/ui/framework/factories/ChildWindowPane.cxx +++ b/sd/source/ui/framework/factories/ChildWindowPane.cxx @@ -25,7 +25,7 @@ #include "ChildWindowPane.hxx" -#include <PaneDockingWindow.hxx> +#include <titledockwin.hxx> #include <ViewShellBase.hxx> #include <ViewShellManager.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -164,7 +164,7 @@ vcl::Window* ChildWindowPane::GetWindow() // From the child window get the docking window and from that the // content window that is the container for the actual content. - PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>( + TitledDockingWindow* pDockingWindow = dynamic_cast<TitledDockingWindow*>( pChildWindow->GetWindow()); if (pDockingWindow == nullptr) break; diff --git a/sd/source/ui/inc/PaneDockingWindow.hxx b/sd/source/ui/inc/PaneDockingWindow.hxx deleted file mode 100644 index c69cb6f94904..000000000000 --- a/sd/source/ui/inc/PaneDockingWindow.hxx +++ /dev/null @@ -1,66 +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 . - */ - -#pragma once - -#include "titledockwin.hxx" - -namespace sd { - - class PaneDockingWindow : public ::sd::TitledDockingWindow -{ -public: - /** Create a new docking window. - @param pBindings - Used, among others, to determine the ViewShellBase and - PaneManager that manage the new docking window. - @param pChildWindow - This child window is the logical container for the new docking - window. - @param pParent - The parent window of the new docking window. - @param rsTitle - the initial title - */ - PaneDockingWindow ( - SfxBindings *pBindings, - SfxChildWindow *pChildWindow, - vcl::Window* pParent, - const OUString& rsTitle); - - virtual ~PaneDockingWindow() override; - virtual void StateChanged( StateChangedType nType ) override; - virtual void MouseButtonDown (const MouseEvent& rEvent) override; - /** When docked the given range is passed to the parent SplitWindow. - */ - void SetValidSizeRange (const Range& rValidSizeRange); - - enum Orientation { HorizontalOrientation, VerticalOrientation, UnknownOrientation }; - /** When the PaneDockingWindow is docked and managed by a split window - it can derive its orientation from the orientation of the split - window and return either HorizontalOrientation or - VerticalOrientation. - Otherwise UnknownOrientation is returned. - */ - Orientation GetOrientation() const; -}; - -} // end of namespace ::sd - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/titledockwin.hxx b/sd/source/ui/inc/titledockwin.hxx index 59e7e04b3531..bdbd386ba62a 100644 --- a/sd/source/ui/inc/titledockwin.hxx +++ b/sd/source/ui/inc/titledockwin.hxx @@ -27,21 +27,31 @@ class ToolBox; namespace sd { - class TitledDockingWindow : public SfxDockingWindow + class TitledDockingWindow final : public SfxDockingWindow { public: + /** Create a new docking window. + @param pBindings + Used, among others, to determine the ViewShellBase and + PaneManager that manage the new docking window. + @param pChildWindow + This child window is the logical container for the new docking + window. + @param pParent + The parent window of the new docking window. + @param rsTitle + the initial title + */ TitledDockingWindow( - SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, - vcl::Window* i_pParent + SfxBindings* i_pBindings, + SfxChildWindow* i_pChildWindow, + vcl::Window* i_pParent, + const OUString& rsTitle ); virtual ~TitledDockingWindow() override; virtual void dispose() override; - /** sets a title to be displayed in the docking window - */ - void SetTitle( const OUString& i_rTitle ); - /** returns the content window, which is to be used as parent window for any content to be displayed in the docking window. */ @@ -53,26 +63,36 @@ namespace sd */ const SvBorder& GetDecorationBorder() const { return m_aBorder; } - protected: + /** When docked the given range is passed to the parent SplitWindow. + */ + void SetValidSizeRange (const Range& rValidSizeRange); + + enum Orientation { HorizontalOrientation, VerticalOrientation, UnknownOrientation }; + /** When the TitledDockingWindow is docked and managed by a split window + it can derive its orientation from the orientation of the split + window and return either HorizontalOrientation or + VerticalOrientation. + Otherwise UnknownOrientation is returned. + */ + Orientation GetOrientation() const; + + private: // Window overridables virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& i_rArea) override; virtual void Resize() override; virtual void StateChanged( StateChangedType i_nType ) override; virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent ) override; virtual void SetText( const OUString& i_rText ) override; - + virtual void MouseButtonDown (const MouseEvent& rEvent) override; virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; - protected: /** internal version of ResetToolBox */ void impl_resetToolBox(); - private: DECL_LINK(OnToolboxItemSelected, ToolBox*, void); void impl_layout(); - private: OUString m_sTitle; VclPtr<ToolBox> m_aToolbox; VclPtr<Window> m_aContentWindow; diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index 390541e3712d..cf59e14d0120 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -35,7 +35,7 @@ #include <model/SlsPageDescriptor.hxx> #include <cache/SlsPageCache.hxx> #include <cache/SlsPageCacheManager.hxx> -#include <PaneDockingWindow.hxx> +#include <titledockwin.hxx> #include <sdpage.hxx> #include <Window.hxx> @@ -316,10 +316,10 @@ void SlideSorterView::UpdateOrientation() { // Get access to the docking window. vcl::Window* pWindow = mrSlideSorter.GetContentWindow(); - PaneDockingWindow* pDockingWindow = nullptr; + TitledDockingWindow* pDockingWindow = nullptr; while (pWindow!=nullptr && pDockingWindow==nullptr) { - pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow); + pDockingWindow = dynamic_cast<TitledDockingWindow*>(pWindow); pWindow = pWindow->GetParent(); } @@ -329,7 +329,7 @@ void SlideSorterView::UpdateOrientation() Application::GetSettings().GetStyleSettings().GetScrollBarSize()); switch (pDockingWindow->GetOrientation()) { - case PaneDockingWindow::HorizontalOrientation: + case TitledDockingWindow::HorizontalOrientation: if (SetOrientation(Layouter::HORIZONTAL)) { const Range aRange (mpLayouter->GetValidVerticalSizeRange()); @@ -339,7 +339,7 @@ void SlideSorterView::UpdateOrientation() } break; - case PaneDockingWindow::VerticalOrientation: + case TitledDockingWindow::VerticalOrientation: if (SetOrientation(Layouter::VERTICAL)) { const Range aRange (mpLayouter->GetValidHorizontalSizeRange()); @@ -349,7 +349,7 @@ void SlideSorterView::UpdateOrientation() } break; - case PaneDockingWindow::UnknownOrientation: + case TitledDockingWindow::UnknownOrientation: if (SetOrientation(Layouter::GRID)) { const sal_Int32 nAdditionalSize (10); |