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 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 85 void SidebarDockingWindow::GetFocus() 86 { 87 mpSidebarController->GetFocusManager().GrabFocus(); 88 } 89 90 91 92 93 SfxChildWindow* SidebarDockingWindow::GetChildWindow (void) 94 { 95 return GetChildWindow_Impl(); 96 } 97 98 99 100 101 sal_Bool SidebarDockingWindow::Close (void) 102 { 103 if (mpSidebarController.is()) 104 { 105 // Do not close the floating window. 106 // Dock it and close just the deck instead. 107 SetFloatingMode(sal_False); 108 mpSidebarController->RequestCloseDeck(); 109 mpSidebarController->NotifyResize(); 110 return sal_False; 111 } 112 else 113 return SfxDockingWindow::Close(); 114 } 115 116 117 118 119 SfxChildAlignment SidebarDockingWindow::CheckAlignment ( 120 SfxChildAlignment eCurrentAlignment, 121 SfxChildAlignment eRequestedAlignment) 122 { 123 switch (eRequestedAlignment) 124 { 125 case SFX_ALIGN_TOP: 126 case SFX_ALIGN_HIGHESTTOP: 127 case SFX_ALIGN_LOWESTTOP: 128 case SFX_ALIGN_BOTTOM: 129 case SFX_ALIGN_LOWESTBOTTOM: 130 case SFX_ALIGN_HIGHESTBOTTOM: 131 return eCurrentAlignment; 132 133 case SFX_ALIGN_LEFT: 134 case SFX_ALIGN_RIGHT: 135 case SFX_ALIGN_FIRSTLEFT: 136 case SFX_ALIGN_LASTLEFT: 137 case SFX_ALIGN_FIRSTRIGHT: 138 case SFX_ALIGN_LASTRIGHT: 139 return eRequestedAlignment; 140 141 default: 142 return eRequestedAlignment; 143 } 144 } 145 146 147 } } // end of namespace sfx2::sidebar 148