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 : :
30 : : #include <svx/svdcrtv.hxx>
31 : : #include "svx/xattr.hxx"
32 : : #include <svx/svdundo.hxx>
33 : : #include <svx/svdocapt.hxx> // special case: transparent filling after Create
34 : : #include <svx/svdoedge.hxx>
35 : : #include <svx/svdpagv.hxx>
36 : : #include <svx/svdpage.hxx>
37 : : #include <svx/svdetc.hxx>
38 : : #include <svx/scene3d.hxx>
39 : : #include <svx/view3d.hxx>
40 : : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
41 : : #include <svx/sdr/contact/displayinfo.hxx>
42 : : #include <svx/svdouno.hxx>
43 : : #include <svx/svdopath.hxx>
44 : : #include <svx/sdr/overlay/overlaypolypolygon.hxx>
45 : : #include <svx/sdr/overlay/overlaymanager.hxx>
46 : : #include <svx/sdrpaintwindow.hxx>
47 : : #include "fmobj.hxx"
48 : : #include <svx/svdocirc.hxx>
49 : : #include <svx/sdr/contact/viewcontact.hxx>
50 : : #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
51 : :
52 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
53 : :
54 : : class ImplConnectMarkerOverlay
55 : : {
56 : : // The OverlayObjects
57 : : ::sdr::overlay::OverlayObjectList maObjects;
58 : :
59 : : // The remembered target object
60 : : const SdrObject& mrObject;
61 : :
62 : : public:
63 : : ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject);
64 : : ~ImplConnectMarkerOverlay();
65 : :
66 : 0 : const SdrObject& GetTargetObject() const { return mrObject; }
67 : : };
68 : :
69 : 0 : ImplConnectMarkerOverlay::ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject)
70 : 0 : : mrObject(rObject)
71 : : {
72 [ # # ]: 0 : basegfx::B2DPolyPolygon aB2DPolyPolygon(rObject.TakeXorPoly());
73 : :
74 [ # # ]: 0 : for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
75 : : {
76 [ # # ]: 0 : SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
77 [ # # ]: 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
78 : :
79 [ # # ]: 0 : if(xTargetOverlay.is())
80 : : {
81 [ # # ]: 0 : Size aHalfLogicSize(xTargetOverlay->getOutputDevice().PixelToLogic(Size(4, 4)));
82 : :
83 : : // object
84 [ # # ][ # # ]: 0 : ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aB2DPolyPolygon);
85 [ # # ]: 0 : xTargetOverlay->add(*pNew);
86 [ # # ]: 0 : maObjects.append(*pNew);
87 : :
88 : : // glue points
89 [ # # ]: 0 : if(rView.IsAutoVertexConnectors())
90 : : {
91 [ # # ]: 0 : for(sal_uInt16 i(0); i < 4; i++)
92 : : {
93 [ # # ]: 0 : SdrGluePoint aGluePoint(rObject.GetVertexGluePoint(i));
94 [ # # ]: 0 : const Point& rPosition = aGluePoint.GetAbsolutePos(rObject);
95 : :
96 : 0 : basegfx::B2DPoint aTopLeft(rPosition.X() - aHalfLogicSize.Width(), rPosition.Y() - aHalfLogicSize.Height());
97 : 0 : basegfx::B2DPoint aBottomRight(rPosition.X() + aHalfLogicSize.Width(), rPosition.Y() + aHalfLogicSize.Height());
98 : :
99 [ # # ]: 0 : basegfx::B2DPolygon aTempPoly;
100 [ # # ]: 0 : aTempPoly.append(aTopLeft);
101 [ # # ]: 0 : aTempPoly.append(basegfx::B2DPoint(aBottomRight.getX(), aTopLeft.getY()));
102 [ # # ]: 0 : aTempPoly.append(aBottomRight);
103 [ # # ]: 0 : aTempPoly.append(basegfx::B2DPoint(aTopLeft.getX(), aBottomRight.getY()));
104 [ # # ]: 0 : aTempPoly.setClosed(true);
105 : :
106 [ # # ]: 0 : basegfx::B2DPolyPolygon aTempPolyPoly;
107 [ # # ]: 0 : aTempPolyPoly.append(aTempPoly);
108 : :
109 [ # # ][ # # ]: 0 : pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aTempPolyPoly);
110 [ # # ]: 0 : xTargetOverlay->add(*pNew);
111 [ # # ]: 0 : maObjects.append(*pNew);
112 [ # # ][ # # ]: 0 : }
113 : : }
114 : : }
115 [ # # ][ # # ]: 0 : }
116 : 0 : }
117 : :
118 : 0 : ImplConnectMarkerOverlay::~ImplConnectMarkerOverlay()
119 : : {
120 : : // The OverlayObjects are cleared using the destructor of OverlayObjectList.
121 : : // That destructor calls clear() at the list which removes all objects from the
122 : : // OverlayManager and deletes them.
123 : 0 : }
124 : :
125 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
126 : :
127 : : class ImpSdrCreateViewExtraData
128 : : {
129 : : // The OverlayObjects for XOR replacement
130 : : ::sdr::overlay::OverlayObjectList maObjects;
131 : :
132 : : public:
133 : : ImpSdrCreateViewExtraData();
134 : : ~ImpSdrCreateViewExtraData();
135 : :
136 : : void CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly);
137 : : void HideOverlay();
138 : : };
139 : :
140 : 4699 : ImpSdrCreateViewExtraData::ImpSdrCreateViewExtraData()
141 : : {
142 : 4699 : }
143 : :
144 : 4508 : ImpSdrCreateViewExtraData::~ImpSdrCreateViewExtraData()
145 : : {
146 [ + - ]: 4508 : HideOverlay();
147 : 4508 : }
148 : :
149 : 0 : void ImpSdrCreateViewExtraData::CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly)
150 : : {
151 [ # # ]: 0 : for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
152 : : {
153 [ # # ]: 0 : SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
154 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = pCandidate->GetOverlayManager();
155 : :
156 [ # # ]: 0 : if (xOverlayManager.is())
157 : : {
158 [ # # ]: 0 : if(pObject)
159 : : {
160 [ # # ]: 0 : const sdr::contact::ViewContact& rVC = pObject->GetViewContact();
161 [ # # ]: 0 : const drawinglayer::primitive2d::Primitive2DSequence aSequence = rVC.getViewIndependentPrimitive2DSequence();
162 [ # # ][ # # ]: 0 : sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
163 : :
164 [ # # ]: 0 : xOverlayManager->add(*pNew);
165 [ # # ][ # # ]: 0 : maObjects.append(*pNew);
166 : : }
167 : :
168 [ # # ][ # # ]: 0 : if(rPolyPoly.count())
169 : : {
170 [ # # ][ # # ]: 0 : ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(rPolyPoly);
171 [ # # ]: 0 : xOverlayManager->add(*pNew);
172 [ # # ]: 0 : maObjects.append(*pNew);
173 : : }
174 : : }
175 [ # # ]: 0 : }
176 : 0 : }
177 : :
178 : 4508 : void ImpSdrCreateViewExtraData::HideOverlay()
179 : : {
180 : : // the clear() call of the list removes all objects from the
181 : : // OverlayManager and deletes them.
182 : 4508 : maObjects.clear();
183 : 4508 : }
184 : :
185 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
186 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
187 : : // CreateView
188 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
189 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
190 : :
191 : 9872 : void SdrCreateView::ImpClearConnectMarker()
192 : : {
193 [ - + ]: 9872 : if(mpCoMaOverlay)
194 : : {
195 [ # # ]: 0 : delete mpCoMaOverlay;
196 : 0 : mpCoMaOverlay = 0L;
197 : : }
198 : 9872 : }
199 : :
200 : 4699 : void SdrCreateView::ImpClearVars()
201 : : {
202 : 4699 : nAktInvent=SdrInventor;
203 : 4699 : nAktIdent=OBJ_NONE;
204 : 4699 : pAktCreate=NULL;
205 : 4699 : pCreatePV=NULL;
206 : 4699 : bAutoTextEdit=sal_False;
207 : 4699 : b1stPointAsCenter=sal_False;
208 : 4699 : aAktCreatePointer=Pointer(POINTER_CROSS);
209 : 4699 : bUseIncompatiblePathCreateInterface=sal_False;
210 : 4699 : bAutoClosePolys=sal_True;
211 : 4699 : nAutoCloseDistPix=5;
212 : 4699 : nFreeHandMinDistPix=10;
213 : :
214 : 4699 : ImpClearConnectMarker();
215 : 4699 : }
216 : :
217 : 4699 : SdrCreateView::SdrCreateView(SdrModel* pModel1, OutputDevice* pOut)
218 : : : SdrDragView(pModel1,pOut),
219 : : mpCoMaOverlay(0L),
220 [ + - ][ + - ]: 4699 : mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
221 : : {
222 [ + - ]: 4699 : ImpClearVars();
223 : 4699 : }
224 : :
225 : 4508 : SdrCreateView::~SdrCreateView()
226 : : {
227 [ + - ]: 4508 : ImpClearConnectMarker();
228 [ + - ][ + - ]: 4508 : delete mpCreateViewExtraData;
229 [ + - ]: 4508 : SdrObject::Free( pAktCreate );
230 [ - + ]: 4508 : }
231 : :
232 : 2168 : sal_Bool SdrCreateView::IsAction() const
233 : : {
234 [ + - ][ - + ]: 2168 : return SdrDragView::IsAction() || pAktCreate!=NULL;
235 : : }
236 : :
237 : 0 : void SdrCreateView::MovAction(const Point& rPnt)
238 : : {
239 : 0 : SdrDragView::MovAction(rPnt);
240 [ # # ]: 0 : if (pAktCreate!=NULL) {
241 : 0 : MovCreateObj(rPnt);
242 : : }
243 : 0 : }
244 : :
245 : 0 : void SdrCreateView::EndAction()
246 : : {
247 [ # # ]: 0 : if (pAktCreate!=NULL) EndCreateObj(SDRCREATE_FORCEEND);
248 : 0 : SdrDragView::EndAction();
249 : 0 : }
250 : :
251 : 0 : void SdrCreateView::BckAction()
252 : : {
253 [ # # ]: 0 : if (pAktCreate!=NULL) BckCreateObj();
254 : 0 : SdrDragView::BckAction();
255 : 0 : }
256 : :
257 : 4877 : void SdrCreateView::BrkAction()
258 : : {
259 : 4877 : SdrDragView::BrkAction();
260 : 4877 : BrkCreateObj();
261 : 4877 : }
262 : :
263 : 0 : void SdrCreateView::TakeActionRect(Rectangle& rRect) const
264 : : {
265 [ # # ]: 0 : if (pAktCreate!=NULL)
266 : : {
267 : 0 : rRect=aDragStat.GetActionRect();
268 [ # # ]: 0 : if (rRect.IsEmpty())
269 : : {
270 : 0 : rRect=Rectangle(aDragStat.GetPrev(),aDragStat.GetNow());
271 : : }
272 : : }
273 : : else
274 : : {
275 : 0 : SdrDragView::TakeActionRect(rRect);
276 : : }
277 : 0 : }
278 : :
279 : 665 : sal_Bool SdrCreateView::CheckEdgeMode()
280 : : {
281 [ - + ]: 665 : if (pAktCreate!=NULL)
282 : : {
283 : : // is managed by EdgeObj
284 [ # # ][ # # ]: 0 : if (nAktInvent==SdrInventor && nAktIdent==OBJ_EDGE) return sal_False;
285 : : }
286 : :
287 [ - + ][ # # ]: 665 : if (!IsCreateMode() || nAktInvent!=SdrInventor || nAktIdent!=OBJ_EDGE)
[ # # ][ + - ]
288 : : {
289 : 665 : ImpClearConnectMarker();
290 : 665 : return sal_False;
291 : : }
292 : : else
293 : : {
294 : : // sal_True, if MouseMove should check Connect
295 : 665 : return !IsAction();
296 : : }
297 : : }
298 : :
299 : 0 : void SdrCreateView::SetConnectMarker(const SdrObjConnection& rCon, const SdrPageView& /*rPV*/)
300 : : {
301 : 0 : SdrObject* pTargetObject = rCon.pObj;
302 : :
303 [ # # ]: 0 : if(pTargetObject)
304 : : {
305 : : // if target object changes, throw away overlay object to make room for changes
306 [ # # ][ # # ]: 0 : if(mpCoMaOverlay && pTargetObject != &mpCoMaOverlay->GetTargetObject())
[ # # ]
307 : : {
308 : 0 : ImpClearConnectMarker();
309 : : }
310 : :
311 [ # # ]: 0 : if(!mpCoMaOverlay)
312 : : {
313 [ # # ]: 0 : mpCoMaOverlay = new ImplConnectMarkerOverlay(*this, *pTargetObject);
314 : : }
315 : : }
316 : : else
317 : : {
318 : 0 : ImpClearConnectMarker();
319 : : }
320 : 0 : }
321 : :
322 : 0 : void SdrCreateView::HideConnectMarker()
323 : : {
324 : 0 : ImpClearConnectMarker();
325 : 0 : }
326 : :
327 : 0 : sal_Bool SdrCreateView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
328 : : {
329 [ # # ][ # # ]: 0 : if(CheckEdgeMode() && pWin)
[ # # ]
330 : : {
331 : 0 : SdrPageView* pPV = GetSdrPageView();
332 : :
333 [ # # ]: 0 : if(pPV)
334 : : {
335 : : // TODO: Change default hit tolerance at IsMarkedHit() some time!
336 [ # # ]: 0 : Point aPos(pWin->PixelToLogic(rMEvt.GetPosPixel()));
337 [ # # ][ # # ]: 0 : sal_Bool bMarkHit=PickHandle(aPos)!=NULL || IsMarkedObjHit(aPos);
[ # # ][ # # ]
338 [ # # ]: 0 : SdrObjConnection aCon;
339 [ # # ][ # # ]: 0 : if (!bMarkHit) SdrEdgeObj::ImpFindConnector(aPos,*pPV,aCon,NULL,pWin);
340 [ # # ][ # # ]: 0 : SetConnectMarker(aCon,*pPV);
341 : : }
342 : : }
343 : 0 : return SdrDragView::MouseMove(rMEvt,pWin);
344 : : }
345 : :
346 : 260 : sal_Bool SdrCreateView::IsTextTool() const
347 : : {
348 [ - + ][ # # ]: 260 : return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_TEXT || nAktIdent==OBJ_TEXTEXT || nAktIdent==OBJ_TITLETEXT || nAktIdent==OBJ_OUTLINETEXT);
[ # # ][ # # ]
[ # # ][ # # ]
349 : : }
350 : :
351 : 260 : sal_Bool SdrCreateView::IsEdgeTool() const
352 : : {
353 [ - + ][ # # ]: 260 : return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_EDGE);
[ # # ]
354 : : }
355 : :
356 : 1215 : sal_Bool SdrCreateView::IsMeasureTool() const
357 : : {
358 [ - + ][ # # ]: 1215 : return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_MEASURE);
[ # # ]
359 : : }
360 : :
361 : 260 : void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent, sal_uInt32 nInvent)
362 : : {
363 [ + - ][ + - ]: 260 : if (nAktInvent!=nInvent || nAktIdent!=nIdent)
364 : : {
365 : 260 : nAktInvent=nInvent;
366 : 260 : nAktIdent=nIdent;
367 [ + - ]: 260 : SdrObject* pObj = SdrObjFactory::MakeNewObject(nInvent,nIdent,NULL,NULL);
368 : :
369 [ + - ]: 260 : if(pObj)
370 : : {
371 : : // Using text tool, mouse cursor is usually I-Beam,
372 : : // crosshairs with tiny I-Beam appears only on MouseButtonDown.
373 [ + - ][ - + ]: 260 : if(IsTextTool())
374 : : {
375 : : // Here the correct pointer needs to be used
376 : : // if the default is set to vertical writing
377 : 0 : aAktCreatePointer = POINTER_TEXT;
378 : : }
379 : : else
380 [ + - ]: 260 : aAktCreatePointer = pObj->GetCreatePointer();
381 : :
382 [ + - ]: 260 : SdrObject::Free( pObj );
383 : : }
384 : : else
385 : : {
386 : 260 : aAktCreatePointer = Pointer(POINTER_CROSS);
387 : : }
388 : : }
389 : :
390 : 260 : CheckEdgeMode();
391 : 260 : ImpSetGlueVisible3(IsEdgeTool());
392 : 260 : }
393 : :
394 : 0 : sal_Bool SdrCreateView::ImpBegCreateObj(sal_uInt32 nInvent, sal_uInt16 nIdent, const Point& rPnt, OutputDevice* pOut,
395 : : short nMinMov, SdrPageView* pPV, const Rectangle& rLogRect, SdrObject* pPreparedFactoryObject)
396 : : {
397 : 0 : sal_Bool bRet=sal_False;
398 : 0 : UnmarkAllObj();
399 : 0 : BrkAction();
400 : :
401 : 0 : ImpClearConnectMarker();
402 : :
403 [ # # ]: 0 : if (pPV!=NULL)
404 : : {
405 : 0 : pCreatePV=pPV;
406 : : }
407 : : else
408 : : {
409 : 0 : pCreatePV = GetSdrPageView();
410 : : }
411 [ # # ]: 0 : if (pCreatePV!=NULL)
412 : : { // otherwise no side registered!
413 [ # # ]: 0 : String aLay(aAktLayer);
414 : :
415 [ # # ][ # # ]: 0 : if(nInvent == SdrInventor && nIdent == OBJ_MEASURE && aMeasureLayer.Len())
[ # # ][ # # ]
416 : : {
417 [ # # ]: 0 : aLay = aMeasureLayer;
418 : : }
419 : :
420 [ # # ]: 0 : SdrLayerID nLayer=pCreatePV->GetPage()->GetLayerAdmin().GetLayerID(aLay,sal_True);
421 [ # # ]: 0 : if (nLayer==SDRLAYER_NOTFOUND) nLayer=0;
422 [ # # ][ # # ]: 0 : if (!pCreatePV->GetLockedLayers().IsSet(nLayer) && pCreatePV->GetVisibleLayers().IsSet(nLayer))
[ # # ]
423 : : {
424 [ # # ]: 0 : if(pPreparedFactoryObject)
425 : : {
426 : 0 : pAktCreate = pPreparedFactoryObject;
427 : :
428 [ # # ]: 0 : if(pCreatePV->GetPage())
429 : : {
430 [ # # ]: 0 : pAktCreate->SetPage(pCreatePV->GetPage());
431 : : }
432 [ # # ]: 0 : else if (pMod)
433 : : {
434 [ # # ]: 0 : pAktCreate->SetModel(pMod);
435 : : }
436 : : }
437 : : else
438 : : {
439 [ # # ]: 0 : pAktCreate = SdrObjFactory::MakeNewObject(nInvent, nIdent, pCreatePV->GetPage(), pMod);
440 : : }
441 : :
442 : 0 : Point aPnt(rPnt);
443 [ # # ][ # # ]: 0 : if (nAktInvent!=SdrInventor || (nAktIdent!=sal_uInt16(OBJ_EDGE) &&
[ # # ][ # # ]
444 : : nAktIdent!=sal_uInt16(OBJ_FREELINE) &&
445 : : nAktIdent!=sal_uInt16(OBJ_FREEFILL) )) { // no snapping for Edge and Freehand
446 [ # # ]: 0 : aPnt=GetSnapPos(aPnt,pCreatePV);
447 : : }
448 [ # # ]: 0 : if (pAktCreate!=NULL)
449 : : {
450 [ # # ][ # # ]: 0 : if (pDefaultStyleSheet!=NULL) pAktCreate->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
451 : :
452 : : // SW uses a naked SdrObject for frame construction. Normally, such an
453 : : // object should not be created. Since it is possible to use it as a helper
454 : : // object (e.g. in letting the user define an area with the interactive
455 : : // construction) at least no items should be set at that object.
456 [ # # ][ # # ]: 0 : if(nInvent != SdrInventor || nIdent != OBJ_NONE)
457 : : {
458 [ # # ]: 0 : pAktCreate->SetMergedItemSet(aDefaultAttr);
459 : : }
460 : :
461 [ # # ][ # # ]: 0 : if (HAS_BASE(SdrCaptionObj,pAktCreate))
[ # # ][ # # ]
[ # # ]
462 : : {
463 [ # # ]: 0 : SfxItemSet aSet(pMod->GetItemPool());
464 [ # # ][ # # ]: 0 : aSet.Put(XFillColorItem(String(),Color(COL_WHITE))); // in case someone turns on Solid
[ # # ][ # # ]
[ # # ]
465 [ # # ][ # # ]: 0 : aSet.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
466 : :
467 [ # # ][ # # ]: 0 : pAktCreate->SetMergedItemSet(aSet);
468 : : }
469 [ # # ][ # # ]: 0 : if (nInvent==SdrInventor && (nIdent==OBJ_TEXT || nIdent==OBJ_TEXTEXT ||
[ # # ][ # # ]
[ # # ]
470 : : nIdent==OBJ_TITLETEXT || nIdent==OBJ_OUTLINETEXT))
471 : : {
472 : : // default for all text frames: no background, no border
473 [ # # ]: 0 : SfxItemSet aSet(pMod->GetItemPool());
474 [ # # ][ # # ]: 0 : aSet.Put(XFillColorItem(String(),Color(COL_WHITE))); // in case someone turns on Solid
[ # # ][ # # ]
[ # # ]
475 [ # # ][ # # ]: 0 : aSet.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
476 [ # # ][ # # ]: 0 : aSet.Put(XLineColorItem(String(),Color(COL_BLACK))); // in case someone turns on Solid
[ # # ][ # # ]
[ # # ]
477 [ # # ][ # # ]: 0 : aSet.Put(XLineStyleItem(XLINE_NONE));
[ # # ]
478 : :
479 [ # # ][ # # ]: 0 : pAktCreate->SetMergedItemSet(aSet);
480 : : }
481 [ # # ][ # # ]: 0 : if (!rLogRect.IsEmpty()) pAktCreate->NbcSetLogicRect(rLogRect);
[ # # ]
482 : :
483 : : // make sure drag start point is inside WorkArea
484 : 0 : const Rectangle& rWorkArea = ((SdrDragView*)this)->GetWorkArea();
485 : :
486 [ # # ][ # # ]: 0 : if(!rWorkArea.IsEmpty())
487 : : {
488 [ # # ]: 0 : if(aPnt.X() < rWorkArea.Left())
489 : : {
490 : 0 : aPnt.X() = rWorkArea.Left();
491 : : }
492 : :
493 [ # # ]: 0 : if(aPnt.X() > rWorkArea.Right())
494 : : {
495 : 0 : aPnt.X() = rWorkArea.Right();
496 : : }
497 : :
498 [ # # ]: 0 : if(aPnt.Y() < rWorkArea.Top())
499 : : {
500 : 0 : aPnt.Y() = rWorkArea.Top();
501 : : }
502 : :
503 [ # # ]: 0 : if(aPnt.Y() > rWorkArea.Bottom())
504 : : {
505 : 0 : aPnt.Y() = rWorkArea.Bottom();
506 : : }
507 : : }
508 : :
509 [ # # ]: 0 : aDragStat.Reset(aPnt);
510 : 0 : aDragStat.SetView((SdrView*)this);
511 : 0 : aDragStat.SetPageView(pCreatePV);
512 [ # # ]: 0 : aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
513 : 0 : pDragWin=pOut;
514 [ # # ][ # # ]: 0 : if (pAktCreate->BegCreate(aDragStat))
515 : : {
516 [ # # ]: 0 : ShowCreateObj(/*pOut,sal_True*/);
517 : 0 : bRet=sal_True;
518 : : }
519 : : else
520 : : {
521 [ # # ]: 0 : SdrObject::Free( pAktCreate );
522 : 0 : pAktCreate=NULL;
523 : 0 : pCreatePV=NULL;
524 : : }
525 : : }
526 [ # # ]: 0 : }
527 : : }
528 : 0 : return bRet;
529 : : }
530 : :
531 : 0 : sal_Bool SdrCreateView::BegCreateObj(const Point& rPnt, OutputDevice* pOut, short nMinMov, SdrPageView* pPV)
532 : : {
533 [ # # ]: 0 : return ImpBegCreateObj(nAktInvent,nAktIdent,rPnt,pOut,nMinMov,pPV,Rectangle(), 0L);
534 : : }
535 : :
536 : 0 : sal_Bool SdrCreateView::BegCreatePreparedObject(const Point& rPnt, sal_Int16 nMinMov, SdrObject* pPreparedFactoryObject)
537 : : {
538 : 0 : sal_uInt32 nInvent(nAktInvent);
539 : 0 : sal_uInt16 nIdent(nAktIdent);
540 : :
541 [ # # ]: 0 : if(pPreparedFactoryObject)
542 : : {
543 : 0 : nInvent = pPreparedFactoryObject->GetObjInventor();
544 : 0 : nIdent = pPreparedFactoryObject->GetObjIdentifier();
545 : : }
546 : :
547 [ # # ]: 0 : return ImpBegCreateObj(nInvent, nIdent, rPnt, 0L, nMinMov, 0L, Rectangle(), pPreparedFactoryObject);
548 : : }
549 : :
550 : 0 : sal_Bool SdrCreateView::BegCreateCaptionObj(const Point& rPnt, const Size& rObjSiz,
551 : : OutputDevice* pOut, short nMinMov, SdrPageView* pPV)
552 : : {
553 : : return ImpBegCreateObj(SdrInventor,OBJ_CAPTION,rPnt,pOut,nMinMov,pPV,
554 [ # # ][ # # ]: 0 : Rectangle(rPnt,Size(rObjSiz.Width()+1,rObjSiz.Height()+1)), 0L);
555 : : }
556 : :
557 : 0 : void SdrCreateView::MovCreateObj(const Point& rPnt)
558 : : {
559 [ # # ]: 0 : if (pAktCreate!=NULL) {
560 : 0 : Point aPnt(rPnt);
561 [ # # ]: 0 : if (!aDragStat.IsNoSnap())
562 : : {
563 [ # # ]: 0 : aPnt=GetSnapPos(aPnt,pCreatePV);
564 : : }
565 [ # # ]: 0 : if (IsOrtho())
566 : : {
567 [ # # ][ # # ]: 0 : if (aDragStat.IsOrtho8Possible()) OrthoDistance8(aDragStat.GetPrev(),aPnt,IsBigOrtho());
[ # # ]
568 [ # # ][ # # ]: 0 : else if (aDragStat.IsOrtho4Possible()) OrthoDistance4(aDragStat.GetPrev(),aPnt,IsBigOrtho());
[ # # ]
569 : : }
570 : :
571 : : // If the drag point was limited and Ortho is active, do
572 : : // the small ortho correction (reduction) -> last parameter to FALSE.
573 [ # # ]: 0 : sal_Bool bDidLimit(ImpLimitToWorkArea(aPnt));
574 [ # # ][ # # ]: 0 : if(bDidLimit && IsOrtho())
[ # # ]
575 : : {
576 [ # # ]: 0 : if(aDragStat.IsOrtho8Possible())
577 [ # # ][ # # ]: 0 : OrthoDistance8(aDragStat.GetPrev(), aPnt, sal_False);
578 [ # # ]: 0 : else if(aDragStat.IsOrtho4Possible())
579 [ # # ][ # # ]: 0 : OrthoDistance4(aDragStat.GetPrev(), aPnt, sal_False);
580 : : }
581 : :
582 [ # # ][ # # ]: 0 : if (aPnt==aDragStat.GetNow()) return;
583 : 0 : bool bMerk(aDragStat.IsMinMoved());
584 [ # # ][ # # ]: 0 : if (aDragStat.CheckMinMoved(aPnt))
585 : : {
586 [ # # ]: 0 : Rectangle aBound;
587 [ # # ][ # # ]: 0 : if (!bMerk) aDragStat.NextPoint();
588 [ # # ]: 0 : aDragStat.NextMove(aPnt);
589 [ # # ]: 0 : pAktCreate->MovCreate(aDragStat);
590 : :
591 : : // MovCreate changes the object, so use ActionChanged() on it
592 [ # # ]: 0 : pAktCreate->ActionChanged();
593 : :
594 : : // replace for DrawCreateObjDiff
595 [ # # ]: 0 : HideCreateObj();
596 [ # # ]: 0 : ShowCreateObj();
597 : : }
598 : : }
599 : : }
600 : :
601 : 0 : sal_Bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
602 : : {
603 : 0 : sal_Bool bRet=sal_False;
604 : 0 : SdrObject* pObjMerk=pAktCreate;
605 : 0 : SdrPageView* pPVMerk=pCreatePV;
606 : :
607 [ # # ]: 0 : if (pAktCreate!=NULL)
608 : : {
609 : 0 : sal_uIntPtr nAnz=aDragStat.GetPointAnz();
610 : :
611 [ # # ][ # # ]: 0 : if (nAnz<=1 && eCmd==SDRCREATE_FORCEEND)
612 : : {
613 [ # # ]: 0 : BrkCreateObj(); // objects with only a single point don't exist (at least today)
614 : 0 : return sal_False; // sal_False = event not interpreted
615 : : }
616 : :
617 : 0 : sal_Bool bPntsEq=nAnz>1;
618 : 0 : sal_uIntPtr i=1;
619 [ # # ]: 0 : Point aP0=aDragStat.GetPoint(0);
620 [ # # ][ # # ]: 0 : while (bPntsEq && i<nAnz) { bPntsEq=aP0==aDragStat.GetPoint(i); i++; }
[ # # ][ # # ]
621 : :
622 [ # # ][ # # ]: 0 : if (pAktCreate->EndCreate(aDragStat,eCmd))
623 : : {
624 [ # # ]: 0 : HideCreateObj();
625 : :
626 [ # # ]: 0 : if (!bPntsEq)
627 : : {
628 : : // otherwise Brk, because all points are equal
629 : 0 : SdrObject* pObj=pAktCreate;
630 : 0 : pAktCreate=NULL;
631 : :
632 : 0 : const SdrLayerAdmin& rAd = pCreatePV->GetPage()->GetLayerAdmin();
633 : 0 : SdrLayerID nLayer(0);
634 : :
635 : : // #i72535#
636 [ # # ][ # # ]: 0 : if(pObj->ISA(FmFormObj))
[ # # ]
637 : : {
638 : : // for FormControls, force to form layer
639 [ # # ]: 0 : nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
640 : : }
641 : : else
642 : : {
643 [ # # ]: 0 : nLayer = rAd.GetLayerID(aAktLayer, sal_True);
644 : : }
645 : :
646 [ # # ]: 0 : if(SDRLAYER_NOTFOUND == nLayer)
647 : : {
648 : 0 : nLayer=0;
649 : : }
650 : :
651 [ # # ]: 0 : pObj->SetLayer(nLayer);
652 : :
653 : : // recognize creation of a new 3D object inside a 3D scene
654 : 0 : sal_Bool bSceneIntoScene(sal_False);
655 : :
656 [ # # ][ # # ]: 0 : if(pObjMerk
[ # # # # ]
[ # # ][ # # ]
657 [ # # ][ # # ]: 0 : && pObjMerk->ISA(E3dScene)
658 : : && pCreatePV
659 : 0 : && pCreatePV->GetAktGroup()
660 [ # # ][ # # ]: 0 : && pCreatePV->GetAktGroup()->ISA(E3dScene))
661 : : {
662 : : sal_Bool bDidInsert = ((E3dView*)this)->ImpCloneAll3DObjectsToDestScene(
663 [ # # ]: 0 : (E3dScene*)pObjMerk, (E3dScene*)pCreatePV->GetAktGroup(), Point(0, 0));
664 : :
665 [ # # ]: 0 : if(bDidInsert)
666 : : {
667 : : // delete object, its content is cloned and inserted
668 [ # # ]: 0 : SdrObject::Free( pObjMerk );
669 : 0 : pObjMerk = 0L;
670 : 0 : bRet = sal_False;
671 : 0 : bSceneIntoScene = sal_True;
672 : : }
673 : : }
674 : :
675 [ # # ]: 0 : if(!bSceneIntoScene)
676 : : {
677 : : // do the same as before
678 [ # # ]: 0 : InsertObjectAtView(pObj, *pCreatePV);
679 : : }
680 : :
681 : 0 : pCreatePV=NULL;
682 : 0 : bRet=sal_True; // sal_True = event interpreted
683 : : }
684 : : else
685 : : {
686 [ # # ]: 0 : BrkCreateObj();
687 : : }
688 : : }
689 : : else
690 : : { // more points
691 [ # # ][ # # ]: 0 : if (eCmd==SDRCREATE_FORCEEND || // nothing there -- force ending
[ # # # # ]
[ # # ]
692 : : nAnz==0 || // no existing points (should never happen)
693 : 0 : (nAnz<=1 && !aDragStat.IsMinMoved())) { // MinMove not met
694 [ # # ]: 0 : BrkCreateObj();
695 : : }
696 : : else
697 : : {
698 : : // replace for DrawCreateObjDiff
699 [ # # ]: 0 : HideCreateObj();
700 [ # # ]: 0 : ShowCreateObj();
701 : 0 : aDragStat.ResetMinMoved(); // NextPoint is at MovCreateObj()
702 : 0 : bRet=sal_True;
703 : : }
704 : : }
705 [ # # ][ # # ]: 0 : if (bRet && pObjMerk!=NULL && IsTextEditAfterCreate())
[ # # ][ # # ]
706 : : {
707 [ # # ][ # # ]: 0 : SdrTextObj* pText=PTR_CAST(SdrTextObj,pObjMerk);
[ # # ][ # # ]
708 [ # # ][ # # ]: 0 : if (pText!=NULL && pText->IsTextFrame())
[ # # ]
709 : : {
710 [ # # ]: 0 : SdrBeginTextEdit(pText, pPVMerk, (Window*)0L, sal_True, (SdrOutliner*)0L, (OutlinerView*)0L);
711 : : }
712 : : }
713 : : }
714 : 0 : return bRet;
715 : : }
716 : :
717 : 0 : void SdrCreateView::BckCreateObj()
718 : : {
719 [ # # ]: 0 : if (pAktCreate!=NULL)
720 : : {
721 [ # # ]: 0 : if (aDragStat.GetPointAnz()<=2 )
722 : : {
723 : 0 : BrkCreateObj();
724 : : }
725 : : else
726 : : {
727 : 0 : HideCreateObj();
728 : 0 : aDragStat.PrevPoint();
729 [ # # ]: 0 : if (pAktCreate->BckCreate(aDragStat))
730 : : {
731 : 0 : ShowCreateObj();
732 : : }
733 : : else
734 : : {
735 : 0 : BrkCreateObj();
736 : : }
737 : : }
738 : : }
739 : 0 : }
740 : :
741 : 4877 : void SdrCreateView::BrkCreateObj()
742 : : {
743 [ - + ]: 4877 : if (pAktCreate!=NULL)
744 : : {
745 : 0 : HideCreateObj();
746 : 0 : pAktCreate->BrkCreate(aDragStat);
747 : 0 : SdrObject::Free( pAktCreate );
748 : 0 : pAktCreate=NULL;
749 : 0 : pCreatePV=NULL;
750 : : }
751 : 4877 : }
752 : :
753 : 0 : void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
754 : : {
755 [ # # ][ # # ]: 0 : if(IsCreateObj() && !aDragStat.IsShown())
[ # # ]
756 : : {
757 [ # # ]: 0 : if(pAktCreate)
758 : : {
759 : : // for migration from XOR, replace DrawDragObj here to create
760 : : // overlay objects instead.
761 : 0 : sal_Bool bUseSolidDragging(IsSolidDragging());
762 : :
763 : : // #i101648# check if dragged object is a naked SdrObject (not
764 : : // a derivation). This is e.g. used in SW Frame construction
765 : : // as placeholder. Do not use SolidDragging for naked SDrObjects,
766 : : // they cannot have a valid optical representation
767 [ # # ][ # # ]: 0 : if(bUseSolidDragging && OBJ_NONE == pAktCreate->GetObjIdentifier())
[ # # ]
768 : : {
769 : 0 : bUseSolidDragging = false;
770 : : }
771 : :
772 : : // check for objects with no fill and no line
773 [ # # ]: 0 : if(bUseSolidDragging)
774 : : {
775 : 0 : const SfxItemSet& rSet = pAktCreate->GetMergedItemSet();
776 : 0 : const XFillStyle eFill(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
777 : 0 : const XLineStyle eLine(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue());
778 : :
779 [ # # ][ # # ]: 0 : if(XLINE_NONE == eLine && XFILL_NONE == eFill)
780 : : {
781 : 0 : bUseSolidDragging = sal_False;
782 : : }
783 : : }
784 : :
785 : : // check for form controls
786 [ # # ]: 0 : if(bUseSolidDragging)
787 : : {
788 [ # # ]: 0 : if(pAktCreate->ISA(SdrUnoObj))
789 : : {
790 : 0 : bUseSolidDragging = sal_False;
791 : : }
792 : : }
793 : :
794 : : // #i101781# force to non-solid dragging when not creating a full circle
795 [ # # ]: 0 : if(bUseSolidDragging)
796 : : {
797 [ # # ]: 0 : SdrCircObj* pCircObj = dynamic_cast< SdrCircObj* >(pAktCreate);
798 : :
799 [ # # ][ # # ]: 0 : if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier())
[ # # ]
800 : : {
801 : : // #i103058# Allow SolidDragging with four points
802 [ # # ]: 0 : if(aDragStat.GetPointAnz() < 4)
803 : : {
804 : 0 : bUseSolidDragging = false;
805 : : }
806 : : }
807 : : }
808 : :
809 [ # # ]: 0 : if(bUseSolidDragging)
810 : : {
811 [ # # ]: 0 : basegfx::B2DPolyPolygon aDragPolyPolygon;
812 : :
813 [ # # ][ # # ]: 0 : if(pAktCreate->ISA(SdrRectObj))
[ # # ]
814 : : {
815 : : // ensure object has some size, necessary for SdrTextObj because
816 : : // there are still untested divisions by that sizes
817 [ # # ]: 0 : Rectangle aCurrentSnapRect(pAktCreate->GetSnapRect());
818 : :
819 [ # # ][ # # ]: 0 : if(!(aCurrentSnapRect.GetWidth() > 1 && aCurrentSnapRect.GetHeight() > 1))
[ # # ][ # # ]
[ # # ]
820 : : {
821 [ # # ][ # # ]: 0 : Rectangle aNewRect(aDragStat.GetStart(), aDragStat.GetStart() + Point(2, 2));
[ # # ]
822 [ # # ]: 0 : pAktCreate->NbcSetSnapRect(aNewRect);
823 : : }
824 : : }
825 : :
826 [ # # ][ # # ]: 0 : if(pAktCreate->ISA(SdrPathObj))
[ # # ]
827 : : {
828 : : // The up-to-now created path needs to be set at the object to have something
829 : : // that can be visualized
830 : 0 : SdrPathObj& rPathObj((SdrPathObj&)(*pAktCreate));
831 [ # # ]: 0 : const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(aDragStat));
832 : :
833 [ # # ][ # # ]: 0 : if(aCurrentPolyPolygon.count())
834 : : {
835 [ # # ]: 0 : rPathObj.NbcSetPathPoly(aCurrentPolyPolygon);
836 : : }
837 : :
838 [ # # ][ # # ]: 0 : aDragPolyPolygon = rPathObj.getDragPolyPolygon(aDragStat);
[ # # ][ # # ]
839 : : }
840 : :
841 : : // use the SdrObject directly for overlay
842 [ # # ][ # # ]: 0 : mpCreateViewExtraData->CreateAndShowOverlay(*this, pAktCreate, aDragPolyPolygon);
843 : : }
844 : : else
845 : : {
846 [ # # ]: 0 : mpCreateViewExtraData->CreateAndShowOverlay(*this, 0, pAktCreate->TakeCreatePoly(aDragStat));
847 : : }
848 : :
849 : : // #i101679# Force changed overlay to be shown
850 [ # # ]: 0 : for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
851 : : {
852 [ # # ]: 0 : SdrPaintWindow* pCandidate = GetPaintWindow(a);
853 [ # # ]: 0 : rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = pCandidate->GetOverlayManager();
854 : :
855 [ # # ]: 0 : if (xOverlayManager.is())
856 : : {
857 [ # # ]: 0 : xOverlayManager->flush();
858 : : }
859 [ # # ]: 0 : }
860 : : }
861 : :
862 : 0 : aDragStat.SetShown(sal_True);
863 : : }
864 : 0 : }
865 : :
866 : 0 : void SdrCreateView::HideCreateObj()
867 : : {
868 [ # # ][ # # ]: 0 : if(IsCreateObj() && aDragStat.IsShown())
[ # # ]
869 : : {
870 : : // for migration from XOR, replace DrawDragObj here to create
871 : : // overlay objects instead.
872 : 0 : mpCreateViewExtraData->HideOverlay();
873 : :
874 : : //DrawCreateObj(pOut,bFull);
875 : 0 : aDragStat.SetShown(sal_False);
876 : : }
877 : 0 : }
878 : :
879 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
880 : :
881 : 1216 : sal_Bool SdrCreateView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const
882 : : {
883 [ - + ]: 1216 : if(pAktCreate)
884 : : {
885 : 0 : rTargetSet.Put(pAktCreate->GetMergedItemSet());
886 : 0 : return sal_True;
887 : : }
888 : : else
889 : : {
890 : 1216 : return SdrDragView::GetAttributes(rTargetSet, bOnlyHardAttr);
891 : : }
892 : : }
893 : :
894 : 0 : sal_Bool SdrCreateView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
895 : : {
896 [ # # ]: 0 : if(pAktCreate)
897 : : {
898 : 0 : pAktCreate->SetMergedItemSetAndBroadcast(rSet, bReplaceAll);
899 : :
900 : 0 : return sal_True;
901 : : }
902 : : else
903 : : {
904 : 0 : return SdrDragView::SetAttributes(rSet,bReplaceAll);
905 : : }
906 : : }
907 : :
908 : 4 : SfxStyleSheet* SdrCreateView::GetStyleSheet() const
909 : : {
910 [ - + ]: 4 : if (pAktCreate!=NULL)
911 : : {
912 : 0 : return pAktCreate->GetStyleSheet();
913 : : }
914 : : else
915 : : {
916 : 4 : return SdrDragView::GetStyleSheet();
917 : : }
918 : : }
919 : :
920 : 0 : sal_Bool SdrCreateView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
921 : : {
922 [ # # ]: 0 : if (pAktCreate!=NULL)
923 : : {
924 : 0 : pAktCreate->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
925 : 0 : return sal_True;
926 : : }
927 : : else
928 : : {
929 : 0 : return SdrDragView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
930 : : }
931 : : }
932 : :
933 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|