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"
25*7a32b0c8SAndre 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 
36*7a32b0c8SAndre Fischer namespace sfx2 { namespace sidebar {
3722de8995SAndre Fischer 
3822de8995SAndre Fischer 
3922de8995SAndre Fischer SidebarDockingWindow::SidebarDockingWindow(
4022de8995SAndre Fischer     SfxBindings* pBindings,
4122de8995SAndre Fischer     SidebarChildWindow& rChildWindow,
4222de8995SAndre Fischer     Window* pParent,
4322de8995SAndre Fischer     WinBits nBits)
4422de8995SAndre Fischer     : SfxDockingWindow(pBindings, &rChildWindow, pParent, nBits),
4522de8995SAndre Fischer       mpSidebarController()
4622de8995SAndre Fischer {
4722de8995SAndre Fischer     // Get the XFrame from the bindings.
4822de8995SAndre Fischer     if (pBindings==NULL || pBindings->GetDispatcher()==NULL)
4922de8995SAndre Fischer     {
5022de8995SAndre Fischer         OSL_ASSERT(pBindings!=NULL);
5122de8995SAndre Fischer         OSL_ASSERT(pBindings->GetDispatcher()!=NULL);
5222de8995SAndre Fischer     }
5322de8995SAndre Fischer     else
5422de8995SAndre Fischer     {
5522de8995SAndre Fischer         const SfxViewFrame* pViewFrame = pBindings->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 
6422de8995SAndre Fischer SidebarDockingWindow::~SidebarDockingWindow (void)
6522de8995SAndre Fischer {
6622de8995SAndre Fischer     DoDispose();
6722de8995SAndre Fischer }
6822de8995SAndre Fischer 
6922de8995SAndre Fischer 
7022de8995SAndre Fischer 
7122de8995SAndre Fischer 
7222de8995SAndre Fischer void SidebarDockingWindow::DoDispose (void)
7322de8995SAndre Fischer {
7422de8995SAndre Fischer }
7522de8995SAndre Fischer 
7622de8995SAndre Fischer 
7722de8995SAndre Fischer 
7822de8995SAndre Fischer 
7922de8995SAndre Fischer void SidebarDockingWindow::GetFocus()
8022de8995SAndre Fischer {
8122de8995SAndre Fischer     SfxDockingWindow::GetFocus();
8222de8995SAndre Fischer }
8322de8995SAndre Fischer 
8422de8995SAndre Fischer 
8522de8995SAndre Fischer 
8622de8995SAndre Fischer 
87*7a32b0c8SAndre Fischer SfxChildWindow* SidebarDockingWindow::GetChildWindow (void)
88*7a32b0c8SAndre Fischer {
89*7a32b0c8SAndre Fischer     return GetChildWindow_Impl();
90*7a32b0c8SAndre Fischer }
91*7a32b0c8SAndre Fischer 
92*7a32b0c8SAndre Fischer 
93*7a32b0c8SAndre Fischer 
94*7a32b0c8SAndre Fischer 
95*7a32b0c8SAndre Fischer sal_Bool SidebarDockingWindow::Close (void)
96*7a32b0c8SAndre Fischer {
97*7a32b0c8SAndre Fischer     if (mpSidebarController.is())
98*7a32b0c8SAndre Fischer     {
99*7a32b0c8SAndre Fischer         // Do not close the floating window.
100*7a32b0c8SAndre Fischer         // Dock it and close just the deck instead.
101*7a32b0c8SAndre Fischer         mpSidebarController->CloseDeck();
102*7a32b0c8SAndre Fischer         SetFloatingMode(sal_False);
103*7a32b0c8SAndre Fischer         mpSidebarController->NotifyResize();
104*7a32b0c8SAndre Fischer         return sal_False;
105*7a32b0c8SAndre Fischer     }
106*7a32b0c8SAndre Fischer     else
107*7a32b0c8SAndre Fischer         return SfxDockingWindow::Close();
108*7a32b0c8SAndre Fischer }
109*7a32b0c8SAndre Fischer 
110*7a32b0c8SAndre Fischer 
111*7a32b0c8SAndre Fischer } } // end of namespace sfx2::sidebar
112