1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 #include <movedfwdfrmsbyobjpos.hxx> 31 #include <txtfrm.hxx> 32 #include <rowfrm.hxx> 33 #include <pagefrm.hxx> 34 #include <ndtxt.hxx> 35 #include <switerator.hxx> 36 37 SwMovedFwdFrmsByObjPos::SwMovedFwdFrmsByObjPos() 38 { 39 } 40 41 SwMovedFwdFrmsByObjPos::~SwMovedFwdFrmsByObjPos() 42 { 43 Clear(); 44 } 45 46 void SwMovedFwdFrmsByObjPos::Insert( const SwTxtFrm& _rMovedFwdFrmByObjPos, 47 const sal_uInt32 _nToPageNum ) 48 { 49 if ( maMovedFwdFrms.end() == 50 maMovedFwdFrms.find( _rMovedFwdFrmByObjPos.GetTxtNode() ) ) 51 { 52 const NodeMapEntry aEntry( _rMovedFwdFrmByObjPos.GetTxtNode(), _nToPageNum ); 53 maMovedFwdFrms.insert( aEntry ); 54 } 55 } 56 57 void SwMovedFwdFrmsByObjPos::Remove( const SwTxtFrm& _rTxtFrm ) 58 { 59 maMovedFwdFrms.erase( _rTxtFrm.GetTxtNode() ); 60 }; 61 62 bool SwMovedFwdFrmsByObjPos::FrmMovedFwdByObjPos( const SwTxtFrm& _rTxtFrm, 63 sal_uInt32& _ornToPageNum ) const 64 { 65 NodeMapIter aIter = maMovedFwdFrms.find( _rTxtFrm.GetTxtNode() ); 66 if ( maMovedFwdFrms.end() != aIter ) 67 { 68 _ornToPageNum = (*aIter).second; 69 return true; 70 } 71 72 return false; 73 } 74 75 // --> OD 2004-10-05 #i26945# 76 bool SwMovedFwdFrmsByObjPos::DoesRowContainMovedFwdFrm( const SwRowFrm& _rRowFrm ) const 77 { 78 bool bDoesRowContainMovedFwdFrm( false ); 79 80 const sal_uInt32 nPageNumOfRow = _rRowFrm.FindPageFrm()->GetPhyPageNum(); 81 82 NodeMapIter aIter = maMovedFwdFrms.begin(); 83 for ( ; aIter != maMovedFwdFrms.end(); ++aIter ) 84 { 85 const NodeMapEntry& rEntry = *(aIter); 86 if ( rEntry.second >= nPageNumOfRow ) 87 { 88 SwIterator<SwTxtFrm,SwTxtNode> aFrmIter( *rEntry.first ); 89 for( SwTxtFrm* pTxtFrm = aFrmIter.First(); pTxtFrm; pTxtFrm = (SwTxtFrm*)aFrmIter.Next() ) 90 { 91 // --> OD 2004-12-03 #115759# - assure that found text frame 92 // is the first one. 93 if ( _rRowFrm.IsAnLower( pTxtFrm ) && !pTxtFrm->GetIndPrev() ) 94 // <-- 95 { 96 bDoesRowContainMovedFwdFrm = true; 97 break; 98 } 99 } 100 } 101 } 102 103 return bDoesRowContainMovedFwdFrm; 104 } 105 // <-- 106 107