LibreOffice Module sw (master)  1
trvlcol.cxx
Go to the documentation of this file.
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 
29 {
30  while( pLayFrame && !pLayFrame->IsColumnFrame() )
31  pLayFrame = pLayFrame->GetUpper();
32  return const_cast<SwLayoutFrame*>(pLayFrame);
33 }
34 
36 {
37  SwLayoutFrame* pActCol = GetCurrColumn( pLayFrame );
38  return pActCol ? static_cast<SwLayoutFrame*>(pActCol->GetNext()) : nullptr;
39 }
40 
42 {
43  SwLayoutFrame* pActCol = GetCurrColumn( pLayFrame );
44  return pActCol ? static_cast<SwLayoutFrame*>(pActCol->GetPrev()) : nullptr;
45 }
46 
48 {
49  return pColFrame ? const_cast<SwContentFrame*>(pColFrame->ContainsContent()) : nullptr;
50 }
51 
53 {
54  SwContentFrame *pRet = GetColumnStt( pColFrame );
55  if( !pRet )
56  return nullptr;
57 
58  SwContentFrame *pNxt = pRet->GetNextContentFrame();
59  while( pNxt && pColFrame->IsAnLower( pNxt ) )
60  {
61  pRet = pNxt;
62  pNxt = pNxt->GetNextContentFrame();
63  }
64  return pRet;
65 }
66 
68 {
69  if( !m_pTableCursor )
70  {
71  SwLayoutFrame* pLayFrame = GetCurrFrame()->GetUpper();
72  if( pLayFrame && nullptr != ( pLayFrame = (*fnWhichCol)( pLayFrame )) )
73  {
74  SwContentFrame* pCnt = (*fnPosCol)( pLayFrame );
75  if( pCnt )
76  {
77  SET_CURR_SHELL( this );
78  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
79  SwCursorSaveState aSaveState( *m_pCurrentCursor );
80 
81  pCnt->Calc(GetOut());
82 
83  Point aPt( pCnt->getFrameArea().Pos() + pCnt->getFramePrintArea().Pos() );
84  if( fnPosCol == GetColumnEnd )
85  {
86  aPt.setX(aPt.getX() + pCnt->getFramePrintArea().Width());
87  aPt.setY(aPt.getY() + pCnt->getFramePrintArea().Height());
88  }
89 
90  pCnt->GetCursorOfst( m_pCurrentCursor->GetPoint(), aPt );
91 
92  if( !m_pCurrentCursor->IsInProtectTable( true ) &&
94  {
95  UpdateCursor();
96  }
97  }
98  }
99  }
100 }
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
SwContentFrame * GetColumnEnd(const SwLayoutFrame *pColFrame)
Definition: trvlcol.cxx:52
SAL_DLLPRIVATE void UpdateCursor(sal_uInt16 eFlags=SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE, bool bIdleEnd=false)
Definition: crsrsh.cxx:1552
SwShellCursor * m_pCurrentCursor
current cursor
Definition: crsrsh.hxx:179
bool IsInProtectTable(bool bMove=false, bool bChgCursor=true)
Definition: swcrsr.cxx:545
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
SwContentFrame * GetColumnStt(const SwLayoutFrame *pColFrame)
Definition: trvlcol.cxx:47
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
virtual bool IsSelOvr(SwCursorSelOverFlags eFlags=SwCursorSelOverFlags::CheckNodeSection|SwCursorSelOverFlags::Toggle|SwCursorSelOverFlags::ChangePos)
Definition: swcrsr.cxx:216
void Height(long nNew)
Definition: swrect.hxx:189
void Pos(const Point &rNew)
Definition: swrect.hxx:167
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1787
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
SwShellTableCursor * m_pTableCursor
table Cursor; only in tables when the selection lays over 2 columns
Definition: crsrsh.hxx:185
bool IsColumnFrame() const
Definition: frame.hxx:1158
SwLayoutFrame * GetPrevColumn(const SwLayoutFrame *pLayFrame)
Definition: trvlcol.cxx:41
A helper class to save cursor state (position).
Definition: swcrsr.hxx:230
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
SwFrame * GetPrev()
Definition: frame.hxx:655
#define SET_CURR_SHELL(shell)
Definition: swtypes.hxx:101
SwLayoutFrame * GetNextColumn(const SwLayoutFrame *pLayFrame)
Definition: trvlcol.cxx:35
virtual bool GetCursorOfst(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:46
void MoveColumn(SwWhichColumn, SwPosColumn)
Definition: trvlcol.cxx:67
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2350
void Width(long nNew)
Definition: swrect.hxx:185
SwContentFrame *(* SwPosColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:67
SwLayoutFrame *(* SwWhichColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:66
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:66
SwLayoutFrame * GetCurrColumn(const SwLayoutFrame *pLayFrame)
Definition: trvlcol.cxx:28
SwFrame * GetNext()
Definition: frame.hxx:654