LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel - TaskPaneTreeNode.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 98 42.9 %
Date: 2012-08-25 Functions: 10 22 45.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 80 20.0 %

           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 "taskpane/TaskPaneTreeNode.hxx"
      31                 :            : 
      32                 :            : #include "taskpane/ControlContainer.hxx"
      33                 :            : #include "taskpane/TitledControl.hxx"
      34                 :            : 
      35                 :            : #include <vector>
      36                 :            : #include <algorithm>
      37                 :            : 
      38                 :            : namespace sd { namespace toolpanel {
      39                 :            : 
      40                 :         47 : TreeNode::TreeNode( TreeNode* pParent)
      41         [ +  - ]:         47 : : mpControlContainer (new ControlContainer(this))
      42                 :            : , mpParent (pParent)
      43 [ +  - ][ +  - ]:         94 : , maStateChangeListeners()
      44                 :            : {
      45                 :         47 : }
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49                 :            : 
      50         [ +  - ]:         47 : TreeNode::~TreeNode (void)
      51                 :            : {
      52         [ -  + ]:         47 : }
      53                 :            : 
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :          0 : void TreeNode::SetParentNode (TreeNode* pNewParent)
      58                 :            : {
      59                 :          0 :     mpParent = pNewParent;
      60                 :          0 :     GetWindow()->SetParent (pNewParent->GetWindow());
      61                 :          0 : }
      62                 :            : 
      63                 :            : 
      64                 :            : 
      65                 :            : 
      66                 :          0 : TreeNode* TreeNode::GetParentNode (void)
      67                 :            : {
      68                 :          0 :     return mpParent;
      69                 :            : }
      70                 :            : 
      71                 :            : 
      72                 :            : 
      73                 :            : 
      74                 :          0 : ::Window* TreeNode::GetWindow (void)
      75                 :            : {
      76                 :          0 :     return NULL;
      77                 :            : }
      78                 :            : 
      79                 :            : 
      80                 :            : 
      81                 :            : 
      82                 :         45 : const ::Window* TreeNode::GetConstWindow (void) const
      83                 :            : {
      84                 :         45 :     return const_cast<TreeNode*>(this)->GetWindow();
      85                 :            : }
      86                 :            : 
      87                 :            : 
      88                 :            : 
      89                 :            : 
      90                 :         21 : sal_Int32 TreeNode::GetMinimumWidth (void)
      91                 :            : {
      92                 :         21 :     sal_Int32 nTotalMinimumWidth = 0;
      93                 :         21 :     unsigned int nCount = mpControlContainer->GetControlCount();
      94         [ +  + ]:         42 :     for (unsigned int nIndex=0; nIndex<nCount; nIndex++)
      95                 :            :     {
      96                 :         21 :         TreeNode* pChild = mpControlContainer->GetControl (nIndex);
      97                 :         21 :         sal_Int32 nMinimumWidth = pChild->GetMinimumWidth ();
      98         [ +  - ]:         21 :         if (nMinimumWidth > nTotalMinimumWidth)
      99                 :         21 :             nTotalMinimumWidth = nMinimumWidth;
     100                 :            :     }
     101                 :            : 
     102                 :         21 :     return nTotalMinimumWidth;
     103                 :            : }
     104                 :            : 
     105                 :            : 
     106                 :            : 
     107                 :            : 
     108                 :          0 : bool TreeNode::IsResizable (void)
     109                 :            : {
     110                 :          0 :     return false;
     111                 :            : }
     112                 :            : 
     113                 :            : 
     114                 :            : 
     115                 :            : 
     116                 :         33 : void TreeNode::RequestResize (void)
     117                 :            : {
     118         [ +  - ]:         33 :     if (mpParent != NULL)
     119                 :         33 :         mpParent->RequestResize();
     120                 :         33 : }
     121                 :            : 
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :          0 : ControlContainer& TreeNode::GetControlContainer (void)
     126                 :            : {
     127                 :          0 :     return *mpControlContainer.get();
     128                 :            : }
     129                 :            : 
     130                 :            : 
     131                 :            : 
     132                 :            : 
     133                 :         15 : bool TreeNode::Expand (bool bExpansionState)
     134                 :            : {
     135                 :         15 :     bool bExpansionStateChanged (false);
     136                 :            : 
     137 [ +  - ][ -  + ]:         15 :     if (IsExpandable() && IsExpanded()!=bExpansionState)
                 [ -  + ]
     138                 :            :     {
     139         [ #  # ]:          0 :         if (bExpansionState)
     140                 :          0 :             GetWindow()->Show();
     141                 :            :         else
     142                 :          0 :             GetWindow()->Hide();
     143                 :          0 :         bExpansionStateChanged = true;
     144                 :            : 
     145                 :          0 :         FireStateChangeEvent (EID_EXPANSION_STATE_CHANGED);
     146                 :            :     }
     147                 :            : 
     148                 :         15 :     return bExpansionStateChanged;
     149                 :            : }
     150                 :            : 
     151                 :            : 
     152                 :            : 
     153                 :            : 
     154                 :         15 : bool TreeNode::IsExpanded (void) const
     155                 :            : {
     156         [ +  - ]:         15 :     if (GetConstWindow()!=NULL)
     157                 :         15 :         return GetConstWindow()->IsVisible();
     158                 :            :     else
     159                 :         15 :         return false;
     160                 :            : }
     161                 :            : 
     162                 :            : 
     163                 :            : 
     164                 :            : 
     165                 :         15 : bool TreeNode::IsExpandable (void) const
     166                 :            : {
     167                 :         15 :     return GetConstWindow()!=NULL;
     168                 :            : }
     169                 :            : 
     170                 :            : 
     171                 :            : 
     172                 :            : 
     173                 :          0 : void TreeNode::Show (bool bExpansionState)
     174                 :            : {
     175         [ #  # ]:          0 :     if (GetWindow() != NULL)
     176                 :            :     {
     177                 :          0 :         bool bWasShowing (IsShowing());
     178                 :          0 :         GetWindow()->Show (bExpansionState);
     179         [ #  # ]:          0 :         if (bWasShowing != bExpansionState)
     180                 :          0 :             FireStateChangeEvent (EID_SHOWING_STATE_CHANGED);
     181                 :            :     }
     182                 :          0 : }
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :            : 
     187                 :          0 : bool TreeNode::IsShowing (void) const
     188                 :            : {
     189                 :          0 :     const ::Window* pWindow = const_cast<TreeNode*>(this)->GetWindow();
     190         [ #  # ]:          0 :     if (pWindow != NULL)
     191                 :          0 :         return pWindow->IsVisible();
     192                 :            :     else
     193                 :          0 :         return false;
     194                 :            : }
     195                 :            : 
     196                 :            : 
     197                 :            : 
     198                 :            : 
     199                 :          0 : TaskPaneShellManager* TreeNode::GetShellManager (void)
     200                 :            : {
     201         [ #  # ]:          0 :     if (mpParent != NULL)
     202                 :          0 :         return mpParent->GetShellManager();
     203                 :            :     else
     204                 :          0 :         return NULL;
     205                 :            : }
     206                 :            : 
     207                 :            : 
     208                 :            : 
     209                 :            : 
     210                 :            : ::com::sun::star::uno::Reference<
     211                 :          0 :     ::com::sun::star::accessibility::XAccessible> TreeNode::GetAccessibleObject (void)
     212                 :            : {
     213                 :            :     ::com::sun::star::uno::Reference<
     214                 :          0 :         ::com::sun::star::accessibility::XAccessible> xAccessible;
     215         [ #  # ]:          0 :     ::Window* pWindow = GetWindow();
     216         [ #  # ]:          0 :     if (pWindow != NULL)
     217                 :            :     {
     218 [ #  # ][ #  # ]:          0 :         xAccessible = pWindow->GetAccessible(sal_False);
     219         [ #  # ]:          0 :         if ( ! xAccessible.is())
     220                 :            :         {
     221                 :            :             ::com::sun::star::uno::Reference<
     222                 :          0 :                 ::com::sun::star::accessibility::XAccessible> xParent;
     223 [ #  # ][ #  # ]:          0 :             if (pWindow->GetAccessibleParentWindow()!=NULL)
     224 [ #  # ][ #  # ]:          0 :                 xParent = pWindow->GetAccessibleParentWindow()->GetAccessible();
                 [ #  # ]
     225 [ #  # ][ #  # ]:          0 :             xAccessible = CreateAccessibleObject(xParent);
     226         [ #  # ]:          0 :             pWindow->SetAccessible(xAccessible);
     227                 :            :         }
     228                 :            :     }
     229                 :          0 :     return xAccessible;
     230                 :            : }
     231                 :            : 
     232                 :            : 
     233                 :            : 
     234                 :            : 
     235                 :            : ::com::sun::star::uno::Reference<
     236                 :          0 :     ::com::sun::star::accessibility::XAccessible> TreeNode::CreateAccessibleObject (
     237                 :            :         const ::com::sun::star::uno::Reference<
     238                 :            :         ::com::sun::star::accessibility::XAccessible>& )
     239                 :            : {
     240         [ #  # ]:          0 :     if (GetWindow() != NULL)
     241                 :          0 :         return GetWindow()->CreateAccessible();
     242                 :            :     else
     243                 :          0 :         return NULL;
     244                 :            : }
     245                 :            : 
     246                 :            : 
     247                 :            : 
     248                 :            : 
     249                 :          0 : void TreeNode::AddStateChangeListener (const Link& rListener)
     250                 :            : {
     251 [ #  # ][ #  # ]:          0 :     if (::std::find (
     252                 :            :         maStateChangeListeners.begin(),
     253                 :            :         maStateChangeListeners.end(),
     254         [ #  # ]:          0 :         rListener) == maStateChangeListeners.end())
     255                 :            :     {
     256                 :          0 :         maStateChangeListeners.push_back(rListener);
     257                 :            :     }
     258                 :          0 : }
     259                 :            : 
     260                 :            : 
     261                 :            : 
     262                 :            : 
     263                 :         47 : void TreeNode::FireStateChangeEvent (
     264                 :            :     TreeNodeStateChangeEventId eEventId,
     265                 :            :     TreeNode* pChild) const
     266                 :            : {
     267                 :         47 :     TreeNodeStateChangeEvent aEvent (*this, eEventId, pChild);
     268         [ +  - ]:         47 :     StateChangeListenerContainer aContainerCopy(maStateChangeListeners);
     269                 :         47 :     StateChangeListenerContainer::iterator aLink (aContainerCopy.begin());
     270                 :         47 :     StateChangeListenerContainer::iterator aEnd (aContainerCopy.end());
     271 [ +  - ][ -  + ]:         47 :     while (aLink!=aEnd)
     272                 :            :     {
     273 [ #  # ][ #  # ]:          0 :         aLink->Call (&aEvent);
     274         [ #  # ]:          0 :         ++aLink;
     275                 :         47 :     }
     276                 :         47 : }
     277                 :            : 
     278                 :            : 
     279                 :            : 
     280                 :         47 : TreeNodeStateChangeEvent::TreeNodeStateChangeEvent (
     281                 :            :     const TreeNode& rNode,
     282                 :            :     TreeNodeStateChangeEventId eEventId,
     283                 :            :     TreeNode* pChild)
     284                 :            :     : mrSource(rNode),
     285                 :            :       meEventId(eEventId),
     286                 :         47 :       mpChild(pChild)
     287                 :            : {
     288                 :         47 : }
     289                 :            : 
     290                 :            : 
     291                 :            : } } // end of namespace ::sd::toolpanel
     292                 :            : 
     293                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10