1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #include <movedfwdfrmsbyobjpos.hxx>
27 #include <txtfrm.hxx>
28 #include <rowfrm.hxx>
29 #include <pagefrm.hxx>
30 #include <ndtxt.hxx>
31 #include <switerator.hxx>
32
SwMovedFwdFrmsByObjPos()33 SwMovedFwdFrmsByObjPos::SwMovedFwdFrmsByObjPos()
34 {
35 }
36
~SwMovedFwdFrmsByObjPos()37 SwMovedFwdFrmsByObjPos::~SwMovedFwdFrmsByObjPos()
38 {
39 Clear();
40 }
41
Insert(const SwTxtFrm & _rMovedFwdFrmByObjPos,const sal_uInt32 _nToPageNum)42 void SwMovedFwdFrmsByObjPos::Insert( const SwTxtFrm& _rMovedFwdFrmByObjPos,
43 const sal_uInt32 _nToPageNum )
44 {
45 if ( maMovedFwdFrms.end() ==
46 maMovedFwdFrms.find( _rMovedFwdFrmByObjPos.GetTxtNode() ) )
47 {
48 const NodeMapEntry aEntry( _rMovedFwdFrmByObjPos.GetTxtNode(), _nToPageNum );
49 maMovedFwdFrms.insert( aEntry );
50 }
51 }
52
Remove(const SwTxtFrm & _rTxtFrm)53 void SwMovedFwdFrmsByObjPos::Remove( const SwTxtFrm& _rTxtFrm )
54 {
55 maMovedFwdFrms.erase( _rTxtFrm.GetTxtNode() );
56 };
57
FrmMovedFwdByObjPos(const SwTxtFrm & _rTxtFrm,sal_uInt32 & _ornToPageNum) const58 bool SwMovedFwdFrmsByObjPos::FrmMovedFwdByObjPos( const SwTxtFrm& _rTxtFrm,
59 sal_uInt32& _ornToPageNum ) const
60 {
61 NodeMapIter aIter = maMovedFwdFrms.find( _rTxtFrm.GetTxtNode() );
62 if ( maMovedFwdFrms.end() != aIter )
63 {
64 _ornToPageNum = (*aIter).second;
65 return true;
66 }
67
68 return false;
69 }
70
71 // --> OD 2004-10-05 #i26945#
DoesRowContainMovedFwdFrm(const SwRowFrm & _rRowFrm) const72 bool SwMovedFwdFrmsByObjPos::DoesRowContainMovedFwdFrm( const SwRowFrm& _rRowFrm ) const
73 {
74 bool bDoesRowContainMovedFwdFrm( false );
75
76 const sal_uInt32 nPageNumOfRow = _rRowFrm.FindPageFrm()->GetPhyPageNum();
77
78 NodeMapIter aIter = maMovedFwdFrms.begin();
79 for ( ; aIter != maMovedFwdFrms.end(); ++aIter )
80 {
81 const NodeMapEntry& rEntry = *(aIter);
82 if ( rEntry.second >= nPageNumOfRow )
83 {
84 SwIterator<SwTxtFrm,SwTxtNode> aFrmIter( *rEntry.first );
85 for( SwTxtFrm* pTxtFrm = aFrmIter.First(); pTxtFrm; pTxtFrm = (SwTxtFrm*)aFrmIter.Next() )
86 {
87 // --> OD 2004-12-03 #115759# - assure that found text frame
88 // is the first one.
89 if ( _rRowFrm.IsAnLower( pTxtFrm ) && !pTxtFrm->GetIndPrev() )
90 // <--
91 {
92 bDoesRowContainMovedFwdFrm = true;
93 break;
94 }
95 }
96 }
97 }
98
99 return bDoesRowContainMovedFwdFrm;
100 }
101 // <--
102
103