Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / sidebar / SidebarDockingWindow.cxx
blob2cc2ae76843d328e46c66f377f7cfed105292cc4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "SidebarDockingWindow.hxx"
20 #include <sfx2/sidebar/SidebarChildWindow.hxx>
21 #include "SidebarController.hxx"
23 #include <sfx2/bindings.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <tools/link.hxx>
27 using namespace css;
28 using namespace css::uno;
30 namespace sfx2 { namespace sidebar {
32 SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChildWindow& rChildWindow,
33 vcl::Window* pParentWindow, WinBits nBits)
34 : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits)
35 , mpSidebarController()
37 // Get the XFrame from the bindings.
38 if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
40 OSL_ASSERT(pSfxBindings!=NULL);
41 OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
43 else
45 const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
46 const SfxFrame& rFrame = pViewFrame->GetFrame();
47 mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
51 SidebarDockingWindow::~SidebarDockingWindow()
53 disposeOnce();
56 void SidebarDockingWindow::dispose()
58 DoDispose();
59 SfxDockingWindow::dispose();
62 void SidebarDockingWindow::DoDispose()
64 Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
65 mpSidebarController.clear();
66 if (xComponent.is())
68 xComponent->dispose();
72 void SidebarDockingWindow::GetFocus()
74 if (mpSidebarController.is())
75 mpSidebarController->GetFocusManager().GrabFocus();
76 else
77 SfxDockingWindow::GetFocus();
80 // fdo#87217
81 bool SidebarDockingWindow::Close()
83 return SfxDockingWindow::Close();
86 SfxChildAlignment SidebarDockingWindow::CheckAlignment (
87 SfxChildAlignment eCurrentAlignment,
88 SfxChildAlignment eRequestedAlignment)
90 switch (eRequestedAlignment)
92 case SfxChildAlignment::TOP:
93 case SfxChildAlignment::HIGHESTTOP:
94 case SfxChildAlignment::LOWESTTOP:
95 case SfxChildAlignment::BOTTOM:
96 case SfxChildAlignment::LOWESTBOTTOM:
97 case SfxChildAlignment::HIGHESTBOTTOM:
98 return eCurrentAlignment;
100 case SfxChildAlignment::LEFT:
101 case SfxChildAlignment::RIGHT:
102 case SfxChildAlignment::FIRSTLEFT:
103 case SfxChildAlignment::LASTLEFT:
104 case SfxChildAlignment::FIRSTRIGHT:
105 case SfxChildAlignment::LASTRIGHT:
106 return eRequestedAlignment;
108 default:
109 return eRequestedAlignment;
113 } } // end of namespace sfx2::sidebar
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */