LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - SidebarDockingWindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 20 32 62.5 %
Date: 2014-04-11 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include "SidebarDockingWindow.hxx"
      20             : #include <sfx2/sidebar/SidebarChildWindow.hxx>
      21             : #include "SidebarController.hxx"
      22             : 
      23             : #include <sfx2/bindings.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : #include <tools/link.hxx>
      26             : 
      27             : using namespace css;
      28             : using namespace cssu;
      29             : 
      30             : 
      31             : namespace sfx2 { namespace sidebar {
      32             : 
      33             : 
      34          17 : SidebarDockingWindow::SidebarDockingWindow(
      35             :     SfxBindings* pSfxBindings,
      36             :     SidebarChildWindow& rChildWindow,
      37             :     Window* pParentWindow,
      38             :     WinBits nBits)
      39             :     : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits),
      40          17 :       mpSidebarController()
      41             : {
      42             :     // Get the XFrame from the bindings.
      43          17 :     if (pSfxBindings==NULL || pSfxBindings->GetDispatcher()==NULL)
      44             :     {
      45             :         OSL_ASSERT(pSfxBindings!=NULL);
      46             :         OSL_ASSERT(pSfxBindings->GetDispatcher()!=NULL);
      47             :     }
      48             :     else
      49             :     {
      50          17 :         const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame();
      51          17 :         const SfxFrame& rFrame = pViewFrame->GetFrame();
      52          17 :         mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface()));
      53             :     }
      54          17 : }
      55             : 
      56             : 
      57             : 
      58             : 
      59          51 : SidebarDockingWindow::~SidebarDockingWindow (void)
      60             : {
      61          17 :     DoDispose();
      62          34 : }
      63             : 
      64             : 
      65             : 
      66             : 
      67          17 : void SidebarDockingWindow::DoDispose (void)
      68             : {
      69          17 :     Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
      70          17 :     mpSidebarController.clear();
      71          17 :     if (xComponent.is())
      72             :     {
      73          17 :         xComponent->dispose();
      74          17 :     }
      75          17 : }
      76             : 
      77             : 
      78             : 
      79             : 
      80           0 : void SidebarDockingWindow::GetFocus()
      81             : {
      82           0 :     mpSidebarController->GetFocusManager().GrabFocus();
      83           0 : }
      84             : 
      85             : 
      86             : 
      87             : 
      88           0 : bool SidebarDockingWindow::Close (void)
      89             : {
      90           0 :     if (mpSidebarController.is())
      91             :     {
      92             :         // Do not close the floating window.
      93             :         // Dock it and close just the deck instead.
      94           0 :         SetFloatingMode(false);
      95           0 :         mpSidebarController->RequestCloseDeck();
      96           0 :         mpSidebarController->NotifyResize();
      97           0 :         return false;
      98             :     }
      99             :     else
     100           0 :         return SfxDockingWindow::Close();
     101             : }
     102             : 
     103             : 
     104             : 
     105             : 
     106          12 : SfxChildAlignment SidebarDockingWindow::CheckAlignment (
     107             :     SfxChildAlignment eCurrentAlignment,
     108             :     SfxChildAlignment eRequestedAlignment)
     109             : {
     110          12 :     switch (eRequestedAlignment)
     111             :     {
     112             :         case SFX_ALIGN_TOP:
     113             :         case SFX_ALIGN_HIGHESTTOP:
     114             :         case SFX_ALIGN_LOWESTTOP:
     115             :         case SFX_ALIGN_BOTTOM:
     116             :         case SFX_ALIGN_LOWESTBOTTOM:
     117             :         case SFX_ALIGN_HIGHESTBOTTOM:
     118           0 :             return eCurrentAlignment;
     119             : 
     120             :         case SFX_ALIGN_LEFT:
     121             :         case SFX_ALIGN_RIGHT:
     122             :         case SFX_ALIGN_FIRSTLEFT:
     123             :         case SFX_ALIGN_LASTLEFT:
     124             :         case SFX_ALIGN_FIRSTRIGHT:
     125             :         case SFX_ALIGN_LASTRIGHT:
     126          12 :             return eRequestedAlignment;
     127             : 
     128             :         default:
     129           0 :             return eRequestedAlignment;
     130             :     }
     131             : }
     132             : 
     133             : 
     134             : } } // end of namespace sfx2::sidebar
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10