xref: /AOO41X/main/sd/source/ui/annotations/annotationtag.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_ANNOTATIONTAG_HXX_
25 #define _SD_ANNOTATIONTAG_HXX_
26 
27 #include <com/sun/star/office/XAnnotation.hpp>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
29 #include <basegfx/polygon/b2dpolypolygontools.hxx>
30 #include "smarttag.hxx"
31 
32 namespace css = ::com::sun::star;
33 
34 namespace sd {
35 
36 class View;
37 class AnnotationManagerImpl;
38 class AnnotationWindow;
39 
40 class AnnotationTag : public SmartTag
41 {
42 public:
43     AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const css::uno::Reference< css::office::XAnnotation >& xAnnotation, Color& rColor, int nIndex, const Font& rFont );
44     virtual ~AnnotationTag();
45 
46     /** returns true if the SmartTag handled the event. */
47     virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
48 
49     /** returns true if the SmartTag consumes this event. */
50     virtual bool KeyInput( const KeyEvent& rKEvt );
51 
52     /** returns true if the SmartTag consumes this event. */
53     virtual bool RequestHelp( const HelpEvent& rHEvt );
54 
55     /** returns true if the SmartTag consumes this event. */
56     virtual bool Command( const CommandEvent& rCEvt );
57 
58     // callbacks from sdr view
59     virtual sal_uLong GetMarkablePointCount() const;
60     virtual sal_uLong GetMarkedPointCount() const;
61     virtual sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
62     virtual void CheckPossibilities();
63     virtual sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
64 
65     void Move( int nDX, int nDY );
66     bool OnMove( const KeyEvent& rKEvt );
67 
68     // ---
69 
70     BitmapEx CreateAnnotationBitmap(bool);
71 
GetAnnotation() const72     css::uno::Reference< css::office::XAnnotation > GetAnnotation() const { return mxAnnotation; }
73 
74     void OpenPopup( bool bEdit );
75     void ClosePopup();
76 
77 protected:
78     virtual void addCustomHandles( SdrHdlList& rHandlerList );
79     virtual bool getContext( SdrViewContext& rContext );
80     virtual void disposing();
81     virtual void select();
82     virtual void deselect();
83 
84     DECL_LINK( WindowEventHandler, VclWindowEvent* );
85     DECL_LINK( ClosePopupHdl, void* );
86 
87 private:
88     AnnotationManagerImpl& mrManager;
89     css::uno::Reference< css::office::XAnnotation > mxAnnotation;
90     std::auto_ptr<AnnotationWindow>                 mpAnnotationWindow;
91     Color                                           maColor;
92     int                                             mnIndex;
93     const Font&                                     mrFont;
94     Size                                            maSize;
95     sal_uLong                                           mnClosePopupEvent;
96     ::Window*                                       mpListenWindow;
97     Point                                           maMouseDownPos;
98 };
99 
100 } // end of namespace sd
101 
102 #endif      // _SD_ANNOTATIONTAG_HXX_
103 
104