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 <layfrm.hxx>
22 #include <cntfrm.hxx>
23 #include <swcrsr.hxx>
24 #include <viscrs.hxx>
25 #include "callnk.hxx"
26 
28 {
29  while( pLayFrame && !pLayFrame->IsColumnFrame() )
30  pLayFrame = pLayFrame->GetUpper();
31  return const_cast<SwLayoutFrame*>(pLayFrame);
32 }
33 
35 {
36  SwLayoutFrame* pActCol = GetCurrColumn( pLayFrame );
37  return pActCol ? static_cast<SwLayoutFrame*>(pActCol->GetNext()) : nullptr;
38 }
39 
41 {
42  SwLayoutFrame* pActCol = GetCurrColumn( pLayFrame );
43  return pActCol ? static_cast<SwLayoutFrame*>(pActCol->GetPrev()) : nullptr;
44 }
45 
47 {
48  return pColFrame ? const_cast<SwContentFrame*>(pColFrame->ContainsContent()) : nullptr;
49 }
50 
52 {
53  SwContentFrame *pRet = GetColumnStt( pColFrame );
54  if( !pRet )
55  return nullptr;
56 
57  SwContentFrame *pNxt = pRet->GetNextContentFrame();
58  while( pNxt && pColFrame->IsAnLower( pNxt ) )
59  {
60  pRet = pNxt;
61  pNxt = pNxt->GetNextContentFrame();
62  }
63  return pRet;
64 }
65 
67 {
68  if( !m_pTableCursor )
69  {
70  SwLayoutFrame* pLayFrame = GetCurrFrame()->GetUpper();
71  if( pLayFrame && nullptr != ( pLayFrame = (*fnWhichCol)( pLayFrame )) )
72  {
73  SwContentFrame* pCnt = (*fnPosCol)( pLayFrame );
74  if( pCnt )
75  {
76  SET_CURR_SHELL( this );
77  SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
78  SwCursorSaveState aSaveState( *m_pCurrentCursor );
79 
80  pCnt->Calc(GetOut());
81 
82  Point aPt( pCnt->getFrameArea().Pos() + pCnt->getFramePrintArea().Pos() );
83  if( fnPosCol == GetColumnEnd )
84  {
85  aPt.setX(aPt.getX() + pCnt->getFramePrintArea().Width());
86  aPt.setY(aPt.getY() + pCnt->getFramePrintArea().Height());
87  }
88 
89  pCnt->GetCursorOfst( m_pCurrentCursor->GetPoint(), aPt );
90 
91  if( !m_pCurrentCursor->IsInProtectTable( true ) &&
93  {
94  UpdateCursor();
95  }
96  }
97  }
98  }
99 }
100 
101 /* 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:51
SAL_DLLPRIVATE void UpdateCursor(sal_uInt16 eFlags=SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE, bool bIdleEnd=false)
Definition: crsrsh.cxx:1551
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:46
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:40
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:34
virtual bool GetCursorOfst(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:46
void MoveColumn(SwWhichColumn, SwPosColumn)
Definition: trvlcol.cxx:66
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2426
void Width(long nNew)
Definition: swrect.hxx:185
SwContentFrame *(* SwPosColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:67
SwLayoutFrame *(* SwWhichColumn)(const SwLayoutFrame *)
Definition: cshtyp.hxx:66
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
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:27
SwFrame * GetNext()
Definition: frame.hxx:654