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
SidebarDockingWindow(SfxBindings * pSfxBindings,SidebarChildWindow & rChildWindow,Window * pParentWindow,WinBits nBits)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
~SidebarDockingWindow(void)64 SidebarDockingWindow::~SidebarDockingWindow (void)
65 {
66 DoDispose();
67 }
68
69
70
71
DoDispose(void)72 void SidebarDockingWindow::DoDispose (void)
73 {
74 Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
75 mpSidebarController.clear();
76 if (xComponent.is())
77 {
78 xComponent->dispose();
79 }
80 }
81
82
83
84
GetFocus()85 void SidebarDockingWindow::GetFocus()
86 {
87 if (mpSidebarController.is())
88 {
89 mpSidebarController->GetFocusManager().GrabFocus();
90 }
91 }
92
93
94
95
GetChildWindow(void)96 SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
97 {
98 return GetChildWindow_Impl();
99 }
100
101
102
103
Close(void)104 sal_Bool SidebarDockingWindow::Close (void)
105 {
106 if (mpSidebarController.is())
107 {
108 // Do not close the floating window.
109 // Dock it and close just the deck instead.
110 SetFloatingMode(sal_False);
111 mpSidebarController->RequestCloseDeck();
112 mpSidebarController->NotifyResize();
113 return sal_False;
114 }
115 else
116 return SfxDockingWindow::Close();
117 }
118
119
120
121
CheckAlignment(SfxChildAlignment eCurrentAlignment,SfxChildAlignment eRequestedAlignment)122 SfxChildAlignment SidebarDockingWindow::CheckAlignment (
123 SfxChildAlignment eCurrentAlignment,
124 SfxChildAlignment eRequestedAlignment)
125 {
126 switch (eRequestedAlignment)
127 {
128 case SFX_ALIGN_TOP:
129 case SFX_ALIGN_HIGHESTTOP:
130 case SFX_ALIGN_LOWESTTOP:
131 case SFX_ALIGN_BOTTOM:
132 case SFX_ALIGN_LOWESTBOTTOM:
133 case SFX_ALIGN_HIGHESTBOTTOM:
134 return eCurrentAlignment;
135
136 case SFX_ALIGN_LEFT:
137 case SFX_ALIGN_RIGHT:
138 case SFX_ALIGN_FIRSTLEFT:
139 case SFX_ALIGN_LASTLEFT:
140 case SFX_ALIGN_FIRSTRIGHT:
141 case SFX_ALIGN_LASTRIGHT:
142 return eRequestedAlignment;
143
144 default:
145 return eRequestedAlignment;
146 }
147 }
148
149
150 } } // end of namespace sfx2::sidebar
151