1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: smarttag.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SD_SMARTTAG_HXX_
32 #define _SD_SMARTTAG_HXX_
34 #include "helper/simplereferencecomponent.hxx"
35 #include <rtl/ref.hxx>
37 #include <svx/svdhdl.hxx>
38 #include <svx/svdview.hxx>
49 /** a smart tag represents a visual user interface element on the documents edit view
50 that is not part of the document. It uses derivations from SmartHdl for its visuals.
51 A SmartTag adds himself to the given view if created. It removes himself if it
52 is disposed before the view is disposed.
54 Derive from this class to implement your own smart tag.
56 class SmartTag
: public SimpleReferenceComponent
58 friend class SmartTagSet
;
61 explicit SmartTag( ::sd::View
& rView
);
64 /** returns true if the SmartTag consumes this event. */
65 virtual bool MouseButtonDown( const MouseEvent
&, SmartHdl
& );
67 /** returns true if the SmartTag consumes this event. */
68 virtual bool KeyInput( const KeyEvent
& rKEvt
);
70 /** returns true if the SmartTag consumes this event. */
71 virtual bool RequestHelp( const HelpEvent
& rHEvt
);
73 /** returns true if the SmartTag consumes this event. */
74 virtual bool Command( const CommandEvent
& rCEvt
);
76 /** returns true if this smart tag is currently selected */
77 bool isSelected() const;
79 ::sd::View
& getView() const { return mrView
; }
82 virtual ULONG
GetMarkablePointCount() const;
83 virtual ULONG
GetMarkedPointCount() const;
84 virtual BOOL
MarkPoint(SdrHdl
& rHdl
, BOOL bUnmark
=FALSE
);
85 virtual void CheckPossibilities();
86 virtual BOOL
MarkPoints(const Rectangle
* pRect
, BOOL bUnmark
);
88 virtual void addCustomHandles( SdrHdlList
& rHandlerList
);
89 virtual void select();
90 virtual void deselect();
91 virtual bool getContext( SdrViewContext
& rContext
);
93 virtual void disposing();
99 SmartTag( const SmartTag
& ); // not implemented
100 SmartTag
& operator=( const SmartTag
& ); // not implemented
103 typedef rtl::Reference
< SmartTag
> SmartTagReference
;
105 /** class to administrate the available smart tags for a single view. */
108 friend class SmartTag
;
110 explicit SmartTagSet( ::sd::View
& rView
);
113 /** selects the given smart tag and updates all handles */
114 void select( const SmartTagReference
& xTag
);
116 /** deselects the current selected smart tag and updates all handles */
119 /** returns the currently selected tag or an empty reference. */
120 const SmartTagReference
& getSelected() const { return mxSelectedTag
; }
122 /** returns true if a SmartTag consumes this event. */
123 bool MouseButtonDown( const MouseEvent
& );
125 /** returns true if a SmartTag consumes this event. */
126 bool KeyInput( const KeyEvent
& rKEvt
);
128 /** returns true if a SmartTag consumes this event. */
129 bool RequestHelp( const HelpEvent
& rHEvt
);
131 /** returns true if a SmartTag consumes this event. */
132 bool Command( const CommandEvent
& rCEvt
);
134 /** disposes all smart tags and clears the set */
137 /** addes the handles from all smart tags to the given list */
138 void addCustomHandles( SdrHdlList
& rHandlerList
);
140 /** returns true if the currently selected smart tag has
141 a special context, returned in rContext. */
142 bool getContext( SdrViewContext
& rContext
) const;
144 // support point editing
145 BOOL
HasMarkablePoints() const;
146 ULONG
GetMarkablePointCount() const;
147 BOOL
HasMarkedPoints() const;
148 ULONG
GetMarkedPointCount() const;
149 BOOL
IsPointMarkable(const SdrHdl
& rHdl
) const;
150 BOOL
MarkPoint(SdrHdl
& rHdl
, BOOL bUnmark
=FALSE
);
151 BOOL
MarkPoints(const Rectangle
* pRect
, BOOL bUnmark
);
153 void CheckPossibilities();
156 SmartTagSet( const SmartTagSet
& ); // not implemented
157 SmartTagSet
& operator=( const SmartTagSet
& ); // not implemented
159 /** adds a new smart tag to this set */
160 void add( const SmartTagReference
& xTag
);
162 /** removes the given smart tag from this set */
163 void remove( const SmartTagReference
& xTag
);
165 std::set
< SmartTagReference
> maSet
;
168 SmartTagReference mxSelectedTag
;
171 /** a derivation from this handle is the visual representation for a smart tag.
172 One smart tag can have more than one handle.
174 class SmartHdl
: public SdrHdl
177 SmartHdl( const SmartTagReference
& xTag
, SdrObject
* pObject
, const Point
& rPnt
, SdrHdlKind eNewKind
=HDL_SMARTTAG
);
178 SmartHdl( const SmartTagReference
& xTag
, const Point
& rPnt
, SdrHdlKind eNewKind
=HDL_SMARTTAG
);
180 const SmartTagReference
& getTag() const { return mxTag
; }
182 virtual bool isMarkable() const;
184 SmartTagReference mxTag
;
187 } // end of namespace sd
189 #endif // _SD_SMARTTAG_HXX_