Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <crsrsh.hxx>
21 : #include <doc.hxx>
22 : #include <layfrm.hxx>
23 : #include <cntfrm.hxx>
24 : #include <swcrsr.hxx>
25 : #include <viscrs.hxx>
26 : #include <callnk.hxx>
27 :
28 :
29 :
30 0 : SwLayoutFrm* GetCurrColumn( const SwLayoutFrm* pLayFrm )
31 : {
32 0 : while( pLayFrm && !pLayFrm->IsColumnFrm() )
33 0 : pLayFrm = pLayFrm->GetUpper();
34 0 : return (SwLayoutFrm*)pLayFrm;
35 : }
36 :
37 :
38 0 : SwLayoutFrm* GetNextColumn( const SwLayoutFrm* pLayFrm )
39 : {
40 0 : SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
41 0 : return pActCol ? (SwLayoutFrm*)pActCol->GetNext() : 0;
42 : }
43 :
44 :
45 0 : SwLayoutFrm* GetPrevColumn( const SwLayoutFrm* pLayFrm )
46 : {
47 0 : SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
48 0 : return pActCol ? (SwLayoutFrm*)pActCol->GetPrev() : 0;
49 : }
50 :
51 :
52 0 : SwCntntFrm* GetColumnStt( const SwLayoutFrm* pColFrm )
53 : {
54 0 : return pColFrm ? (SwCntntFrm*)pColFrm->ContainsCntnt() : 0;
55 : }
56 :
57 :
58 0 : SwCntntFrm* GetColumnEnd( const SwLayoutFrm* pColFrm )
59 : {
60 0 : SwCntntFrm *pRet = GetColumnStt( pColFrm );
61 0 : if( !pRet )
62 0 : return 0;
63 :
64 0 : SwCntntFrm *pNxt = pRet->GetNextCntntFrm();
65 0 : while( pNxt && pColFrm->IsAnLower( pNxt ) )
66 : {
67 0 : pRet = pNxt;
68 0 : pNxt = pNxt->GetNextCntntFrm();
69 : }
70 0 : return pRet;
71 : }
72 :
73 :
74 : SwWhichColumn fnColumnPrev = &GetPrevColumn;
75 : SwWhichColumn fnColumnCurr = &GetCurrColumn;
76 : SwWhichColumn fnColumnNext = &GetNextColumn;
77 : SwPosColumn fnColumnStart = &GetColumnStt;
78 : SwPosColumn fnColumnEnd = &GetColumnEnd;
79 :
80 :
81 0 : sal_Bool SwCrsrShell::MoveColumn( SwWhichColumn fnWhichCol, SwPosColumn fnPosCol )
82 : {
83 0 : sal_Bool bRet = sal_False;
84 0 : if( !pTblCrsr )
85 : {
86 0 : SwLayoutFrm* pLayFrm = GetCurrFrm()->GetUpper();
87 0 : if( pLayFrm && 0 != ( pLayFrm = (*fnWhichCol)( pLayFrm )) )
88 : {
89 0 : SwCntntFrm* pCnt = (*fnPosCol)( pLayFrm );
90 0 : if( pCnt )
91 : {
92 0 : SET_CURR_SHELL( this );
93 0 : SwCallLink aLk( *this ); // watch Crsr-Moves; call Link if needed
94 0 : SwCrsrSaveState aSaveState( *pCurCrsr );
95 :
96 0 : pCnt->Calc();
97 :
98 0 : Point aPt( pCnt->Frm().Pos() + pCnt->Prt().Pos() );
99 0 : if( fnPosCol == GetColumnEnd )
100 : {
101 0 : aPt.X() += pCnt->Prt().Width();
102 0 : aPt.Y() += pCnt->Prt().Height();
103 : }
104 :
105 0 : pCnt->GetCrsrOfst( pCurCrsr->GetPoint(), aPt );
106 :
107 0 : if( !pCurCrsr->IsInProtectTable( sal_True ) &&
108 0 : !pCurCrsr->IsSelOvr() )
109 : {
110 0 : UpdateCrsr();
111 0 : bRet = sal_True;
112 0 : }
113 : }
114 : }
115 : }
116 0 : return bRet;
117 : }
118 :
119 :
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|