1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27
28 #include <svx/fmglob.hxx>
29 #include <svx/svdview.hxx>
30 #include <svx/fmshell.hxx>
31
32 #include "view.hxx"
33 #include "edtwin.hxx"
34 #include "wrtsh.hxx"
35 #include "drawbase.hxx"
36 #include "conform.hxx"
37
38 extern sal_Bool bNoInterrupt; // in mainwn.cxx
39
40 /*************************************************************************
41 |*
42 |* Konstruktor
43 |*
44 \************************************************************************/
45
46
ConstFormControl(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)47 ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
48 SwDrawBase(pWrtShell, pEditWin, pSwView)
49 {
50 m_bInsForm = sal_True;
51 }
52
53 /*************************************************************************
54 |*
55 |* MouseButtonDown-event
56 |*
57 \************************************************************************/
58
59
MouseButtonDown(const MouseEvent & rMEvt)60 sal_Bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
61 {
62 sal_Bool bReturn = sal_False;
63
64 SdrView *pSdrView = m_pSh->GetDrawView();
65
66 pSdrView->SetOrtho(rMEvt.IsShift());
67 pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
68
69 if (rMEvt.IsMod2())
70 {
71 pSdrView->SetCreate1stPointAsCenter(sal_True);
72 pSdrView->SetResizeAtCenter(sal_True);
73 }
74 else
75 {
76 pSdrView->SetCreate1stPointAsCenter(sal_False);
77 pSdrView->SetResizeAtCenter(sal_False);
78 }
79
80 SdrViewEvent aVEvt;
81 SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
82
83 // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
84 if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
85 (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
86 {
87 bNoInterrupt = sal_True;
88 m_pWin->CaptureMouse();
89
90 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
91
92 m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
93 bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos);
94
95 if (bReturn)
96 m_pWin->SetDrawAction(sal_True);
97 }
98 else
99 bReturn = SwDrawBase::MouseButtonDown(rMEvt);
100
101 return (bReturn);
102 }
103
104 /*************************************************************************
105 |*
106 |* Function aktivieren
107 |*
108 \************************************************************************/
109
110
Activate(const sal_uInt16 nSlotId)111 void ConstFormControl::Activate(const sal_uInt16 nSlotId)
112 {
113 m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
114 SwDrawBase::Activate(nSlotId);
115 m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
116
117 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
118 }
119 /* -----------------------------19.04.2002 12:42------------------------------
120
121 ---------------------------------------------------------------------------*/
CreateDefaultObject()122 void ConstFormControl::CreateDefaultObject()
123 {
124 Point aStartPos(GetDefaultCenterPos());
125 Point aEndPos(aStartPos);
126 aStartPos.X() -= 2 * MM50;
127 aStartPos.Y() -= MM50;
128 aEndPos.X() += 2 * MM50;
129 aEndPos.Y() += MM50;
130
131 if(!m_pSh->HasDrawView())
132 m_pSh->MakeDrawView();
133
134 SdrView *pSdrView = m_pSh->GetDrawView();
135 pSdrView->SetDesignMode(sal_True);
136 m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos);
137 m_pSh->MoveCreate(aEndPos);
138 m_pSh->EndCreate(SDRCREATE_FORCEEND);
139 }
140
141