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 :
31 : namespace sfx2 { namespace sidebar {
32 :
33 :
34 4700 : SidebarDockingWindow::SidebarDockingWindow(
35 : SfxBindings* pSfxBindings,
36 : SidebarChildWindow& rChildWindow,
37 : vcl::Window* pParentWindow,
38 : WinBits nBits)
39 : : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits),
40 4700 : mpSidebarController()
41 : {
42 : // Get the XFrame from the bindings.
43 4700 : if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
44 : {
45 : OSL_ASSERT(pSfxBindings!=NULL);
46 : OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
47 : }
48 : else
49 : {
50 4700 : const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
51 4700 : const SfxFrame& rFrame = pViewFrame->GetFrame();
52 4700 : mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
53 : }
54 4700 : }
55 :
56 :
57 :
58 :
59 14100 : SidebarDockingWindow::~SidebarDockingWindow (void)
60 : {
61 4700 : DoDispose();
62 9400 : }
63 :
64 :
65 :
66 :
67 4700 : void SidebarDockingWindow::DoDispose (void)
68 : {
69 4700 : Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
70 4700 : mpSidebarController.clear();
71 4700 : if (xComponent.is())
72 : {
73 4700 : xComponent->dispose();
74 4700 : }
75 4700 : }
76 :
77 :
78 :
79 :
80 4 : void SidebarDockingWindow::GetFocus()
81 : {
82 4 : if (mpSidebarController.is())
83 0 : mpSidebarController->GetFocusManager().GrabFocus();
84 : else
85 4 : SfxDockingWindow::GetFocus();
86 4 : }
87 :
88 :
89 :
90 :
91 0 : bool SidebarDockingWindow::Close (void)
92 : {
93 0 : if (mpSidebarController.is())
94 : {
95 : // Do not close the floating window.
96 : // Dock it and close just the deck instead.
97 0 : SetFloatingMode(false);
98 0 : mpSidebarController->RequestCloseDeck();
99 0 : mpSidebarController->NotifyResize();
100 0 : return false;
101 : }
102 : else
103 0 : return SfxDockingWindow::Close();
104 : }
105 :
106 :
107 :
108 :
109 4624 : SfxChildAlignment SidebarDockingWindow::CheckAlignment (
110 : SfxChildAlignment eCurrentAlignment,
111 : SfxChildAlignment eRequestedAlignment)
112 : {
113 4624 : switch (eRequestedAlignment)
114 : {
115 : case SFX_ALIGN_TOP:
116 : case SFX_ALIGN_HIGHESTTOP:
117 : case SFX_ALIGN_LOWESTTOP:
118 : case SFX_ALIGN_BOTTOM:
119 : case SFX_ALIGN_LOWESTBOTTOM:
120 : case SFX_ALIGN_HIGHESTBOTTOM:
121 0 : return eCurrentAlignment;
122 :
123 : case SFX_ALIGN_LEFT:
124 : case SFX_ALIGN_RIGHT:
125 : case SFX_ALIGN_FIRSTLEFT:
126 : case SFX_ALIGN_LASTLEFT:
127 : case SFX_ALIGN_FIRSTRIGHT:
128 : case SFX_ALIGN_LASTRIGHT:
129 4624 : return eRequestedAlignment;
130 :
131 : default:
132 0 : return eRequestedAlignment;
133 : }
134 : }
135 :
136 :
137 951 : } } // end of namespace sfx2::sidebar
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|