Files
libreoffice/sw/source/core/access/accfrmobj.cxx
Jan Holesovsky 5630cca203 Merge commit 'ooo/DEV300_m103'
Conflicts:
	sw/inc/calbck.hxx
	sw/inc/crsrsh.hxx
	sw/inc/dcontact.hxx
	sw/inc/doc.hxx
	sw/inc/docufld.hxx
	sw/inc/editsh.hxx
	sw/inc/expfld.hxx
	sw/inc/fchrfmt.hxx
	sw/inc/fmtcol.hxx
	sw/inc/fmthdft.hxx
	sw/inc/fmtpdsc.hxx
	sw/inc/format.hxx
	sw/inc/frmfmt.hxx
	sw/inc/ndhints.hxx
	sw/inc/ndtxt.hxx
	sw/inc/node.hxx
	sw/inc/numrule.hxx
	sw/inc/paratr.hxx
	sw/inc/swtable.hxx
	sw/inc/unocrsr.hxx
	sw/inc/unofield.hxx
	sw/inc/unoframe.hxx
	sw/inc/unoport.hxx
	sw/inc/unostyle.hxx
	sw/inc/usrfld.hxx
	sw/inc/viewopt.hxx
	sw/inc/viewsh.hxx
	sw/source/core/access/accframebase.cxx
	sw/source/core/access/accmap.cxx
	sw/source/core/access/accnotextframe.cxx
	sw/source/core/access/accpara.cxx
	sw/source/core/access/accpara.hxx
	sw/source/core/attr/calbck.cxx
	sw/source/core/crsr/callnk.cxx
	sw/source/core/crsr/crsrsh.cxx
	sw/source/core/doc/acmplwrd.cxx
	sw/source/core/doc/doc.cxx
	sw/source/core/doc/docdesc.cxx
	sw/source/core/doc/docdraw.cxx
	sw/source/core/doc/docfly.cxx
	sw/source/core/doc/docfmt.cxx
	sw/source/core/doc/doclay.cxx
	sw/source/core/doc/docnew.cxx
	sw/source/core/doc/docnum.cxx
	sw/source/core/doc/doctxm.cxx
	sw/source/core/doc/fmtcol.cxx
	sw/source/core/doc/htmltbl.cxx
	sw/source/core/doc/number.cxx
	sw/source/core/docnode/ndsect.cxx
	sw/source/core/docnode/ndtbl.cxx
	sw/source/core/docnode/node.cxx
	sw/source/core/docnode/node2lay.cxx
	sw/source/core/docnode/section.cxx
	sw/source/core/docnode/swbaslnk.cxx
	sw/source/core/draw/dcontact.cxx
	sw/source/core/draw/dview.cxx
	sw/source/core/edit/autofmt.cxx
	sw/source/core/edit/editsh.cxx
	sw/source/core/edit/edlingu.cxx
	sw/source/core/fields/authfld.cxx
	sw/source/core/fields/dbfld.cxx
	sw/source/core/fields/docufld.cxx
	sw/source/core/fields/expfld.cxx
	sw/source/core/fields/reffld.cxx
	sw/source/core/fields/tblcalc.cxx
	sw/source/core/frmedt/fefly1.cxx
	sw/source/core/frmedt/feshview.cxx
	sw/source/core/frmedt/tblsel.cxx
	sw/source/core/inc/flyfrm.hxx
	sw/source/core/inc/prevwpage.hxx
	sw/source/core/inc/rolbck.hxx
	sw/source/core/inc/txtfrm.hxx
	sw/source/core/layout/atrfrm.cxx
	sw/source/core/layout/findfrm.cxx
	sw/source/core/layout/flowfrm.cxx
	sw/source/core/layout/fly.cxx
	sw/source/core/layout/flycnt.cxx
	sw/source/core/layout/flylay.cxx
	sw/source/core/layout/frmtool.cxx
	sw/source/core/layout/hffrm.cxx
	sw/source/core/layout/pagechg.cxx
	sw/source/core/layout/pagedesc.cxx
	sw/source/core/layout/paintfrm.cxx
	sw/source/core/layout/sectfrm.cxx
	sw/source/core/layout/ssfrm.cxx
	sw/source/core/layout/tabfrm.cxx
	sw/source/core/layout/wsfrm.cxx
	sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
	sw/source/core/table/swtable.cxx
	sw/source/core/text/EnhancedPDFExportHelper.cxx
	sw/source/core/text/inftxt.cxx
	sw/source/core/text/porfld.cxx
	sw/source/core/text/txtdrop.cxx
	sw/source/core/text/txtfly.cxx
	sw/source/core/text/txtfrm.cxx
	sw/source/core/text/txtio.cxx
	sw/source/core/text/txttab.cxx
	sw/source/core/tox/tox.cxx
	sw/source/core/txtnode/atrflyin.cxx
	sw/source/core/txtnode/fmtatr2.cxx
	sw/source/core/txtnode/ndtxt.cxx
	sw/source/core/undo/SwUndoPageDesc.cxx
	sw/source/core/undo/undraw.cxx
	sw/source/core/unocore/unochart.cxx
	sw/source/core/unocore/unocoll.cxx
	sw/source/core/unocore/unodraw.cxx
	sw/source/core/unocore/unofield.cxx
	sw/source/core/unocore/unoframe.cxx
	sw/source/core/unocore/unoftn.cxx
	sw/source/core/unocore/unoidx.cxx
	sw/source/core/unocore/unoobj2.cxx
	sw/source/core/unocore/unoparagraph.cxx
	sw/source/core/unocore/unoport.cxx
	sw/source/core/unocore/unoportenum.cxx
	sw/source/core/unocore/unoredline.cxx
	sw/source/core/unocore/unoredlines.cxx
	sw/source/core/unocore/unorefmk.cxx
	sw/source/core/unocore/unosect.cxx
	sw/source/core/unocore/unosett.cxx
	sw/source/core/unocore/unostyle.cxx
	sw/source/core/unocore/unotbl.cxx
	sw/source/core/unocore/unotext.cxx
	sw/source/core/view/viewimp.cxx
	sw/source/core/view/viewpg.cxx
	sw/source/core/view/viewsh.cxx
	sw/source/core/view/vnew.cxx
	sw/source/core/view/vprint.cxx
	sw/source/filter/ww8/rtfexport.cxx
	sw/source/filter/ww8/rtfexport.hxx
	sw/source/filter/ww8/wrtw8nds.cxx
	sw/source/filter/ww8/wrtww8gr.cxx
	sw/source/filter/xml/XMLRedlineImportHelper.cxx
	sw/source/ui/app/apphdl.cxx
	sw/source/ui/app/docsh.cxx
	sw/source/ui/app/docsh2.cxx
	sw/source/ui/app/swmodul1.cxx
	sw/source/ui/config/viewopt.cxx
	sw/source/ui/fldui/fldpage.cxx
	sw/source/ui/uiview/srcview.cxx
	sw/source/ui/uiview/view.cxx
	sw/source/ui/uno/unotxdoc.cxx
	sw/source/ui/vba/wordvbahelper.cxx
	sw/source/ui/wrtsh/wrtsh1.cxx
