LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/access - accframe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 206 0.0 %
Date: 2012-12-17 Functions: 0 19 0.0 %
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             : 
      20             : #include <hintids.hxx>
      21             : #include <editeng/brshitem.hxx>
      22             : #include <flyfrm.hxx>
      23             : #include <rootfrm.hxx>
      24             : #include <txtfrm.hxx>
      25             : #include <sectfrm.hxx>
      26             : #include <section.hxx>
      27             : #include <viewsh.hxx>
      28             : #include <viewopt.hxx>
      29             : #include <doc.hxx>
      30             : #include <frmatr.hxx>
      31             : #include <pagefrm.hxx>
      32             : #include <pagedesc.hxx>
      33             : #include <fmtanchr.hxx>
      34             : #include <fldbas.hxx>
      35             : #include <dcontact.hxx>
      36             : #include <accmap.hxx>
      37             : #include <accfrmobjslist.hxx>
      38             : #include <accfrmobjmap.hxx>
      39             : #include <accframe.hxx>
      40             : 
      41             : using namespace sw::access;
      42             : 
      43             : // Regarding visibilily (or in terms of accessibility: regarding the showing
      44             : // state): A frame is visible and therfor contained in the tree if its frame
      45             : // size overlaps with the visible area. The bounding box however is the
      46             : // frame's paint area.
      47           0 : /* static */ sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap,
      48             :                                                          const SwRect& rVisArea,
      49             :                                                          const SwFrm *pFrm,
      50             :                                                          sal_Bool bInPagePreview )
      51             : {
      52           0 :     sal_Int32 nCount = 0;
      53             : 
      54           0 :     const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap );
      55           0 :     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
      56           0 :     while( aIter != aVisList.end() )
      57             :     {
      58           0 :         const SwAccessibleChild& rLower = *aIter;
      59           0 :         if( rLower.IsAccessible( bInPagePreview ) )
      60             :         {
      61           0 :             nCount++;
      62             :         }
      63           0 :         else if( rLower.GetSwFrm() )
      64             :         {
      65             :             // There are no unaccessible SdrObjects that count
      66             :             nCount += GetChildCount( rAccMap,
      67             :                                      rVisArea, rLower.GetSwFrm(),
      68           0 :                                      bInPagePreview );
      69             :         }
      70           0 :         ++aIter;
      71             :     }
      72             : 
      73           0 :     return nCount;
      74             : }
      75             : 
      76           0 : /* static */ SwAccessibleChild SwAccessibleFrame::GetChild(
      77             :                                                 SwAccessibleMap& rAccMap,
      78             :                                                 const SwRect& rVisArea,
      79             :                                                 const SwFrm& rFrm,
      80             :                                                 sal_Int32& rPos,
      81             :                                                 sal_Bool bInPagePreview )
      82             : {
      83           0 :     SwAccessibleChild aRet;
      84             : 
      85           0 :     if( rPos >= 0 )
      86             :     {
      87           0 :         if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
      88             :         {
      89             :             // We need a sorted list here
      90           0 :             const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
      91           0 :             SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
      92           0 :             while( aIter != aVisMap.end() && !aRet.IsValid() )
      93             :             {
      94           0 :                 const SwAccessibleChild& rLower = (*aIter).second;
      95           0 :                 if( rLower.IsAccessible( bInPagePreview ) )
      96             :                 {
      97           0 :                     if( 0 == rPos )
      98           0 :                         aRet = rLower;
      99             :                     else
     100           0 :                         rPos--;
     101             :                 }
     102           0 :                 else if( rLower.GetSwFrm() )
     103             :                 {
     104             :                     // There are no unaccessible SdrObjects that count
     105             :                     aRet = GetChild( rAccMap,
     106           0 :                                      rVisArea, *(rLower.GetSwFrm()), rPos,
     107           0 :                                      bInPagePreview );
     108             :                 }
     109           0 :                 ++aIter;
     110           0 :             }
     111             :         }
     112             :         else
     113             :         {
     114             :             // The unsorted list is sorted enough, because it return lower
     115             :             // frames in the correct order.
     116           0 :             const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
     117           0 :             SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
     118           0 :             while( aIter != aVisList.end() && !aRet.IsValid() )
     119             :             {
     120           0 :                 const SwAccessibleChild& rLower = *aIter;
     121           0 :                 if( rLower.IsAccessible( bInPagePreview ) )
     122             :                 {
     123           0 :                     if( 0 == rPos )
     124           0 :                         aRet = rLower;
     125             :                     else
     126           0 :                         rPos--;
     127             :                 }
     128           0 :                 else if( rLower.GetSwFrm() )
     129             :                 {
     130             :                     // There are no unaccessible SdrObjects that count
     131             :                     aRet = GetChild( rAccMap,
     132           0 :                                      rVisArea, *(rLower.GetSwFrm()), rPos,
     133           0 :                                      bInPagePreview );
     134             :                 }
     135           0 :                 ++aIter;
     136             :             }
     137             :         }
     138             :     }
     139             : 
     140           0 :     return aRet;
     141             : }
     142             : 
     143           0 : /* static */ sal_Bool SwAccessibleFrame::GetChildIndex(
     144             :                                                 SwAccessibleMap& rAccMap,
     145             :                                                 const SwRect& rVisArea,
     146             :                                                 const SwFrm& rFrm,
     147             :                                                 const SwAccessibleChild& rChild,
     148             :                                                 sal_Int32& rPos,
     149             :                                                 sal_Bool bInPagePreview )
     150             : {
     151           0 :     sal_Bool bFound = sal_False;
     152             : 
     153           0 :     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
     154             :     {
     155             :         // We need a sorted list here
     156           0 :         const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
     157           0 :         SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
     158           0 :         while( aIter != aVisMap.end() && !bFound )
     159             :         {
     160           0 :             const SwAccessibleChild& rLower = (*aIter).second;
     161           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     162             :             {
     163           0 :                 if( rChild == rLower )
     164           0 :                     bFound = sal_True;
     165             :                 else
     166           0 :                     rPos++;
     167             :             }
     168           0 :             else if( rLower.GetSwFrm() )
     169             :             {
     170             :                 // There are no unaccessible SdrObjects that count
     171             :                 bFound = GetChildIndex( rAccMap,
     172           0 :                                         rVisArea, *(rLower.GetSwFrm()), rChild,
     173           0 :                                         rPos, bInPagePreview );
     174             :             }
     175           0 :             ++aIter;
     176           0 :         }
     177             :     }
     178             :     else
     179             :     {
     180             :         // The unsorted list is sorted enough, because it return lower
     181             :         // frames in the correct order.
     182           0 :         const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
     183           0 :         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
     184           0 :         while( aIter != aVisList.end() && !bFound )
     185             :         {
     186           0 :             const SwAccessibleChild& rLower = *aIter;
     187           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     188             :             {
     189           0 :                 if( rChild == rLower )
     190           0 :                     bFound = sal_True;
     191             :                 else
     192           0 :                     rPos++;
     193             :             }
     194           0 :             else if( rLower.GetSwFrm() )
     195             :             {
     196             :                 // There are no unaccessible SdrObjects that count
     197             :                 bFound = GetChildIndex( rAccMap,
     198           0 :                                         rVisArea, *(rLower.GetSwFrm()), rChild,
     199           0 :                                         rPos, bInPagePreview );
     200             :             }
     201           0 :             ++aIter;
     202             :         }
     203             :     }
     204             : 
     205           0 :     return bFound;
     206             : }
     207             : 
     208           0 : SwAccessibleChild SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea,
     209             :                                           const SwFrm& rFrm,
     210             :                                           const Point& rPixPos,
     211             :                                           sal_Bool bInPagePreview,
     212             :                                           SwAccessibleMap& rAccMap )
     213             : {
     214           0 :     SwAccessibleChild aRet;
     215             : 
     216           0 :     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
     217             :     {
     218             :         // We need a sorted list here, and we have to reverse iterate,
     219             :         // because objects in front should be returned.
     220           0 :         const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
     221           0 :         SwAccessibleChildMap::const_reverse_iterator aRIter( aVisMap.rbegin() );
     222           0 :         while( aRIter != aVisMap.rend() && !aRet.IsValid() )
     223             :         {
     224           0 :             const SwAccessibleChild& rLower = (*aRIter).second;
     225             :             // A frame is returned if it's frame size is inside the visarea
     226             :             // and the positiion is inside the frame's paint area.
     227           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     228             :             {
     229           0 :                 SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
     230           0 :                 if( !aLogBounds.IsEmpty() )
     231             :                 {
     232           0 :                     Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
     233           0 :                     if( aPixBounds.IsInside( rPixPos ) )
     234           0 :                         aRet = rLower;
     235             :                 }
     236             :             }
     237           0 :             else if( rLower.GetSwFrm() )
     238             :             {
     239             :                 // There are no unaccessible SdrObjects that count
     240           0 :                 aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
     241           0 :                                         bInPagePreview, rAccMap );
     242             :             }
     243           0 :             ++aRIter;
     244           0 :         }
     245             :     }
     246             :     else
     247             :     {
     248             :         // The unsorted list is sorted enough, because it returns lower
     249             :         // frames in the correct order. Morover, we can iterate forward,
     250             :         // because the lowers don't overlap!
     251           0 :         const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
     252           0 :         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
     253           0 :         while( aIter != aVisList.end() && !aRet.IsValid() )
     254             :         {
     255           0 :             const SwAccessibleChild& rLower = *aIter;
     256             :             // A frame is returned if it's frame size is inside the visarea
     257             :             // and the positiion is inside the frame's paint area.
     258           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     259             :             {
     260           0 :                 SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
     261           0 :                 if( !aLogBounds.IsEmpty() )
     262             :                 {
     263           0 :                     Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
     264           0 :                     if( aPixBounds.IsInside( rPixPos ) )
     265           0 :                         aRet = rLower;
     266             :                 }
     267             :             }
     268           0 :             else if( rLower.GetSwFrm() )
     269             :             {
     270             :                 // There are no unaccessible SdrObjects that count
     271           0 :                 aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
     272           0 :                                    bInPagePreview, rAccMap );
     273             :             }
     274           0 :             ++aIter;
     275             :         }
     276             :     }
     277             : 
     278           0 :     return aRet;
     279             : }
     280             : 
     281           0 : /* static */ void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
     282             :                                                   const SwRect& rVisArea,
     283             :                                                   const SwFrm& rFrm,
     284             :                                                   ::std::list< SwAccessibleChild >& rChildren,
     285             :                                                   sal_Bool bInPagePreview )
     286             : {
     287           0 :     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
     288             :     {
     289             :         // We need a sorted list here
     290           0 :         const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
     291           0 :         SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
     292           0 :         while( aIter != aVisMap.end() )
     293             :         {
     294           0 :             const SwAccessibleChild& rLower = (*aIter).second;
     295           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     296             :             {
     297           0 :                 rChildren.push_back( rLower );
     298             :             }
     299           0 :             else if( rLower.GetSwFrm() )
     300             :             {
     301             :                 // There are no unaccessible SdrObjects that count
     302           0 :                 GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
     303           0 :                              rChildren, bInPagePreview );
     304             :             }
     305           0 :             ++aIter;
     306           0 :         }
     307             :     }
     308             :     else
     309             :     {
     310             :         // The unsorted list is sorted enough, because it return lower
     311             :         // frames in the correct order.
     312           0 :         const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
     313           0 :         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
     314           0 :         while( aIter != aVisList.end() )
     315             :         {
     316           0 :             const SwAccessibleChild& rLower = *aIter;
     317           0 :             if( rLower.IsAccessible( bInPagePreview ) )
     318             :             {
     319           0 :                 rChildren.push_back( rLower );
     320             :             }
     321           0 :             else if( rLower.GetSwFrm() )
     322             :             {
     323             :                 // There are no unaccessible SdrObjects that count
     324           0 :                 GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
     325           0 :                              rChildren, bInPagePreview );
     326             :             }
     327           0 :             ++aIter;
     328             :         }
     329             :     }
     330           0 : }
     331             : 
     332           0 : SwRect SwAccessibleFrame::GetBounds( const SwAccessibleMap& rAccMap,
     333             :                                      const SwFrm *pFrm )
     334             : {
     335           0 :     if( !pFrm )
     336           0 :         pFrm = GetFrm();
     337             : 
     338           0 :     SwAccessibleChild aFrm( pFrm );
     339           0 :     SwRect aBounds( aFrm.GetBounds( rAccMap ).Intersection( maVisArea ) );
     340           0 :     return aBounds;
     341             : }
     342             : 
     343           0 : sal_Bool SwAccessibleFrame::IsEditable( ViewShell *pVSh ) const
     344             : {
     345           0 :     const SwFrm *pFrm = GetFrm();
     346           0 :     if( !pFrm )
     347           0 :         return sal_False;
     348             : 
     349             :     OSL_ENSURE( pVSh, "no view shell" );
     350           0 :     if( pVSh && (pVSh->GetViewOptions()->IsReadonly() ||
     351           0 :                  pVSh->IsPreView()) )
     352           0 :         return sal_False;
     353             : 
     354           0 :     if( !pFrm->IsRootFrm() && pFrm->IsProtected() )
     355           0 :         return sal_False;
     356             : 
     357           0 :     return sal_True;
     358             : }
     359             : 
     360           0 : sal_Bool SwAccessibleFrame::IsOpaque( ViewShell *pVSh ) const
     361             : {
     362           0 :     SwAccessibleChild aFrm( GetFrm() );
     363           0 :     if( !aFrm.GetSwFrm() )
     364           0 :         return sal_False;
     365             : 
     366             :     OSL_ENSURE( pVSh, "no view shell" );
     367           0 :     if( !pVSh )
     368           0 :         return sal_False;
     369             : 
     370           0 :     const SwViewOption *pVOpt = pVSh->GetViewOptions();
     371           0 :     do
     372             :     {
     373           0 :         const SwFrm *pFrm = aFrm.GetSwFrm();
     374           0 :         if( pFrm->IsRootFrm() )
     375           0 :             return sal_True;
     376             : 
     377           0 :         if( pFrm->IsPageFrm() && !pVOpt->IsPageBack() )
     378           0 :             return sal_False;
     379             : 
     380           0 :         const SvxBrushItem &rBack = pFrm->GetAttrSet()->GetBackground();
     381           0 :         if( !rBack.GetColor().GetTransparency() ||
     382           0 :              rBack.GetGraphicPos() != GPOS_NONE )
     383           0 :             return sal_True;
     384             : 
     385             :         // If a fly frame has a transparent background color, we have to consider the background.
     386             :         // But a background color "no fill"/"auto fill" has *not* to be considered.
     387           0 :         if( pFrm->IsFlyFrm() &&
     388           0 :             (rBack.GetColor().GetTransparency() != 0) &&
     389           0 :             (rBack.GetColor() != COL_TRANSPARENT)
     390             :           )
     391           0 :             return sal_True;
     392             : 
     393           0 :         if( pFrm->IsSctFrm() )
     394             :         {
     395           0 :             const SwSection* pSection = ((SwSectionFrm*)pFrm)->GetSection();
     396           0 :             if( pSection && ( TOX_HEADER_SECTION == pSection->GetType() ||
     397           0 :                 TOX_CONTENT_SECTION == pSection->GetType() ) &&
     398           0 :                 !pVOpt->IsReadonly() &&
     399           0 :                 SwViewOption::IsIndexShadings() )
     400           0 :                 return sal_True;
     401             :         }
     402           0 :         if( pFrm->IsFlyFrm() )
     403           0 :             aFrm = static_cast<const SwFlyFrm*>(pFrm)->GetAnchorFrm();
     404             :         else
     405           0 :             aFrm = pFrm->GetUpper();
     406           0 :     } while( aFrm.GetSwFrm() && !aFrm.IsAccessible( IsInPagePreview() ) );
     407             : 
     408           0 :     return sal_False;
     409             : }
     410             : 
     411           0 : SwAccessibleFrame::SwAccessibleFrame( const SwRect& rVisArea,
     412             :                                       const SwFrm *pF,
     413             :                                       sal_Bool bIsPagePreview ) :
     414             :     maVisArea( rVisArea ),
     415             :     mpFrm( pF ),
     416           0 :     mbIsInPagePreview( bIsPagePreview )
     417             : {
     418           0 : }
     419             : 
     420           0 : SwAccessibleFrame::~SwAccessibleFrame()
     421             : {
     422           0 : }
     423             : 
     424           0 : /* static */ const SwFrm* SwAccessibleFrame::GetParent( const SwAccessibleChild& rFrmOrObj,
     425             :                                                         sal_Bool bInPagePreview )
     426             : {
     427           0 :     return rFrmOrObj.GetParent( bInPagePreview );
     428             : }
     429             : 
     430           0 : String SwAccessibleFrame::GetFormattedPageNumber() const
     431             : {
     432           0 :     sal_uInt16 nPageNum = GetFrm()->GetVirtPageNum();
     433             :     sal_uInt32 nFmt = GetFrm()->FindPageFrm()->GetPageDesc()
     434           0 :                               ->GetNumType().GetNumberingType();
     435           0 :     if( SVX_NUM_NUMBER_NONE == nFmt )
     436           0 :         nFmt = SVX_NUM_ARABIC;
     437             : 
     438           0 :     String sRet( FormatNumber( nPageNum, nFmt ) );
     439           0 :     return sRet;
     440             : }
     441             : 
     442           0 : sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap ) const
     443             : {
     444           0 :     return GetChildCount( rAccMap, maVisArea, mpFrm, IsInPagePreview() );
     445             : }
     446             : 
     447           0 : sw::access::SwAccessibleChild SwAccessibleFrame::GetChild(
     448             :                                                 SwAccessibleMap& rAccMap,
     449             :                                                 sal_Int32 nPos ) const
     450             : {
     451           0 :     return SwAccessibleFrame::GetChild( rAccMap, maVisArea, *mpFrm, nPos, IsInPagePreview() );
     452             : }
     453             : 
     454           0 : sal_Int32 SwAccessibleFrame::GetChildIndex( SwAccessibleMap& rAccMap,
     455             :                                             const sw::access::SwAccessibleChild& rChild ) const
     456             : {
     457           0 :     sal_Int32 nPos = 0;
     458           0 :     return GetChildIndex( rAccMap, maVisArea, *mpFrm, rChild, nPos, IsInPagePreview() )
     459             :            ? nPos
     460           0 :            : -1L;
     461             : }
     462             : 
     463           0 : sw::access::SwAccessibleChild SwAccessibleFrame::GetChildAtPixel(
     464             :                                                 const Point& rPos,
     465             :                                                 SwAccessibleMap& rAccMap ) const
     466             : {
     467           0 :     return GetChildAtPixel( maVisArea, *mpFrm, rPos, IsInPagePreview(), rAccMap );
     468             : }
     469             : 
     470           0 : void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
     471             :                                      ::std::list< sw::access::SwAccessibleChild >& rChildren ) const
     472             : {
     473           0 :     GetChildren( rAccMap, maVisArea, *mpFrm, rChildren, IsInPagePreview() );
     474           0 : }
     475             : 
     476           0 : sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap,
     477             :                                        const sw::access::SwAccessibleChild& rFrmOrObj ) const
     478             : {
     479           0 :     return IsShowing( rFrmOrObj.GetBox( rAccMap ) );
     480             : }
     481             : 
     482             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10