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 0 : SwLayoutFrm* GetCurrColumn( const SwLayoutFrm* pLayFrm )
29 : {
30 0 : while( pLayFrm && !pLayFrm->IsColumnFrm() )
31 0 : pLayFrm = pLayFrm->GetUpper();
32 0 : return (SwLayoutFrm*)pLayFrm;
33 : }
34 :
35 0 : SwLayoutFrm* GetNextColumn( const SwLayoutFrm* pLayFrm )
36 : {
37 0 : SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
38 0 : return pActCol ? (SwLayoutFrm*)pActCol->GetNext() : 0;
39 : }
40 :
41 0 : SwLayoutFrm* GetPrevColumn( const SwLayoutFrm* pLayFrm )
42 : {
43 0 : SwLayoutFrm* pActCol = GetCurrColumn( pLayFrm );
44 0 : return pActCol ? (SwLayoutFrm*)pActCol->GetPrev() : 0;
45 : }
46 :
47 0 : SwCntntFrm* GetColumnStt( const SwLayoutFrm* pColFrm )
48 : {
49 0 : return pColFrm ? (SwCntntFrm*)pColFrm->ContainsCntnt() : 0;
50 : }
51 :
52 0 : SwCntntFrm* GetColumnEnd( const SwLayoutFrm* pColFrm )
53 : {
54 0 : SwCntntFrm *pRet = GetColumnStt( pColFrm );
55 0 : if( !pRet )
56 0 : return 0;
57 :
58 0 : SwCntntFrm *pNxt = pRet->GetNextCntntFrm();
59 0 : while( pNxt && pColFrm->IsAnLower( pNxt ) )
60 : {
61 0 : pRet = pNxt;
62 0 : pNxt = pNxt->GetNextCntntFrm();
63 : }
64 0 : return pRet;
65 : }
66 :
67 : SwWhichColumn fnColumnPrev = &GetPrevColumn;
68 : SwWhichColumn fnColumnCurr = &GetCurrColumn;
69 : SwWhichColumn fnColumnNext = &GetNextColumn;
70 : SwPosColumn fnColumnStart = &GetColumnStt;
71 : SwPosColumn fnColumnEnd = &GetColumnEnd;
72 :
73 0 : sal_Bool SwCrsrShell::MoveColumn( SwWhichColumn fnWhichCol, SwPosColumn fnPosCol )
74 : {
75 0 : sal_Bool bRet = sal_False;
76 0 : if( !m_pTblCrsr )
77 : {
78 0 : SwLayoutFrm* pLayFrm = GetCurrFrm()->GetUpper();
79 0 : if( pLayFrm && 0 != ( pLayFrm = (*fnWhichCol)( pLayFrm )) )
80 : {
81 0 : SwCntntFrm* pCnt = (*fnPosCol)( pLayFrm );
82 0 : if( pCnt )
83 : {
84 0 : SET_CURR_SHELL( this );
85 0 : SwCallLink aLk( *this ); // watch Crsr-Moves; call Link if needed
86 0 : SwCrsrSaveState aSaveState( *m_pCurCrsr );
87 :
88 0 : pCnt->Calc();
89 :
90 0 : Point aPt( pCnt->Frm().Pos() + pCnt->Prt().Pos() );
91 0 : if( fnPosCol == GetColumnEnd )
92 : {
93 0 : aPt.setX(aPt.getX() + pCnt->Prt().Width());
94 0 : aPt.setY(aPt.getY() + pCnt->Prt().Height());
95 : }
96 :
97 0 : pCnt->GetCrsrOfst( m_pCurCrsr->GetPoint(), aPt );
98 :
99 0 : if( !m_pCurCrsr->IsInProtectTable( sal_True ) &&
100 0 : !m_pCurCrsr->IsSelOvr() )
101 : {
102 0 : UpdateCrsr();
103 0 : bRet = sal_True;
104 0 : }
105 : }
106 : }
107 : }
108 0 : return bRet;
109 : }
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|