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