xref: /aoo42x/main/sw/source/core/crsr/trvlcol.cxx (revision efeef26f)
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 
27 
28 
29 #include <crsrsh.hxx>
30 #include <doc.hxx>
31 #include <layfrm.hxx>
32 #include <cntfrm.hxx>
33 #include <swcrsr.hxx>
34 #include <viscrs.hxx>
35 #include <callnk.hxx>
36 
37 
38 
GetCurrColumn(const SwLayoutFrm * pLayFrm)39 SwLayoutFrm* GetCurrColumn( const SwLayoutFrm* pLayFrm )
40 {
41 	while( pLayFrm && !pLayFrm->IsColumnFrm() )
42 		pLayFrm = pLayFrm->GetUpper();
43 	return (SwLayoutFrm*)pLayFrm;
44 }
45 
46 
GetNextColumn(const SwLayoutFrm * pLayFrm)47 SwLayoutFrm* GetNextColumn( const SwLayoutFrm* pLayFrm )
48 {
49 	SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
50 	return pActCol ? (SwLayoutFrm*)pActCol->GetNext() : 0;
51 }
52 
53 
GetPrevColumn(const SwLayoutFrm * pLayFrm)54 SwLayoutFrm* GetPrevColumn( const SwLayoutFrm* pLayFrm )
55 {
56 	SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
57 	return pActCol ? (SwLayoutFrm*)pActCol->GetPrev() : 0;
58 }
59 
60 
GetColumnStt(const SwLayoutFrm * pColFrm)61 SwCntntFrm* GetColumnStt( const SwLayoutFrm* pColFrm )
62 {
63 	return pColFrm ? (SwCntntFrm*)pColFrm->ContainsCntnt() : 0;
64 }
65 
66 
GetColumnEnd(const SwLayoutFrm * pColFrm)67 SwCntntFrm* GetColumnEnd( const SwLayoutFrm* pColFrm )
68 {
69 	SwCntntFrm *pRet = GetColumnStt( pColFrm );
70 	if( !pRet )
71 		return 0;
72 
73 	SwCntntFrm *pNxt = pRet->GetNextCntntFrm();
74 	while( pNxt && pColFrm->IsAnLower( pNxt ) )
75 	{
76 		pRet = pNxt;
77 		pNxt = pNxt->GetNextCntntFrm();
78 	}
79 	return pRet;
80 }
81 
82 
83 SwWhichColumn fnColumnPrev = &GetPrevColumn;
84 SwWhichColumn fnColumnCurr = &GetCurrColumn;
85 SwWhichColumn fnColumnNext = &GetNextColumn;
86 SwPosColumn fnColumnStart = &GetColumnStt;
87 SwPosColumn fnColumnEnd = &GetColumnEnd;
88 
89 
MoveColumn(SwWhichColumn fnWhichCol,SwPosColumn fnPosCol)90 sal_Bool SwCrsrShell::MoveColumn( SwWhichColumn fnWhichCol, SwPosColumn fnPosCol )
91 {
92 	sal_Bool bRet = sal_False;
93 	if( !pTblCrsr )
94 	{
95 		SwLayoutFrm* pLayFrm = GetCurrFrm()->GetUpper();
96 		if( pLayFrm && 0 != ( pLayFrm = (*fnWhichCol)( pLayFrm )) )
97 		{
98 			SwCntntFrm* pCnt = (*fnPosCol)( pLayFrm );
99 			if( pCnt )
100 			{
101 				SET_CURR_SHELL( this );
102 				SwCallLink aLk( *this );        // Crsr-Moves ueberwachen, evt. Link callen
103 				SwCrsrSaveState aSaveState( *pCurCrsr );
104 
105 				pCnt->Calc();					// ???
106 
107 				Point aPt( pCnt->Frm().Pos() + pCnt->Prt().Pos() );
108 				if( fnPosCol == GetColumnEnd )
109 				{
110 					aPt.X() += pCnt->Prt().Width();
111 					aPt.Y() += pCnt->Prt().Height();
112 				}
113 
114 				pCnt->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
115 
116 				if( !pCurCrsr->IsInProtectTable( sal_True ) &&
117 					!pCurCrsr->IsSelOvr() )
118 				{
119 					UpdateCrsr();
120 					bRet = sal_True;
121 				}
122 			}
123 		}
124 	}
125 	return bRet;
126 }
127 
128 
129 
130