LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/view - SlsToolTip.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 69 17.4 %
Date: 2012-08-25 Functions: 3 10 30.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 102 6.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "view/SlsToolTip.hxx"
      31                 :            : #include "view/SlideSorterView.hxx"
      32                 :            : #include "view/SlsLayouter.hxx"
      33                 :            : #include "view/SlsTheme.hxx"
      34                 :            : #include "sdpage.hxx"
      35                 :            : #include "sdresid.hxx"
      36                 :            : #include "glob.hrc"
      37                 :            : #include <vcl/help.hxx>
      38                 :            : 
      39                 :            : using ::rtl::OUString;
      40                 :            : 
      41                 :            : namespace sd { namespace slidesorter { namespace view {
      42                 :            : 
      43                 :        130 : ToolTip::ToolTip (SlideSorter& rSlideSorter)
      44                 :            :     : mrSlideSorter(rSlideSorter),
      45                 :            :       msDefaultHelpText(),
      46                 :            :       msCurrentHelpText(),
      47                 :            :       mnHelpWindowHandle(0),
      48         [ +  - ]:        130 :       maTimer()
      49                 :            : {
      50         [ +  - ]:        130 :     maTimer.SetTimeout(Theme_ToolTipDelay);
      51         [ +  - ]:        130 :     maTimer.SetTimeoutHdl(LINK(this, ToolTip, DelayTrigger));
      52                 :        130 : }
      53                 :            : 
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57         [ +  - ]:        130 : ToolTip::~ToolTip (void)
      58                 :            : {
      59         [ +  - ]:        130 :     maTimer.Stop();
      60         [ +  - ]:        130 :     Hide();
      61                 :        130 : }
      62                 :            : 
      63                 :            : 
      64                 :            : 
      65                 :            : 
      66                 :          0 : void ToolTip::SetPage (const model::SharedPageDescriptor& rpDescriptor)
      67                 :            : {
      68         [ #  # ]:          0 :     if (mpDescriptor != rpDescriptor)
      69                 :            :     {
      70                 :          0 :         maTimer.Stop();
      71                 :          0 :         Hide();
      72                 :            : 
      73                 :          0 :         mpDescriptor = rpDescriptor;
      74                 :            : 
      75         [ #  # ]:          0 :         if (mpDescriptor)
      76                 :            :         {
      77         [ #  # ]:          0 :             SdPage* pPage = mpDescriptor->GetPage();
      78                 :          0 :             OUString sHelpText;
      79         [ #  # ]:          0 :             if (pPage != NULL)
      80 [ #  # ][ #  # ]:          0 :                 sHelpText = pPage->GetName();
      81                 :            :             else
      82                 :            :             {
      83                 :            :                 OSL_ASSERT(mpDescriptor->GetPage() != NULL);
      84                 :            :             }
      85         [ #  # ]:          0 :             if (sHelpText.isEmpty())
      86                 :            :             {
      87 [ #  # ][ #  # ]:          0 :                 sHelpText = String(SdResId(STR_PAGE));
         [ #  # ][ #  # ]
      88 [ #  # ][ #  # ]:          0 :                 sHelpText += String::CreateFromInt32(mpDescriptor->GetPageIndex()+1);
         [ #  # ][ #  # ]
      89                 :            :             }
      90                 :            : 
      91                 :          0 :             msDefaultHelpText = sHelpText;
      92                 :          0 :             msCurrentHelpText = sHelpText;
      93         [ #  # ]:          0 :             Show(false);
      94                 :            :         }
      95                 :            :         else
      96                 :            :         {
      97                 :          0 :             msDefaultHelpText = OUString();
      98                 :          0 :             msCurrentHelpText = OUString();
      99                 :            :         }
     100                 :            :     }
     101                 :          0 : }
     102                 :            : 
     103                 :            : 
     104                 :            : 
     105                 :            : 
     106                 :          0 : void ToolTip::ShowDefaultHelpText (void)
     107                 :            : {
     108         [ #  # ]:          0 :     if (msCurrentHelpText != msDefaultHelpText)
     109                 :            :     {
     110                 :          0 :         const bool bIsVisible (Hide());
     111                 :            : 
     112                 :          0 :         msCurrentHelpText = msDefaultHelpText;
     113                 :            : 
     114                 :          0 :         Show(bIsVisible);
     115                 :            :     }
     116                 :          0 : }
     117                 :            : 
     118                 :            : 
     119                 :            : 
     120                 :            : 
     121                 :          0 : void ToolTip::ShowHelpText (const ::rtl::OUString& rsHelpText)
     122                 :            : {
     123         [ #  # ]:          0 :     if (msCurrentHelpText != rsHelpText)
     124                 :            :     {
     125                 :          0 :         const bool bIsVisible (Hide());
     126                 :            : 
     127                 :          0 :         msCurrentHelpText = rsHelpText;
     128                 :            : 
     129                 :          0 :         Show(bIsVisible);
     130                 :            :     }
     131                 :          0 : }
     132                 :            : 
     133                 :            : 
     134                 :            : 
     135                 :            : 
     136                 :          0 : void ToolTip::Show (const bool bNoDelay)
     137                 :            : {
     138         [ #  # ]:          0 :     if (bNoDelay)
     139                 :          0 :         DoShow();
     140                 :            :     else
     141                 :          0 :         maTimer.Start();
     142                 :          0 : }
     143                 :            : 
     144                 :            : 
     145                 :            : 
     146                 :            : 
     147                 :          0 : void ToolTip::DoShow (void)
     148                 :            : {
     149         [ #  # ]:          0 :     if (maTimer.IsActive())
     150                 :            :     {
     151                 :            :         // The delay timer is active.  Wait for it to trigger the showing of
     152                 :            :         // the tool tip.
     153                 :            :         return;
     154                 :            :     }
     155                 :            : 
     156         [ #  # ]:          0 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     157 [ #  # ][ #  # ]:          0 :     if (!msCurrentHelpText.isEmpty() && pWindow)
                 [ #  # ]
     158                 :            :     {
     159                 :            :         Rectangle aBox (
     160 [ #  # ][ #  # ]:          0 :             mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
     161                 :            :                 mpDescriptor,
     162                 :            :                 PageObjectLayouter::Preview,
     163 [ #  # ][ #  # ]:          0 :                 PageObjectLayouter::WindowCoordinateSystem));
                 [ #  # ]
     164                 :            : 
     165                 :            :         // Do not show the help text when the (lower edge of the ) preview
     166                 :            :         // is not visible.  The tool tip itself may still be outside the
     167                 :            :         // window.
     168 [ #  # ][ #  # ]:          0 :         if (aBox.Bottom() >= pWindow->GetSizePixel().Height())
     169                 :            :             return;
     170                 :            : 
     171                 :          0 :         ::Window* pParent (pWindow.get());
     172 [ #  # ][ #  # ]:          0 :         while (pParent!=NULL && pParent->GetParent()!=NULL)
         [ #  # ][ #  # ]
     173         [ #  # ]:          0 :             pParent = pParent->GetParent();
     174         [ #  # ]:          0 :         const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft());
     175                 :            : 
     176                 :            :         // We do not know how high the tool tip will be but want its top
     177                 :            :         // edge not its bottom to be at a specific position (a little below
     178                 :            :         // the preview).  Therefore we use a little trick and place the tool
     179                 :            :         // tip at the top of a rectangle that is placed below the preview.
     180 [ #  # ][ #  # ]:          0 :         aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3);
     181                 :            :         mnHelpWindowHandle = Help::ShowTip(
     182                 :          0 :             pWindow.get(),
     183                 :            :             aBox,
     184                 :            :             msCurrentHelpText,
     185   [ #  #  #  # ]:          0 :             QUICKHELP_CENTER | QUICKHELP_TOP);
                 [ #  # ]
     186 [ #  # ][ #  # ]:          0 :     }
     187                 :            : }
     188                 :            : 
     189                 :            : 
     190                 :            : 
     191                 :            : 
     192                 :        130 : bool ToolTip::Hide (void)
     193                 :            : {
     194         [ -  + ]:        130 :     if (mnHelpWindowHandle>0)
     195                 :            :     {
     196                 :          0 :         Help::HideTip(mnHelpWindowHandle);
     197                 :          0 :         mnHelpWindowHandle = 0;
     198                 :          0 :         return true;
     199                 :            :     }
     200                 :            :     else
     201                 :        130 :         return false;
     202                 :            : }
     203                 :            : 
     204                 :            : 
     205                 :            : 
     206                 :            : 
     207                 :          0 : IMPL_LINK_NOARG(ToolTip, DelayTrigger)
     208                 :            : {
     209                 :          0 :     DoShow();
     210                 :            : 
     211                 :          0 :     return 0;
     212                 :            : }
     213                 :            : 
     214                 :            : } } } // end of namespace ::sd::slidesorter::view
     215                 :            : 
     216                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10