bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / source / sidebar / SidebarDockingWindow.cxx
blobfe18b32dae969ad959a9fa8845ce2de242a4e441
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #include "SidebarDockingWindow.hxx"
19 #include "sfx2/sidebar/SidebarChildWindow.hxx"
20 #include "SidebarController.hxx"
22 #include "sfx2/bindings.hxx"
23 #include "sfx2/dispatch.hxx"
24 #include <tools/link.hxx>
26 using namespace css;
27 using namespace cssu;
30 namespace sfx2 { namespace sidebar {
33 SidebarDockingWindow::SidebarDockingWindow(
34 SfxBindings* pSfxBindings,
35 SidebarChildWindow& rChildWindow,
36 Window* pParentWindow,
37 WinBits nBits)
38 : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits),
39 mpSidebarController()
41 // Get the XFrame from the bindings.
42 if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
44 OSL_ASSERT(pSfxBindings!=NULL);
45 OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
47 else
49 const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
50 const SfxFrame& rFrame = pViewFrame->GetFrame();
51 mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
58 SidebarDockingWindow::~SidebarDockingWindow (void)
60 DoDispose();
66 void SidebarDockingWindow::DoDispose (void)
73 void SidebarDockingWindow::GetFocus()
75 mpSidebarController->GetFocusManager().GrabFocus();
81 SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
83 return GetChildWindow_Impl();
89 sal_Bool SidebarDockingWindow::Close (void)
91 if (mpSidebarController.is())
93 // Do not close the floating window.
94 // Dock it and close just the deck instead.
95 SetFloatingMode(sal_False);
96 mpSidebarController->RequestCloseDeck();
97 mpSidebarController->NotifyResize();
98 return sal_False;
100 else
101 return SfxDockingWindow::Close();
107 SfxChildAlignment SidebarDockingWindow::CheckAlignment (
108 SfxChildAlignment eCurrentAlignment,
109 SfxChildAlignment eRequestedAlignment)
111 switch (eRequestedAlignment)
113 case SFX_ALIGN_TOP:
114 case SFX_ALIGN_HIGHESTTOP:
115 case SFX_ALIGN_LOWESTTOP:
116 case SFX_ALIGN_BOTTOM:
117 case SFX_ALIGN_LOWESTBOTTOM:
118 case SFX_ALIGN_HIGHESTBOTTOM:
119 return eCurrentAlignment;
121 case SFX_ALIGN_LEFT:
122 case SFX_ALIGN_RIGHT:
123 case SFX_ALIGN_FIRSTLEFT:
124 case SFX_ALIGN_LASTLEFT:
125 case SFX_ALIGN_FIRSTRIGHT:
126 case SFX_ALIGN_LASTRIGHT:
127 return eRequestedAlignment;
129 default:
130 return eRequestedAlignment;
135 } } // end of namespace sfx2::sidebar