1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include "precompiled_sfx2.hxx"
23 
24 #include "SidebarDockingWindow.hxx"
25 #include "sfx2/sidebar/SidebarChildWindow.hxx"
26 #include "SidebarController.hxx"
27 
28 #include "sfx2/bindings.hxx"
29 #include "sfx2/dispatch.hxx"
30 #include <tools/link.hxx>
31 
32 using namespace css;
33 using namespace cssu;
34 
35 
36 namespace sfx2 { namespace sidebar {
37 
38 
39 SidebarDockingWindow::SidebarDockingWindow(
40     SfxBindings* pBindings,
41     SidebarChildWindow& rChildWindow,
42     Window* pParent,
43     WinBits nBits)
44     : SfxDockingWindow(pBindings, &rChildWindow, pParent, nBits),
45       mpSidebarController()
46 {
47     // Get the XFrame from the bindings.
48     if (pBindings==NULL || pBindings->GetDispatcher()==NULL)
49     {
50         OSL_ASSERT(pBindings!=NULL);
51         OSL_ASSERT(pBindings->GetDispatcher()!=NULL);
52     }
53     else
54     {
55         const SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame();
56         const SfxFrame& rFrame = pViewFrame->GetFrame();
57         mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
58     }
59 }
60 
61 
62 
63 
64 SidebarDockingWindow::~SidebarDockingWindow (void)
65 {
66     DoDispose();
67 }
68 
69 
70 
71 
72 void SidebarDockingWindow::DoDispose (void)
73 {
74 }
75 
76 
77 
78 
79 void SidebarDockingWindow::GetFocus()
80 {
81     SfxDockingWindow::GetFocus();
82 }
83 
84 
85 
86 
87 SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
88 {
89     return GetChildWindow_Impl();
90 }
91 
92 
93 
94 
95 sal_Bool SidebarDockingWindow::Close (void)
96 {
97     if (mpSidebarController.is())
98     {
99         // Do not close the floating window.
100         // Dock it and close just the deck instead.
101         mpSidebarController->CloseDeck();
102         SetFloatingMode(sal_False);
103         mpSidebarController->NotifyResize();
104         return sal_False;
105     }
106     else
107         return SfxDockingWindow::Close();
108 }
109 
110 
111 } } // end of namespace sfx2::sidebar
112