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* pSfxBindings,
41     SidebarChildWindow& rChildWindow,
42     Window* pParentWindow,
43     WinBits nBits)
44     : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits),
45       mpSidebarController()
46 {
47     // Get the XFrame from the bindings.
48     if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
49     {
50         OSL_ASSERT(pSfxBindings!=NULL);
51         OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
52     }
53     else
54     {
55         const SfxViewFrame* pViewFrame = pSfxBindings->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     mpSidebarController->GetFocusManager().GrabFocus();
82 }
83 
84 
85 
86 
87 long SidebarDockingWindow::PreNotify (NotifyEvent& rEvent)
88 {
89     switch (rEvent.GetType())
90     {
91         case EVENT_KEYINPUT:
92         {
93             const KeyEvent* pKeyEvent = rEvent.GetKeyEvent();
94             if (pKeyEvent != NULL)
95                 return mpSidebarController->GetFocusManager().NotifyDockingWindowEvent(*pKeyEvent);
96             else
97                 break;
98         }
99 
100         case EVENT_GETFOCUS:
101             OSL_TRACE("");
102             break;
103 
104     }
105 
106     return SfxDockingWindow::PreNotify(rEvent);
107 }
108 
109 
110 
111 
112 SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
113 {
114     return GetChildWindow_Impl();
115 }
116 
117 
118 
119 
120 sal_Bool SidebarDockingWindow::Close (void)
121 {
122     if (mpSidebarController.is())
123     {
124         // Do not close the floating window.
125         // Dock it and close just the deck instead.
126         mpSidebarController->RequestCloseDeck();
127         SetFloatingMode(sal_False);
128         mpSidebarController->NotifyResize();
129         return sal_False;
130     }
131     else
132         return SfxDockingWindow::Close();
133 }
134 
135 
136 } } // end of namespace sfx2::sidebar
137