LibreOffice Module sd (master) 1
smarttag.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
20#pragma once
21
23#include <rtl/ref.hxx>
24#include <set>
25#include <svx/svdhdl.hxx>
26#include <svx/svdview.hxx>
27
28class KeyEvent;
29class MouseEvent;
30
31namespace sd
32{
33class View;
34class SmartHdl;
35
44{
45 friend class SmartTagSet;
46
47public:
48 explicit SmartTag(::sd::View& rView);
49 virtual ~SmartTag() override;
50
52 virtual bool MouseButtonDown(const MouseEvent&, SmartHdl&);
53
55 virtual bool KeyInput(const KeyEvent& rKEvt);
56
58 virtual bool Command(const CommandEvent& rCEvt);
59
61 bool isSelected() const { return mbSelected; }
62
63 ::sd::View& getView() const { return mrView; }
64
65protected:
66 virtual sal_Int32 GetMarkablePointCount() const;
67 virtual sal_Int32 GetMarkedPointCount() const;
68 virtual bool MarkPoint(SdrHdl& rHdl, bool bUnmark);
69 virtual void CheckPossibilities();
70 virtual bool MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark);
71
72 virtual void addCustomHandles(SdrHdlList& rHandlerList);
73 virtual void select();
74 virtual void deselect();
75 virtual bool getContext(SdrViewContext& rContext);
76
77 virtual void disposing() override;
78
81
82private:
83 SmartTag(const SmartTag&) = delete;
84 SmartTag& operator=(const SmartTag&) = delete;
85};
86
88
91{
92 friend class SmartTag;
93
94public:
95 explicit SmartTagSet(::sd::View& rView);
97
99 void select(const SmartTagReference& xTag);
100
102 void deselect();
103
105 const SmartTagReference& getSelected() const { return mxSelectedTag; }
106
108 bool MouseButtonDown(const MouseEvent&);
109
111 bool KeyInput(const KeyEvent& rKEvt);
112
114 bool Command(const CommandEvent& rCEvt);
115
117 void Dispose();
118
120 void addCustomHandles(SdrHdlList& rHandlerList);
121
124 bool getContext(SdrViewContext& rContext) const;
125
126 // support point editing
127 bool HasMarkablePoints() const;
129 bool HasMarkedPoints() const;
131 bool MarkPoint(SdrHdl& rHdl, bool bUnmark);
132 bool MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark);
133
134 void CheckPossibilities();
135
136private:
137 SmartTagSet(const SmartTagSet&) = delete;
139
141 void add(const SmartTagReference& xTag);
142
144 void remove(const SmartTagReference& xTag);
145
146 std::set<SmartTagReference> maSet;
147
151};
152
156class SmartHdl : public SdrHdl
157{
158public:
159 SmartHdl(SmartTagReference xTag, SdrObject* pObject, const Point& rPnt, SdrHdlKind eNewKind);
160 SmartHdl(SmartTagReference xTag, const Point& rPnt, SdrHdlKind eNewKind);
161
162 const SmartTagReference& getTag() const { return mxSmartTag; }
163
164private:
166};
167
168} // end of namespace sd
169
170/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A simple base implementation for reference-counted components.
a derivation from this handle is the visual representation for a smart tag.
Definition: smarttag.hxx:157
SmartHdl(SmartTagReference xTag, SdrObject *pObject, const Point &rPnt, SdrHdlKind eNewKind)
Definition: smarttag.cxx:319
SmartTagReference mxSmartTag
Definition: smarttag.hxx:165
const SmartTagReference & getTag() const
Definition: smarttag.hxx:162
class to administrate the available smart tags for a single view.
Definition: smarttag.hxx:91
void Dispose()
disposes all smart tags and clears the set
Definition: smarttag.cxx:144
bool MouseButtonDown(const MouseEvent &)
returns true if a SmartTag consumes this event.
Definition: smarttag.cxx:183
SmartTagSet(const SmartTagSet &)=delete
bool KeyInput(const KeyEvent &rKEvt)
returns true if a SmartTag consumes this event.
Definition: smarttag.cxx:207
SmartTagReference mxMouseOverTag
Definition: smarttag.hxx:150
bool HasMarkedPoints() const
Definition: smarttag.cxx:285
sal_uLong GetMarkablePointCount() const
Definition: smarttag.cxx:278
bool MarkPoints(const ::tools::Rectangle *pRect, bool bUnmark)
Definition: smarttag.cxx:306
void remove(const SmartTagReference &xTag)
removes the given smart tag from this set
Definition: smarttag.cxx:130
::sd::View & mrView
Definition: smarttag.hxx:148
bool Command(const CommandEvent &rCEvt)
returns true if a SmartTag consumes this event.
Definition: smarttag.cxx:227
void select(const SmartTagReference &xTag)
selects the given smart tag and updates all handles
Definition: smarttag.cxx:155
void CheckPossibilities()
Definition: smarttag.cxx:313
bool HasMarkablePoints() const
Definition: smarttag.cxx:273
void deselect()
deselects the current selected smart tag and updates all handles
Definition: smarttag.cxx:172
bool getContext(SdrViewContext &rContext) const
returns true if the currently selected smart tag has a special context, returned in rContext.
Definition: smarttag.cxx:263
bool MarkPoint(SdrHdl &rHdl, bool bUnmark)
Definition: smarttag.cxx:298
sal_uLong GetMarkedPointCount() const
Definition: smarttag.cxx:290
std::set< SmartTagReference > maSet
Definition: smarttag.hxx:146
SmartTagReference mxSelectedTag
Definition: smarttag.hxx:149
const SmartTagReference & getSelected() const
returns the currently selected tag or an empty reference.
Definition: smarttag.hxx:105
SmartTagSet(::sd::View &rView)
void addCustomHandles(SdrHdlList &rHandlerList)
adds the handles from all smart tags to the given list
Definition: smarttag.cxx:255
void add(const SmartTagReference &xTag)
adds a new smart tag to this set
Definition: smarttag.cxx:118
SmartTagSet & operator=(const SmartTagSet &)=delete
a smart tag represents a visual user interface element on the documents edit view that is not part of...
Definition: smarttag.hxx:44
::sd::View & mrView
Definition: smarttag.hxx:79
virtual void addCustomHandles(SdrHdlList &rHandlerList)
Definition: smarttag.cxx:60
virtual bool KeyInput(const KeyEvent &rKEvt)
returns true if the SmartTag consumes this event.
Definition: smarttag.cxx:49
virtual void select()
Definition: smarttag.cxx:64
bool mbSelected
Definition: smarttag.hxx:80
SmartTag & operator=(const SmartTag &)=delete
virtual void deselect()
Definition: smarttag.cxx:69
virtual bool getContext(SdrViewContext &rContext)
Definition: smarttag.cxx:80
virtual bool Command(const CommandEvent &rCEvt)
returns true if the SmartTag consumes this event.
Definition: smarttag.cxx:55
virtual void disposing() override
Definition: smarttag.cxx:74
virtual void CheckPossibilities()
Definition: smarttag.cxx:105
::sd::View & getView() const
Definition: smarttag.hxx:63
SmartTag(::sd::View &rView)
Definition: smarttag.cxx:31
virtual bool MouseButtonDown(const MouseEvent &, SmartHdl &)
returns true if the SmartTag consumes this event.
Definition: smarttag.cxx:43
bool isSelected() const
returns true if this smart tag is currently selected
Definition: smarttag.hxx:61
virtual bool MarkPoint(SdrHdl &rHdl, bool bUnmark)
Definition: smarttag.cxx:95
SmartTag(const SmartTag &)=delete
virtual sal_Int32 GetMarkedPointCount() const
Definition: smarttag.cxx:90
virtual bool MarkPoints(const ::tools::Rectangle *pRect, bool bUnmark)
Definition: smarttag.cxx:100
virtual ~SmartTag() override
Definition: smarttag.cxx:39
virtual sal_Int32 GetMarkablePointCount() const
Definition: smarttag.cxx:85
EmbeddedObjectRef * pObject
rtl::Reference< SmartTag > SmartTagReference
Definition: smarttag.hxx:87
sal_uIntPtr sal_uLong
SdrHdlKind
SdrViewContext