bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / svdcrtv.cxx
blobe6980bd720064c3048fcd0f051406457df9025de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
38 #include "fmobj.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
48 // The OverlayObjects
49 ::sdr::overlay::OverlayObjectList maObjects;
51 // The remembered target object
52 const SdrObject& mrObject;
54 public:
55 ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject);
56 ~ImplConnectMarkerOverlay();
58 const SdrObject& GetTargetObject() const { return mrObject; }
61 ImplConnectMarkerOverlay::ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject)
62 : mrObject(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)));
75 // object
76 ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aB2DPolyPolygon);
77 xTargetOverlay->add(*pNew);
78 maObjects.append(*pNew);
80 // glue points
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;
124 public:
125 ImpSdrCreateViewExtraData();
126 ~ImpSdrCreateViewExtraData();
128 void CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly);
129 void HideOverlay();
132 ImpSdrCreateViewExtraData::ImpSdrCreateViewExtraData()
136 ImpSdrCreateViewExtraData::~ImpSdrCreateViewExtraData()
138 HideOverlay();
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())
150 if(pObject)
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.
174 maObjects.clear();
177 ////////////////////////////////////////////////////////////////////////////////////////////////////
178 ////////////////////////////////////////////////////////////////////////////////////////////////////
179 // CreateView
180 ////////////////////////////////////////////////////////////////////////////////////////////////////
181 ////////////////////////////////////////////////////////////////////////////////////////////////////
183 void SdrCreateView::ImpClearConnectMarker()
185 if(mpCoMaOverlay)
187 delete mpCoMaOverlay;
188 mpCoMaOverlay = 0L;
192 void SdrCreateView::ImpClearVars()
194 nAktInvent=SdrInventor;
195 nAktIdent=OBJ_NONE;
196 pAktCreate=NULL;
197 pCreatePV=NULL;
198 bAutoTextEdit=sal_False;
199 b1stPointAsCenter=sal_False;
200 aAktCreatePointer=Pointer(POINTER_CROSS);
201 bUseIncompatiblePathCreateInterface=sal_False;
202 bAutoClosePolys=sal_True;
203 nAutoCloseDistPix=5;
204 nFreeHandMinDistPix=10;
206 ImpClearConnectMarker();
209 SdrCreateView::SdrCreateView(SdrModel* pModel1, OutputDevice* pOut)
210 : SdrDragView(pModel1,pOut),
211 mpCoMaOverlay(0L),
212 mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
214 ImpClearVars();
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) {
233 MovCreateObj(rPnt);
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();
252 BrkCreateObj();
255 void SdrCreateView::TakeActionRect(Rectangle& rRect) const
257 if (pAktCreate!=NULL)
259 rRect=aDragStat.GetActionRect();
260 if (rRect.IsEmpty())
262 rRect=Rectangle(aDragStat.GetPrev(),aDragStat.GetNow());
265 else
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();
282 return sal_False;
284 else
286 // sal_True, if MouseMove should check Connect
287 return !IsAction();
291 void SdrCreateView::SetConnectMarker(const SdrObjConnection& rCon, const SdrPageView& /*rPV*/)
293 SdrObject* pTargetObject = rCon.pObj;
295 if(pTargetObject)
297 // if target object changes, throw away overlay object to make room for changes
298 if(mpCoMaOverlay && pTargetObject != &mpCoMaOverlay->GetTargetObject())
300 ImpClearConnectMarker();
303 if(!mpCoMaOverlay)
305 mpCoMaOverlay = new ImplConnectMarkerOverlay(*this, *pTargetObject);
308 else
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();
325 if(pPV)
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)
357 nAktInvent=nInvent;
358 nAktIdent=nIdent;
359 SdrObject* pObj = SdrObjFactory::MakeNewObject(nInvent,nIdent,NULL,NULL);
361 if(pObj)
363 // Using text tool, mouse cursor is usually I-Beam,
364 // crosshairs with tiny I-Beam appears only on MouseButtonDown.
365 if(IsTextTool())
367 // Here the correct pointer needs to be used
368 // if the default is set to vertical writing
369 aAktCreatePointer = POINTER_TEXT;
371 else
372 aAktCreatePointer = pObj->GetCreatePointer();
374 SdrObject::Free( pObj );
376 else
378 aAktCreatePointer = Pointer(POINTER_CROSS);
382 CheckEdgeMode();
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;
390 UnmarkAllObj();
391 BrkAction();
393 ImpClearConnectMarker();
395 if (pPV!=NULL)
397 pCreatePV=pPV;
399 else
401 pCreatePV = GetSdrPageView();
403 if (pCreatePV!=NULL)
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());
424 else if (pMod)
426 pAktCreate->SetModel(pMod);
429 else
431 pAktCreate = SdrObjFactory::MakeNewObject(nInvent, nIdent, pCreatePV->GetPage(), pMod);
434 Point aPnt(rPnt);
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));
505 pDragWin=pOut;
506 if (pAktCreate->BegCreate(aDragStat))
508 ShowCreateObj(/*pOut,sal_True*/);
509 bRet=sal_True;
511 else
513 SdrObject::Free( pAktCreate );
514 pAktCreate=NULL;
515 pCreatePV=NULL;
520 return bRet;
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) {
552 Point aPnt(rPnt);
553 if (!aDragStat.IsNoSnap())
555 aPnt=GetSnapPos(aPnt,pCreatePV);
557 if (IsOrtho())
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
586 HideCreateObj();
587 ShowCreateObj();
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
608 bool bPntsEq=nAnz>1;
609 sal_uIntPtr i=1;
610 Point aP0=aDragStat.GetPoint(0);
611 while (bPntsEq && i<nAnz) { bPntsEq=aP0==aDragStat.GetPoint(i); i++; }
613 if (pAktCreate->EndCreate(aDragStat,eCmd))
615 HideCreateObj();
617 if (!bPntsEq)
619 // otherwise Brk, because all points are equal
620 SdrObject* pObj=pAktCreate;
621 pAktCreate=NULL;
623 const SdrLayerAdmin& rAd = pCreatePV->GetPage()->GetLayerAdmin();
624 SdrLayerID nLayer(0);
626 // #i72535#
627 if(pObj->ISA(FmFormObj))
629 // for FormControls, force to form layer
630 nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
632 else
634 nLayer = rAd.GetLayerID(aAktLayer, sal_True);
637 if(SDRLAYER_NOTFOUND == nLayer)
639 nLayer=0;
642 pObj->SetLayer(nLayer);
644 // recognize creation of a new 3D object inside a 3D scene
645 bool bSceneIntoScene(false);
647 if(pObjMerk
648 && pObjMerk->ISA(E3dScene)
649 && pCreatePV
650 && pCreatePV->GetAktGroup()
651 && pCreatePV->GetAktGroup()->ISA(E3dScene))
653 bool bDidInsert = ((E3dView*)this)->ImpCloneAll3DObjectsToDestScene(
654 (E3dScene*)pObjMerk, (E3dScene*)pCreatePV->GetAktGroup(), Point(0, 0));
656 if(bDidInsert)
658 // delete object, its content is cloned and inserted
659 SdrObject::Free( pObjMerk );
660 pObjMerk = 0L;
661 bRet = sal_False;
662 bSceneIntoScene = true;
666 if(!bSceneIntoScene)
668 // do the same as before
669 InsertObjectAtView(pObj, *pCreatePV);
672 pCreatePV=NULL;
673 bRet=sal_True; // sal_True = event interpreted
675 else
677 BrkCreateObj();
680 else
681 { // more points
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
685 BrkCreateObj();
687 else
689 // replace for DrawCreateObjDiff
690 HideCreateObj();
691 ShowCreateObj();
692 aDragStat.ResetMinMoved(); // NextPoint is at MovCreateObj()
693 bRet=sal_True;
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);
705 return bRet;
708 void SdrCreateView::BckCreateObj()
710 if (pAktCreate!=NULL)
712 if (aDragStat.GetPointAnz()<=2 )
714 BrkCreateObj();
716 else
718 HideCreateObj();
719 aDragStat.PrevPoint();
720 if (pAktCreate->BckCreate(aDragStat))
722 ShowCreateObj();
724 else
726 BrkCreateObj();
732 void SdrCreateView::BrkCreateObj()
734 if (pAktCreate!=NULL)
736 HideCreateObj();
737 pAktCreate->BrkCreate(aDragStat);
738 SdrObject::Free( pAktCreate );
739 pAktCreate=NULL;
740 pCreatePV=NULL;
744 void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
746 if(IsCreateObj() && !aDragStat.IsShown())
748 if(pAktCreate)
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);
835 else
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
880 if(pAktCreate)
882 rTargetSet.Put(pAktCreate->GetMergedItemSet());
883 return sal_True;
885 else
887 return SdrDragView::GetAttributes(rTargetSet, bOnlyHardAttr);
891 sal_Bool SdrCreateView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
893 if(pAktCreate)
895 pAktCreate->SetMergedItemSetAndBroadcast(rSet, bReplaceAll);
897 return sal_True;
899 else
901 return SdrDragView::SetAttributes(rSet,bReplaceAll);
905 SfxStyleSheet* SdrCreateView::GetStyleSheet() const
907 if (pAktCreate!=NULL)
909 return pAktCreate->GetStyleSheet();
911 else
913 return SdrDragView::GetStyleSheet();
917 sal_Bool SdrCreateView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
919 if (pAktCreate!=NULL)
921 pAktCreate->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
922 return sal_True;
924 else
926 return SdrDragView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
930 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */