1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/svdcrtv.hxx>
22 #include "svx/xattr.hxx"
23 #include <svx/svdundo.hxx>
24 #include <svx/svdocapt.hxx> // special case: transparent filling after Create
25 #include <svx/svdoedge.hxx>
26 #include <svx/svdpagv.hxx>
27 #include <svx/svdpage.hxx>
28 #include <svx/svdetc.hxx>
29 #include <svx/scene3d.hxx>
30 #include <svx/view3d.hxx>
31 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
32 #include <svx/sdr/contact/displayinfo.hxx>
33 #include <svx/svdouno.hxx>
34 #include <svx/svdopath.hxx>
35 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
36 #include <svx/sdr/overlay/overlaymanager.hxx>
37 #include <svx/sdrpaintwindow.hxx>
39 #include <svx/svdocirc.hxx>
40 #include <svx/sdr/contact/viewcontact.hxx>
41 #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
42 #include <basegfx/matrix/b2dhommatrixtools.hxx>
44 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 class ImplConnectMarkerOverlay
49 ::sdr::overlay::OverlayObjectList maObjects
;
51 // The remembered target object
52 const SdrObject
& mrObject
;
55 ImplConnectMarkerOverlay(const SdrCreateView
& rView
, SdrObject
& rObject
);
56 ~ImplConnectMarkerOverlay();
58 const SdrObject
& GetTargetObject() const { return mrObject
; }
61 ImplConnectMarkerOverlay::ImplConnectMarkerOverlay(const SdrCreateView
& rView
, SdrObject
& rObject
)
64 basegfx::B2DPolyPolygon
aB2DPolyPolygon(rObject
.TakeXorPoly());
66 for(sal_uInt32
a(0L); a
< rView
.PaintWindowCount(); a
++)
68 SdrPaintWindow
* pCandidate
= rView
.GetPaintWindow(a
);
69 rtl::Reference
< ::sdr::overlay::OverlayManager
> xTargetOverlay
= pCandidate
->GetOverlayManager();
71 if(xTargetOverlay
.is())
73 Size
aHalfLogicSize(xTargetOverlay
->getOutputDevice().PixelToLogic(Size(4, 4)));
76 ::sdr::overlay::OverlayPolyPolygonStriped
* pNew
= new ::sdr::overlay::OverlayPolyPolygonStriped(aB2DPolyPolygon
);
77 xTargetOverlay
->add(*pNew
);
78 maObjects
.append(*pNew
);
81 if(rView
.IsAutoVertexConnectors())
83 for(sal_uInt16
i(0); i
< 4; i
++)
85 SdrGluePoint
aGluePoint(rObject
.GetVertexGluePoint(i
));
86 const Point
& rPosition
= aGluePoint
.GetAbsolutePos(rObject
);
88 basegfx::B2DPoint
aTopLeft(rPosition
.X() - aHalfLogicSize
.Width(), rPosition
.Y() - aHalfLogicSize
.Height());
89 basegfx::B2DPoint
aBottomRight(rPosition
.X() + aHalfLogicSize
.Width(), rPosition
.Y() + aHalfLogicSize
.Height());
91 basegfx::B2DPolygon aTempPoly
;
92 aTempPoly
.append(aTopLeft
);
93 aTempPoly
.append(basegfx::B2DPoint(aBottomRight
.getX(), aTopLeft
.getY()));
94 aTempPoly
.append(aBottomRight
);
95 aTempPoly
.append(basegfx::B2DPoint(aTopLeft
.getX(), aBottomRight
.getY()));
96 aTempPoly
.setClosed(true);
98 basegfx::B2DPolyPolygon aTempPolyPoly
;
99 aTempPolyPoly
.append(aTempPoly
);
101 pNew
= new ::sdr::overlay::OverlayPolyPolygonStriped(aTempPolyPoly
);
102 xTargetOverlay
->add(*pNew
);
103 maObjects
.append(*pNew
);
110 ImplConnectMarkerOverlay::~ImplConnectMarkerOverlay()
112 // The OverlayObjects are cleared using the destructor of OverlayObjectList.
113 // That destructor calls clear() at the list which removes all objects from the
114 // OverlayManager and deletes them.
117 ////////////////////////////////////////////////////////////////////////////////////////////////////
119 class ImpSdrCreateViewExtraData
121 // The OverlayObjects for XOR replacement
122 ::sdr::overlay::OverlayObjectList maObjects
;
125 ImpSdrCreateViewExtraData();
126 ~ImpSdrCreateViewExtraData();
128 void CreateAndShowOverlay(const SdrCreateView
& rView
, const SdrObject
* pObject
, const basegfx::B2DPolyPolygon
& rPolyPoly
);
132 ImpSdrCreateViewExtraData::ImpSdrCreateViewExtraData()
136 ImpSdrCreateViewExtraData::~ImpSdrCreateViewExtraData()
141 void ImpSdrCreateViewExtraData::CreateAndShowOverlay(const SdrCreateView
& rView
, const SdrObject
* pObject
, const basegfx::B2DPolyPolygon
& rPolyPoly
)
143 for(sal_uInt32
a(0L); a
< rView
.PaintWindowCount(); a
++)
145 SdrPaintWindow
* pCandidate
= rView
.GetPaintWindow(a
);
146 rtl::Reference
<sdr::overlay::OverlayManager
> xOverlayManager
= pCandidate
->GetOverlayManager();
148 if (xOverlayManager
.is())
152 const sdr::contact::ViewContact
& rVC
= pObject
->GetViewContact();
153 const drawinglayer::primitive2d::Primitive2DSequence aSequence
= rVC
.getViewIndependentPrimitive2DSequence();
154 sdr::overlay::OverlayObject
* pNew
= new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence
);
156 xOverlayManager
->add(*pNew
);
157 maObjects
.append(*pNew
);
160 if(rPolyPoly
.count())
162 ::sdr::overlay::OverlayPolyPolygonStriped
* pNew
= new ::sdr::overlay::OverlayPolyPolygonStriped(rPolyPoly
);
163 xOverlayManager
->add(*pNew
);
164 maObjects
.append(*pNew
);
170 void ImpSdrCreateViewExtraData::HideOverlay()
172 // the clear() call of the list removes all objects from the
173 // OverlayManager and deletes them.
177 ////////////////////////////////////////////////////////////////////////////////////////////////////
178 ////////////////////////////////////////////////////////////////////////////////////////////////////
180 ////////////////////////////////////////////////////////////////////////////////////////////////////
181 ////////////////////////////////////////////////////////////////////////////////////////////////////
183 void SdrCreateView::ImpClearConnectMarker()
187 delete mpCoMaOverlay
;
192 void SdrCreateView::ImpClearVars()
194 nAktInvent
=SdrInventor
;
198 bAutoTextEdit
=sal_False
;
199 b1stPointAsCenter
=sal_False
;
200 aAktCreatePointer
=Pointer(POINTER_CROSS
);
201 bUseIncompatiblePathCreateInterface
=sal_False
;
202 bAutoClosePolys
=sal_True
;
204 nFreeHandMinDistPix
=10;
206 ImpClearConnectMarker();
209 SdrCreateView::SdrCreateView(SdrModel
* pModel1
, OutputDevice
* pOut
)
210 : SdrDragView(pModel1
,pOut
),
212 mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
217 SdrCreateView::~SdrCreateView()
219 ImpClearConnectMarker();
220 delete mpCreateViewExtraData
;
221 SdrObject::Free( pAktCreate
);
224 sal_Bool
SdrCreateView::IsAction() const
226 return SdrDragView::IsAction() || pAktCreate
!=NULL
;
229 void SdrCreateView::MovAction(const Point
& rPnt
)
231 SdrDragView::MovAction(rPnt
);
232 if (pAktCreate
!=NULL
) {
237 void SdrCreateView::EndAction()
239 if (pAktCreate
!=NULL
) EndCreateObj(SDRCREATE_FORCEEND
);
240 SdrDragView::EndAction();
243 void SdrCreateView::BckAction()
245 if (pAktCreate
!=NULL
) BckCreateObj();
246 SdrDragView::BckAction();
249 void SdrCreateView::BrkAction()
251 SdrDragView::BrkAction();
255 void SdrCreateView::TakeActionRect(Rectangle
& rRect
) const
257 if (pAktCreate
!=NULL
)
259 rRect
=aDragStat
.GetActionRect();
262 rRect
=Rectangle(aDragStat
.GetPrev(),aDragStat
.GetNow());
267 SdrDragView::TakeActionRect(rRect
);
271 sal_Bool
SdrCreateView::CheckEdgeMode()
273 if (pAktCreate
!=NULL
)
275 // is managed by EdgeObj
276 if (nAktInvent
==SdrInventor
&& nAktIdent
==OBJ_EDGE
) return sal_False
;
279 if (!IsCreateMode() || nAktInvent
!=SdrInventor
|| nAktIdent
!=OBJ_EDGE
)
281 ImpClearConnectMarker();
286 // sal_True, if MouseMove should check Connect
291 void SdrCreateView::SetConnectMarker(const SdrObjConnection
& rCon
, const SdrPageView
& /*rPV*/)
293 SdrObject
* pTargetObject
= rCon
.pObj
;
297 // if target object changes, throw away overlay object to make room for changes
298 if(mpCoMaOverlay
&& pTargetObject
!= &mpCoMaOverlay
->GetTargetObject())
300 ImpClearConnectMarker();
305 mpCoMaOverlay
= new ImplConnectMarkerOverlay(*this, *pTargetObject
);
310 ImpClearConnectMarker();
314 void SdrCreateView::HideConnectMarker()
316 ImpClearConnectMarker();
319 sal_Bool
SdrCreateView::MouseMove(const MouseEvent
& rMEvt
, Window
* pWin
)
321 if(CheckEdgeMode() && pWin
)
323 SdrPageView
* pPV
= GetSdrPageView();
327 // TODO: Change default hit tolerance at IsMarkedHit() some time!
328 Point
aPos(pWin
->PixelToLogic(rMEvt
.GetPosPixel()));
329 bool bMarkHit
=PickHandle(aPos
)!=NULL
|| IsMarkedObjHit(aPos
);
330 SdrObjConnection aCon
;
331 if (!bMarkHit
) SdrEdgeObj::ImpFindConnector(aPos
,*pPV
,aCon
,NULL
,pWin
);
332 SetConnectMarker(aCon
,*pPV
);
335 return SdrDragView::MouseMove(rMEvt
,pWin
);
338 bool SdrCreateView::IsTextTool() const
340 return eEditMode
==SDREDITMODE_CREATE
&& nAktInvent
==SdrInventor
&& (nAktIdent
==OBJ_TEXT
|| nAktIdent
==OBJ_TEXTEXT
|| nAktIdent
==OBJ_TITLETEXT
|| nAktIdent
==OBJ_OUTLINETEXT
);
343 bool SdrCreateView::IsEdgeTool() const
345 return eEditMode
==SDREDITMODE_CREATE
&& nAktInvent
==SdrInventor
&& (nAktIdent
==OBJ_EDGE
);
348 bool SdrCreateView::IsMeasureTool() const
350 return eEditMode
==SDREDITMODE_CREATE
&& nAktInvent
==SdrInventor
&& (nAktIdent
==OBJ_MEASURE
);
353 void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent
, sal_uInt32 nInvent
)
355 if (nAktInvent
!=nInvent
|| nAktIdent
!=nIdent
)
359 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(nInvent
,nIdent
,NULL
,NULL
);
363 // Using text tool, mouse cursor is usually I-Beam,
364 // crosshairs with tiny I-Beam appears only on MouseButtonDown.
367 // Here the correct pointer needs to be used
368 // if the default is set to vertical writing
369 aAktCreatePointer
= POINTER_TEXT
;
372 aAktCreatePointer
= pObj
->GetCreatePointer();
374 SdrObject::Free( pObj
);
378 aAktCreatePointer
= Pointer(POINTER_CROSS
);
383 ImpSetGlueVisible3(IsEdgeTool());
386 sal_Bool
SdrCreateView::ImpBegCreateObj(sal_uInt32 nInvent
, sal_uInt16 nIdent
, const Point
& rPnt
, OutputDevice
* pOut
,
387 short nMinMov
, SdrPageView
* pPV
, const Rectangle
& rLogRect
, SdrObject
* pPreparedFactoryObject
)
389 sal_Bool bRet
=sal_False
;
393 ImpClearConnectMarker();
401 pCreatePV
= GetSdrPageView();
404 { // otherwise no side registered!
405 String
aLay(aAktLayer
);
407 if(nInvent
== SdrInventor
&& nIdent
== OBJ_MEASURE
&& aMeasureLayer
.Len())
409 aLay
= aMeasureLayer
;
412 SdrLayerID nLayer
=pCreatePV
->GetPage()->GetLayerAdmin().GetLayerID(aLay
,sal_True
);
413 if (nLayer
==SDRLAYER_NOTFOUND
) nLayer
=0;
414 if (!pCreatePV
->GetLockedLayers().IsSet(nLayer
) && pCreatePV
->GetVisibleLayers().IsSet(nLayer
))
416 if(pPreparedFactoryObject
)
418 pAktCreate
= pPreparedFactoryObject
;
420 if(pCreatePV
->GetPage())
422 pAktCreate
->SetPage(pCreatePV
->GetPage());
426 pAktCreate
->SetModel(pMod
);
431 pAktCreate
= SdrObjFactory::MakeNewObject(nInvent
, nIdent
, pCreatePV
->GetPage(), pMod
);
435 if (nAktInvent
!=SdrInventor
|| (nAktIdent
!=sal_uInt16(OBJ_EDGE
) &&
436 nAktIdent
!=sal_uInt16(OBJ_FREELINE
) &&
437 nAktIdent
!=sal_uInt16(OBJ_FREEFILL
) )) { // no snapping for Edge and Freehand
438 aPnt
=GetSnapPos(aPnt
,pCreatePV
);
440 if (pAktCreate
!=NULL
)
442 if (pDefaultStyleSheet
!=NULL
) pAktCreate
->NbcSetStyleSheet(pDefaultStyleSheet
, sal_False
);
444 // SW uses a naked SdrObject for frame construction. Normally, such an
445 // object should not be created. Since it is possible to use it as a helper
446 // object (e.g. in letting the user define an area with the interactive
447 // construction) at least no items should be set at that object.
448 if(nInvent
!= SdrInventor
|| nIdent
!= OBJ_NONE
)
450 pAktCreate
->SetMergedItemSet(aDefaultAttr
);
453 if (HAS_BASE(SdrCaptionObj
,pAktCreate
))
455 SfxItemSet
aSet(pMod
->GetItemPool());
456 aSet
.Put(XFillColorItem(String(),Color(COL_WHITE
))); // in case someone turns on Solid
457 aSet
.Put(XFillStyleItem(XFILL_NONE
));
459 pAktCreate
->SetMergedItemSet(aSet
);
461 if (nInvent
==SdrInventor
&& (nIdent
==OBJ_TEXT
|| nIdent
==OBJ_TEXTEXT
||
462 nIdent
==OBJ_TITLETEXT
|| nIdent
==OBJ_OUTLINETEXT
))
464 // default for all text frames: no background, no border
465 SfxItemSet
aSet(pMod
->GetItemPool());
466 aSet
.Put(XFillColorItem(String(),Color(COL_WHITE
))); // in case someone turns on Solid
467 aSet
.Put(XFillStyleItem(XFILL_NONE
));
468 aSet
.Put(XLineColorItem(String(),Color(COL_BLACK
))); // in case someone turns on Solid
469 aSet
.Put(XLineStyleItem(XLINE_NONE
));
471 pAktCreate
->SetMergedItemSet(aSet
);
473 if (!rLogRect
.IsEmpty()) pAktCreate
->NbcSetLogicRect(rLogRect
);
475 // make sure drag start point is inside WorkArea
476 const Rectangle
& rWorkArea
= ((SdrDragView
*)this)->GetWorkArea();
478 if(!rWorkArea
.IsEmpty())
480 if(aPnt
.X() < rWorkArea
.Left())
482 aPnt
.X() = rWorkArea
.Left();
485 if(aPnt
.X() > rWorkArea
.Right())
487 aPnt
.X() = rWorkArea
.Right();
490 if(aPnt
.Y() < rWorkArea
.Top())
492 aPnt
.Y() = rWorkArea
.Top();
495 if(aPnt
.Y() > rWorkArea
.Bottom())
497 aPnt
.Y() = rWorkArea
.Bottom();
501 aDragStat
.Reset(aPnt
);
502 aDragStat
.SetView((SdrView
*)this);
503 aDragStat
.SetPageView(pCreatePV
);
504 aDragStat
.SetMinMove(ImpGetMinMovLogic(nMinMov
,pOut
));
506 if (pAktCreate
->BegCreate(aDragStat
))
508 ShowCreateObj(/*pOut,sal_True*/);
513 SdrObject::Free( pAktCreate
);
523 sal_Bool
SdrCreateView::BegCreateObj(const Point
& rPnt
, OutputDevice
* pOut
, short nMinMov
, SdrPageView
* pPV
)
525 return ImpBegCreateObj(nAktInvent
,nAktIdent
,rPnt
,pOut
,nMinMov
,pPV
,Rectangle(), 0L);
528 sal_Bool
SdrCreateView::BegCreatePreparedObject(const Point
& rPnt
, sal_Int16 nMinMov
, SdrObject
* pPreparedFactoryObject
)
530 sal_uInt32
nInvent(nAktInvent
);
531 sal_uInt16
nIdent(nAktIdent
);
533 if(pPreparedFactoryObject
)
535 nInvent
= pPreparedFactoryObject
->GetObjInventor();
536 nIdent
= pPreparedFactoryObject
->GetObjIdentifier();
539 return ImpBegCreateObj(nInvent
, nIdent
, rPnt
, 0L, nMinMov
, 0L, Rectangle(), pPreparedFactoryObject
);
542 sal_Bool
SdrCreateView::BegCreateCaptionObj(const Point
& rPnt
, const Size
& rObjSiz
,
543 OutputDevice
* pOut
, short nMinMov
, SdrPageView
* pPV
)
545 return ImpBegCreateObj(SdrInventor
,OBJ_CAPTION
,rPnt
,pOut
,nMinMov
,pPV
,
546 Rectangle(rPnt
,Size(rObjSiz
.Width()+1,rObjSiz
.Height()+1)), 0L);
549 void SdrCreateView::MovCreateObj(const Point
& rPnt
)
551 if (pAktCreate
!=NULL
) {
553 if (!aDragStat
.IsNoSnap())
555 aPnt
=GetSnapPos(aPnt
,pCreatePV
);
559 if (aDragStat
.IsOrtho8Possible()) OrthoDistance8(aDragStat
.GetPrev(),aPnt
,IsBigOrtho());
560 else if (aDragStat
.IsOrtho4Possible()) OrthoDistance4(aDragStat
.GetPrev(),aPnt
,IsBigOrtho());
563 // If the drag point was limited and Ortho is active, do
564 // the small ortho correction (reduction) -> last parameter to FALSE.
565 sal_Bool
bDidLimit(ImpLimitToWorkArea(aPnt
));
566 if(bDidLimit
&& IsOrtho())
568 if(aDragStat
.IsOrtho8Possible())
569 OrthoDistance8(aDragStat
.GetPrev(), aPnt
, sal_False
);
570 else if(aDragStat
.IsOrtho4Possible())
571 OrthoDistance4(aDragStat
.GetPrev(), aPnt
, sal_False
);
574 if (aPnt
==aDragStat
.GetNow()) return;
575 bool bMerk(aDragStat
.IsMinMoved());
576 if (aDragStat
.CheckMinMoved(aPnt
))
578 if (!bMerk
) aDragStat
.NextPoint();
579 aDragStat
.NextMove(aPnt
);
580 pAktCreate
->MovCreate(aDragStat
);
582 // MovCreate changes the object, so use ActionChanged() on it
583 pAktCreate
->ActionChanged();
585 // replace for DrawCreateObjDiff
592 sal_Bool
SdrCreateView::EndCreateObj(SdrCreateCmd eCmd
)
594 sal_Bool bRet
=sal_False
;
595 SdrObject
* pObjMerk
=pAktCreate
;
596 SdrPageView
* pPVMerk
=pCreatePV
;
598 if (pAktCreate
!=NULL
)
600 sal_uIntPtr nAnz
=aDragStat
.GetPointAnz();
602 if (nAnz
<=1 && eCmd
==SDRCREATE_FORCEEND
)
604 BrkCreateObj(); // objects with only a single point don't exist (at least today)
605 return sal_False
; // sal_False = event not interpreted
610 Point aP0
=aDragStat
.GetPoint(0);
611 while (bPntsEq
&& i
<nAnz
) { bPntsEq
=aP0
==aDragStat
.GetPoint(i
); i
++; }
613 if (pAktCreate
->EndCreate(aDragStat
,eCmd
))
619 // otherwise Brk, because all points are equal
620 SdrObject
* pObj
=pAktCreate
;
623 const SdrLayerAdmin
& rAd
= pCreatePV
->GetPage()->GetLayerAdmin();
624 SdrLayerID
nLayer(0);
627 if(pObj
->ISA(FmFormObj
))
629 // for FormControls, force to form layer
630 nLayer
= rAd
.GetLayerID(rAd
.GetControlLayerName(), true);
634 nLayer
= rAd
.GetLayerID(aAktLayer
, sal_True
);
637 if(SDRLAYER_NOTFOUND
== nLayer
)
642 pObj
->SetLayer(nLayer
);
644 // recognize creation of a new 3D object inside a 3D scene
645 bool bSceneIntoScene(false);
648 && pObjMerk
->ISA(E3dScene
)
650 && pCreatePV
->GetAktGroup()
651 && pCreatePV
->GetAktGroup()->ISA(E3dScene
))
653 bool bDidInsert
= ((E3dView
*)this)->ImpCloneAll3DObjectsToDestScene(
654 (E3dScene
*)pObjMerk
, (E3dScene
*)pCreatePV
->GetAktGroup(), Point(0, 0));
658 // delete object, its content is cloned and inserted
659 SdrObject::Free( pObjMerk
);
662 bSceneIntoScene
= true;
668 // do the same as before
669 InsertObjectAtView(pObj
, *pCreatePV
);
673 bRet
=sal_True
; // sal_True = event interpreted
682 if (eCmd
==SDRCREATE_FORCEEND
|| // nothing there -- force ending
683 nAnz
==0 || // no existing points (should never happen)
684 (nAnz
<=1 && !aDragStat
.IsMinMoved())) { // MinMove not met
689 // replace for DrawCreateObjDiff
692 aDragStat
.ResetMinMoved(); // NextPoint is at MovCreateObj()
696 if (bRet
&& pObjMerk
!=NULL
&& IsTextEditAfterCreate())
698 SdrTextObj
* pText
=PTR_CAST(SdrTextObj
,pObjMerk
);
699 if (pText
!=NULL
&& pText
->IsTextFrame())
701 SdrBeginTextEdit(pText
, pPVMerk
, (Window
*)0L, sal_True
, (SdrOutliner
*)0L, (OutlinerView
*)0L);
708 void SdrCreateView::BckCreateObj()
710 if (pAktCreate
!=NULL
)
712 if (aDragStat
.GetPointAnz()<=2 )
719 aDragStat
.PrevPoint();
720 if (pAktCreate
->BckCreate(aDragStat
))
732 void SdrCreateView::BrkCreateObj()
734 if (pAktCreate
!=NULL
)
737 pAktCreate
->BrkCreate(aDragStat
);
738 SdrObject::Free( pAktCreate
);
744 void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
746 if(IsCreateObj() && !aDragStat
.IsShown())
750 // for migration from XOR, replace DrawDragObj here to create
751 // overlay objects instead.
752 sal_Bool
bUseSolidDragging(IsSolidDragging());
754 // #i101648# check if dragged object is a naked SdrObject (not
755 // a derivation). This is e.g. used in SW Frame construction
756 // as placeholder. Do not use SolidDragging for naked SDrObjects,
757 // they cannot have a valid optical representation
758 if(bUseSolidDragging
&& OBJ_NONE
== pAktCreate
->GetObjIdentifier())
760 bUseSolidDragging
= false;
763 // check for objects with no fill and no line
764 if(bUseSolidDragging
)
766 const SfxItemSet
& rSet
= pAktCreate
->GetMergedItemSet();
767 const XFillStyle
eFill(((XFillStyleItem
&)(rSet
.Get(XATTR_FILLSTYLE
))).GetValue());
768 const XLineStyle
eLine(((XLineStyleItem
&)(rSet
.Get(XATTR_LINESTYLE
))).GetValue());
770 if(XLINE_NONE
== eLine
&& XFILL_NONE
== eFill
)
772 bUseSolidDragging
= sal_False
;
776 // check for form controls
777 if(bUseSolidDragging
)
779 if(pAktCreate
->ISA(SdrUnoObj
))
781 bUseSolidDragging
= sal_False
;
785 // #i101781# force to non-solid dragging when not creating a full circle
786 if(bUseSolidDragging
)
788 SdrCircObj
* pCircObj
= dynamic_cast< SdrCircObj
* >(pAktCreate
);
790 if(pCircObj
&& OBJ_CIRC
!= pCircObj
->GetObjIdentifier())
792 // #i103058# Allow SolidDragging with four points
793 if(aDragStat
.GetPointAnz() < 4)
795 bUseSolidDragging
= false;
800 if(bUseSolidDragging
)
802 basegfx::B2DPolyPolygon aDragPolyPolygon
;
804 if(pAktCreate
->ISA(SdrRectObj
))
806 // ensure object has some size, necessary for SdrTextObj because
807 // there are still untested divisions by that sizes
808 Rectangle
aCurrentSnapRect(pAktCreate
->GetSnapRect());
810 if(!(aCurrentSnapRect
.GetWidth() > 1 && aCurrentSnapRect
.GetHeight() > 1))
812 Rectangle
aNewRect(aDragStat
.GetStart(), aDragStat
.GetStart() + Point(2, 2));
813 pAktCreate
->NbcSetSnapRect(aNewRect
);
817 if(pAktCreate
->ISA(SdrPathObj
))
819 // The up-to-now created path needs to be set at the object to have something
820 // that can be visualized
821 SdrPathObj
& rPathObj((SdrPathObj
&)(*pAktCreate
));
822 const basegfx::B2DPolyPolygon
aCurrentPolyPolygon(rPathObj
.getObjectPolyPolygon(aDragStat
));
824 if(aCurrentPolyPolygon
.count())
826 rPathObj
.NbcSetPathPoly(aCurrentPolyPolygon
);
829 aDragPolyPolygon
= rPathObj
.getDragPolyPolygon(aDragStat
);
832 // use the SdrObject directly for overlay
833 mpCreateViewExtraData
->CreateAndShowOverlay(*this, pAktCreate
, aDragPolyPolygon
);
837 ::basegfx::B2DPolyPolygon aPoly
= pAktCreate
->TakeCreatePoly(aDragStat
);
838 Point aGridOff
= pAktCreate
->GetGridOffset();
839 // Hack for calc, transform position of create placeholder
840 // object according to current zoom so as objects relative
841 // position to grid appears stable
842 aPoly
.transform( basegfx::tools::createTranslateB2DHomMatrix( aGridOff
.X(), aGridOff
.Y() ) );
843 mpCreateViewExtraData
->CreateAndShowOverlay(*this, 0, aPoly
);
846 // #i101679# Force changed overlay to be shown
847 for(sal_uInt32
a(0); a
< PaintWindowCount(); a
++)
849 SdrPaintWindow
* pCandidate
= GetPaintWindow(a
);
850 rtl::Reference
<sdr::overlay::OverlayManager
> xOverlayManager
= pCandidate
->GetOverlayManager();
852 if (xOverlayManager
.is())
854 xOverlayManager
->flush();
859 aDragStat
.SetShown(sal_True
);
863 void SdrCreateView::HideCreateObj()
865 if(IsCreateObj() && aDragStat
.IsShown())
867 // for migration from XOR, replace DrawDragObj here to create
868 // overlay objects instead.
869 mpCreateViewExtraData
->HideOverlay();
871 //DrawCreateObj(pOut,bFull);
872 aDragStat
.SetShown(sal_False
);
876 ////////////////////////////////////////////////////////////////////////////////////////////////////
878 sal_Bool
SdrCreateView::GetAttributes(SfxItemSet
& rTargetSet
, sal_Bool bOnlyHardAttr
) const
882 rTargetSet
.Put(pAktCreate
->GetMergedItemSet());
887 return SdrDragView::GetAttributes(rTargetSet
, bOnlyHardAttr
);
891 sal_Bool
SdrCreateView::SetAttributes(const SfxItemSet
& rSet
, sal_Bool bReplaceAll
)
895 pAktCreate
->SetMergedItemSetAndBroadcast(rSet
, bReplaceAll
);
901 return SdrDragView::SetAttributes(rSet
,bReplaceAll
);
905 SfxStyleSheet
* SdrCreateView::GetStyleSheet() const
907 if (pAktCreate
!=NULL
)
909 return pAktCreate
->GetStyleSheet();
913 return SdrDragView::GetStyleSheet();
917 sal_Bool
SdrCreateView::SetStyleSheet(SfxStyleSheet
* pStyleSheet
, sal_Bool bDontRemoveHardAttr
)
919 if (pAktCreate
!=NULL
)
921 pAktCreate
->SetStyleSheet(pStyleSheet
,bDontRemoveHardAttr
);
926 return SdrDragView::SetStyleSheet(pStyleSheet
,bDontRemoveHardAttr
);
930 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */