merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / access / accfrmobjmap.cxx
blobc82f5dfef3d173bd05f8c3702ee6c785450d5bef
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: accfrmobjmap.cxx,v $
10 * $Revision: 1.8 $
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"
35 #include <doc.hxx>
36 #include <frmfmt.hxx>
37 #include <pagefrm.hxx>
38 #include <txtfrm.hxx>
39 #include <node.hxx>
40 // OD 2004-05-24 #i28701#
41 #include <sortedobjs.hxx>
43 #ifndef _ACCFFRMOBJMAP_HXX
44 #include <accfrmobjmap.hxx>
45 #endif
47 ::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert(
48 sal_uInt32 nPos, const SwFrmOrObj& rLower )
50 SwFrmOrObjMapKey aKey( SwFrmOrObjMapKey::TEXT, nPos );
51 value_type aEntry( aKey, rLower );
52 return _SwFrmOrObjMap::insert( aEntry );
55 ::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert(
56 const SdrObject *pObj, const SwFrmOrObj& rLower, const SwDoc *pDoc )
58 if( !bLayerIdsValid )
60 nHellId = pDoc->GetHellId();
61 nControlsId = pDoc->GetControlsId();
62 bLayerIdsValid = sal_True;
65 SdrLayerID nLayer = pObj->GetLayer();
66 SwFrmOrObjMapKey::LayerId eLayerId = (nHellId == nLayer)
67 ? SwFrmOrObjMapKey::HELL
68 : ((nControlsId == nLayer) ? SwFrmOrObjMapKey::CONTROLS
69 : SwFrmOrObjMapKey::HEAVEN);
70 SwFrmOrObjMapKey aKey( eLayerId, pObj->GetOrdNum() );
71 value_type aEntry( aKey, rLower );
72 return _SwFrmOrObjMap::insert( aEntry );
75 SwFrmOrObjMap::SwFrmOrObjMap(
76 const SwRect& rVisArea, const SwFrm *pFrm ) :
77 bLayerIdsValid( sal_False )
79 SwFrmOrObj aFrm( pFrm );
80 sal_Bool bVisibleOnly = aFrm.IsVisibleChildrenOnly();
82 sal_uInt32 nPos = 0;
83 SwFrmOrObj aLower( pFrm->GetLower() );
84 while( aLower.GetSwFrm() )
86 if( !bVisibleOnly || aLower.GetBox().IsOver( rVisArea ) )
87 insert( nPos++, aLower );
89 aLower = aLower.GetSwFrm()->GetNext();
92 if( pFrm->IsPageFrm() )
94 ASSERT( bVisibleOnly, "page frame within tab frame???" );
95 const SwPageFrm *pPgFrm =
96 static_cast< const SwPageFrm * >( pFrm );
97 const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
98 if( pObjs )
100 const SwDoc *pDoc = pPgFrm->GetFmt()->GetDoc();
101 for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
103 aLower = (*pObjs)[i]->GetDrawObj();
104 if( aLower.GetBox().IsOver( rVisArea ) )
105 insert( aLower.GetSdrObject(), aLower, pDoc );
109 else if( pFrm->IsTxtFrm() )
111 const SwDoc *pDoc = static_cast< const SwTxtFrm * >( pFrm )->GetNode()
112 ->GetDoc();
113 const SwSortedObjs *pObjs = pFrm->GetDrawObjs();
114 if( pObjs )
116 for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
118 aLower = (*pObjs)[i]->GetDrawObj();
119 if( aLower.IsBoundAsChar() &&
120 (!bVisibleOnly || aLower.GetBox().IsOver( rVisArea )) )
121 insert( aLower.GetSdrObject(), aLower, pDoc );