2011-03-23 17:00:12 +01:00

431 lines
11 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
#include <accfrmobj.hxx>
#include <accmap.hxx>
#include <acccontext.hxx>
#include <viewsh.hxx>
#include <rootfrm.hxx>
#include <flyfrm.hxx>
#include <pagefrm.hxx>
#include <cellfrm.hxx>
#include <swtable.hxx>
#include <dflyobj.hxx>
#include <frmfmt.hxx>
#include <fmtanchr.hxx>
#include <dcontact.hxx>
#include <vcl/window.hxx>
namespace css = ::com::sun::star;
namespace sw { namespace access {
SwAccessibleChild::SwAccessibleChild()
: mpFrm( 0 )
, mpDrawObj( 0 )
, mpWindow( 0 )
{}
SwAccessibleChild::SwAccessibleChild( const SdrObject* pDrawObj )
: mpFrm( 0 )
, mpDrawObj( 0 )
, mpWindow( 0 )
{
Init( pDrawObj );
}
SwAccessibleChild::SwAccessibleChild( const SwFrm* pFrm )
: mpFrm( 0 )
, mpDrawObj( 0 )
, mpWindow( 0 )
{
Init( pFrm );
}
SwAccessibleChild::SwAccessibleChild( Window* pWindow )
: mpFrm( 0 )
, mpDrawObj( 0 )
, mpWindow( 0 )
{
Init( pWindow );
}
SwAccessibleChild::SwAccessibleChild( const SwFrm* pFrm,
const SdrObject* pDrawObj,
Window* pWindow )
{
if ( pFrm )
{
Init( pFrm );
}
else if ( pDrawObj )
{
Init( pDrawObj );
}
else if ( pWindow )
{
Init( pWindow );
}
OSL_ENSURE( (!pFrm || pFrm == mpFrm) &&
(!pDrawObj || pDrawObj == mpDrawObj) &&
(!pWindow || pWindow == mpWindow),
"invalid frame/object/window combination" );
}
void SwAccessibleChild::Init( const SdrObject* pDrawObj )
{
mpDrawObj = pDrawObj;
mpFrm = mpDrawObj && mpDrawObj->ISA(SwVirtFlyDrawObj)
? static_cast < const SwVirtFlyDrawObj * >( mpDrawObj )->GetFlyFrm()
: 0;
mpWindow = 0;
}
void SwAccessibleChild::Init( const SwFrm* pFrm )
{
mpFrm = pFrm;
mpDrawObj = mpFrm && mpFrm->IsFlyFrm()
? static_cast < const SwFlyFrm * >( mpFrm )->GetVirtDrawObj()
: 0;
mpWindow = 0;
}
void SwAccessibleChild::Init( Window* pWindow )
{
mpWindow = pWindow;
mpFrm = 0;
mpDrawObj = 0;
}
bool SwAccessibleChild::IsAccessible( sal_Bool bPagePreview ) const
{
bool bRet( false );
if ( mpFrm )
{
bRet = mpFrm->IsAccessibleFrm() &&
( !mpFrm->IsCellFrm() ||
static_cast<const SwCellFrm *>( mpFrm )->GetTabBox()->GetSttNd() != 0 ) &&
!mpFrm->IsInCoveredCell() &&
( bPagePreview ||
!mpFrm->IsPageFrm() );
}
else if ( mpDrawObj )
{
bRet = true;
}
else if ( mpWindow )
{
bRet = true;
}
return bRet;
}
bool SwAccessibleChild::IsBoundAsChar() const
{
bool bRet( false );
if ( mpFrm )
{
bRet = mpFrm->IsFlyFrm() &&
static_cast< const SwFlyFrm *>(mpFrm)->IsFlyInCntFrm();
}
else if ( mpDrawObj )
{
const SwFrmFmt* mpFrmFmt = ::FindFrmFmt( mpDrawObj );
bRet = mpFrmFmt
? (FLY_AS_CHAR == mpFrmFmt->GetAnchor().GetAnchorId())
: false;
}
else if ( mpWindow )
{
bRet = false;
}
return bRet;
}
SwAccessibleChild::SwAccessibleChild( const SwAccessibleChild& r )
: mpFrm( r.mpFrm )
, mpDrawObj( r.mpDrawObj )
, mpWindow( r.mpWindow )
{}
SwAccessibleChild& SwAccessibleChild::operator=( const SwAccessibleChild& r )
{
mpDrawObj = r.mpDrawObj;
mpFrm = r.mpFrm;
mpWindow = r.mpWindow;
return *this;
}
SwAccessibleChild& SwAccessibleChild::operator=( const SdrObject* pDrawObj )
{
Init( pDrawObj );
return *this;
}
SwAccessibleChild& SwAccessibleChild::operator=( const SwFrm* pFrm )
{
Init( pFrm );
return *this;
}
SwAccessibleChild& SwAccessibleChild::operator=( Window* pWindow )
{
Init( pWindow );
return *this;
}
bool SwAccessibleChild::operator==( const SwAccessibleChild& r ) const
{
return mpFrm == r.mpFrm &&
mpDrawObj == r.mpDrawObj &&
mpWindow == r.mpWindow;
}
bool SwAccessibleChild::IsValid() const
{
return mpFrm != 0 ||
mpDrawObj != 0 ||
mpWindow != 0;
}
const SdrObject* SwAccessibleChild::GetDrawObject() const
{
return mpDrawObj;
}
const SwFrm *SwAccessibleChild::GetSwFrm() const
{
return mpFrm;
}
Window* SwAccessibleChild::GetWindow() const
{
return mpWindow;
}
bool SwAccessibleChild::IsVisibleChildrenOnly() const
{
bool bRet( false );
if ( !mpFrm )
{
bRet = true;
}
else
{
bRet = mpFrm->IsRootFrm() ||
!( mpFrm->IsTabFrm() ||
mpFrm->IsInTab() ||
( IsBoundAsChar() &&
static_cast<const SwFlyFrm*>(mpFrm)->GetAnchorFrm()->IsInTab() ) );
}
return bRet;
}
SwRect SwAccessibleChild::GetBox( const SwAccessibleMap& rAccMap ) const
{
SwRect aBox;
if ( mpFrm )
{
if ( mpFrm->IsPageFrm() &&
static_cast< const SwPageFrm * >( mpFrm )->IsEmptyPage() )
{
aBox = SwRect( mpFrm->Frm().Left(), mpFrm->Frm().Top()-1, 1, 1 );
}
else if ( mpFrm->IsTabFrm() )
{
aBox = SwRect( mpFrm->Frm() );
aBox.Intersection( mpFrm->GetUpper()->Frm() );
}
else
{
aBox = mpFrm->Frm();
}
}
else if( mpDrawObj )
{
aBox = SwRect( mpDrawObj->GetCurrentBoundRect() );
}
else if ( mpWindow )
{
aBox = SwRect( rAccMap.GetShell()->GetWin()->PixelToLogic(
Rectangle( mpWindow->GetPosPixel(),
mpWindow->GetSizePixel() ) ) );
}
return aBox;
}
SwRect SwAccessibleChild::GetBounds( const SwAccessibleMap& rAccMap ) const
{
SwRect aBound;
if( mpFrm )
{
if( mpFrm->IsPageFrm() &&
static_cast< const SwPageFrm * >( mpFrm )->IsEmptyPage() )
{
aBound = SwRect( mpFrm->Frm().Left(), mpFrm->Frm().Top()-1, 0, 0 );
}
else
aBound = mpFrm->PaintArea();
}
else if( mpDrawObj )
{
aBound = GetBox( rAccMap );
}
else if ( mpWindow )
{
aBound = GetBox( rAccMap );
}
return aBound;
}
bool SwAccessibleChild::AlwaysIncludeAsChild() const
{
bool bAlwaysIncludedAsChild( false );
if ( mpWindow )
{
bAlwaysIncludedAsChild = true;
}
return bAlwaysIncludedAsChild;
}
const SwFrm* SwAccessibleChild::GetParent( const sal_Bool bInPagePreview ) const
{
const SwFrm* pParent( 0 );
if ( mpFrm )
{
if( mpFrm->IsFlyFrm() )
{
const SwFlyFrm* pFly = static_cast< const SwFlyFrm *>( mpFrm );
if( pFly->IsFlyInCntFrm() )
{
// For FLY_AS_CHAR the parent is the anchor
pParent = pFly->GetAnchorFrm();
OSL_ENSURE( SwAccessibleChild( pParent ).IsAccessible( bInPagePreview ),
"parent is not accessible" );
}
else
{
// In any other case the parent is the root frm
// (in page preview, the page frame)
if( bInPagePreview )
pParent = pFly->FindPageFrm();
else
pParent = pFly->getRootFrm();
}
}
else
{
SwAccessibleChild aUpper( mpFrm->GetUpper() );
while( aUpper.GetSwFrm() && !aUpper.IsAccessible(bInPagePreview) )
{
aUpper = aUpper.GetSwFrm()->GetUpper();
}
pParent = aUpper.GetSwFrm();
}
}
else if( mpDrawObj )
{
const SwDrawContact *pContact =
static_cast< const SwDrawContact* >( GetUserCall( mpDrawObj ) );
OSL_ENSURE( pContact, "sdr contact is missing" );
if( pContact )
{
const SwFrmFmt *pFrmFmt = pContact->GetFmt();
OSL_ENSURE( pFrmFmt, "frame format is missing" );
if( pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
{
// For FLY_AS_CHAR the parent is the anchor
pParent = pContact->GetAnchorFrm();
OSL_ENSURE( SwAccessibleChild( pParent ).IsAccessible( bInPagePreview ),
"parent is not accessible" );
}
else
{
// In any other case the parent is the root frm
if( bInPagePreview )
pParent = pContact->GetAnchorFrm()->FindPageFrm();
else
pParent = pContact->GetAnchorFrm()->getRootFrm();
}
}
}
else if ( mpWindow )
{
css::uno::Reference < css::accessibility::XAccessible > xAcc =
mpWindow->GetAccessible();
if ( xAcc.is() )
{
css::uno::Reference < css::accessibility::XAccessibleContext > xAccContext =
xAcc->getAccessibleContext();
if ( xAccContext.is() )
{
css::uno::Reference < css::accessibility::XAccessible > xAccParent =
xAccContext->getAccessibleParent();
if ( xAccParent.is() )
{
SwAccessibleContext* pAccParentImpl =
dynamic_cast< SwAccessibleContext *>( xAccParent.get() );
if ( pAccParentImpl )
{
pParent = pAccParentImpl->GetFrm();
}
}
}
}
}
return pParent;
}
} } // eof of namespace sw::access
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */