Files
libreoffice/sw/source/core/access/accframe.cxx

483 lines
17 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2002-02-04 13:10:18 +00:00
2002-02-05 14:52:06 +00:00
#include <hintids.hxx>
#include <editeng/brushitem.hxx>
2002-02-05 14:52:06 +00:00
#include <flyfrm.hxx>
2002-02-04 13:10:18 +00:00
#include <rootfrm.hxx>
#include <txtfrm.hxx>
2002-02-05 14:52:06 +00:00
#include <sectfrm.hxx>
#include <section.hxx>
2002-02-04 13:10:18 +00:00
#include <viewsh.hxx>
2002-02-05 14:52:06 +00:00
#include <viewopt.hxx>
#include <doc.hxx>
#include <frmatr.hxx>
2002-04-11 13:04:40 +00:00
#include <pagefrm.hxx>
#include <pagedesc.hxx>
2002-05-15 12:22:47 +00:00
#include <fmtanchr.hxx>
2002-04-11 13:04:40 +00:00
#include <fldbas.hxx>
2002-05-15 12:22:47 +00:00
#include <dcontact.hxx>
#include <accmap.hxx>
2002-04-05 11:18:25 +00:00
#include <accfrmobjslist.hxx>
#include <accfrmobjmap.hxx>
2002-02-04 13:10:18 +00:00
#include <accframe.hxx>
using namespace sw::access;
2002-04-05 11:18:25 +00:00
// Regarding visibility (or in terms of accessibility: regarding the showing
2002-02-11 11:51:16 +00:00
// state): A frame is visible and therfor contained in the tree if its frame
// size overlaps with the visible area. The bounding box however is the
// frame's paint area.
sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap,
const SwRect& rVisArea,
const SwFrm *pFrm,
sal_Bool bInPagePreview )
2002-02-04 13:10:18 +00:00
{
sal_Int32 nCount = 0;
2002-04-05 11:18:25 +00:00
const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-11 13:04:40 +00:00
while( aIter != aVisList.end() )
2002-02-04 13:10:18 +00:00
{
const SwAccessibleChild& rLower = *aIter;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-02-04 13:10:18 +00:00
{
2002-04-11 13:04:40 +00:00
nCount++;
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
nCount += GetChildCount( rAccMap,
rVisArea, rLower.GetSwFrm(),
2002-05-22 10:48:43 +00:00
bInPagePreview );
2002-02-04 13:10:18 +00:00
}
2002-04-05 11:18:25 +00:00
++aIter;
2002-02-04 13:10:18 +00:00
}
return nCount;
}
SwAccessibleChild SwAccessibleFrame::GetChild(
SwAccessibleMap& rAccMap,
const SwRect& rVisArea,
const SwFrm& rFrm,
sal_Int32& rPos,
sal_Bool bInPagePreview )
2002-02-04 13:10:18 +00:00
{
SwAccessibleChild aRet;
2002-02-05 14:52:06 +00:00
if( rPos >= 0 )
2002-02-04 13:10:18 +00:00
{
if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
// We need a sorted list here
const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
2002-04-05 11:18:25 +00:00
while( aIter != aVisMap.end() && !aRet.IsValid() )
2002-02-04 13:10:18 +00:00
{
const SwAccessibleChild& rLower = (*aIter).second;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-02-05 14:52:06 +00:00
{
if( 0 == rPos )
2002-04-05 11:18:25 +00:00
aRet = rLower;
2002-02-05 14:52:06 +00:00
else
rPos--;
}
2002-04-05 11:18:25 +00:00
else if( rLower.GetSwFrm() )
2002-02-05 14:52:06 +00:00
{
2002-04-05 11:18:25 +00:00
// There are no unaccessible SdrObjects that count
aRet = GetChild( rAccMap,
rVisArea, *(rLower.GetSwFrm()), rPos,
2002-05-22 10:48:43 +00:00
bInPagePreview );
2002-02-05 14:52:06 +00:00
}
2002-04-05 11:18:25 +00:00
++aIter;
}
}
else
{
// The unsorted list is sorted enough, because it returns lower
2002-04-05 11:18:25 +00:00
// frames in the correct order.
const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-05 11:18:25 +00:00
while( aIter != aVisList.end() && !aRet.IsValid() )
{
const SwAccessibleChild& rLower = *aIter;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-04-05 11:18:25 +00:00
{
if( 0 == rPos )
aRet = rLower;
else
rPos--;
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
aRet = GetChild( rAccMap,
rVisArea, *(rLower.GetSwFrm()), rPos,
2002-05-22 10:48:43 +00:00
bInPagePreview );
2002-04-05 11:18:25 +00:00
}
++aIter;
2002-02-04 13:10:18 +00:00
}
}
}
2002-04-05 11:18:25 +00:00
return aRet;
2002-02-04 13:10:18 +00:00
}
sal_Bool SwAccessibleFrame::GetChildIndex(
SwAccessibleMap& rAccMap,
const SwRect& rVisArea,
const SwFrm& rFrm,
const SwAccessibleChild& rChild,
sal_Int32& rPos,
sal_Bool bInPagePreview )
2002-02-04 13:10:18 +00:00
{
sal_Bool bFound = sal_False;
2002-04-05 11:18:25 +00:00
if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
// We need a sorted list here
const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
2002-04-05 11:18:25 +00:00
while( aIter != aVisMap.end() && !bFound )
2002-02-04 13:10:18 +00:00
{
const SwAccessibleChild& rLower = (*aIter).second;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
if( rChild == rLower )
2002-02-04 13:10:18 +00:00
bFound = sal_True;
else
rPos++;
}
2002-04-05 11:18:25 +00:00
else if( rLower.GetSwFrm() )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
// There are no unaccessible SdrObjects that count
bFound = GetChildIndex( rAccMap,
rVisArea, *(rLower.GetSwFrm()), rChild,
2002-05-22 10:48:43 +00:00
rPos, bInPagePreview );
2002-02-04 13:10:18 +00:00
}
2002-04-05 11:18:25 +00:00
++aIter;
}
}
else
{
// The unsorted list is sorted enough, because it returns lower
2002-04-05 11:18:25 +00:00
// frames in the correct order.
const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-05 11:18:25 +00:00
while( aIter != aVisList.end() && !bFound )
{
const SwAccessibleChild& rLower = *aIter;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-04-05 11:18:25 +00:00
{
if( rChild == rLower )
bFound = sal_True;
else
rPos++;
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
bFound = GetChildIndex( rAccMap,
rVisArea, *(rLower.GetSwFrm()), rChild,
2002-05-22 10:48:43 +00:00
rPos, bInPagePreview );
2002-04-05 11:18:25 +00:00
}
++aIter;
2002-02-04 13:10:18 +00:00
}
}
return bFound;
}
SwAccessibleChild SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea,
const SwFrm& rFrm,
const Point& rPixPos,
sal_Bool bInPagePreview,
SwAccessibleMap& rAccMap )
2002-02-04 13:10:18 +00:00
{
SwAccessibleChild aRet;
2002-04-05 11:18:25 +00:00
if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
// We need a sorted list here, and we have to reverse iterate,
// because objects in front should be returned.
const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
SwAccessibleChildMap::const_reverse_iterator aRIter( aVisMap.rbegin() );
2002-04-05 11:18:25 +00:00
while( aRIter != aVisMap.rend() && !aRet.IsValid() )
2002-02-04 13:10:18 +00:00
{
const SwAccessibleChild& rLower = (*aRIter).second;
2002-04-05 11:18:25 +00:00
// A frame is returned if it's frame size is inside the visarea
// and the positiion is inside the frame's paint area.
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-02-04 13:10:18 +00:00
{
SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
if( !aLogBounds.IsEmpty() )
{
Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
if( aPixBounds.IsInside( rPixPos ) )
aRet = rLower;
}
2002-02-04 13:10:18 +00:00
}
2002-04-05 11:18:25 +00:00
else if( rLower.GetSwFrm() )
2002-02-04 13:10:18 +00:00
{
2002-04-05 11:18:25 +00:00
// There are no unaccessible SdrObjects that count
aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
bInPagePreview, rAccMap );
2002-02-04 13:10:18 +00:00
}
2010-12-29 21:01:56 +00:00
++aRIter;
2002-04-05 11:18:25 +00:00
}
}
else
{
// The unsorted list is sorted enough, because it returns lower
// frames in the correct order. Morover, we can iterate forward,
// because the lowers don't overlap!
const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-05 11:18:25 +00:00
while( aIter != aVisList.end() && !aRet.IsValid() )
{
const SwAccessibleChild& rLower = *aIter;
2002-04-05 11:18:25 +00:00
// A frame is returned if it's frame size is inside the visarea
// and the positiion is inside the frame's paint area.
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-04-05 11:18:25 +00:00
{
SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
if( !aLogBounds.IsEmpty() )
{
Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
if( aPixBounds.IsInside( rPixPos ) )
aRet = rLower;
}
2002-04-05 11:18:25 +00:00
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
bInPagePreview, rAccMap );
2002-04-05 11:18:25 +00:00
}
++aIter;
2002-02-04 13:10:18 +00:00
}
}
2002-04-05 11:18:25 +00:00
return aRet;
2002-02-04 13:10:18 +00:00
}
void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
const SwRect& rVisArea,
const SwFrm& rFrm,
::std::list< SwAccessibleChild >& rChildren,
sal_Bool bInPagePreview )
2002-05-15 12:22:47 +00:00
{
if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
2002-05-15 12:22:47 +00:00
{
// We need a sorted list here
const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
2002-05-15 12:22:47 +00:00
while( aIter != aVisMap.end() )
{
const SwAccessibleChild& rLower = (*aIter).second;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-05-15 12:22:47 +00:00
{
rChildren.push_back( rLower );
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
rChildren, bInPagePreview );
2002-05-15 12:22:47 +00:00
}
++aIter;
}
}
else
{
// The unsorted list is sorted enough, because it returns lower
2002-05-15 12:22:47 +00:00
// frames in the correct order.
const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-05-15 12:22:47 +00:00
while( aIter != aVisList.end() )
{
const SwAccessibleChild& rLower = *aIter;
2002-05-22 10:48:43 +00:00
if( rLower.IsAccessible( bInPagePreview ) )
2002-05-15 12:22:47 +00:00
{
rChildren.push_back( rLower );
}
else if( rLower.GetSwFrm() )
{
// There are no unaccessible SdrObjects that count
GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
rChildren, bInPagePreview );
2002-05-15 12:22:47 +00:00
}
++aIter;
}
}
}
SwRect SwAccessibleFrame::GetBounds( const SwAccessibleMap& rAccMap,
const SwFrm *pFrm )
2002-02-04 13:10:18 +00:00
{
if( !pFrm )
pFrm = GetFrm();
2002-02-27 08:32:33 +00:00
SwAccessibleChild aFrm( pFrm );
SwRect aBounds( aFrm.GetBounds( rAccMap ).Intersection( maVisArea ) );
2002-02-04 13:10:18 +00:00
return aBounds;
}
sal_Bool SwAccessibleFrame::IsEditable( ViewShell *pVSh ) const
2002-02-05 14:52:06 +00:00
{
const SwFrm *pFrm = GetFrm();
if( !pFrm )
return sal_False;
OSL_ENSURE( pVSh, "no view shell" );
2002-07-10 15:53:35 +00:00
if( pVSh && (pVSh->GetViewOptions()->IsReadonly() ||
pVSh->IsPreView()) )
2002-02-05 14:52:06 +00:00
return sal_False;
if( !pFrm->IsRootFrm() && pFrm->IsProtected() )
return sal_False;
2002-02-05 14:52:06 +00:00
return sal_True;
2002-02-05 14:52:06 +00:00
}
sal_Bool SwAccessibleFrame::IsOpaque( ViewShell *pVSh ) const
2002-02-05 14:52:06 +00:00
{
SwAccessibleChild aFrm( GetFrm() );
2002-04-11 13:04:40 +00:00
if( !aFrm.GetSwFrm() )
2002-02-05 14:52:06 +00:00
return sal_False;
OSL_ENSURE( pVSh, "no view shell" );
2002-02-05 14:52:06 +00:00
if( !pVSh )
return sal_False;
const SwViewOption *pVOpt = pVSh->GetViewOptions();
do
{
2002-04-11 13:04:40 +00:00
const SwFrm *pFrm = aFrm.GetSwFrm();
2002-02-05 14:52:06 +00:00
if( pFrm->IsRootFrm() )
return sal_True;
if( pFrm->IsPageFrm() && !pVOpt->IsPageBack() )
return sal_False;
const SvxBrushItem &rBack = pFrm->GetAttrSet()->GetBackground();
if( !rBack.GetColor().GetTransparency() ||
rBack.GetGraphicPos() != GPOS_NONE )
return sal_True;
2011-01-30 04:19:53 +09:00
// If a fly frame has a transparent background color, we have to consider the background.
// But a background color "no fill"/"auto fill" should *not* be considered.
if( pFrm->IsFlyFrm() &&
(rBack.GetColor().GetTransparency() != 0) &&
(rBack.GetColor() != COL_TRANSPARENT)
)
return sal_True;
2002-02-05 14:52:06 +00:00
if( pFrm->IsSctFrm() )
{
const SwSection* pSection = ((SwSectionFrm*)pFrm)->GetSection();
if( pSection && ( TOX_HEADER_SECTION == pSection->GetType() ||
TOX_CONTENT_SECTION == pSection->GetType() ) &&
!pVOpt->IsReadonly() &&
SwViewOption::IsIndexShadings() )
2002-02-05 14:52:06 +00:00
return sal_True;
}
2002-04-11 13:04:40 +00:00
if( pFrm->IsFlyFrm() )
aFrm = static_cast<const SwFlyFrm*>(pFrm)->GetAnchorFrm();
2002-02-05 14:52:06 +00:00
else
2002-04-11 13:04:40 +00:00
aFrm = pFrm->GetUpper();
2002-05-22 10:48:43 +00:00
} while( aFrm.GetSwFrm() && !aFrm.IsAccessible( IsInPagePreview() ) );
2002-02-05 14:52:06 +00:00
return sal_False;
}
2002-04-11 13:04:40 +00:00
SwAccessibleFrame::SwAccessibleFrame( const SwRect& rVisArea,
2002-05-22 10:48:43 +00:00
const SwFrm *pF,
sal_Bool bIsPagePreview ) :
maVisArea( rVisArea ),
mpFrm( pF ),
mbIsInPagePreview( bIsPagePreview )
2002-02-04 13:10:18 +00:00
{
}
SwAccessibleFrame::~SwAccessibleFrame()
{
}
const SwFrm* SwAccessibleFrame::GetParent( const SwAccessibleChild& rFrmOrObj,
sal_Bool bInPagePreview )
2002-02-04 13:10:18 +00:00
{
return rFrmOrObj.GetParent( bInPagePreview );
2002-02-04 13:10:18 +00:00
}
2002-04-11 13:04:40 +00:00
String SwAccessibleFrame::GetFormattedPageNumber() const
{
2002-04-11 13:04:40 +00:00
sal_uInt16 nPageNum = GetFrm()->GetVirtPageNum();
sal_uInt32 nFmt = GetFrm()->FindPageFrm()->GetPageDesc()
->GetNumType().GetNumberingType();
if( SVX_NUM_NUMBER_NONE == nFmt )
nFmt = SVX_NUM_ARABIC;
String sRet( FormatNumber( nPageNum, nFmt ) );
return sRet;
}
sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap ) const
{
return GetChildCount( rAccMap, maVisArea, mpFrm, IsInPagePreview() );
}
sw::access::SwAccessibleChild SwAccessibleFrame::GetChild(
SwAccessibleMap& rAccMap,
sal_Int32 nPos ) const
{
return SwAccessibleFrame::GetChild( rAccMap, maVisArea, *mpFrm, nPos, IsInPagePreview() );
}
sal_Int32 SwAccessibleFrame::GetChildIndex( SwAccessibleMap& rAccMap,
const sw::access::SwAccessibleChild& rChild ) const
{
sal_Int32 nPos = 0;
return GetChildIndex( rAccMap, maVisArea, *mpFrm, rChild, nPos, IsInPagePreview() )
? nPos
: -1L;
}
sw::access::SwAccessibleChild SwAccessibleFrame::GetChildAtPixel(
const Point& rPos,
SwAccessibleMap& rAccMap ) const
{
return GetChildAtPixel( maVisArea, *mpFrm, rPos, IsInPagePreview(), rAccMap );
}
void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
::std::list< sw::access::SwAccessibleChild >& rChildren ) const
{
GetChildren( rAccMap, maVisArea, *mpFrm, rChildren, IsInPagePreview() );
}
sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap,
const sw::access::SwAccessibleChild& rFrmOrObj ) const
{
return IsShowing( rFrmOrObj.GetBox( rAccMap ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */