122de8995SAndre Fischer /**************************************************************
222de8995SAndre Fischer  *
322de8995SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
422de8995SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
522de8995SAndre Fischer  * distributed with this work for additional information
622de8995SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
722de8995SAndre Fischer  * to you under the Apache License, Version 2.0 (the
822de8995SAndre Fischer  * "License"); you may not use this file except in compliance
922de8995SAndre Fischer  * with the License.  You may obtain a copy of the License at
1022de8995SAndre Fischer  *
1122de8995SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
1222de8995SAndre Fischer  *
1322de8995SAndre Fischer  * Unless required by applicable law or agreed to in writing,
1422de8995SAndre Fischer  * software distributed under the License is distributed on an
1522de8995SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1622de8995SAndre Fischer  * KIND, either express or implied.  See the License for the
1722de8995SAndre Fischer  * specific language governing permissions and limitations
1822de8995SAndre Fischer  * under the License.
1922de8995SAndre Fischer  *
2022de8995SAndre Fischer  *************************************************************/
2122de8995SAndre Fischer 
2222de8995SAndre Fischer #include "precompiled_sfx2.hxx"
2322de8995SAndre Fischer 
2422de8995SAndre Fischer #include "SidebarDockingWindow.hxx"
257a32b0c8SAndre Fischer #include "sfx2/sidebar/SidebarChildWindow.hxx"
2622de8995SAndre Fischer #include "SidebarController.hxx"
2722de8995SAndre Fischer 
2822de8995SAndre Fischer #include "sfx2/bindings.hxx"
2922de8995SAndre Fischer #include "sfx2/dispatch.hxx"
3022de8995SAndre Fischer #include <tools/link.hxx>
3122de8995SAndre Fischer 
3222de8995SAndre Fischer using namespace css;
3322de8995SAndre Fischer using namespace cssu;
3422de8995SAndre Fischer 
3522de8995SAndre Fischer 
367a32b0c8SAndre Fischer namespace sfx2 { namespace sidebar {
3722de8995SAndre Fischer 
3822de8995SAndre Fischer 
SidebarDockingWindow(SfxBindings * pSfxBindings,SidebarChildWindow & rChildWindow,Window * pParentWindow,WinBits nBits)3922de8995SAndre Fischer SidebarDockingWindow::SidebarDockingWindow(
4013e1c3b4SAndre Fischer     SfxBindings* pSfxBindings,
4122de8995SAndre Fischer     SidebarChildWindow& rChildWindow,
4213e1c3b4SAndre Fischer     Window* pParentWindow,
4322de8995SAndre Fischer     WinBits nBits)
4413e1c3b4SAndre Fischer     : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits),
4522de8995SAndre Fischer       mpSidebarController()
4622de8995SAndre Fischer {
4722de8995SAndre Fischer     // Get the XFrame from the bindings.
4813e1c3b4SAndre Fischer     if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
4922de8995SAndre Fischer     {
5013e1c3b4SAndre Fischer         OSL_ASSERT(pSfxBindings!=NULL);
5113e1c3b4SAndre Fischer         OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
5222de8995SAndre Fischer     }
5322de8995SAndre Fischer     else
5422de8995SAndre Fischer     {
5513e1c3b4SAndre Fischer         const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
5622de8995SAndre Fischer         const SfxFrame& rFrame = pViewFrame->GetFrame();
57ff12d537SAndre Fischer         mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
5822de8995SAndre Fischer     }
5922de8995SAndre Fischer }
6022de8995SAndre Fischer 
6122de8995SAndre Fischer 
6222de8995SAndre Fischer 
6322de8995SAndre Fischer 
~SidebarDockingWindow(void)6422de8995SAndre Fischer SidebarDockingWindow::~SidebarDockingWindow (void)
6522de8995SAndre Fischer {
6622de8995SAndre Fischer     DoDispose();
6722de8995SAndre Fischer }
6822de8995SAndre Fischer 
6922de8995SAndre Fischer 
7022de8995SAndre Fischer 
7122de8995SAndre Fischer 
DoDispose(void)7222de8995SAndre Fischer void SidebarDockingWindow::DoDispose (void)
7322de8995SAndre Fischer {
74e4bfc5b7SAndre Fischer     Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
75e4bfc5b7SAndre Fischer     mpSidebarController.clear();
76e4bfc5b7SAndre Fischer     if (xComponent.is())
77e4bfc5b7SAndre Fischer     {
78e4bfc5b7SAndre Fischer         xComponent->dispose();
79e4bfc5b7SAndre Fischer     }
8022de8995SAndre Fischer }
8122de8995SAndre Fischer 
8222de8995SAndre Fischer 
8322de8995SAndre Fischer 
8422de8995SAndre Fischer 
GetFocus()8522de8995SAndre Fischer void SidebarDockingWindow::GetFocus()
8622de8995SAndre Fischer {
87*7b6083c8SOliver-Rainer Wittmann     if (mpSidebarController.is())
88*7b6083c8SOliver-Rainer Wittmann     {
89*7b6083c8SOliver-Rainer Wittmann         mpSidebarController->GetFocusManager().GrabFocus();
90*7b6083c8SOliver-Rainer Wittmann     }
9165908a7eSAndre Fischer }
9265908a7eSAndre Fischer 
9365908a7eSAndre Fischer 
9465908a7eSAndre Fischer 
9565908a7eSAndre Fischer 
GetChildWindow(void)967a32b0c8SAndre Fischer SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
977a32b0c8SAndre Fischer {
987a32b0c8SAndre Fischer     return GetChildWindow_Impl();
997a32b0c8SAndre Fischer }
1007a32b0c8SAndre Fischer 
1017a32b0c8SAndre Fischer 
1027a32b0c8SAndre Fischer 
1037a32b0c8SAndre Fischer 
Close(void)1047a32b0c8SAndre Fischer sal_Bool SidebarDockingWindow::Close (void)
1057a32b0c8SAndre Fischer {
1067a32b0c8SAndre Fischer     if (mpSidebarController.is())
1077a32b0c8SAndre Fischer     {
1087a32b0c8SAndre Fischer         // Do not close the floating window.
1097a32b0c8SAndre Fischer         // Dock it and close just the deck instead.
1107a32b0c8SAndre Fischer         SetFloatingMode(sal_False);
111bae763b6SAndre Fischer         mpSidebarController->RequestCloseDeck();
1127a32b0c8SAndre Fischer         mpSidebarController->NotifyResize();
1137a32b0c8SAndre Fischer         return sal_False;
1147a32b0c8SAndre Fischer     }
1157a32b0c8SAndre Fischer     else
1167a32b0c8SAndre Fischer         return SfxDockingWindow::Close();
1177a32b0c8SAndre Fischer }
1187a32b0c8SAndre Fischer 
1197a32b0c8SAndre Fischer 
1206fa16b61SAndre Fischer 
1216fa16b61SAndre Fischer 
CheckAlignment(SfxChildAlignment eCurrentAlignment,SfxChildAlignment eRequestedAlignment)1226fa16b61SAndre Fischer SfxChildAlignment SidebarDockingWindow::CheckAlignment (
1236fa16b61SAndre Fischer     SfxChildAlignment eCurrentAlignment,
1246fa16b61SAndre Fischer     SfxChildAlignment eRequestedAlignment)
1256fa16b61SAndre Fischer {
1266fa16b61SAndre Fischer     switch (eRequestedAlignment)
1276fa16b61SAndre Fischer     {
1286fa16b61SAndre Fischer         case SFX_ALIGN_TOP:
1296fa16b61SAndre Fischer         case SFX_ALIGN_HIGHESTTOP:
1306fa16b61SAndre Fischer         case SFX_ALIGN_LOWESTTOP:
1316fa16b61SAndre Fischer         case SFX_ALIGN_BOTTOM:
1326fa16b61SAndre Fischer         case SFX_ALIGN_LOWESTBOTTOM:
1336fa16b61SAndre Fischer         case SFX_ALIGN_HIGHESTBOTTOM:
1346fa16b61SAndre Fischer             return eCurrentAlignment;
1356fa16b61SAndre Fischer 
1366fa16b61SAndre Fischer         case SFX_ALIGN_LEFT:
1376fa16b61SAndre Fischer         case SFX_ALIGN_RIGHT:
1386fa16b61SAndre Fischer         case SFX_ALIGN_FIRSTLEFT:
1396fa16b61SAndre Fischer         case SFX_ALIGN_LASTLEFT:
1406fa16b61SAndre Fischer         case SFX_ALIGN_FIRSTRIGHT:
1416fa16b61SAndre Fischer         case SFX_ALIGN_LASTRIGHT:
1426fa16b61SAndre Fischer             return eRequestedAlignment;
1436fa16b61SAndre Fischer 
1446fa16b61SAndre Fischer         default:
1456fa16b61SAndre Fischer             return eRequestedAlignment;
1466fa16b61SAndre Fischer     }
1476fa16b61SAndre Fischer }
1486fa16b61SAndre Fischer 
1496fa16b61SAndre Fischer 
1507a32b0c8SAndre Fischer } } // end of namespace sfx2::sidebar
151