1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5b190011SAndrew Rist  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19*5b190011SAndrew Rist  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/util/XChangesNotifier.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <vcl/help.hxx>
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
33cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
36cdf0e10cSrcweir #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
37cdf0e10cSrcweir #include <svx/sdr/overlay/overlaybitmapex.hxx>
38cdf0e10cSrcweir #include <svx/svdpagv.hxx>
39cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx>
40cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
41cdf0e10cSrcweir #include <svx/svddrgmt.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "View.hxx"
44cdf0e10cSrcweir #include "sdresid.hxx"
45cdf0e10cSrcweir #include "annotations.hrc"
46cdf0e10cSrcweir #include "annotationmanagerimpl.hxx"
47cdf0e10cSrcweir #include "annotationwindow.hxx"
48cdf0e10cSrcweir #include "annotationtag.hxx"
49cdf0e10cSrcweir #include "sdpage.hxx"
50cdf0e10cSrcweir #include "ViewShell.hxx"
51cdf0e10cSrcweir #include "app.hrc"
52cdf0e10cSrcweir #include "Window.hxx"
53cdf0e10cSrcweir #include "drawdoc.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using ::rtl::OUString;
56cdf0e10cSrcweir using namespace ::com::sun::star::uno;
57cdf0e10cSrcweir using namespace ::com::sun::star::lang;
58cdf0e10cSrcweir //using namespace ::com::sun::star::util;
59cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
60cdf0e10cSrcweir using namespace ::com::sun::star::office;
61cdf0e10cSrcweir using namespace ::com::sun::star::geometry;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace sd
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
67cdf0e10cSrcweir static const int DRGPIX     = 2;                               // Drag MinMove in Pixel
68cdf0e10cSrcweir 
69cdf0e10cSrcweir // --------------------------------------------------------------------
70cdf0e10cSrcweir 
getInitials(const OUString & rName)71cdf0e10cSrcweir static OUString getInitials( const OUString& rName )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	OUString sInitials;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	const sal_Unicode * pStr = rName.getStr();
76cdf0e10cSrcweir 	sal_Int32 nLength = rName.getLength();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	while( nLength )
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		// skip whitespace
81cdf0e10cSrcweir 		while( nLength && (*pStr <= ' ') )
82cdf0e10cSrcweir 		{
83cdf0e10cSrcweir 			nLength--; pStr++;
84cdf0e10cSrcweir 		}
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 		// take letter
87cdf0e10cSrcweir 		if( nLength )
88cdf0e10cSrcweir 		{
89cdf0e10cSrcweir 			sInitials += OUString( *pStr );
90cdf0e10cSrcweir 			nLength--; pStr++;
91cdf0e10cSrcweir 		}
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		// skip letters until whitespace
94cdf0e10cSrcweir 		while( nLength && (*pStr > ' ') )
95cdf0e10cSrcweir 		{
96cdf0e10cSrcweir 			nLength--; pStr++;
97cdf0e10cSrcweir 		}
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	return sInitials;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // --------------------------------------------------------------------
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // --------------------------------------------------------------------
106cdf0e10cSrcweir 
107cdf0e10cSrcweir class AnnotationDragMove : public SdrDragMove
108cdf0e10cSrcweir {
109cdf0e10cSrcweir public:
110cdf0e10cSrcweir 	AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag);
111cdf0e10cSrcweir 	virtual bool BeginSdrDrag();
112cdf0e10cSrcweir 	virtual bool EndSdrDrag(bool bCopy);
113cdf0e10cSrcweir 	virtual void MoveSdrDrag(const Point& rNoSnapPnt);
114cdf0e10cSrcweir 	virtual void CancelSdrDrag();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir private:
117cdf0e10cSrcweir 	rtl::Reference <AnnotationTag > mxTag;
118cdf0e10cSrcweir 	Point maOrigin;
119cdf0e10cSrcweir };
120cdf0e10cSrcweir 
AnnotationDragMove(SdrDragView & rNewView,const rtl::Reference<AnnotationTag> & xTag)121cdf0e10cSrcweir AnnotationDragMove::AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag)
122cdf0e10cSrcweir : SdrDragMove(rNewView)
123cdf0e10cSrcweir , mxTag( xTag )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
BeginSdrDrag()127cdf0e10cSrcweir bool AnnotationDragMove::BeginSdrDrag()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	DragStat().Ref1()=GetDragHdl()->GetPos();
130cdf0e10cSrcweir 	DragStat().SetShown(!DragStat().IsShown());
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	maOrigin = GetDragHdl()->GetPos();
133cdf0e10cSrcweir 	DragStat().SetActionRect(Rectangle(maOrigin,maOrigin));
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	return true;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
MoveSdrDrag(const Point & rNoSnapPnt)138cdf0e10cSrcweir void AnnotationDragMove::MoveSdrDrag(const Point& rNoSnapPnt)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	Point aPnt(rNoSnapPnt);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	if (DragStat().CheckMinMoved(rNoSnapPnt))
143cdf0e10cSrcweir 	{
144cdf0e10cSrcweir 		if (aPnt!=DragStat().GetNow())
145cdf0e10cSrcweir 		{
146cdf0e10cSrcweir 			Hide();
147cdf0e10cSrcweir 			DragStat().NextMove(aPnt);
148cdf0e10cSrcweir             GetDragHdl()->SetPos( maOrigin + Point( DragStat().GetDX(), DragStat().GetDY() ) );
149cdf0e10cSrcweir 			Show();
150cdf0e10cSrcweir 			DragStat().SetActionRect(Rectangle(aPnt,aPnt));
151cdf0e10cSrcweir 		}
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
EndSdrDrag(bool)155cdf0e10cSrcweir bool AnnotationDragMove::EndSdrDrag(bool /*bCopy*/)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	Hide();
158cdf0e10cSrcweir 	if( mxTag.is() )
159cdf0e10cSrcweir 		mxTag->Move( DragStat().GetDX(), DragStat().GetDY() );
160cdf0e10cSrcweir 	return sal_True;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
CancelSdrDrag()163cdf0e10cSrcweir void AnnotationDragMove::CancelSdrDrag()
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	Hide();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir // --------------------------------------------------------------------
169cdf0e10cSrcweir 
170cdf0e10cSrcweir class AnnotationHdl : public SmartHdl
171cdf0e10cSrcweir {
172cdf0e10cSrcweir public:
173cdf0e10cSrcweir 	AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt );
174cdf0e10cSrcweir 	virtual ~AnnotationHdl();
175cdf0e10cSrcweir 	virtual void CreateB2dIAObject();
176cdf0e10cSrcweir 	virtual sal_Bool IsFocusHdl() const;
177cdf0e10cSrcweir 	virtual Pointer GetSdrDragPointer() const;
178cdf0e10cSrcweir 	virtual bool isMarkable() const;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir private:
182cdf0e10cSrcweir 	Reference< XAnnotation > mxAnnotation;
183cdf0e10cSrcweir 	rtl::Reference< AnnotationTag > mxTag;
184cdf0e10cSrcweir };
185cdf0e10cSrcweir 
186cdf0e10cSrcweir // --------------------------------------------------------------------
187cdf0e10cSrcweir 
AnnotationHdl(const SmartTagReference & xTag,const Reference<XAnnotation> & xAnnotation,const Point & rPnt)188cdf0e10cSrcweir AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt )
189cdf0e10cSrcweir : SmartHdl( xTag, rPnt )
190cdf0e10cSrcweir , mxAnnotation( xAnnotation )
191cdf0e10cSrcweir , mxTag( dynamic_cast< AnnotationTag* >( xTag.get() ) )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // --------------------------------------------------------------------
196cdf0e10cSrcweir 
~AnnotationHdl()197cdf0e10cSrcweir AnnotationHdl::~AnnotationHdl()
198cdf0e10cSrcweir {
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir // --------------------------------------------------------------------
202cdf0e10cSrcweir 
CreateB2dIAObject()203cdf0e10cSrcweir void AnnotationHdl::CreateB2dIAObject()
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	// first throw away old one
206cdf0e10cSrcweir 	GetRidOfIAObject();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	if( mxAnnotation.is() )
209cdf0e10cSrcweir 	{
210cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		const Point aTagPos( GetPos() );
213cdf0e10cSrcweir 		basegfx::B2DPoint aPosition( aTagPos.X(), aTagPos.Y() );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         const bool bFocused = IsFocusHdl() && pHdlList && (pHdlList->GetFocusHdl() == this);
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 		BitmapEx aBitmapEx( mxTag->CreateAnnotationBitmap(mxTag->isSelected()) );
218cdf0e10cSrcweir 		BitmapEx aBitmapEx2;
219cdf0e10cSrcweir 		if( bFocused )
220cdf0e10cSrcweir 		    aBitmapEx2 = mxTag->CreateAnnotationBitmap(!mxTag->isSelected() );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 		if(pHdlList)
223cdf0e10cSrcweir 		{
224cdf0e10cSrcweir 			SdrMarkView* pView = pHdlList->GetView();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 			if(pView && !pView->areMarkHandlesHidden())
227cdf0e10cSrcweir 			{
228cdf0e10cSrcweir 				SdrPageView* pPageView = pView->GetSdrPageView();
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 				if(pPageView)
231cdf0e10cSrcweir 				{
232cdf0e10cSrcweir 					for(sal_uInt32 b = 0; b < pPageView->PageWindowCount(); b++)
233cdf0e10cSrcweir 					{
234cdf0e10cSrcweir 						// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
235cdf0e10cSrcweir 						const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 						SdrPaintWindow& rPaintWindow = rPageWindow.GetPaintWindow();
238cdf0e10cSrcweir 						if(rPaintWindow.OutputToWindow() && rPageWindow.GetOverlayManager() )
239cdf0e10cSrcweir 						{
240cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pOverlayObject = 0;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 					        // animate focused handles
243cdf0e10cSrcweir 					        if(bFocused)
244cdf0e10cSrcweir 					        {
245cdf0e10cSrcweir 						        const sal_uInt32 nBlinkTime = sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 						        pOverlayObject = new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition, aBitmapEx, aBitmapEx2, nBlinkTime, 0, 0, 0, 0 );
248cdf0e10cSrcweir /*
249cdf0e10cSrcweir 							        (sal_uInt16)(aBitmapEx.GetSizePixel().Width() - 1) >> 1,
250cdf0e10cSrcweir 							        (sal_uInt16)(aBitmapEx.GetSizePixel().Height() - 1) >> 1,
251cdf0e10cSrcweir 							        (sal_uInt16)(aBitmapEx2.GetSizePixel().Width() - 1) >> 1,
252cdf0e10cSrcweir 							        (sal_uInt16)(aBitmapEx2.GetSizePixel().Height() - 1) >> 1);
253cdf0e10cSrcweir */
254cdf0e10cSrcweir 					        }
255cdf0e10cSrcweir 					        else
256cdf0e10cSrcweir 					        {
257cdf0e10cSrcweir 							    pOverlayObject = new ::sdr::overlay::OverlayBitmapEx( aPosition, aBitmapEx, 0, 0 );
258cdf0e10cSrcweir 							}
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pOverlayObject);
261cdf0e10cSrcweir 							maOverlayGroup.append(*pOverlayObject);
262cdf0e10cSrcweir 						}
263cdf0e10cSrcweir 					}
264cdf0e10cSrcweir 				}
265cdf0e10cSrcweir 			}
266cdf0e10cSrcweir 		}
267cdf0e10cSrcweir 	}
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // --------------------------------------------------------------------
271cdf0e10cSrcweir 
IsFocusHdl() const272cdf0e10cSrcweir sal_Bool AnnotationHdl::IsFocusHdl() const
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	return sal_True;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // --------------------------------------------------------------------
278cdf0e10cSrcweir 
isMarkable() const279cdf0e10cSrcweir bool AnnotationHdl::isMarkable() const
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	return false;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir // --------------------------------------------------------------------
285cdf0e10cSrcweir 
GetSdrDragPointer() const286cdf0e10cSrcweir Pointer AnnotationHdl::GetSdrDragPointer() const
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	PointerStyle eStyle = POINTER_NOTALLOWED;
289cdf0e10cSrcweir 	if( mxTag.is() )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		if( mxTag->isSelected() )
292cdf0e10cSrcweir 		{
293cdf0e10cSrcweir 			eStyle = POINTER_MOVE;
294cdf0e10cSrcweir 		}
295cdf0e10cSrcweir 		else
296cdf0e10cSrcweir 		{
297cdf0e10cSrcweir 			eStyle = POINTER_ARROW;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 		}
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir 	return Pointer( eStyle );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir // ====================================================================
305cdf0e10cSrcweir 
AnnotationTag(AnnotationManagerImpl & rManager,::sd::View & rView,const Reference<XAnnotation> & xAnnotation,Color & rColor,int nIndex,const Font & rFont)306cdf0e10cSrcweir AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const Reference< XAnnotation >& xAnnotation, Color& rColor, int nIndex, const Font& rFont )
307cdf0e10cSrcweir : SmartTag( rView )
308cdf0e10cSrcweir , mrManager( rManager )
309cdf0e10cSrcweir , mxAnnotation( xAnnotation )
310cdf0e10cSrcweir , maColor( rColor )
311cdf0e10cSrcweir , mnIndex( nIndex )
312cdf0e10cSrcweir , mrFont( rFont )
313cdf0e10cSrcweir , mnClosePopupEvent( 0 )
314cdf0e10cSrcweir , mpListenWindow( 0 )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir // --------------------------------------------------------------------
319cdf0e10cSrcweir 
~AnnotationTag()320cdf0e10cSrcweir AnnotationTag::~AnnotationTag()
321cdf0e10cSrcweir {
322cdf0e10cSrcweir 	DBG_ASSERT( !mxAnnotation.is(), "sd::AnnotationTag::~AnnotationTag(), dispose me first!" );
323cdf0e10cSrcweir 	Dispose();
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir // --------------------------------------------------------------------
327cdf0e10cSrcweir 
328cdf0e10cSrcweir /** returns true if the AnnotationTag handled the event. */
MouseButtonDown(const MouseEvent & rMEvt,SmartHdl &)329cdf0e10cSrcweir bool AnnotationTag::MouseButtonDown( const MouseEvent& rMEvt, SmartHdl& /*rHdl*/ )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	if( !mxAnnotation.is() )
332cdf0e10cSrcweir 		return false;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     bool bRet = false;
335cdf0e10cSrcweir 	if( !isSelected() )
336cdf0e10cSrcweir 	{
337cdf0e10cSrcweir 		SmartTagReference xTag( this );
338cdf0e10cSrcweir 		mrView.getSmartTags().select( xTag );
339cdf0e10cSrcweir 		bRet = true;
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir 	/*
342cdf0e10cSrcweir 	if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		// double click;
345cdf0e10cSrcweir 		return true;
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir 	else */
348cdf0e10cSrcweir 	if( rMEvt.IsLeft() && !rMEvt.IsRight() )
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
351cdf0e10cSrcweir 		if( pWindow )
352cdf0e10cSrcweir 		{
353cdf0e10cSrcweir             maMouseDownPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		    if( mpListenWindow )
356cdf0e10cSrcweir 		        mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler));
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 		    mpListenWindow = pWindow;
359cdf0e10cSrcweir             mpListenWindow->AddEventListener( LINK(this, AnnotationTag, WindowEventHandler));
360cdf0e10cSrcweir         }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 		bRet = true;
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	return bRet;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // --------------------------------------------------------------------
369cdf0e10cSrcweir 
370cdf0e10cSrcweir /** returns true if the SmartTag consumes this event. */
KeyInput(const KeyEvent & rKEvt)371cdf0e10cSrcweir bool AnnotationTag::KeyInput( const KeyEvent& rKEvt )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	if( !mxAnnotation.is() )
374cdf0e10cSrcweir 		return false;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
377cdf0e10cSrcweir 	switch( nCode )
378cdf0e10cSrcweir 	{
379cdf0e10cSrcweir 	case KEY_DELETE:
380cdf0e10cSrcweir 	    mrManager.DeleteAnnotation( mxAnnotation );
381cdf0e10cSrcweir 	    return true;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	case KEY_DOWN:
384cdf0e10cSrcweir 	case KEY_UP:
385cdf0e10cSrcweir 	case KEY_LEFT:
386cdf0e10cSrcweir 	case KEY_RIGHT:
387cdf0e10cSrcweir 		return OnMove( rKEvt );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	case KEY_ESCAPE:
390cdf0e10cSrcweir 	{
391cdf0e10cSrcweir 		SmartTagReference xThis( this );
392cdf0e10cSrcweir 		mrView.getSmartTags().deselect();
393cdf0e10cSrcweir 		return true;
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	case KEY_TAB:
397cdf0e10cSrcweir 	    mrManager.SelectNextAnnotation(!rKEvt.GetKeyCode().IsShift());
398cdf0e10cSrcweir 	    return true;
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     case KEY_RETURN:
401cdf0e10cSrcweir    	case KEY_SPACE:
402cdf0e10cSrcweir    	    OpenPopup( true );
403cdf0e10cSrcweir    	    return true;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	default:
406cdf0e10cSrcweir 		return false;
407cdf0e10cSrcweir 	}
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir /** returns true if the SmartTag consumes this event. */
RequestHelp(const HelpEvent &)411cdf0e10cSrcweir bool AnnotationTag::RequestHelp( const HelpEvent& /*rHEvt*/ )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir /*
414cdf0e10cSrcweir 	::Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
415cdf0e10cSrcweir     if( mxAnnotation.is() && pWindow )
416cdf0e10cSrcweir     {
417cdf0e10cSrcweir         OUString aHelpText( mrManager.GetHelpText( mxAnnotation ) );
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	    RealPoint2D aPosition( mxAnnotation->getPosition() );
420cdf0e10cSrcweir 	    Point aPos( pWindow->LogicToPixel( Point( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ) ) );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir         Rectangle aRect( aPos, maSize );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	    if (Help::IsBalloonHelpEnabled())
425cdf0e10cSrcweir 		    Help::ShowBalloon( pWindow, aPos, aRect, aHelpText);
426cdf0e10cSrcweir 	    else if (Help::IsQuickHelpEnabled())
427cdf0e10cSrcweir 		    Help::ShowQuickHelp( pWindow, aRect, aHelpText);
428cdf0e10cSrcweir 
429cdf0e10cSrcweir         return true;
430cdf0e10cSrcweir    }
431cdf0e10cSrcweir */
432cdf0e10cSrcweir    return false;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir /** returns true if the SmartTag consumes this event. */
Command(const CommandEvent & rCEvt)436cdf0e10cSrcweir bool AnnotationTag::Command( const CommandEvent& rCEvt )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
439cdf0e10cSrcweir     {
440cdf0e10cSrcweir         ::Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
441cdf0e10cSrcweir         if( pWindow )
442cdf0e10cSrcweir         {
443cdf0e10cSrcweir             Rectangle aContextRect(rCEvt.GetMousePosPixel(),Size(1,1));
444cdf0e10cSrcweir        	    mrManager.ExecuteAnnotationContextMenu( mxAnnotation, pWindow, aContextRect );
445cdf0e10cSrcweir 	        return true;
446cdf0e10cSrcweir 	    }
447cdf0e10cSrcweir     }
448cdf0e10cSrcweir 
449cdf0e10cSrcweir     return false;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
Move(int nDX,int nDY)452cdf0e10cSrcweir void AnnotationTag::Move( int nDX, int nDY )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir 	if( mxAnnotation.is() )
455cdf0e10cSrcweir 	{
456cdf0e10cSrcweir         if( mrManager.GetDoc()->IsUndoEnabled() )
457cdf0e10cSrcweir             mrManager.GetDoc()->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_MOVE ) ) );
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 		RealPoint2D aPosition( mxAnnotation->getPosition() );
460cdf0e10cSrcweir 		aPosition.X += (double)nDX / 100.0;
461cdf0e10cSrcweir 		aPosition.Y += (double)nDY / 100.0;
462cdf0e10cSrcweir 		mxAnnotation->setPosition( aPosition );
463cdf0e10cSrcweir 
464cdf0e10cSrcweir         if( mrManager.GetDoc()->IsUndoEnabled() )
465cdf0e10cSrcweir             mrManager.GetDoc()->EndUndo();
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 		mrView.updateHandles();
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
OnMove(const KeyEvent & rKEvt)471cdf0e10cSrcweir bool AnnotationTag::OnMove( const KeyEvent& rKEvt )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir 	long nX = 0;
474cdf0e10cSrcweir 	long nY = 0;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	switch( rKEvt.GetKeyCode().GetCode() )
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 	case KEY_UP:	nY = -1; break;
479cdf0e10cSrcweir 	case KEY_DOWN:	nY =  1; break;
480cdf0e10cSrcweir 	case KEY_LEFT:	nX = -1; break;
481cdf0e10cSrcweir 	case KEY_RIGHT:	nX =  1; break;
482cdf0e10cSrcweir 	default: break;
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	if(rKEvt.GetKeyCode().IsMod2())
486cdf0e10cSrcweir 	{
487cdf0e10cSrcweir 		OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
488cdf0e10cSrcweir 		Size aLogicSizeOnePixel = (pOut) ? pOut->PixelToLogic(Size(1,1)) : Size(100, 100);
489cdf0e10cSrcweir 		nX *= aLogicSizeOnePixel.Width();
490cdf0e10cSrcweir 		nY *= aLogicSizeOnePixel.Height();
491cdf0e10cSrcweir 	}
492cdf0e10cSrcweir 	else
493cdf0e10cSrcweir 	{
494cdf0e10cSrcweir 		// old, fixed move distance
495cdf0e10cSrcweir 		nX *= 100;
496cdf0e10cSrcweir 		nY *= 100;
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	if( nX || nY )
500cdf0e10cSrcweir 	{
501cdf0e10cSrcweir 		// move the annotation
502cdf0e10cSrcweir 		Move( nX, nY );
503cdf0e10cSrcweir 	}
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	return true;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir // --------------------------------------------------------------------
509cdf0e10cSrcweir 
CheckPossibilities()510cdf0e10cSrcweir void AnnotationTag::CheckPossibilities()
511cdf0e10cSrcweir {
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir // --------------------------------------------------------------------
515cdf0e10cSrcweir 
GetMarkablePointCount() const516cdf0e10cSrcweir sal_uLong AnnotationTag::GetMarkablePointCount() const
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	return 0;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir // --------------------------------------------------------------------
522cdf0e10cSrcweir 
GetMarkedPointCount() const523cdf0e10cSrcweir sal_uLong AnnotationTag::GetMarkedPointCount() const
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	return 0;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir // --------------------------------------------------------------------
529cdf0e10cSrcweir 
MarkPoint(SdrHdl &,sal_Bool)530cdf0e10cSrcweir sal_Bool AnnotationTag::MarkPoint(SdrHdl& /*rHdl*/, sal_Bool /*bUnmark*/ )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir 	sal_Bool bRet=sal_False;
533cdf0e10cSrcweir 	return bRet;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir // --------------------------------------------------------------------
537cdf0e10cSrcweir 
MarkPoints(const Rectangle *,sal_Bool)538cdf0e10cSrcweir sal_Bool AnnotationTag::MarkPoints(const Rectangle* /*pRect*/, sal_Bool /*bUnmark*/ )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	sal_Bool bChgd=sal_False;
541cdf0e10cSrcweir 	return bChgd;
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir // --------------------------------------------------------------------
545cdf0e10cSrcweir 
getContext(SdrViewContext &)546cdf0e10cSrcweir bool AnnotationTag::getContext( SdrViewContext& /*rContext*/ )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir 	return false;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir // --------------------------------------------------------------------
552cdf0e10cSrcweir 
addCustomHandles(SdrHdlList & rHandlerList)553cdf0e10cSrcweir void AnnotationTag::addCustomHandles( SdrHdlList& rHandlerList )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	if( mxAnnotation.is() )
556cdf0e10cSrcweir 	{
557cdf0e10cSrcweir 		SmartTagReference xThis( this );
558cdf0e10cSrcweir 		Point aPoint;
559cdf0e10cSrcweir 		AnnotationHdl* pHdl = new AnnotationHdl( xThis, mxAnnotation, aPoint );
560cdf0e10cSrcweir 		pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
561cdf0e10cSrcweir 		pHdl->SetPageView( mrView.GetSdrPageView() );
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 		RealPoint2D aPosition( mxAnnotation->getPosition() );
564cdf0e10cSrcweir 		Point aBasePos( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) );
565cdf0e10cSrcweir 		pHdl->SetPos( aBasePos );
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 		rHandlerList.AddHdl( pHdl );
568cdf0e10cSrcweir 	}
569cdf0e10cSrcweir }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir // --------------------------------------------------------------------
572cdf0e10cSrcweir 
disposing()573cdf0e10cSrcweir void AnnotationTag::disposing()
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     if( mpListenWindow )
576cdf0e10cSrcweir     {
577cdf0e10cSrcweir         mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler));
578cdf0e10cSrcweir     }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     if( mnClosePopupEvent )
581cdf0e10cSrcweir     {
582cdf0e10cSrcweir         Application::RemoveUserEvent( mnClosePopupEvent );
583cdf0e10cSrcweir         mnClosePopupEvent = 0;
584cdf0e10cSrcweir     }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 	mxAnnotation.clear();
587cdf0e10cSrcweir     ClosePopup();
588cdf0e10cSrcweir 	SmartTag::disposing();
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir // --------------------------------------------------------------------
592cdf0e10cSrcweir 
select()593cdf0e10cSrcweir void AnnotationTag::select()
594cdf0e10cSrcweir {
595cdf0e10cSrcweir 	SmartTag::select();
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	mrManager.onTagSelected( *this );
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
600cdf0e10cSrcweir 	if( pWindow )
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir         RealPoint2D aPosition( mxAnnotation->getPosition() );
603cdf0e10cSrcweir         Point aPos( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) );
604cdf0e10cSrcweir 
605cdf0e10cSrcweir         Rectangle aVisRect( aPos, pWindow->PixelToLogic(maSize) );
606cdf0e10cSrcweir 		mrView.MakeVisible(aVisRect, *pWindow);
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir // --------------------------------------------------------------------
611cdf0e10cSrcweir 
deselect()612cdf0e10cSrcweir void AnnotationTag::deselect()
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	SmartTag::deselect();
615cdf0e10cSrcweir 
616cdf0e10cSrcweir     ClosePopup();
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 	mrManager.onTagDeselected( *this );
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir // --------------------------------------------------------------------
622cdf0e10cSrcweir 
CreateAnnotationBitmap(bool bSelected)623cdf0e10cSrcweir BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )
624cdf0e10cSrcweir {
625cdf0e10cSrcweir 	VirtualDevice aVDev;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	OUString sAuthor( getInitials( mxAnnotation->getAuthor() ) );
628cdf0e10cSrcweir 	sAuthor += OUString( sal_Unicode( ' ' ) );
629cdf0e10cSrcweir 	sAuthor += OUString::valueOf( (sal_Int32)mnIndex );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 	aVDev.SetFont( mrFont );
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 	const int BORDER_X = 4; // pixels
634cdf0e10cSrcweir 	const int BORDER_Y = 4; // pixels
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 	maSize = Size( aVDev.GetTextWidth( sAuthor ) + 2*BORDER_X, aVDev.GetTextHeight() + 2*BORDER_Y );
637cdf0e10cSrcweir 	aVDev.SetOutputSizePixel( maSize, sal_False );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	Color aBorderColor( maColor );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	if( bSelected )
642cdf0e10cSrcweir 	{
643cdf0e10cSrcweir 		aBorderColor.Invert();
644cdf0e10cSrcweir 	}
645cdf0e10cSrcweir 	else
646cdf0e10cSrcweir 	{
647cdf0e10cSrcweir 		if( maColor.IsDark() )
648cdf0e10cSrcweir 		{
649cdf0e10cSrcweir 			aBorderColor.IncreaseLuminance( 32 );
650cdf0e10cSrcweir 		}
651cdf0e10cSrcweir 		else
652cdf0e10cSrcweir 		{
653cdf0e10cSrcweir 			aBorderColor.DecreaseLuminance( 32 );
654cdf0e10cSrcweir 		}
655cdf0e10cSrcweir 	}
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 	Point aPos;
658cdf0e10cSrcweir 	Rectangle aBorderRect( aPos, maSize );
659cdf0e10cSrcweir 	aVDev.SetLineColor(aBorderColor);
660cdf0e10cSrcweir 	aVDev.SetFillColor(maColor);
661cdf0e10cSrcweir 	aVDev.DrawRect( aBorderRect );
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 	aVDev.SetTextColor( maColor.IsDark() ? COL_WHITE : COL_BLACK );
664cdf0e10cSrcweir 	aVDev.DrawText( Point( BORDER_X, BORDER_Y ), sAuthor );
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	return aVDev.GetBitmapEx( aPos, maSize );
667cdf0e10cSrcweir }
668cdf0e10cSrcweir 
OpenPopup(bool bEdit)669cdf0e10cSrcweir void AnnotationTag::OpenPopup( bool bEdit )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir     if( !mxAnnotation.is() )
672cdf0e10cSrcweir         return;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     if( !mpAnnotationWindow.get() )
675cdf0e10cSrcweir     {
676cdf0e10cSrcweir    	    ::Window* pWindow = dynamic_cast< ::Window* >( getView().GetFirstOutputDevice() );
677cdf0e10cSrcweir    	    if( pWindow )
678cdf0e10cSrcweir    	    {
679cdf0e10cSrcweir             RealPoint2D aPosition( mxAnnotation->getPosition() );
680cdf0e10cSrcweir 	        Point aPos( pWindow->OutputToScreenPixel( pWindow->LogicToPixel( Point( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ) ) ) );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir             aPos.X() += 4; // magic!
683cdf0e10cSrcweir             aPos.Y() += 1;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir             Rectangle aRect( aPos, maSize );
686cdf0e10cSrcweir 
687cdf0e10cSrcweir             mpAnnotationWindow.reset( new AnnotationWindow( mrManager, mrView.GetDocSh(), pWindow->GetWindow(WINDOW_FRAME) ) );
688cdf0e10cSrcweir         	mpAnnotationWindow->InitControls();
689cdf0e10cSrcweir         	mpAnnotationWindow->setAnnotation(mxAnnotation);
690cdf0e10cSrcweir 
691cdf0e10cSrcweir             sal_uInt16 nArrangeIndex = 0;
692cdf0e10cSrcweir             Point aPopupPos( FloatingWindow::CalcFloatingPosition( mpAnnotationWindow.get(), aRect, FLOATWIN_POPUPMODE_RIGHT, nArrangeIndex ) );
693cdf0e10cSrcweir             Size aPopupSize( 320, 240 );
694cdf0e10cSrcweir 
695cdf0e10cSrcweir             mpAnnotationWindow->SetPosSizePixel( aPopupPos, aPopupSize );
696cdf0e10cSrcweir             mpAnnotationWindow->DoResize();
697cdf0e10cSrcweir 
698cdf0e10cSrcweir             mpAnnotationWindow->Show();
699cdf0e10cSrcweir             mpAnnotationWindow->GrabFocus();
700cdf0e10cSrcweir             mpAnnotationWindow->AddEventListener( LINK(this, AnnotationTag, WindowEventHandler));
701cdf0e10cSrcweir         }
702cdf0e10cSrcweir     }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     if( bEdit && mpAnnotationWindow.get() )
705cdf0e10cSrcweir         mpAnnotationWindow->StartEdit();
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
ClosePopup()708cdf0e10cSrcweir void AnnotationTag::ClosePopup()
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     if( mpAnnotationWindow.get() )
711cdf0e10cSrcweir     {
712cdf0e10cSrcweir         mpAnnotationWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler));
713cdf0e10cSrcweir         mpAnnotationWindow->Deactivate();
714cdf0e10cSrcweir         mpAnnotationWindow.reset();
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
IMPL_LINK(AnnotationTag,WindowEventHandler,VclWindowEvent *,pEvent)718cdf0e10cSrcweir IMPL_LINK(AnnotationTag, WindowEventHandler, VclWindowEvent*, pEvent)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir     if( pEvent != NULL )
721cdf0e10cSrcweir     {
722cdf0e10cSrcweir         ::Window* pWindow = pEvent->GetWindow();
723cdf0e10cSrcweir 
724cdf0e10cSrcweir         if( pWindow )
725cdf0e10cSrcweir         {
726cdf0e10cSrcweir             if( pWindow == mpAnnotationWindow.get() )
727cdf0e10cSrcweir             {
728cdf0e10cSrcweir                 if( pEvent->GetId() == VCLEVENT_WINDOW_DEACTIVATE )
729cdf0e10cSrcweir                 {
730cdf0e10cSrcweir                     if( mnClosePopupEvent )
731cdf0e10cSrcweir                         Application::RemoveUserEvent( mnClosePopupEvent );
732cdf0e10cSrcweir 
733cdf0e10cSrcweir                     mnClosePopupEvent = Application::PostUserEvent( LINK( this, AnnotationTag, ClosePopupHdl ) );
734cdf0e10cSrcweir                 }
735cdf0e10cSrcweir             }
736cdf0e10cSrcweir             else if( pWindow == mpListenWindow )
737cdf0e10cSrcweir             {
738cdf0e10cSrcweir                 switch( pEvent->GetId() )
739cdf0e10cSrcweir                 {
740cdf0e10cSrcweir                 case VCLEVENT_WINDOW_MOUSEBUTTONUP:
741cdf0e10cSrcweir                     {
742cdf0e10cSrcweir                         // if we stop pressing the button without a mouse move we open the popup
743cdf0e10cSrcweir                         mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler));
744cdf0e10cSrcweir                         mpListenWindow = 0;
745cdf0e10cSrcweir                         if( mpAnnotationWindow.get() == 0 )
746cdf0e10cSrcweir                             OpenPopup(false);
747cdf0e10cSrcweir                     }
748cdf0e10cSrcweir                     break;
749cdf0e10cSrcweir                 case VCLEVENT_WINDOW_MOUSEMOVE:
750cdf0e10cSrcweir                     {
751cdf0e10cSrcweir                         // if we move the mouse after a button down we wan't to start draging
752cdf0e10cSrcweir                         mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler));
753cdf0e10cSrcweir                         mpListenWindow = 0;
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	                    SdrHdl* pHdl = mrView.PickHandle(maMouseDownPos);
756cdf0e10cSrcweir                         if( pHdl )
757cdf0e10cSrcweir                         {
758cdf0e10cSrcweir 		                    mrView.BrkAction();
759cdf0e10cSrcweir 		                    const sal_uInt16 nDrgLog = (sal_uInt16)pWindow->PixelToLogic(Size(DRGPIX,0)).Width();
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 		                    rtl::Reference< AnnotationTag > xTag( this );
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 		                    SdrDragMethod* pDragMethod = new AnnotationDragMove( mrView, xTag );
764cdf0e10cSrcweir 		                    mrView.BegDragObj(maMouseDownPos, NULL, pHdl, nDrgLog, pDragMethod );
765cdf0e10cSrcweir 		                }
766cdf0e10cSrcweir 		            }
767cdf0e10cSrcweir                     break;
768cdf0e10cSrcweir                 case VCLEVENT_OBJECT_DYING:
769cdf0e10cSrcweir                     mpListenWindow = 0;
770cdf0e10cSrcweir                     break;
771cdf0e10cSrcweir                 }
772cdf0e10cSrcweir             }
773cdf0e10cSrcweir         }
774cdf0e10cSrcweir     }
775cdf0e10cSrcweir     return sal_True;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
IMPL_LINK(AnnotationTag,ClosePopupHdl,void *,EMPTYARG)778cdf0e10cSrcweir IMPL_LINK( AnnotationTag, ClosePopupHdl, void *, EMPTYARG )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir     mnClosePopupEvent = 0;
781cdf0e10cSrcweir     ClosePopup();
782cdf0e10cSrcweir     return 0;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir } // end of namespace sd
786cdf0e10cSrcweir 
787