1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <svx/svdview.hxx>
32cdf0e10cSrcweir #include <editeng/outliner.hxx>
33cdf0e10cSrcweir //#ifndef _SVDVMARK_HXX //autogen
34cdf0e10cSrcweir //#include <svx/svdvmark.hxx>
35cdf0e10cSrcweir //#endif
36cdf0e10cSrcweir #include <svx/svdobj.hxx>
37cdf0e10cSrcweir #include <sot/exchange.hxx>
38cdf0e10cSrcweir #include <sot/formats.hxx>
39cdf0e10cSrcweir #include <sfx2/bindings.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
42cdf0e10cSrcweir #include <fmturl.hxx>
43cdf0e10cSrcweir #include <frmfmt.hxx>
44cdf0e10cSrcweir #include <wrtsh.hxx>
45cdf0e10cSrcweir #include <edtwin.hxx>
46cdf0e10cSrcweir #ifndef _VIEW_HXX
47cdf0e10cSrcweir #include <view.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #include <viewopt.hxx>
50cdf0e10cSrcweir #include <swdtflvr.hxx>
51cdf0e10cSrcweir #include <swmodule.hxx>
52cdf0e10cSrcweir #ifndef _DOCSH_HXX
53cdf0e10cSrcweir #include <docsh.hxx>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #include <wdocsh.hxx>
56cdf0e10cSrcweir #include <swundo.hxx>
57cdf0e10cSrcweir
58cdf0e10cSrcweir using namespace ::com::sun::star;
59cdf0e10cSrcweir
60cdf0e10cSrcweir // no include "dbgoutsw.hxx" here!!!!!!
61cdf0e10cSrcweir
62cdf0e10cSrcweir extern sal_Bool bNoInterrupt;
63cdf0e10cSrcweir extern sal_Bool bFrmDrag;
64cdf0e10cSrcweir extern sal_Bool bDDTimerStarted;
65cdf0e10cSrcweir
66cdf0e10cSrcweir sal_Bool bExecuteDrag = sal_False;
67cdf0e10cSrcweir
StartDDTimer()68cdf0e10cSrcweir void SwEditWin::StartDDTimer()
69cdf0e10cSrcweir {
70cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK(this, SwEditWin, DDHandler));
71cdf0e10cSrcweir aTimer.SetTimeout(480);
72cdf0e10cSrcweir aTimer.Start();
73cdf0e10cSrcweir bDDTimerStarted = sal_True;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir
StopDDTimer(SwWrtShell * pSh,const Point & rPt)77cdf0e10cSrcweir void SwEditWin::StopDDTimer(SwWrtShell *pSh, const Point &rPt)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir aTimer.Stop();
80cdf0e10cSrcweir bDDTimerStarted = sal_False;
81cdf0e10cSrcweir if(!pSh->IsSelFrmMode())
82cdf0e10cSrcweir (pSh->*pSh->fnSetCrsr)(&rPt,sal_False);
83cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK(this,SwEditWin, TimerHandler));
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
StartDrag(sal_Int8,const Point & rPosPixel)86cdf0e10cSrcweir void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell();
89cdf0e10cSrcweir if( rSh.GetDrawView() )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True );
92cdf0e10cSrcweir if( rSh.GetDrawView()->Command( aDragEvent, this ) )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
95cdf0e10cSrcweir return; // Event von der SdrView ausgewertet
96cdf0e10cSrcweir }
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir if ( !pApplyTempl && !rSh.IsDrawCreate() && !IsDrawAction())
100cdf0e10cSrcweir {
101cdf0e10cSrcweir sal_Bool bStart = sal_False, bDelSelect = sal_False;
102cdf0e10cSrcweir SdrObject *pObj = NULL;
103cdf0e10cSrcweir Point aDocPos( PixelToLogic( rPosPixel ) );
104cdf0e10cSrcweir if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPos, sal_True, sal_True))
105cdf0e10cSrcweir //Wir sind nicht beim Selektieren und stehen auf einer
106cdf0e10cSrcweir //Selektion
107cdf0e10cSrcweir bStart = sal_True;
108cdf0e10cSrcweir else if ( !bFrmDrag && rSh.IsSelFrmMode() &&
109cdf0e10cSrcweir rSh.IsInsideSelectedObj( aDocPos ) )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir //Wir sind nicht am internen Draggen und stehen auf
112cdf0e10cSrcweir //einem Objekt (Rahmen, Zeichenobjekt)
113cdf0e10cSrcweir
114cdf0e10cSrcweir bStart = sal_True;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir else if( !bFrmDrag && rView.GetDocShell()->IsReadOnly() &&
117cdf0e10cSrcweir OBJCNT_NONE != rSh.GetObjCntType( aDocPos, pObj ))
118cdf0e10cSrcweir {
119cdf0e10cSrcweir rSh.LockPaint();
120cdf0e10cSrcweir if( rSh.SelectObj( aDocPos, 0, pObj ))
121cdf0e10cSrcweir bStart = bDelSelect = sal_True;
122cdf0e10cSrcweir else
123cdf0e10cSrcweir rSh.UnlockPaint();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir else
126cdf0e10cSrcweir {
127cdf0e10cSrcweir SwContentAtPos aSwContentAtPos( SwContentAtPos::SW_INETATTR );
128cdf0e10cSrcweir bStart = rSh.GetContentAtPos( aDocPos,
129cdf0e10cSrcweir aSwContentAtPos,
130cdf0e10cSrcweir sal_False );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir if ( bStart && !bIsInDrag )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir bMBPressed = sal_False;
136cdf0e10cSrcweir ReleaseMouse();
137cdf0e10cSrcweir bFrmDrag = sal_False;
138cdf0e10cSrcweir bExecuteDrag = sal_True;
139cdf0e10cSrcweir SwEditWin::nDDStartPosY = aDocPos.Y();
140cdf0e10cSrcweir SwEditWin::nDDStartPosX = aDocPos.X();
141cdf0e10cSrcweir aMovePos = aDocPos;
142cdf0e10cSrcweir StartExecuteDrag();
143cdf0e10cSrcweir if( bDelSelect )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir rSh.UnSelectFrm();
146cdf0e10cSrcweir rSh.UnlockPaint();
147cdf0e10cSrcweir }
148cdf0e10cSrcweir }
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
StartExecuteDrag()152cdf0e10cSrcweir void SwEditWin::StartExecuteDrag()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir if( !bExecuteDrag || bIsInDrag )
155cdf0e10cSrcweir return;
156cdf0e10cSrcweir
157cdf0e10cSrcweir bIsInDrag = sal_True;
158cdf0e10cSrcweir
159cdf0e10cSrcweir SwTransferable* pTransfer = new SwTransferable( rView.GetWrtShell() );
160cdf0e10cSrcweir uno::Reference<
161cdf0e10cSrcweir datatransfer::XTransferable > xRef( pTransfer );
162cdf0e10cSrcweir
163cdf0e10cSrcweir pTransfer->StartDrag( this, aMovePos );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
DragFinished()166cdf0e10cSrcweir void SwEditWin::DragFinished()
167cdf0e10cSrcweir {
168cdf0e10cSrcweir DropCleanup();
169cdf0e10cSrcweir aTimer.SetTimeoutHdl( LINK(this,SwEditWin, TimerHandler) );
170cdf0e10cSrcweir bIsInDrag = sal_False;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir
DropCleanup()174cdf0e10cSrcweir void SwEditWin::DropCleanup()
175cdf0e10cSrcweir {
176cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell();
177cdf0e10cSrcweir
178cdf0e10cSrcweir // Stati zuruecksetzen
179cdf0e10cSrcweir bNoInterrupt = sal_False;
180cdf0e10cSrcweir if ( bOldIdleSet )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir ((SwViewOption*)rSh.GetViewOptions())->SetIdle( bOldIdle );
183cdf0e10cSrcweir bOldIdleSet = sal_False;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir if ( pUserMarker )
186cdf0e10cSrcweir CleanupDropUserMarker();
187cdf0e10cSrcweir else
188cdf0e10cSrcweir rSh.UnSetVisCrsr();
189cdf0e10cSrcweir
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
CleanupDropUserMarker()192cdf0e10cSrcweir void SwEditWin::CleanupDropUserMarker()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir if ( pUserMarker )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir delete pUserMarker;
197cdf0e10cSrcweir pUserMarker = 0;
198cdf0e10cSrcweir pUserMarkerObj = 0;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir
203cdf0e10cSrcweir //Messehack (MA,MBA)
lcl_SelectShellForDrop(SwView & rView)204cdf0e10cSrcweir void lcl_SelectShellForDrop( SwView &rView )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir if ( !rView.GetCurShell() )
207cdf0e10cSrcweir rView.SelectShell();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
ExecuteDrop(const ExecuteDropEvent & rEvt)210cdf0e10cSrcweir sal_Int8 SwEditWin::ExecuteDrop( const ExecuteDropEvent& rEvt )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir ::lcl_SelectShellForDrop( GetView() );
213cdf0e10cSrcweir DropCleanup();
214cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE;
215cdf0e10cSrcweir
216cdf0e10cSrcweir //Ein Drop auf eine offene OutlinerView geht uns nichts an (siehe auch QueryDrop)
217cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell();
218cdf0e10cSrcweir const Point aDocPt( PixelToLogic( rEvt.maPosPixel ));
219cdf0e10cSrcweir SdrObject *pObj = 0;
220cdf0e10cSrcweir OutlinerView* pOLV;
221cdf0e10cSrcweir rSh.GetObjCntType( aDocPt, pObj );
222cdf0e10cSrcweir
223cdf0e10cSrcweir if( pObj && 0 != ( pOLV = rSh.GetDrawView()->GetTextEditOutlinerView() ))
224cdf0e10cSrcweir {
225cdf0e10cSrcweir Rectangle aRect( pOLV->GetOutputArea() );
226cdf0e10cSrcweir aRect.Union( pObj->GetLogicRect() );
227cdf0e10cSrcweir const Point aPos = pOLV->GetWindow()->PixelToLogic(rEvt.maPosPixel);
228cdf0e10cSrcweir if ( aRect.IsInside(aPos) )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir rSh.StartAllAction();
231cdf0e10cSrcweir //!! sal_Int8 nRet = DND_ACTION_NONE/*pOLV->ExecuteDrop( rEvt )*/;
232cdf0e10cSrcweir rSh.EndAllAction();
233cdf0e10cSrcweir return nRet;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir
238cdf0e10cSrcweir // dvo 2002-05-27, #99027#: There's a special treatment for file lists with a single
239cdf0e10cSrcweir // element, that depends on the actual content of the
240cdf0e10cSrcweir // Transferable to be accessible. Since the transferable
241cdf0e10cSrcweir // may only be accessed after the drop has been accepted
242cdf0e10cSrcweir // (according to KA due to Java D&D), we'll have to
243cdf0e10cSrcweir // reevaluate the drop action once more _with_ the
244cdf0e10cSrcweir // Transferable.
245cdf0e10cSrcweir sal_uInt16 nEventAction;
246cdf0e10cSrcweir sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
247cdf0e10cSrcweir : rEvt.mnAction;
248cdf0e10cSrcweir m_nDropAction = SotExchange::GetExchangeAction(
249cdf0e10cSrcweir GetDataFlavorExVector(),
250cdf0e10cSrcweir m_nDropDestination,
251cdf0e10cSrcweir rEvt.mnAction,
252cdf0e10cSrcweir //!! rEvt.GetSourceOptions(),
253cdf0e10cSrcweir nUserOpt, m_nDropFormat, nEventAction, 0,
254cdf0e10cSrcweir &rEvt.maDropEvent.Transferable );
255cdf0e10cSrcweir
256cdf0e10cSrcweir
257cdf0e10cSrcweir TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
258cdf0e10cSrcweir nRet = rEvt.mnAction;
259cdf0e10cSrcweir if( !SwTransferable::PasteData( aData, rSh, m_nDropAction, m_nDropFormat,
260cdf0e10cSrcweir m_nDropDestination, sal_False, rEvt.mbDefault, &aDocPt, nRet))
261cdf0e10cSrcweir //!! nRet = SFX_APP()->ExecuteDrop( rEvt );
262cdf0e10cSrcweir nRet = DND_ACTION_NONE;
263cdf0e10cSrcweir else if ( SW_MOD()->pDragDrop )
264cdf0e10cSrcweir //Bei internem D&D nicht mehr aufraeumen!
265cdf0e10cSrcweir SW_MOD()->pDragDrop->SetCleanUp( sal_False );
266cdf0e10cSrcweir
267cdf0e10cSrcweir return nRet;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
270cdf0e10cSrcweir
GetDropDestination(const Point & rPixPnt,SdrObject ** ppObj)271cdf0e10cSrcweir sal_uInt16 SwEditWin::GetDropDestination( const Point& rPixPnt, SdrObject ** ppObj )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell();
274cdf0e10cSrcweir const Point aDocPt( PixelToLogic( rPixPnt ) );
27569a74367SOliver-Rainer Wittmann if( rSh.ChgCurrPam( aDocPt )
27669a74367SOliver-Rainer Wittmann || rSh.IsOverReadOnlyPos( aDocPt )
27769a74367SOliver-Rainer Wittmann || rSh.DocPtInsideInputFld( aDocPt ) )
278cdf0e10cSrcweir return 0;
279cdf0e10cSrcweir
280cdf0e10cSrcweir SdrObject *pObj = NULL;
281cdf0e10cSrcweir const ObjCntType eType = rSh.GetObjCntType( aDocPt, pObj );
282cdf0e10cSrcweir
283cdf0e10cSrcweir //Drop auf OutlinerView (TextEdit im Drawing) soll diese selbst entscheiden!
284cdf0e10cSrcweir if( pObj )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir OutlinerView* pOLV = rSh.GetDrawView()->GetTextEditOutlinerView();
287cdf0e10cSrcweir if ( pOLV )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir Rectangle aRect( pOLV->GetOutputArea() );
290cdf0e10cSrcweir aRect.Union( pObj->GetLogicRect() );
291cdf0e10cSrcweir const Point aPos = pOLV->GetWindow()->PixelToLogic( rPixPnt );
292cdf0e10cSrcweir if( aRect.IsInside( aPos ) )
293cdf0e10cSrcweir return 0;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir //Auf was wollen wir denn gerade droppen?
298cdf0e10cSrcweir sal_uInt16 nDropDestination = 0;
299cdf0e10cSrcweir
300cdf0e10cSrcweir //Sonst etwas aus der DrawingEngine getroffen?
301cdf0e10cSrcweir if( OBJCNT_NONE != eType )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir switch ( eType )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir case OBJCNT_GRF:
306cdf0e10cSrcweir {
307cdf0e10cSrcweir sal_Bool bLink,
308cdf0e10cSrcweir bIMap = 0 != rSh.GetFmtFromObj( aDocPt )->GetURL().GetMap();
309cdf0e10cSrcweir String aDummy;
310cdf0e10cSrcweir rSh.GetGrfAtPos( aDocPt, aDummy, bLink );
311cdf0e10cSrcweir if ( bLink && bIMap )
312cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
313cdf0e10cSrcweir else if ( bLink )
314cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
315cdf0e10cSrcweir else if ( bIMap )
316cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_GRAPH_W_IMAP;
317cdf0e10cSrcweir else
318cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_GRAPHOBJ;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir break;
321cdf0e10cSrcweir case OBJCNT_FLY:
322cdf0e10cSrcweir if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
323cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_TEXTFRAME_WEB;
324cdf0e10cSrcweir else
325cdf0e10cSrcweir nDropDestination = EXCHG_DEST_DOC_TEXTFRAME;
326cdf0e10cSrcweir break;
327cdf0e10cSrcweir case OBJCNT_OLE: nDropDestination = EXCHG_DEST_DOC_OLEOBJ; break;
328cdf0e10cSrcweir case OBJCNT_CONTROL: /* no Action avail */
329cdf0e10cSrcweir case OBJCNT_SIMPLE: nDropDestination = EXCHG_DEST_DOC_DRAWOBJ; break;
330cdf0e10cSrcweir case OBJCNT_URLBUTTON: nDropDestination = EXCHG_DEST_DOC_URLBUTTON; break;
331cdf0e10cSrcweir case OBJCNT_GROUPOBJ: nDropDestination = EXCHG_DEST_DOC_GROUPOBJ; break;
332cdf0e10cSrcweir
333*870262e3SDon Lewis default: ASSERT( sal_False, "new ObjectType?" );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir }
336cdf0e10cSrcweir if ( !nDropDestination )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
339cdf0e10cSrcweir nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
340cdf0e10cSrcweir else
341cdf0e10cSrcweir nDropDestination = EXCHG_DEST_SWDOC_FREE_AREA;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir if( ppObj )
344cdf0e10cSrcweir *ppObj = pObj;
345cdf0e10cSrcweir return nDropDestination;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
AcceptDrop(const AcceptDropEvent & rEvt)348cdf0e10cSrcweir sal_Int8 SwEditWin::AcceptDrop( const AcceptDropEvent& rEvt )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir if( rEvt.mbLeaving )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir DropCleanup();
353cdf0e10cSrcweir return rEvt.mnAction;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir if( rView.GetDocShell()->IsReadOnly() )
357cdf0e10cSrcweir return DND_ACTION_NONE;
358cdf0e10cSrcweir
359cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell();
360cdf0e10cSrcweir
361cdf0e10cSrcweir Point aPixPt( rEvt.maPosPixel );
362cdf0e10cSrcweir
363cdf0e10cSrcweir // If the cursor is near the inner boundary
364cdf0e10cSrcweir // we attempt to scroll towards the desired direction.
365cdf0e10cSrcweir Point aPoint;
366cdf0e10cSrcweir Rectangle aWin(aPoint,GetOutputSizePixel());
367cdf0e10cSrcweir const int nMargin = 10;
368cdf0e10cSrcweir aWin.Left() += nMargin;
369cdf0e10cSrcweir aWin.Top() += nMargin;
370cdf0e10cSrcweir aWin.Right() -= nMargin;
371cdf0e10cSrcweir aWin.Bottom() -= nMargin;
372cdf0e10cSrcweir if(!aWin.IsInside(aPixPt)) {
373cdf0e10cSrcweir static sal_uLong last_tick = 0;
374cdf0e10cSrcweir sal_uLong current_tick = Time::GetSystemTicks();
375cdf0e10cSrcweir if((current_tick-last_tick) > 500) {
376cdf0e10cSrcweir last_tick = current_tick;
377cdf0e10cSrcweir if(!bOldIdleSet) {
378cdf0e10cSrcweir bOldIdle = rSh.GetViewOptions()->IsIdle();
379cdf0e10cSrcweir ((SwViewOption *)rSh.GetViewOptions())->SetIdle(sal_False);
380cdf0e10cSrcweir bOldIdleSet = sal_True;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir CleanupDropUserMarker();
383cdf0e10cSrcweir if(aPixPt.X() > aWin.Right()) aPixPt.X() += nMargin;
384cdf0e10cSrcweir if(aPixPt.X() < aWin.Left()) aPixPt.X() -= nMargin;
385cdf0e10cSrcweir if(aPixPt.Y() > aWin.Bottom()) aPixPt.Y() += nMargin;
386cdf0e10cSrcweir if(aPixPt.Y() < aWin.Top()) aPixPt.Y() -= nMargin;
387cdf0e10cSrcweir Point aDocPt(PixelToLogic(aPixPt));
388cdf0e10cSrcweir SwRect rect(aDocPt,Size(1,1));
389cdf0e10cSrcweir rSh.MakeVisible(rect);
390cdf0e10cSrcweir }
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir if(bOldIdleSet) {
394cdf0e10cSrcweir ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bOldIdle );
395cdf0e10cSrcweir bOldIdleSet = sal_False;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir SdrObject *pObj = NULL;
399cdf0e10cSrcweir m_nDropDestination = GetDropDestination( aPixPt, &pObj );
400cdf0e10cSrcweir if( !m_nDropDestination )
401cdf0e10cSrcweir return DND_ACTION_NONE;
402cdf0e10cSrcweir
403cdf0e10cSrcweir sal_uInt16 nEventAction;
404cdf0e10cSrcweir sal_Int8 nUserOpt = rEvt.mbDefault ? EXCHG_IN_ACTION_DEFAULT
405cdf0e10cSrcweir : rEvt.mnAction;
406cdf0e10cSrcweir
407cdf0e10cSrcweir m_nDropAction = SotExchange::GetExchangeAction(
408cdf0e10cSrcweir GetDataFlavorExVector(),
409cdf0e10cSrcweir m_nDropDestination,
410cdf0e10cSrcweir rEvt.mnAction,
411cdf0e10cSrcweir //!! rEvt.GetSourceOptions(),
412cdf0e10cSrcweir nUserOpt, m_nDropFormat, nEventAction );
413cdf0e10cSrcweir
414cdf0e10cSrcweir if( EXCHG_INOUT_ACTION_NONE != m_nDropAction )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir const Point aDocPt( PixelToLogic( aPixPt ) );
417cdf0e10cSrcweir
418cdf0e10cSrcweir //Bei den default Aktionen wollen wir noch ein bischen mitreden.
419cdf0e10cSrcweir SwModule *pMod = SW_MOD();
420cdf0e10cSrcweir if( pMod->pDragDrop )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir sal_Bool bCleanup = sal_False;
423cdf0e10cSrcweir //Zeichenobjekte in Kopf-/Fusszeilen sind nicht erlaubt
424cdf0e10cSrcweir
425cdf0e10cSrcweir SwWrtShell *pSrcSh = pMod->pDragDrop->GetShell();
426cdf0e10cSrcweir if( (pSrcSh->GetSelFrmType() == FRMTYPE_DRAWOBJ) &&
427cdf0e10cSrcweir pSrcSh->IsSelContainsControl() &&
428cdf0e10cSrcweir (rSh.GetFrmType( &aDocPt, sal_False ) & (FRMTYPE_HEADER|FRMTYPE_FOOTER)) )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir bCleanup = sal_True;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir // keine positionsgeschuetzten Objecte verschieben!
433cdf0e10cSrcweir else if( DND_ACTION_MOVE == rEvt.mnAction &&
434cdf0e10cSrcweir pSrcSh->IsSelObjProtected( FLYPROTECT_POS ) )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir bCleanup = sal_True;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir else if( rEvt.mbDefault )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir // JP 13.08.98: internes Drag&Drop: bei gleichem Doc ein Move
441cdf0e10cSrcweir // ansonten ein Copy - Task 54974
442cdf0e10cSrcweir nEventAction = pSrcSh->GetDoc() == rSh.GetDoc()
443cdf0e10cSrcweir ? DND_ACTION_MOVE
444cdf0e10cSrcweir : DND_ACTION_COPY;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir if ( bCleanup )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir CleanupDropUserMarker();
449cdf0e10cSrcweir rSh.UnSetVisCrsr();
450cdf0e10cSrcweir return DND_ACTION_NONE;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir else
454cdf0e10cSrcweir {
455cdf0e10cSrcweir //D&D von ausserhalb des SW soll per default ein Copy sein.
456cdf0e10cSrcweir if( EXCHG_IN_ACTION_DEFAULT == nEventAction &&
457cdf0e10cSrcweir DND_ACTION_MOVE == rEvt.mnAction )
458cdf0e10cSrcweir nEventAction = DND_ACTION_COPY;
459cdf0e10cSrcweir
460cdf0e10cSrcweir if( (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE == m_nDropFormat &&
461cdf0e10cSrcweir EXCHG_IN_ACTION_LINK == m_nDropAction) ||
462cdf0e10cSrcweir SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == m_nDropFormat )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir SdrMarkView* pMView = PTR_CAST( SdrMarkView, rSh.GetDrawView() );
465cdf0e10cSrcweir if( pMView && !pMView->IsDesignMode() )
466cdf0e10cSrcweir return DND_ACTION_NONE;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir if ( EXCHG_IN_ACTION_DEFAULT != nEventAction )
471cdf0e10cSrcweir nUserOpt = (sal_Int8)nEventAction;
472cdf0e10cSrcweir
473cdf0e10cSrcweir // show DropCursor or UserMarker ?
474cdf0e10cSrcweir if( EXCHG_DEST_SWDOC_FREE_AREA_WEB == m_nDropDestination ||
475cdf0e10cSrcweir EXCHG_DEST_SWDOC_FREE_AREA == m_nDropDestination )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir CleanupDropUserMarker();
478cdf0e10cSrcweir SwContentAtPos aCont( SwContentAtPos::SW_CONTENT_CHECK );
479cdf0e10cSrcweir if(rSh.GetContentAtPos(aDocPt, aCont))
480cdf0e10cSrcweir rSh.SwCrsrShell::SetVisCrsr( aDocPt );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir else
483cdf0e10cSrcweir {
484cdf0e10cSrcweir rSh.UnSetVisCrsr();
485cdf0e10cSrcweir
486cdf0e10cSrcweir if ( pUserMarkerObj != pObj )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir CleanupDropUserMarker();
489cdf0e10cSrcweir pUserMarkerObj = pObj;
490cdf0e10cSrcweir
491cdf0e10cSrcweir if(pUserMarkerObj)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), *pUserMarkerObj );
494cdf0e10cSrcweir }
495cdf0e10cSrcweir }
496cdf0e10cSrcweir }
497cdf0e10cSrcweir return nUserOpt;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir
500cdf0e10cSrcweir CleanupDropUserMarker();
501cdf0e10cSrcweir rSh.UnSetVisCrsr();
502cdf0e10cSrcweir //!! return SFX_APP()->AcceptDrop( rEvt );
503cdf0e10cSrcweir return DND_ACTION_NONE;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir
IMPL_LINK(SwEditWin,DDHandler,Timer *,EMPTYARG)507cdf0e10cSrcweir IMPL_LINK( SwEditWin, DDHandler, Timer *, EMPTYARG )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir bDDTimerStarted = sal_False;
510cdf0e10cSrcweir aTimer.Stop();
511cdf0e10cSrcweir aTimer.SetTimeout(240);
512cdf0e10cSrcweir bMBPressed = sal_False;
513cdf0e10cSrcweir ReleaseMouse();
514cdf0e10cSrcweir bFrmDrag = sal_False;
515cdf0e10cSrcweir
516cdf0e10cSrcweir if ( rView.GetViewFrame() )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir bExecuteDrag = sal_True;
519cdf0e10cSrcweir StartExecuteDrag();
520cdf0e10cSrcweir }
521cdf0e10cSrcweir return 0;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir
525cdf0e10cSrcweir
526