merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / layout / swselectionlist.cxx
blob50a149cb743cee8176ae02d9fb04a0256420f10a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swselectionlist.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <swselectionlist.hxx>
35 #include <layfrm.hxx>
36 #include <flyfrm.hxx>
37 #include <ftnfrm.hxx>
39 /** This class is used as parameter for functions to create a rectangular text selection
42 namespace {
44 /** Find the context of a given frame
46 A context is the environment where text is allowed to flow.
47 The context is represented by
48 - the SwRootFrm if the frame is part of a page body
49 - the SwHeaderFrm if the frame is part of a page header
50 - the SwFooterFrm if the frame is part of a page footer
51 - the (master) SwFtnFrm if the frame is part of footnote
52 - the (first) SwFlyFrm if the frame is part of a (linked) fly frame
54 @param pFrm
55 the given frame
57 @return the context of the frame, represented by a SwFrm*
59 const SwFrm* getContext( const SwFrm* pFrm )
61 while( pFrm )
63 if( pFrm->IsRootFrm() || pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() )
64 break;
65 if( pFrm->IsFlyFrm() )
67 const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>( pFrm );
68 while( pFly->GetPrevLink() )
69 pFly = pFly->GetPrevLink();
70 break;
72 if( pFrm->IsFtnFrm() )
74 const SwFtnFrm* pFtn = static_cast<const SwFtnFrm*>( pFrm );
75 while( pFtn->GetMaster() )
76 pFtn = pFtn->GetMaster();
77 break;
79 pFrm = pFrm->GetUpper();
81 return pFrm;
85 SwSelectionList::SwSelectionList( const SwFrm* pInitCxt ) :
86 pContext( getContext( pInitCxt ) )
90 bool SwSelectionList::checkContext( const SwFrm* pCheck )
92 pCheck = getContext( pCheck );
93 if( !pContext )
94 pContext = pCheck;
95 return pContext == pCheck;