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