LibreOffice Module sw (master) 1
unocrsr.hxx
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#ifndef INCLUDED_SW_INC_UNOCRSR_HXX
20#define INCLUDED_SW_INC_UNOCRSR_HXX
21
22#include "swcrsr.hxx"
24#include <svl/lstner.hxx>
25#include <utility>
26
27namespace sw
28{
29 struct SW_DLLPUBLIC UnoCursorHint final : public SfxHint
30 {
32 virtual ~UnoCursorHint() override;
33 };
34}
35
36class SAL_DLLPUBLIC_RTTI SwUnoCursor : public virtual SwCursor
37{
38private:
42
43public:
45 SwUnoCursor( const SwPosition &rPos );
46 virtual ~SwUnoCursor() override;
47
48protected:
49
51 bool & io_rbLeft, bool bVisualAllowed, bool bInsertCursor) override;
52 virtual void DoSetBidiLevelUpDown() override;
53
54public:
55
56 // Does a selection of content exist in table?
57 // Return value indicates if the cursor remains at its old position.
58 virtual bool IsSelOvr( SwCursorSelOverFlags eFlags =
62
63 virtual bool IsReadOnlyAvailable() const override;
64
65 bool IsRemainInSection() const { return m_bRemainInSection; }
66 void SetRemainInSection( bool bFlag ) { m_bRemainInSection = bFlag; }
67
68 virtual bool IsSkipOverProtectSections() const override
69 { return m_bSkipOverProtectSections; }
70 void SetSkipOverProtectSections( bool bFlag )
71 { m_bSkipOverProtectSections = bFlag; }
72
73 virtual bool IsSkipOverHiddenSections() const override
74 { return m_bSkipOverHiddenSections; }
75 void SetSkipOverHiddenSections( bool bFlag )
76 { m_bSkipOverHiddenSections = bFlag; }
77};
78
79class SwUnoTableCursor final : public virtual SwUnoCursor, public virtual SwTableCursor
80{
81 // The selection has the same order as the table boxes, i.e.
82 // if something is deleted from the one array at a certain position
83 // it has also to be deleted from the other!
85
87
88public:
89 SwUnoTableCursor( const SwPosition& rPos );
90 virtual ~SwUnoTableCursor() override;
91
92 // Does a selection of content exist in table?
93 // Return value indicates if the cursor remains at its old position.
94 virtual bool IsSelOvr( SwCursorSelOverFlags eFlags =
98
99 void MakeBoxSels();
100
102 const SwCursor& GetSelRing() const { return m_aTableSel; }
103};
104
105namespace sw
106{
107 class UnoCursorPointer final : public SfxListener
108 {
109 public:
111 {}
112 UnoCursorPointer(std::shared_ptr<SwUnoCursor> pCursor)
113 : m_pCursor(std::move(pCursor))
114 {
115 StartListening(m_pCursor->m_aNotifier);
116 }
118 : SfxListener()
119 , m_pCursor(rOther.m_pCursor)
120 {
121 if(m_pCursor)
122 StartListening(m_pCursor->m_aNotifier);
123 }
124 virtual ~UnoCursorPointer() override
125 {
126 if(m_pCursor)
127 EndListening(m_pCursor->m_aNotifier);
128 }
129 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override
130 {
131 if(m_pCursor)
132 {
133 if(typeid(rHint) == typeid(UnoCursorHint))
134 EndListening(rBC);
135 }
137 m_pCursor.reset();
138 };
140 { return m_pCursor.get(); }
142 { return get(); }
144 { return *get(); }
146 {
147 if (m_pCursor)
148 {
149 EndListening(m_pCursor->m_aNotifier);
150 }
151 if(aOther.m_pCursor)
152 StartListening(aOther.m_pCursor->m_aNotifier);
153 m_pCursor = aOther.m_pCursor;
154 return *this;
155 }
156 explicit operator bool() const
157 { return static_cast<bool>(m_pCursor); }
158 void reset(std::shared_ptr<SwUnoCursor> pNew)
159 {
160 if(pNew)
161 StartListening(pNew->m_aNotifier);
162 if (m_pCursor)
163 EndListening(m_pCursor->m_aNotifier);
164 m_pCursor = pNew;
165 }
166 private:
167 std::shared_ptr<SwUnoCursor> m_pCursor;
168 };
169}
170#endif
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
sal_uInt16 GetBroadcasterCount() const
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
virtual void DoSetBidiLevelUpDown()
Definition: swcrsr.cxx:1954
virtual bool IsSelOvr(SwCursorSelOverFlags eFlags=SwCursorSelOverFlags::CheckNodeSection|SwCursorSelOverFlags::Toggle|SwCursorSelOverFlags::ChangePos)
Definition: swcrsr.cxx:222
virtual const SwContentFrame * DoSetBidiLevelLeftRight(bool &io_rbLeft, bool bVisualAllowed, bool bInsertCursor)
Definition: swcrsr.cxx:1672
virtual bool IsReadOnlyAvailable() const
Definition: swcrsr.cxx:150
SwCursor * MakeBoxSels(SwCursor *pCurrentCursor)
Definition: swcrsr.cxx:2403
bool IsRemainInSection() const
Definition: unocrsr.hxx:65
virtual bool IsSkipOverHiddenSections() const override
Definition: unocrsr.hxx:73
bool m_bSkipOverHiddenSections
Definition: unocrsr.hxx:40
void SetRemainInSection(bool bFlag)
Definition: unocrsr.hxx:66
virtual bool IsSkipOverProtectSections() const override
Definition: unocrsr.hxx:68
void SetSkipOverHiddenSections(bool bFlag)
Definition: unocrsr.hxx:75
bool m_bSkipOverProtectSections
Definition: unocrsr.hxx:41
void SetSkipOverProtectSections(bool bFlag)
Definition: unocrsr.hxx:70
SfxBroadcaster m_aNotifier
Definition: unocrsr.hxx:44
bool m_bRemainInSection
Definition: unocrsr.hxx:39
SwCursor m_aTableSel
Definition: unocrsr.hxx:84
SwCursor & GetSelRing()
Definition: unocrsr.hxx:101
const SwCursor & GetSelRing() const
Definition: unocrsr.hxx:102
SwUnoTableCursor(const SwPosition &rPos)
Definition: unocrsr.cxx:156
void MakeBoxSels()
Definition: unocrsr.cxx:184
virtual ~SwUnoTableCursor() override
Definition: unocrsr.cxx:165
virtual bool IsSelOvr(SwCursorSelOverFlags eFlags=SwCursorSelOverFlags::CheckNodeSection|SwCursorSelOverFlags::Toggle|SwCursorSelOverFlags::ChangePos) override
Definition: unocrsr.cxx:171
UnoCursorPointer(const UnoCursorPointer &rOther)
Definition: unocrsr.hxx:117
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: unocrsr.hxx:129
SwUnoCursor * operator->() const
Definition: unocrsr.hxx:141
std::shared_ptr< SwUnoCursor > m_pCursor
Definition: unocrsr.hxx:167
SwUnoCursor * get() const
Definition: unocrsr.hxx:139
virtual ~UnoCursorPointer() override
Definition: unocrsr.hxx:124
void reset(std::shared_ptr< SwUnoCursor > pNew)
Definition: unocrsr.hxx:158
UnoCursorPointer(std::shared_ptr< SwUnoCursor > pCursor)
Definition: unocrsr.hxx:112
UnoCursorPointer & operator=(UnoCursorPointer aOther)
Definition: unocrsr.hxx:145
SwUnoCursor & operator*() const
Definition: unocrsr.hxx:143
Dialog to specify the properties of date form field.
Marks a position in the document model.
Definition: pam.hxx:37
SwCursorSelOverFlags
Definition: swcrsr.hxx:50
#define SW_DLLPUBLIC
Definition: swdllapi.h:28