1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_CRSR_BLOCKCURSOR_HXX
20 #define INCLUDED_SW_SOURCE_CORE_CRSR_BLOCKCURSOR_HXX
23 #include <tools/gen.hxx>
30 /** Access to the block cursor
32 A block cursor contains a SwShellCursor and additional information about
33 the rectangle which has been created by pressing the mouse button and
36 It's simply an aggregation of a SwShellCursor and a rectangle defined by
37 a start and an end point.
41 SwShellCursor maCursor
;
42 std::optional
<Point
> maStartPt
;
43 std::optional
<Point
> maEndPt
;
46 SwBlockCursor( const SwCursorShell
& rCursorSh
, const SwPosition
&rPos
) :
47 maCursor( rCursorSh
, rPos
) {}
48 /** Access to the shell cursor
50 @return SwShellCursor& which represents the start and end position of the
51 current block selection
53 SwShellCursor
& getShellCursor();
54 /** Defines the starting vertex of the block selection
57 rPt should contain the document coordinates of the mouse cursor when
58 the block selection starts (MouseButtonDown)
60 void setStartPoint( const Point
&rPt
) { maStartPt
= rPt
; }
61 /** Defines the ending vertex of the block selection
64 rPt should contain the document coordinates of the mouse cursor when
65 the block selection has started and the mouse has been moved (MouseMove)
67 void setEndPoint( const Point
&rPt
) { maEndPt
= rPt
; }
68 /** The document coordinates where the block selection has been started
70 @return 0, if no start point has been set
72 std::optional
<Point
> const & getStartPoint() const { return maStartPt
; }
73 /** The document coordinates where the block selection ends (at the moment)
75 @return 0, if no end point has been set
77 std::optional
<Point
> const & getEndPoint() const { return maEndPt
; }
78 /** Deletion of the mouse created rectangle
80 When start and end points exist, the block cursor depends on this. If the
81 cursor is moved by cursor keys (e.g. up/down, home/end) the mouse rectangle
82 is obsolete and has to be deleted.
84 void clearPoints() { maStartPt
.reset(); maEndPt
.reset(); }
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */