Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #include "SidebarDockingWindow.hxx"
20 : #include <sfx2/sidebar/SidebarChildWindow.hxx>
21 : #include "SidebarController.hxx"
22 :
23 : #include <sfx2/bindings.hxx>
24 : #include <sfx2/dispatch.hxx>
25 : #include <tools/link.hxx>
26 :
27 : using namespace css;
28 : using namespace css::uno;
29 :
30 : namespace sfx2 { namespace sidebar {
31 :
32 3155 : SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChildWindow& rChildWindow,
33 : vcl::Window* pParentWindow, WinBits nBits)
34 : : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits)
35 3155 : , mpSidebarController()
36 : {
37 : // Get the XFrame from the bindings.
38 3155 : if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
39 : {
40 : OSL_ASSERT(pSfxBindings!=NULL);
41 : OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
42 : }
43 : else
44 : {
45 3155 : const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
46 3155 : const SfxFrame& rFrame = pViewFrame->GetFrame();
47 3155 : mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
48 : }
49 3155 : }
50 :
51 9453 : SidebarDockingWindow::~SidebarDockingWindow()
52 : {
53 3151 : disposeOnce();
54 6302 : }
55 :
56 3151 : void SidebarDockingWindow::dispose()
57 : {
58 3151 : DoDispose();
59 3151 : SfxDockingWindow::dispose();
60 3151 : }
61 :
62 3151 : void SidebarDockingWindow::DoDispose()
63 : {
64 3151 : Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
65 3151 : mpSidebarController.clear();
66 3151 : if (xComponent.is())
67 : {
68 3151 : xComponent->dispose();
69 3151 : }
70 3151 : }
71 :
72 0 : void SidebarDockingWindow::GetFocus()
73 : {
74 0 : if (mpSidebarController.is())
75 0 : mpSidebarController->GetFocusManager().GrabFocus();
76 : else
77 0 : SfxDockingWindow::GetFocus();
78 0 : }
79 :
80 : // fdo#87217
81 0 : bool SidebarDockingWindow::Close()
82 : {
83 0 : return SfxDockingWindow::Close();
84 : }
85 :
86 3058 : SfxChildAlignment SidebarDockingWindow::CheckAlignment (
87 : SfxChildAlignment eCurrentAlignment,
88 : SfxChildAlignment eRequestedAlignment)
89 : {
90 3058 : switch (eRequestedAlignment)
91 : {
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 0 : return eCurrentAlignment;
99 :
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 3058 : return eRequestedAlignment;
107 :
108 : default:
109 0 : return eRequestedAlignment;
110 : }
111 : }
112 :
113 : } } // end of namespace sfx2::sidebar
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|