1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10*efeef26fSAndrew Rist * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*efeef26fSAndrew Rist * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19*efeef26fSAndrew Rist * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <crsrsh.hxx> 30cdf0e10cSrcweir #include <doc.hxx> 31cdf0e10cSrcweir #include <layfrm.hxx> 32cdf0e10cSrcweir #include <cntfrm.hxx> 33cdf0e10cSrcweir #include <swcrsr.hxx> 34cdf0e10cSrcweir #include <viscrs.hxx> 35cdf0e10cSrcweir #include <callnk.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir GetCurrColumn(const SwLayoutFrm * pLayFrm)39cdf0e10cSrcweirSwLayoutFrm* GetCurrColumn( const SwLayoutFrm* pLayFrm ) 40cdf0e10cSrcweir { 41cdf0e10cSrcweir while( pLayFrm && !pLayFrm->IsColumnFrm() ) 42cdf0e10cSrcweir pLayFrm = pLayFrm->GetUpper(); 43cdf0e10cSrcweir return (SwLayoutFrm*)pLayFrm; 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir GetNextColumn(const SwLayoutFrm * pLayFrm)47cdf0e10cSrcweirSwLayoutFrm* GetNextColumn( const SwLayoutFrm* pLayFrm ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm ); 50cdf0e10cSrcweir return pActCol ? (SwLayoutFrm*)pActCol->GetNext() : 0; 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir GetPrevColumn(const SwLayoutFrm * pLayFrm)54cdf0e10cSrcweirSwLayoutFrm* GetPrevColumn( const SwLayoutFrm* pLayFrm ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm ); 57cdf0e10cSrcweir return pActCol ? (SwLayoutFrm*)pActCol->GetPrev() : 0; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir GetColumnStt(const SwLayoutFrm * pColFrm)61cdf0e10cSrcweirSwCntntFrm* GetColumnStt( const SwLayoutFrm* pColFrm ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir return pColFrm ? (SwCntntFrm*)pColFrm->ContainsCntnt() : 0; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir GetColumnEnd(const SwLayoutFrm * pColFrm)67cdf0e10cSrcweirSwCntntFrm* GetColumnEnd( const SwLayoutFrm* pColFrm ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir SwCntntFrm *pRet = GetColumnStt( pColFrm ); 70cdf0e10cSrcweir if( !pRet ) 71cdf0e10cSrcweir return 0; 72cdf0e10cSrcweir 73cdf0e10cSrcweir SwCntntFrm *pNxt = pRet->GetNextCntntFrm(); 74cdf0e10cSrcweir while( pNxt && pColFrm->IsAnLower( pNxt ) ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir pRet = pNxt; 77cdf0e10cSrcweir pNxt = pNxt->GetNextCntntFrm(); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir return pRet; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir SwWhichColumn fnColumnPrev = &GetPrevColumn; 84cdf0e10cSrcweir SwWhichColumn fnColumnCurr = &GetCurrColumn; 85cdf0e10cSrcweir SwWhichColumn fnColumnNext = &GetNextColumn; 86cdf0e10cSrcweir SwPosColumn fnColumnStart = &GetColumnStt; 87cdf0e10cSrcweir SwPosColumn fnColumnEnd = &GetColumnEnd; 88cdf0e10cSrcweir 89cdf0e10cSrcweir MoveColumn(SwWhichColumn fnWhichCol,SwPosColumn fnPosCol)90cdf0e10cSrcweirsal_Bool SwCrsrShell::MoveColumn( SwWhichColumn fnWhichCol, SwPosColumn fnPosCol ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir sal_Bool bRet = sal_False; 93cdf0e10cSrcweir if( !pTblCrsr ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir SwLayoutFrm* pLayFrm = GetCurrFrm()->GetUpper(); 96cdf0e10cSrcweir if( pLayFrm && 0 != ( pLayFrm = (*fnWhichCol)( pLayFrm )) ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir SwCntntFrm* pCnt = (*fnPosCol)( pLayFrm ); 99cdf0e10cSrcweir if( pCnt ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir SET_CURR_SHELL( this ); 102cdf0e10cSrcweir SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen 103cdf0e10cSrcweir SwCrsrSaveState aSaveState( *pCurCrsr ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir pCnt->Calc(); // ??? 106cdf0e10cSrcweir 107cdf0e10cSrcweir Point aPt( pCnt->Frm().Pos() + pCnt->Prt().Pos() ); 108cdf0e10cSrcweir if( fnPosCol == GetColumnEnd ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir aPt.X() += pCnt->Prt().Width(); 111cdf0e10cSrcweir aPt.Y() += pCnt->Prt().Height(); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir pCnt->GetCrsrOfst( pCurCrsr->GetPoint(), aPt ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if( !pCurCrsr->IsInProtectTable( sal_True ) && 117cdf0e10cSrcweir !pCurCrsr->IsSelOvr() ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir UpdateCrsr(); 120cdf0e10cSrcweir bRet = sal_True; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125cdf0e10cSrcweir return bRet; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130