Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/util/XChangesNotifier.hpp>
30 : :
31 : : #include <basegfx/matrix/b2dhommatrix.hxx>
32 : : #include <basegfx/polygon/b2dpolygontools.hxx>
33 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
34 : :
35 : : #include <sfx2/viewfrm.hxx>
36 : : #include <sfx2/dispatch.hxx>
37 : :
38 : : #include <svx/sdr/overlay/overlaymanager.hxx>
39 : : #include <svx/sdr/overlay/overlaypolypolygon.hxx>
40 : : #include <svx/svdpagv.hxx>
41 : : #include <svx/sdrpagewindow.hxx>
42 : : #include <svx/sdrpaintwindow.hxx>
43 : : #include <svx/svdopath.hxx>
44 : : #include <svx/xlndsit.hxx>
45 : : #include <svx/xlnclit.hxx>
46 : : #include <svx/xlnstit.hxx>
47 : : #include <svx/xlnedit.hxx>
48 : : #include <svx/xlnstwit.hxx>
49 : : #include <svx/xlnedwit.hxx>
50 : : #include <svx/xlnstcit.hxx>
51 : : #include <svx/xlnedcit.hxx>
52 : : #include <svx/xlntrit.hxx>
53 : : #include <svx/svxids.hrc>
54 : : #include <svx/polypolygoneditor.hxx>
55 : : #include <svx/svddrgmt.hxx>
56 : :
57 : : #include "CustomAnimationPane.hxx"
58 : : #include "View.hxx"
59 : : #include "motionpathtag.hxx"
60 : : #include "sdpage.hxx"
61 : : #include "ViewShell.hxx"
62 : : #include "app.hrc"
63 : : #include "Window.hxx"
64 : :
65 : : #include <svx/sdr/contact/viewcontact.hxx>
66 : : #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
67 : :
68 : : using ::rtl::OUString;
69 : : using ::sdr::PolyPolygonEditor;
70 : : using namespace ::com::sun::star::uno;
71 : : using namespace ::com::sun::star::lang;
72 : : using namespace ::com::sun::star::util;
73 : : using namespace ::com::sun::star::drawing;
74 : :
75 : : namespace sd
76 : : {
77 : :
78 : : const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
79 : : static const int DRGPIX = 2; // Drag MinMove in Pixel
80 : :
81 : : // --------------------------------------------------------------------
82 : :
83 [ # # ][ # # ]: 0 : class PathDragMove : public SdrDragMove
84 : : {
85 : : private:
86 : : basegfx::B2DPolyPolygon maPathPolyPolygon;
87 : :
88 : : protected:
89 : : virtual void createSdrDragEntries();
90 : :
91 : : public:
92 : 0 : PathDragMove(SdrDragView& rNewView,
93 : : const rtl::Reference <MotionPathTag >& xTag,
94 : : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
95 : : : SdrDragMove(rNewView),
96 : : maPathPolyPolygon(rPathPolyPolygon),
97 [ # # ]: 0 : mxTag( xTag )
98 : 0 : {}
99 : :
100 : 0 : PathDragMove(SdrDragView& rNewView,
101 : : const rtl::Reference <MotionPathTag >& xTag)
102 : : : SdrDragMove(rNewView),
103 : : maPathPolyPolygon(),
104 [ # # ]: 0 : mxTag( xTag )
105 : 0 : {}
106 : :
107 : : virtual bool BeginSdrDrag();
108 : : virtual bool EndSdrDrag(bool bCopy);
109 : :
110 : : rtl::Reference <MotionPathTag > mxTag;
111 : : };
112 : :
113 : 0 : void PathDragMove::createSdrDragEntries()
114 : : {
115 : : // call parent
116 : 0 : SdrDragMove::createSdrDragEntries();
117 : :
118 [ # # ]: 0 : if(maPathPolyPolygon.count())
119 : : {
120 [ # # ]: 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
121 : : }
122 : 0 : }
123 : :
124 : 0 : bool PathDragMove::BeginSdrDrag()
125 : : {
126 [ # # ]: 0 : if( mxTag.is() )
127 : : {
128 : 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
129 [ # # ]: 0 : if( pPathObj )
130 : : {
131 : 0 : DragStat().SetActionRect(pPathObj->GetCurrentBoundRect());
132 : : }
133 : : }
134 : 0 : Show();
135 : 0 : return sal_True;
136 : : }
137 : :
138 : 0 : bool PathDragMove::EndSdrDrag(bool /*bCopy*/)
139 : : {
140 : 0 : Hide();
141 [ # # ]: 0 : if( mxTag.is() )
142 : 0 : mxTag->MovePath( DragStat().GetDX(), DragStat().GetDY() );
143 : 0 : return sal_True;
144 : : }
145 : : // --------------------------------------------------------------------
146 : :
147 [ # # ][ # # ]: 0 : class PathDragResize : public SdrDragResize
148 : : {
149 : : private:
150 : : basegfx::B2DPolyPolygon maPathPolyPolygon;
151 : :
152 : : protected:
153 : : virtual void createSdrDragEntries();
154 : :
155 : : public:
156 : 0 : PathDragResize(SdrDragView& rNewView,
157 : : const rtl::Reference <MotionPathTag >& xTag,
158 : : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
159 : : : SdrDragResize(rNewView),
160 : : maPathPolyPolygon(rPathPolyPolygon),
161 [ # # ]: 0 : mxTag( xTag )
162 : 0 : {}
163 : :
164 : 0 : PathDragResize(SdrDragView& rNewView,
165 : : const rtl::Reference <MotionPathTag >& xTag)
166 : : : SdrDragResize(rNewView),
167 : : maPathPolyPolygon(),
168 [ # # ]: 0 : mxTag( xTag )
169 : 0 : {}
170 : :
171 : : virtual bool EndSdrDrag(bool bCopy);
172 : : rtl::Reference <MotionPathTag > mxTag;
173 : : };
174 : :
175 : 0 : void PathDragResize::createSdrDragEntries()
176 : : {
177 : : // call parent
178 : 0 : SdrDragResize::createSdrDragEntries();
179 : :
180 [ # # ]: 0 : if(maPathPolyPolygon.count())
181 : : {
182 [ # # ]: 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
183 : : }
184 : 0 : }
185 : :
186 : 0 : bool PathDragResize::EndSdrDrag(bool /*bCopy*/)
187 : : {
188 : 0 : Hide();
189 [ # # ]: 0 : if( mxTag.is() )
190 : : {
191 : 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
192 [ # # ]: 0 : if( pPathObj )
193 : : {
194 : 0 : const Point aRef( DragStat().Ref1() );
195 [ # # ]: 0 : basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aRef.X(), -aRef.Y()));
196 [ # # ][ # # ]: 0 : aTrans.scale(double(aXFact), double(aYFact));
[ # # ]
197 [ # # ]: 0 : aTrans.translate(aRef.X(), aRef.Y());
198 [ # # ]: 0 : basegfx::B2DPolyPolygon aDragPoly(pPathObj->GetPathPoly());
199 [ # # ]: 0 : aDragPoly.transform(aTrans);
200 [ # # ][ # # ]: 0 : pPathObj->SetPathPoly( aDragPoly );
[ # # ]
201 : : }
202 : : }
203 : 0 : return sal_True;
204 : : }
205 : :
206 : : // --------------------------------------------------------------------
207 : :
208 [ # # ][ # # ]: 0 : class PathDragObjOwn : public SdrDragObjOwn
209 : : {
210 : : private:
211 : : basegfx::B2DPolyPolygon maPathPolyPolygon;
212 : :
213 : : protected:
214 : : virtual void createSdrDragEntries();
215 : :
216 : : public:
217 : 0 : PathDragObjOwn(SdrDragView& rNewView,
218 : : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
219 : : : SdrDragObjOwn(rNewView),
220 [ # # ]: 0 : maPathPolyPolygon(rPathPolyPolygon)
221 : 0 : {}
222 : :
223 : 0 : PathDragObjOwn(SdrDragView& rNewView)
224 : : : SdrDragObjOwn(rNewView),
225 [ # # ]: 0 : maPathPolyPolygon()
226 : 0 : {}
227 : :
228 : : virtual bool EndSdrDrag(bool bCopy);
229 : : };
230 : :
231 : 0 : void PathDragObjOwn::createSdrDragEntries()
232 : : {
233 : : // call parent
234 : 0 : SdrDragObjOwn::createSdrDragEntries();
235 : :
236 [ # # ]: 0 : if(maPathPolyPolygon.count())
237 : : {
238 [ # # ]: 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
239 : : }
240 : 0 : }
241 : :
242 : 0 : bool PathDragObjOwn::EndSdrDrag(bool /*bCopy*/)
243 : : {
244 : 0 : Hide();
245 : :
246 : 0 : SdrObject* pObj = GetDragObj();
247 : :
248 [ # # ]: 0 : if(pObj)
249 : : {
250 : 0 : return pObj->applySpecialDrag(DragStat());
251 : : }
252 : : else
253 : : {
254 : 0 : return false;
255 : : }
256 : : }
257 : :
258 : : // --------------------------------------------------------------------
259 : :
260 : : class SdPathHdl : public SmartHdl
261 : : {
262 : : public:
263 : : SdPathHdl( const SmartTagReference& xTag, SdrPathObj* mpPathObj );
264 : : virtual ~SdPathHdl();
265 : : virtual void CreateB2dIAObject();
266 : : virtual sal_Bool IsFocusHdl() const;
267 : : virtual Pointer GetSdrDragPointer() const;
268 : : virtual bool isMarkable() const;
269 : :
270 : : private:
271 : : SdrPathObj* mpPathObj;
272 : : rtl::Reference< MotionPathTag > mxTag;
273 : : };
274 : :
275 : : // --------------------------------------------------------------------
276 : :
277 : 0 : SdPathHdl::SdPathHdl( const SmartTagReference& xTag, SdrPathObj* pPathObj )
278 : 0 : : SmartHdl( xTag, pPathObj->GetCurrentBoundRect().TopLeft() )
279 : : , mpPathObj( pPathObj )
280 [ # # ][ # # ]: 0 : , mxTag( dynamic_cast< MotionPathTag* >( xTag.get() ) )
281 : : {
282 : 0 : }
283 : :
284 : : // --------------------------------------------------------------------
285 : :
286 : 0 : SdPathHdl::~SdPathHdl()
287 : : {
288 [ # # ]: 0 : }
289 : :
290 : : // --------------------------------------------------------------------
291 : :
292 : 0 : void SdPathHdl::CreateB2dIAObject()
293 : : {
294 : : // first throw away old one
295 : 0 : GetRidOfIAObject();
296 : :
297 [ # # ]: 0 : if(pHdlList)
298 : : {
299 : 0 : SdrMarkView* pView = pHdlList->GetView();
300 : :
301 [ # # ][ # # ]: 0 : if(pView && !pView->areMarkHandlesHidden())
[ # # ]
302 : : {
303 : 0 : SdrPageView* pPageView = pView->GetSdrPageView();
304 : :
305 [ # # ]: 0 : if(pPageView)
306 : : {
307 [ # # ]: 0 : for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
308 : : {
309 : 0 : const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
310 : :
311 [ # # ]: 0 : if(rPageWindow.GetPaintWindow().OutputToWindow())
312 : : {
313 [ # # ]: 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
314 [ # # ][ # # ]: 0 : if (xManager.is() && mpPathObj)
[ # # ]
315 : : {
316 [ # # ]: 0 : const sdr::contact::ViewContact& rVC = mpPathObj->GetViewContact();
317 [ # # ]: 0 : const drawinglayer::primitive2d::Primitive2DSequence aSequence = rVC.getViewIndependentPrimitive2DSequence();
318 [ # # ][ # # ]: 0 : sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
319 : :
320 [ # # ]: 0 : xManager->add(*pNew);
321 [ # # ][ # # ]: 0 : maOverlayGroup.append(*pNew);
322 [ # # ]: 0 : }
323 : : }
324 : : }
325 : : }
326 : : }
327 : : }
328 : 0 : }
329 : :
330 : : // --------------------------------------------------------------------
331 : :
332 : 0 : sal_Bool SdPathHdl::IsFocusHdl() const
333 : : {
334 : 0 : return sal_False;
335 : : }
336 : :
337 : : // --------------------------------------------------------------------
338 : :
339 : 0 : bool SdPathHdl::isMarkable() const
340 : : {
341 : 0 : return false;
342 : : }
343 : :
344 : : // --------------------------------------------------------------------
345 : :
346 : 0 : Pointer SdPathHdl::GetSdrDragPointer() const
347 : : {
348 : 0 : PointerStyle eStyle = POINTER_NOTALLOWED;
349 [ # # ]: 0 : if( mxTag.is() )
350 : : {
351 [ # # ]: 0 : if( mxTag->isSelected() )
352 : : {
353 [ # # ][ # # ]: 0 : if( !mxTag->getView().IsFrameDragSingles() && mxTag->getView().IsInsObjPointMode() )
[ # # ]
354 : 0 : eStyle = POINTER_CROSS;
355 : : else
356 : 0 : eStyle = POINTER_MOVE;
357 : : }
358 : : else
359 : : {
360 : 0 : eStyle = POINTER_ARROW;
361 : :
362 : : }
363 : : }
364 : 0 : return Pointer( eStyle );
365 : : }
366 : :
367 : : // ====================================================================
368 : :
369 : 0 : MotionPathTag::MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, const CustomAnimationEffectPtr& pEffect )
370 : : : SmartTag( rView )
371 : : , mrPane( rPane )
372 : : , mpEffect( pEffect )
373 : : , mxOrigin( pEffect->getTargetShape() )
374 : : , msLastPath( pEffect->getPath() )
375 [ # # ][ # # ]: 0 : , mbInUpdatePath( false )
[ # # ][ # # ]
[ # # ]
376 : : {
377 [ # # ]: 0 : mpPathObj = mpEffect->createSdrPathObjFromPath();
378 [ # # ]: 0 : mxPolyPoly = mpPathObj->GetPathPoly();
379 [ # # ][ # # ]: 0 : maOriginPos = mxOrigin->getPosition();
380 : :
381 : 0 : SdrPage* pPage = mrView.GetSdrPageView()->GetPage();
382 [ # # ]: 0 : if( pPage )
383 : : {
384 [ # # ]: 0 : mpPathObj->SetPage( pPage );
385 [ # # ]: 0 : mpPathObj->SetObjList( pPage );
386 : : }
387 : :
388 [ # # ]: 0 : XDash aDash( XDASH_RECT, 1, 80, 1, 80, 80);
389 : 0 : rtl::OUString aEmpty( "?" );
390 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem( XLineDashItem( aEmpty, aDash ) );
[ # # ][ # # ]
[ # # ]
391 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem( XLineStyleItem( XLINE_DASH ) );
[ # # ]
392 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem( XLineColorItem(aEmpty, ::Color(COL_GRAY)) );
[ # # ][ # # ]
[ # # ]
393 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
[ # # ]
394 : :
395 [ # # ]: 0 : ::basegfx::B2DPolygon aStartArrow;
396 [ # # ]: 0 : aStartArrow.append(::basegfx::B2DPoint(20.0, 0.0));
397 [ # # ]: 0 : aStartArrow.append(::basegfx::B2DPoint(0.0, 0.0));
398 [ # # ]: 0 : aStartArrow.append(::basegfx::B2DPoint(10.0, 30.0));
399 [ # # ]: 0 : aStartArrow.setClosed(true);
400 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineStartItem(aEmpty,::basegfx::B2DPolyPolygon(aStartArrow)));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
401 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineStartWidthItem(400));
[ # # ]
402 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineStartCenterItem(sal_True));
[ # # ]
403 : :
404 [ # # ]: 0 : updatePathAttributes();
405 : :
406 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineTransparenceItem(50));
[ # # ]
407 : :
408 [ # # ][ # # ]: 0 : mpMark = new SdrMark( mpPathObj, mrView.GetSdrPageView() );
409 : :
410 [ # # ]: 0 : mpPathObj->AddListener( *this );
411 : :
412 [ # # ]: 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
413 [ # # ]: 0 : if( xNotifier.is() )
414 : : {
415 [ # # ]: 0 : Reference< XChangesListener > xListener( this );
416 [ # # ][ # # ]: 0 : xNotifier->addChangesListener( this );
[ # # ]
417 [ # # ]: 0 : }
418 : 0 : }
419 : :
420 : : // --------------------------------------------------------------------
421 : :
422 [ # # ][ # # ]: 0 : MotionPathTag::~MotionPathTag()
[ # # ]
423 : : {
424 : : DBG_ASSERT( mpPathObj == 0, "sd::MotionPathTag::~MotionPathTag(), dispose me first!" );
425 [ # # ]: 0 : Dispose();
426 [ # # ]: 0 : }
427 : :
428 : : // --------------------------------------------------------------------
429 : :
430 : 0 : void MotionPathTag::updatePathAttributes()
431 : : {
432 : 0 : rtl::OUString aEmpty( "?" );
433 : :
434 [ # # ]: 0 : ::basegfx::B2DPolygon aCandidate;
435 [ # # ][ # # ]: 0 : if( mxPolyPoly.count() )
436 : : {
437 [ # # ][ # # ]: 0 : aCandidate = mxPolyPoly.getB2DPolygon(0);
[ # # ]
438 [ # # ]: 0 : ::basegfx::tools::checkClosed( aCandidate );
439 : : }
440 : :
441 [ # # ][ # # ]: 0 : if( !aCandidate.isClosed() )
442 : : {
443 [ # # ]: 0 : ::basegfx::B2DPolygon aEndArrow;
444 [ # # ]: 0 : aEndArrow.append(::basegfx::B2DPoint(10.0, 0.0));
445 [ # # ]: 0 : aEndArrow.append(::basegfx::B2DPoint(0.0, 30.0));
446 [ # # ]: 0 : aEndArrow.append(::basegfx::B2DPoint(20.0, 30.0));
447 [ # # ]: 0 : aEndArrow.setClosed(true);
448 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineEndItem(aEmpty,::basegfx::B2DPolyPolygon(aEndArrow)));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
449 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineEndWidthItem(400));
[ # # ]
450 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineEndCenterItem(sal_True));
[ # # ][ # # ]
451 : : }
452 : : else
453 : : {
454 [ # # ][ # # ]: 0 : mpPathObj->SetMergedItem(XLineEndItem());
[ # # ]
455 [ # # ]: 0 : }
456 : 0 : }
457 : :
458 : : // --------------------------------------------------------------------
459 : :
460 : 0 : void MotionPathTag::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
461 : : {
462 [ # # ][ # # ]: 0 : if( mpPathObj && !mbInUpdatePath && dynamic_cast< const SdrHint* >( &rHint ) && (mpEffect.get() != 0) )
[ # # ][ # # ]
[ # # ][ # # ]
463 : : {
464 [ # # ]: 0 : if( mxPolyPoly != mpPathObj->GetPathPoly() )
465 : : {
466 : 0 : mbInUpdatePath = true;
467 [ # # ]: 0 : mxPolyPoly = mpPathObj->GetPathPoly();
468 : 0 : rtl::Reference< MotionPathTag > xTag( this );
469 [ # # ]: 0 : mrPane.updatePathFromMotionPathTag( xTag );
470 [ # # ]: 0 : msLastPath = mpEffect->getPath();
471 [ # # ]: 0 : updatePathAttributes();
472 : 0 : mbInUpdatePath = false;
473 : : }
474 : : }
475 : 0 : }
476 : :
477 : : // --------------------------------------------------------------------
478 : :
479 : 0 : void MotionPathTag::MovePath( int nDX, int nDY )
480 : : {
481 [ # # ]: 0 : if( mpPathObj )
482 : : {
483 [ # # ]: 0 : mpPathObj->Move( Size( nDX, nDY ) );
484 : 0 : mrView.updateHandles();
485 : : }
486 : 0 : }
487 : :
488 : : // --------------------------------------------------------------------
489 : :
490 : : /** returns true if the MotionPathTag handled the event. */
491 : 0 : bool MotionPathTag::MouseButtonDown( const MouseEvent& rMEvt, SmartHdl& rHdl )
492 : : {
493 [ # # ]: 0 : if( !mpPathObj )
494 : 0 : return false;
495 : :
496 [ # # ]: 0 : if( !isSelected() )
497 : : {
498 [ # # ]: 0 : SmartTagReference xTag( this );
499 [ # # ]: 0 : mrView.getSmartTags().select( xTag );
500 [ # # ]: 0 : selectionChanged();
501 [ # # ]: 0 : return true;
502 : : }
503 : : else
504 : : {
505 [ # # ][ # # ]: 0 : if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
[ # # ]
506 : : {
507 : 0 : mrView.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_EDIT, SFX_CALLMODE_ASYNCHRON);
508 : 0 : return true;
509 : : }
510 [ # # ]: 0 : else if( rMEvt.IsLeft() )
511 : : {
512 [ # # ]: 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
513 [ # # ]: 0 : Point aMDPos( pOut->PixelToLogic( rMEvt.GetPosPixel() ) );
514 : :
515 [ # # ][ # # ]: 0 : if( !mrView.IsFrameDragSingles() && mrView.IsInsObjPointMode() && (rHdl.GetObjHdlNum() == SMART_TAG_HDL_NUM) )
[ # # ][ # # ]
516 : : {
517 : : // insert a point in edit mode
518 : 0 : const bool bNewObj = rMEvt.IsMod1();
519 : :
520 [ # # ]: 0 : mrView.BrkAction();
521 : :
522 : 0 : Point aPt(aMDPos); // - pMarkedPV->GetOffset());
523 : :
524 [ # # ]: 0 : if(bNewObj)
525 [ # # ]: 0 : aPt = mrView.GetSnapPos(aPt,mrView.GetSdrPageView());
526 : :
527 [ # # ]: 0 : bool bClosed0(mpPathObj->IsClosedObj());
528 : :
529 [ # # ]: 0 : sal_uInt32 nInsPointNum = mpPathObj->NbcInsPointOld(aPt, bNewObj, sal_True);
530 : :
531 [ # # ][ # # ]: 0 : if(bClosed0 != mpPathObj->IsClosedObj())
532 : : {
533 : : // Obj was closed implicit
534 : : // object changed
535 [ # # ]: 0 : mpPathObj->SetChanged();
536 [ # # ]: 0 : mpPathObj->BroadcastObjectChange();
537 : : }
538 : :
539 [ # # ]: 0 : if(0xffffffff != nInsPointNum)
540 : : {
541 [ # # ]: 0 : mrView.UnmarkAllPoints();
542 [ # # ]: 0 : mrView.updateHandles();
543 : :
544 [ # # ][ # # ]: 0 : bool bRet = mrView.BegDragObj(aMDPos, pOut, mrView.GetHdl(nInsPointNum+1), 0, new PathDragObjOwn( mrView ) );
[ # # ][ # # ]
545 : :
546 [ # # ]: 0 : if (bRet)
547 : : {
548 : 0 : const_cast< SdrDragStat* >( &mrView.GetDragStat() )->SetMinMoved();
549 [ # # ]: 0 : mrView.MovDragObj(aMDPos);
550 : : }
551 : : }
552 : 0 : return true;
553 : : }
554 : : else
555 : : {
556 : 0 : SmartHdl* pHdl = &rHdl;
557 [ # # ][ # # ]: 0 : if (!mrView.IsPointMarked(*pHdl) || rMEvt.IsShift())
[ # # ][ # # ]
558 : : {
559 [ # # ]: 0 : if (!rMEvt.IsShift())
560 : : {
561 [ # # ]: 0 : mrView.UnmarkAllPoints();
562 [ # # ][ # # ]: 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
563 : : }
564 : : else
565 : : {
566 [ # # ][ # # ]: 0 : if (mrView.IsPointMarked(*pHdl) )
567 : : {
568 [ # # ]: 0 : mrView.UnmarkPoint(*pHdl);
569 : 0 : pHdl = NULL;
570 : : }
571 : : else
572 : : {
573 [ # # ][ # # ]: 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
574 : : }
575 : : }
576 : :
577 [ # # ]: 0 : if (pHdl)
578 [ # # ]: 0 : mrView.MarkPoint(*pHdl);
579 : : }
580 : :
581 : :
582 [ # # ][ # # ]: 0 : if( pHdl && !rMEvt.IsRight() )
[ # # ]
583 : : {
584 [ # # ]: 0 : mrView.BrkAction();
585 [ # # ]: 0 : const sal_uInt16 nDrgLog = (sal_uInt16)pOut->PixelToLogic(Size(DRGPIX,0)).Width();
586 : :
587 : 0 : rtl::Reference< MotionPathTag > xTag( this );
588 : : SdrDragMethod* pDragMethod;
589 : :
590 : : // #i95646# add DragPoly as geometry to each local SdrDragMethod to be able
591 : : // to create the needed local SdrDragEntry for it in createSdrDragEntries()
592 [ # # ]: 0 : const basegfx::B2DPolyPolygon aDragPoly(mpPathObj->GetPathPoly());
593 : :
594 [ # # ][ # # ]: 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
[ # # ]
595 : : {
596 [ # # ][ # # ]: 0 : pDragMethod = new PathDragMove( mrView, xTag, aDragPoly );
597 [ # # ]: 0 : pHdl->SetPos( aMDPos );
598 : : }
599 [ # # ]: 0 : else if( pHdl->GetKind() == HDL_POLY )
600 : : {
601 [ # # ][ # # ]: 0 : pDragMethod = new PathDragObjOwn( mrView, aDragPoly );
602 : : }
603 : : else
604 : : {
605 [ # # ][ # # ]: 0 : pDragMethod = new PathDragResize( mrView, xTag, aDragPoly );
606 : : }
607 : :
608 [ # # ][ # # ]: 0 : mrView.BegDragObj(aMDPos, NULL, pHdl, nDrgLog, pDragMethod );
609 : : }
610 : 0 : return true;
611 : : }
612 : : }
613 : : }
614 : :
615 : 0 : return false;
616 : : }
617 : :
618 : : // --------------------------------------------------------------------
619 : :
620 : : /** returns true if the SmartTag consumes this event. */
621 : 0 : bool MotionPathTag::KeyInput( const KeyEvent& rKEvt )
622 : : {
623 [ # # ]: 0 : if( !mpPathObj )
624 : 0 : return false;
625 : :
626 : 0 : sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
627 [ # # # # : 0 : switch( nCode )
# # ]
628 : : {
629 : : case KEY_DELETE:
630 : 0 : return OnDelete();
631 : :
632 : : case KEY_DOWN:
633 : : case KEY_UP:
634 : : case KEY_LEFT:
635 : : case KEY_RIGHT:
636 : 0 : return OnMove( rKEvt );
637 : :
638 : : case KEY_ESCAPE:
639 : : {
640 [ # # ]: 0 : SmartTagReference xThis( this );
641 [ # # ]: 0 : mrView.getSmartTags().deselect();
642 [ # # ]: 0 : return true;
643 : : }
644 : :
645 : : case KEY_TAB:
646 : 0 : return OnTabHandles( rKEvt );
647 : :
648 : : case KEY_SPACE:
649 : 0 : return OnMarkHandle( rKEvt );
650 : :
651 : : default:
652 : 0 : break;
653 : : }
654 : 0 : return false;
655 : : }
656 : :
657 : 0 : bool MotionPathTag::OnDelete()
658 : : {
659 : 0 : mrPane.remove( mpEffect );
660 : 0 : return true;
661 : : }
662 : :
663 : 0 : bool MotionPathTag::OnTabHandles( const KeyEvent& rKEvt )
664 : : {
665 [ # # ][ # # ]: 0 : if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
[ # # ]
666 : : {
667 : 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
668 : 0 : sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
669 : :
670 : 0 : ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
671 : :
672 : : // guarantee visibility of focused handle
673 : 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
674 : :
675 [ # # ]: 0 : if(pHdl)
676 : : {
677 : 0 : Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
678 [ # # ]: 0 : if( pWindow )
679 : : {
680 : 0 : Point aHdlPosition(pHdl->GetPos());
681 [ # # ]: 0 : Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
682 [ # # ]: 0 : mrView.MakeVisible(aVisRect, *pWindow);
683 : : }
684 : : }
685 : :
686 : 0 : return true;
687 : : }
688 : :
689 : 0 : return false;
690 : : }
691 : :
692 : 0 : bool MotionPathTag::OnMarkHandle( const KeyEvent& rKEvt )
693 : : {
694 : 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
695 : 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
696 : :
697 [ # # ][ # # ]: 0 : if(pHdl && pHdl->GetKind() == HDL_POLY )
[ # # ]
698 : : {
699 : : // rescue ID of point with focus
700 : 0 : sal_uInt32 nPol(pHdl->GetPolyNum());
701 : 0 : sal_uInt32 nPnt(pHdl->GetPointNum());
702 : :
703 [ # # ]: 0 : if(mrView.IsPointMarked(*pHdl))
704 : : {
705 [ # # ]: 0 : if(rKEvt.GetKeyCode().IsShift())
706 : : {
707 : 0 : mrView.UnmarkPoint(*pHdl);
708 : : }
709 : : }
710 : : else
711 : : {
712 [ # # ]: 0 : if(!rKEvt.GetKeyCode().IsShift())
713 : : {
714 : 0 : mrView.UnmarkAllPoints();
715 : : }
716 : 0 : mrView.MarkPoint(*pHdl);
717 : : }
718 : :
719 [ # # ]: 0 : if(0L == rHdlList.GetFocusHdl())
720 : : {
721 : : // restore point with focus
722 : 0 : SdrHdl* pNewOne = 0L;
723 : :
724 [ # # ][ # # ]: 0 : for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
[ # # ]
725 : : {
726 : 0 : SdrHdl* pAct = rHdlList.GetHdl(a);
727 : :
728 [ # # ][ # # ]: 0 : if(pAct && pAct->GetKind() == HDL_POLY && pAct->GetPolyNum() == nPol && pAct->GetPointNum() == nPnt)
[ # # ][ # # ]
[ # # ]
729 : 0 : pNewOne = pAct;
730 : : }
731 : :
732 [ # # ]: 0 : if(pNewOne)
733 : 0 : ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
734 : : }
735 : : }
736 : :
737 : 0 : return true;
738 : : }
739 : :
740 : 0 : bool MotionPathTag::OnMove( const KeyEvent& rKEvt )
741 : : {
742 : 0 : long nX = 0;
743 : 0 : long nY = 0;
744 : :
745 [ # # # # : 0 : switch( rKEvt.GetKeyCode().GetCode() )
# ]
746 : : {
747 : 0 : case KEY_UP: nY = -1; break;
748 : 0 : case KEY_DOWN: nY = 1; break;
749 : 0 : case KEY_LEFT: nX = -1; break;
750 : 0 : case KEY_RIGHT: nX = 1; break;
751 : 0 : default: break;
752 : : }
753 : :
754 [ # # ]: 0 : if(rKEvt.GetKeyCode().IsMod2())
755 : : {
756 [ # # ]: 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
757 [ # # ][ # # ]: 0 : Size aLogicSizeOnePixel = (pOut) ? pOut->PixelToLogic(Size(1,1)) : Size(100, 100);
[ # # ][ # # ]
758 : 0 : nX *= aLogicSizeOnePixel.Width();
759 : 0 : nY *= aLogicSizeOnePixel.Height();
760 : : }
761 : : else
762 : : {
763 : : // old, fixed move distance
764 : 0 : nX *= 100;
765 : 0 : nY *= 100;
766 : : }
767 : :
768 [ # # ][ # # ]: 0 : if( nX || nY )
769 : : {
770 : : // in point edit mode move the handle with the focus
771 : 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
772 : 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
773 : :
774 [ # # ]: 0 : if(pHdl)
775 : : {
776 : : // now move the Handle (nX, nY)
777 : 0 : Point aStartPoint(pHdl->GetPos());
778 : 0 : Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
779 : :
780 : : // start dragging
781 : 0 : rtl::Reference< MotionPathTag > xTag( this );
782 : 0 : SdrDragMethod* pDragMethod = 0;
783 [ # # ][ # # ]: 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
[ # # ]
784 : : {
785 [ # # ][ # # ]: 0 : pDragMethod = new PathDragMove( mrView, xTag );
786 : : }
787 [ # # ]: 0 : else if( pHdl->GetKind() == HDL_POLY )
788 : : {
789 [ # # ][ # # ]: 0 : pDragMethod = new PathDragObjOwn( mrView );
790 : : }
791 [ # # ]: 0 : else if( pHdl->GetKind() != HDL_BWGT )
792 : : {
793 [ # # ][ # # ]: 0 : pDragMethod = new PathDragResize( mrView, xTag );
794 : : }
795 [ # # ]: 0 : mrView.BegDragObj(aStartPoint, 0, pHdl, 0, pDragMethod);
796 : :
797 [ # # ]: 0 : if(mrView.IsDragObj())
798 : : {
799 : 0 : bool bWasNoSnap = mrView.GetDragStat().IsNoSnap();
800 : 0 : sal_Bool bWasSnapEnabled = mrView.IsSnapEnabled();
801 : :
802 : : // switch snapping off
803 [ # # ]: 0 : if(!bWasNoSnap)
804 : 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(sal_True);
805 [ # # ]: 0 : if(bWasSnapEnabled)
806 : 0 : mrView.SetSnapEnabled(sal_False);
807 : :
808 [ # # ]: 0 : mrView.MovAction(aEndPoint);
809 [ # # ]: 0 : mrView.EndDragObj();
810 : :
811 : : // restore snap
812 [ # # ]: 0 : if(!bWasNoSnap)
813 : 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(bWasNoSnap);
814 [ # # ]: 0 : if(bWasSnapEnabled)
815 : 0 : mrView.SetSnapEnabled(bWasSnapEnabled);
816 : 0 : }
817 : : }
818 : : else
819 : : {
820 : : // move the path
821 : 0 : MovePath( nX, nY );
822 : : }
823 : : }
824 : :
825 : 0 : return true;
826 : : }
827 : :
828 : : // --------------------------------------------------------------------
829 : :
830 : 0 : sal_uLong MotionPathTag::GetMarkablePointCount() const
831 : : {
832 [ # # ][ # # ]: 0 : if( mpPathObj && isSelected() )
[ # # ]
833 : : {
834 : 0 : return mpPathObj->GetPointCount();
835 : : }
836 : : else
837 : : {
838 : 0 : return 0;
839 : : }
840 : : }
841 : :
842 : : // --------------------------------------------------------------------
843 : :
844 : 0 : sal_uLong MotionPathTag::GetMarkedPointCount() const
845 : : {
846 [ # # ]: 0 : if( mpMark )
847 : : {
848 : 0 : const SdrUShortCont* pPts=mpMark->GetMarkedPoints();
849 [ # # ]: 0 : return pPts ? pPts->size() : 0;
850 : : }
851 : : else
852 : : {
853 : 0 : return 0;
854 : : }
855 : : }
856 : :
857 : : // --------------------------------------------------------------------
858 : :
859 : 0 : sal_Bool MotionPathTag::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
860 : : {
861 : 0 : sal_Bool bRet=sal_False;
862 [ # # ][ # # ]: 0 : if( mpPathObj && mrView.IsPointMarkable( rHdl ) && (rHdl.GetKind() != HDL_SMARTTAG) )
[ # # ][ # # ]
863 : : {
864 [ # # ]: 0 : SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( &rHdl );
865 [ # # ][ # # ]: 0 : if( pSmartHdl && pSmartHdl->getTag().get() == this )
[ # # ]
866 : : {
867 : 0 : mpMark->ForceMarkedPoints();
868 [ # # ]: 0 : if (mrView.MarkPointHelper(&rHdl,mpMark,bUnmark))
869 : : {
870 : 0 : mrView.MarkListHasChanged();
871 : 0 : bRet=sal_True;
872 : : }
873 : : }
874 : : }
875 : 0 : return bRet;
876 : : }
877 : :
878 : : // --------------------------------------------------------------------
879 : :
880 : 0 : sal_Bool MotionPathTag::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark )
881 : : {
882 : 0 : sal_Bool bChgd=sal_False;
883 : :
884 [ # # ][ # # ]: 0 : if( mpPathObj && isSelected() )
[ # # ]
885 : : {
886 : 0 : sal_Int32 nHdlNum = mrView.GetHdlList().GetHdlCount() - 1;
887 [ # # ]: 0 : while( nHdlNum > 0 )
888 : : {
889 [ # # ]: 0 : SmartHdl* pHdl = dynamic_cast< SmartHdl* >( mrView.GetHdl( sal::static_int_cast< sal_uLong >( nHdlNum-- ) ) );
890 : :
891 [ # # ][ # # ]: 0 : if( pHdl && (pHdl->getTag().get() == this) && mrView.IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark)
[ # # ][ # # ]
[ # # ]
892 : : {
893 : 0 : Point aPos(pHdl->GetPos());
894 [ # # ][ # # ]: 0 : if( pRect==NULL || pRect->IsInside(aPos))
[ # # ][ # # ]
895 : : {
896 [ # # ][ # # ]: 0 : if( mrView.MarkPointHelper(pHdl,mpMark,bUnmark) )
897 : 0 : bChgd=sal_True;
898 : : }
899 : : }
900 : : }
901 : :
902 [ # # ]: 0 : if(bChgd)
903 : 0 : mrView.MarkListHasChanged();
904 : : }
905 : :
906 : 0 : return bChgd;
907 : : }
908 : :
909 : : // --------------------------------------------------------------------
910 : :
911 : 0 : bool MotionPathTag::getContext( SdrViewContext& rContext )
912 : : {
913 [ # # ][ # # ]: 0 : if( mpPathObj && isSelected() && !mrView.IsFrameDragSingles() )
[ # # ][ # # ]
914 : : {
915 : 0 : rContext = SDRCONTEXT_POINTEDIT;
916 : 0 : return true;
917 : : }
918 : : else
919 : : {
920 : 0 : return false;
921 : : }
922 : : }
923 : :
924 : : // --------------------------------------------------------------------
925 : :
926 : 0 : void MotionPathTag::CheckPossibilities()
927 : : {
928 [ # # ]: 0 : if( mpPathObj )
929 : : {
930 [ # # ]: 0 : if( isSelected() )
931 : : {
932 : 0 : mrView.SetMoveAllowed( true );
933 : 0 : mrView.SetMoveProtected( false );
934 : 0 : mrView.SetResizeFreeAllowed( true );
935 : 0 : mrView.SetResizePropAllowed( true );
936 : 0 : mrView.SetResizeProtected( false );
937 : :
938 [ # # ]: 0 : if( !mrView.IsFrameDragSingles() )
939 : : {
940 : 0 : bool b1stSmooth(true);
941 : 0 : bool b1stSegm(true);
942 : 0 : bool bCurve(false);
943 : 0 : bool bSmoothFuz(false);
944 : 0 : bool bSegmFuz(false);
945 : 0 : basegfx::B2VectorContinuity eSmooth = basegfx::CONTINUITY_NONE;
946 : :
947 [ # # ]: 0 : mrView.CheckPolyPossibilitiesHelper( mpMark, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
948 : : }
949 : : }
950 : : }
951 : 0 : }
952 : :
953 : : // --------------------------------------------------------------------
954 : :
955 : 0 : void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
956 : : {
957 [ # # ]: 0 : if( mpPathObj )
958 : : {
959 [ # # ][ # # ]: 0 : ::com::sun::star::awt::Point aPos( mxOrigin->getPosition() );
960 [ # # ][ # # ]: 0 : if( (aPos.X != maOriginPos.X) || (aPos.Y != maOriginPos.Y) )
961 : : {
962 : : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
963 [ # # ]: 0 : aPos.X - maOriginPos.X, aPos.Y - maOriginPos.Y));
964 [ # # ]: 0 : mxPolyPoly.transform( aTransform );
965 [ # # ]: 0 : mpPathObj->SetPathPoly( mxPolyPoly );
966 [ # # ]: 0 : maOriginPos = aPos;
967 : : }
968 : :
969 [ # # ]: 0 : SmartTagReference xThis( this );
970 [ # # ][ # # ]: 0 : SdPathHdl* pHdl = new SdPathHdl( xThis, mpPathObj );
971 : 0 : pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
972 : 0 : pHdl->SetPageView( mrView.GetSdrPageView() );
973 : :
974 : :
975 [ # # ]: 0 : pHdl->SetObj(mpPathObj);
976 [ # # ]: 0 : rHandlerList.AddHdl( pHdl );
977 : :
978 [ # # ][ # # ]: 0 : if( isSelected() )
979 : : {
980 : 0 : mrView.GetSdrPageView()->SetHasMarkedObj(sal_True);
981 : :
982 [ # # ]: 0 : if( !mrView.IsFrameDragSingles() )
983 : : {
984 [ # # ][ # # ]: 0 : SdrHdlList aTemp( rHandlerList.GetView() );
985 [ # # ]: 0 : mpPathObj->AddToHdlList( aTemp );
986 : 0 : const SdrUShortCont* pMrkPnts=mpMark->GetMarkedPoints();
987 : :
988 : : sal_uInt32 nHandle;
989 [ # # ]: 0 : for( nHandle = 0; nHandle < aTemp.GetHdlCount(); ++nHandle )
990 : : {
991 [ # # ]: 0 : SdrHdl* pTempHdl = aTemp.GetHdl( nHandle );
992 : :
993 [ # # ][ # # ]: 0 : SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj, pTempHdl->GetPos(), pTempHdl->GetKind() );
994 : 0 : pSmartHdl->SetObjHdlNum( nHandle );
995 : 0 : pSmartHdl->SetPolyNum( pTempHdl->GetPolyNum() );
996 : 0 : pSmartHdl->SetPointNum( pTempHdl->GetPointNum() );
997 : 0 : pSmartHdl->SetPlusHdl( pTempHdl->IsPlusHdl() );
998 : 0 : pSmartHdl->SetSourceHdlNum( pTempHdl->GetSourceHdlNum() );
999 : 0 : pSmartHdl->SetPageView( mrView.GetSdrPageView() );
1000 : :
1001 [ # # ]: 0 : rHandlerList.AddHdl( pSmartHdl );
1002 : :
1003 [ # # ][ # # ]: 0 : const bool bSelected= pMrkPnts && pMrkPnts->find( sal_uInt16(nHandle) ) != pMrkPnts->end();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1004 [ # # ]: 0 : pSmartHdl->SetSelected(bSelected);
1005 : :
1006 [ # # ][ # # ]: 0 : if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
[ # # ]
1007 : : {
1008 [ # # ]: 0 : sal_uInt32 nPlusAnz=mpPathObj->GetPlusHdlCount(*pSmartHdl);
1009 [ # # ]: 0 : for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
1010 : : {
1011 [ # # ]: 0 : SdrHdl* pPlusHdl = mpPathObj->GetPlusHdl(*pSmartHdl,nPlusNum);
1012 [ # # ]: 0 : if (pPlusHdl!=NULL)
1013 : : {
1014 [ # # ]: 0 : pPlusHdl->SetObj(mpPathObj);
1015 : 0 : pPlusHdl->SetPageView(mrView.GetSdrPageView());
1016 : 0 : pPlusHdl->SetPlusHdl(sal_True);
1017 [ # # ]: 0 : rHandlerList.AddHdl(pPlusHdl);
1018 : : }
1019 : : }
1020 : : }
1021 [ # # ]: 0 : }
1022 : : }
1023 : : else
1024 : : {
1025 [ # # ]: 0 : Rectangle aRect(mpPathObj->GetCurrentBoundRect());
1026 : :
1027 [ # # ][ # # ]: 0 : if(!aRect.IsEmpty())
1028 : : {
1029 : 0 : sal_uLong nCount = rHandlerList.GetHdlCount();
1030 : :
1031 : 0 : sal_Bool bWdt0=aRect.Left()==aRect.Right();
1032 : 0 : sal_Bool bHgt0=aRect.Top()==aRect.Bottom();
1033 [ # # ][ # # ]: 0 : if (bWdt0 && bHgt0)
1034 : : {
1035 [ # # ][ # # ]: 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft(),HDL_UPLFT));
[ # # ]
1036 : : }
1037 [ # # ][ # # ]: 0 : else if (bWdt0 || bHgt0)
1038 : : {
1039 [ # # ][ # # ]: 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
[ # # ]
1040 [ # # ][ # # ]: 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight(),HDL_LWRGT));
[ # # ][ # # ]
1041 : : }
1042 : : else
1043 : : {
1044 [ # # ][ # # ]: 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
[ # # ][ # # ]
[ # # ]
1045 [ # # ][ # # ]: 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopCenter() ,HDL_UPPER));
[ # # ][ # # ]
[ # # ]
1046 [ # # ][ # # ]: 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopRight() ,HDL_UPRGT));
[ # # ][ # # ]
[ # # ][ # # ]
1047 [ # # ][ # # ]: 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.LeftCenter() ,HDL_LEFT ));
[ # # ][ # # ]
[ # # ]
1048 [ # # ][ # # ]: 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.RightCenter() ,HDL_RIGHT));
[ # # ][ # # ]
[ # # ]
1049 [ # # ][ # # ]: 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomLeft() ,HDL_LWLFT));
[ # # ][ # # ]
[ # # ][ # # ]
1050 [ # # ][ # # ]: 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomCenter(),HDL_LOWER));
[ # # ][ # # ]
[ # # ]
1051 [ # # ][ # # ]: 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight() ,HDL_LWRGT));
[ # # ][ # # ]
[ # # ][ # # ]
1052 : : }
1053 : :
1054 [ # # ]: 0 : while( nCount < rHandlerList.GetHdlCount() )
1055 : : {
1056 [ # # ]: 0 : rHandlerList.GetHdl(nCount++)->SetPageView( mrView.GetSdrPageView() );
1057 : : }
1058 : : }
1059 : : }
1060 [ # # ]: 0 : }
1061 : : }
1062 : 0 : }
1063 : :
1064 : : // --------------------------------------------------------------------
1065 : :
1066 : 0 : void MotionPathTag::disposing()
1067 : : {
1068 [ # # ]: 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
1069 [ # # ]: 0 : if( xNotifier.is() )
1070 : : {
1071 [ # # ]: 0 : Reference< XChangesListener > xListener( this );
1072 [ # # ][ # # ]: 0 : xNotifier->removeChangesListener( this );
[ # # ]
1073 : : }
1074 : :
1075 [ # # ]: 0 : if( mpPathObj )
1076 : : {
1077 : 0 : SdrPathObj* pPathObj = mpPathObj;
1078 : 0 : mpPathObj = 0;
1079 [ # # ]: 0 : mrView.updateHandles();
1080 [ # # ][ # # ]: 0 : delete pPathObj;
1081 : : }
1082 : :
1083 [ # # ]: 0 : if( mpMark )
1084 : : {
1085 [ # # ][ # # ]: 0 : delete mpMark;
1086 : 0 : mpMark = 0;
1087 : : }
1088 : :
1089 [ # # ]: 0 : SmartTag::disposing();
1090 : 0 : }
1091 : :
1092 : : // --------------------------------------------------------------------
1093 : :
1094 : 0 : void MotionPathTag::deselect()
1095 : : {
1096 : 0 : SmartTag::deselect();
1097 : :
1098 [ # # ]: 0 : if( mpMark )
1099 : : {
1100 : 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1101 : :
1102 [ # # ]: 0 : if( pPts )
1103 : 0 : pPts->clear();
1104 : : }
1105 : :
1106 : 0 : selectionChanged();
1107 : 0 : }
1108 : :
1109 : 0 : void MotionPathTag::selectionChanged()
1110 : : {
1111 [ # # ][ # # ]: 0 : if( mrView.GetViewShell() && mrView.GetViewShell()->GetViewFrame() )
[ # # ]
1112 : : {
1113 : 0 : SfxBindings& rBindings = mrView.GetViewShell()->GetViewFrame()->GetBindings();
1114 : 0 : rBindings.InvalidateAll(sal_True);
1115 : : }
1116 : 0 : }
1117 : : // --------------------------------------------------------------------
1118 : : // IPolyPolygonEditorController
1119 : : // --------------------------------------------------------------------
1120 : :
1121 : 0 : void MotionPathTag::DeleteMarkedPoints()
1122 : : {
1123 [ # # ][ # # ]: 0 : if( mpPathObj && IsDeleteMarkedPointsPossible() )
[ # # ]
1124 : : {
1125 : 0 : mrView.BrkAction();
1126 : :
1127 : 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1128 : :
1129 [ # # ]: 0 : if( pPts )
1130 : : {
1131 [ # # ]: 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1132 [ # # ][ # # ]: 0 : if( aEditor.DeletePoints( *pPts ) )
1133 : : {
1134 [ # # ][ # # ]: 0 : if( aEditor.GetPolyPolygon().count() )
1135 : : {
1136 [ # # ]: 0 : mpPathObj->SetPathPoly( aEditor.GetPolyPolygon() );
1137 : : }
1138 : :
1139 [ # # ]: 0 : mrView.UnmarkAllPoints();
1140 [ # # ]: 0 : mrView.MarkListHasChanged();
1141 [ # # ]: 0 : mrView.updateHandles();
1142 [ # # ]: 0 : }
1143 : : }
1144 : : }
1145 : 0 : }
1146 : :
1147 : 0 : sal_Bool MotionPathTag::IsDeleteMarkedPointsPossible() const
1148 : : {
1149 [ # # ][ # # ]: 0 : return mpPathObj && isSelected() && (GetMarkedPointCount() != 0);
[ # # ]
1150 : : }
1151 : :
1152 : 0 : void MotionPathTag::RipUpAtMarkedPoints()
1153 : : {
1154 : : // not supported for motion path
1155 : 0 : }
1156 : :
1157 : 0 : bool MotionPathTag::IsRipUpAtMarkedPointsPossible() const
1158 : : {
1159 : : // not supported for motion path
1160 : 0 : return false;
1161 : : }
1162 : :
1163 : 0 : sal_Bool MotionPathTag::IsSetMarkedSegmentsKindPossible() const
1164 : : {
1165 [ # # ]: 0 : if( mpPathObj )
1166 : 0 : return mrView.IsSetMarkedSegmentsKindPossible();
1167 : : else
1168 : 0 : return sal_False;
1169 : : }
1170 : :
1171 : 0 : SdrPathSegmentKind MotionPathTag::GetMarkedSegmentsKind() const
1172 : : {
1173 [ # # ]: 0 : if( mpPathObj )
1174 : 0 : return mrView.GetMarkedSegmentsKind();
1175 : : else
1176 : 0 : return SDRPATHSEGMENT_LINE;
1177 : : }
1178 : :
1179 : 0 : void MotionPathTag::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
1180 : : {
1181 [ # # ][ # # ]: 0 : if(mpPathObj && isSelected() && (GetMarkedPointCount() != 0))
[ # # ][ # # ]
1182 : : {
1183 : 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1184 [ # # ]: 0 : if(pPts)
1185 : : {
1186 [ # # ]: 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1187 [ # # ][ # # ]: 0 : if(aEditor.SetSegmentsKind( eKind, *pPts ) )
1188 : : {
1189 [ # # ]: 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1190 [ # # ]: 0 : mrView.MarkListHasChanged();
1191 [ # # ]: 0 : mrView.updateHandles();
1192 [ # # ]: 0 : }
1193 : : }
1194 : : }
1195 : 0 : }
1196 : :
1197 : 0 : sal_Bool MotionPathTag::IsSetMarkedPointsSmoothPossible() const
1198 : : {
1199 [ # # ]: 0 : if( mpPathObj )
1200 : 0 : return mrView.IsSetMarkedPointsSmoothPossible();
1201 : : else
1202 : 0 : return sal_False;
1203 : : }
1204 : :
1205 : 0 : SdrPathSmoothKind MotionPathTag::GetMarkedPointsSmooth() const
1206 : : {
1207 [ # # ]: 0 : if( mpPathObj )
1208 : 0 : return mrView.GetMarkedPointsSmooth();
1209 : : else
1210 : 0 : return SDRPATHSMOOTH_ANGULAR;
1211 : : }
1212 : :
1213 : 0 : void MotionPathTag::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
1214 : : {
1215 : : basegfx::B2VectorContinuity eFlags;
1216 : :
1217 [ # # ]: 0 : if(SDRPATHSMOOTH_ANGULAR == eKind)
1218 : : {
1219 : 0 : eFlags = basegfx::CONTINUITY_NONE;
1220 : : }
1221 [ # # ]: 0 : else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
1222 : : {
1223 : 0 : eFlags = basegfx::CONTINUITY_C1;
1224 : : }
1225 [ # # ]: 0 : else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
1226 : : {
1227 : 0 : eFlags = basegfx::CONTINUITY_C2;
1228 : : }
1229 : : else
1230 : : {
1231 : 0 : return;
1232 : : }
1233 : :
1234 [ # # ][ # # ]: 0 : if(mpPathObj && mpMark && isSelected() && (GetMarkedPointCount() != 0))
[ # # ][ # # ]
[ # # ]
1235 : : {
1236 : 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1237 [ # # ]: 0 : if(pPts)
1238 : : {
1239 [ # # ]: 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1240 [ # # ][ # # ]: 0 : if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
1241 : : {
1242 [ # # ]: 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1243 [ # # ]: 0 : mrView.MarkListHasChanged();
1244 [ # # ]: 0 : mrView.updateHandles();
1245 [ # # ]: 0 : }
1246 : : }
1247 : : }
1248 : : }
1249 : :
1250 : 0 : void MotionPathTag::CloseMarkedObjects(sal_Bool /*bToggle*/, sal_Bool /*bOpen*/ )
1251 : : {
1252 : : // not supported for motion path
1253 : 0 : }
1254 : :
1255 : 0 : bool MotionPathTag::IsOpenCloseMarkedObjectsPossible() const
1256 : : {
1257 : : // not supported for motion path
1258 : 0 : return false;
1259 : : }
1260 : :
1261 : 0 : SdrObjClosedKind MotionPathTag::GetMarkedObjectsClosedState() const
1262 : : {
1263 : : // not supported for motion path
1264 : 0 : return SDROBJCLOSED_OPEN;
1265 : : }
1266 : :
1267 : : // XChangesListener
1268 : 0 : void SAL_CALL MotionPathTag::changesOccurred( const ChangesEvent& /*Event*/ ) throw (RuntimeException)
1269 : : {
1270 [ # # ][ # # ]: 0 : if( mpPathObj && !mbInUpdatePath && (mpEffect->getPath() != msLastPath) )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1271 : : {
1272 : 0 : mbInUpdatePath =true;
1273 : 0 : msLastPath = mpEffect->getPath();
1274 : 0 : mpEffect->updateSdrPathObjFromPath( *mpPathObj );
1275 : 0 : mbInUpdatePath = false;
1276 : 0 : updatePathAttributes();
1277 : 0 : mrView.updateHandles();
1278 : : }
1279 : 0 : }
1280 : :
1281 : 0 : void SAL_CALL MotionPathTag::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
1282 : : {
1283 [ # # ]: 0 : if( mpPathObj )
1284 : 0 : Dispose();
1285 : 0 : }
1286 : :
1287 : 0 : Any SAL_CALL MotionPathTag::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException)
1288 : : {
1289 [ # # ]: 0 : if( aType == XChangesListener::static_type() )
1290 [ # # ]: 0 : return Any( Reference< XChangesListener >( this ) );
1291 [ # # ]: 0 : if( aType == XEventListener::static_type() )
1292 [ # # ]: 0 : return Any( Reference< XEventListener >( this ) );
1293 [ # # ]: 0 : if( aType == XInterface::static_type() )
1294 [ # # ]: 0 : return Any( Reference< XInterface >( this ) );
1295 : :
1296 : 0 : return Any();
1297 : : }
1298 : :
1299 : 0 : void SAL_CALL MotionPathTag::acquire() throw ()
1300 : : {
1301 : 0 : SimpleReferenceComponent::acquire();
1302 : 0 : }
1303 : :
1304 : 0 : void SAL_CALL MotionPathTag::release( ) throw ()
1305 : : {
1306 : 0 : SimpleReferenceComponent::release();
1307 : 0 : }
1308 : :
1309 : : } // end of namespace sd
1310 : :
1311 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|