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 : : #include <svx/fmglob.hxx>
30 : : #include <svx/svdview.hxx>
31 : : #include <svx/fmshell.hxx>
32 : :
33 : : #include "view.hxx"
34 : : #include "edtwin.hxx"
35 : : #include "wrtsh.hxx"
36 : : #include "drawbase.hxx"
37 : : #include "conform.hxx"
38 : :
39 : : extern sal_Bool bNoInterrupt; // in mainwn.cxx
40 : :
41 : : /*************************************************************************
42 : : |*
43 : : |* Konstruktor
44 : : |*
45 : : \************************************************************************/
46 : :
47 : :
48 : 0 : ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
49 : 0 : SwDrawBase(pWrtShell, pEditWin, pSwView)
50 : : {
51 : 0 : m_bInsForm = sal_True;
52 : 0 : }
53 : :
54 : : /*************************************************************************
55 : : |*
56 : : |* MouseButtonDown-event
57 : : |*
58 : : \************************************************************************/
59 : :
60 : :
61 : 0 : sal_Bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
62 : : {
63 : 0 : sal_Bool bReturn = sal_False;
64 : :
65 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
66 : :
67 : 0 : pSdrView->SetOrtho(rMEvt.IsShift());
68 : 0 : pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
69 : :
70 [ # # ]: 0 : if (rMEvt.IsMod2())
71 : : {
72 : 0 : pSdrView->SetCreate1stPointAsCenter(sal_True);
73 : 0 : pSdrView->SetResizeAtCenter(sal_True);
74 : : }
75 : : else
76 : : {
77 : 0 : pSdrView->SetCreate1stPointAsCenter(sal_False);
78 : 0 : pSdrView->SetResizeAtCenter(sal_False);
79 : : }
80 : :
81 [ # # ]: 0 : SdrViewEvent aVEvt;
82 [ # # ]: 0 : SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
83 : :
84 : : // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
85 [ # # ][ # # ]: 0 : if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
[ # # ][ # # ]
[ # # ][ # # ]
86 [ # # ]: 0 : (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
87 : : {
88 : 0 : bNoInterrupt = sal_True;
89 [ # # ]: 0 : m_pWin->CaptureMouse();
90 : :
91 [ # # ]: 0 : m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
92 : :
93 [ # # ]: 0 : m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
94 [ # # ]: 0 : bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos);
95 : :
96 [ # # ]: 0 : if (bReturn)
97 : 0 : m_pWin->SetDrawAction(sal_True);
98 : : }
99 : : else
100 [ # # ]: 0 : bReturn = SwDrawBase::MouseButtonDown(rMEvt);
101 : :
102 [ # # ]: 0 : return (bReturn);
103 : : }
104 : :
105 : : /*************************************************************************
106 : : |*
107 : : |* Function aktivieren
108 : : |*
109 : : \************************************************************************/
110 : :
111 : :
112 : 0 : void ConstFormControl::Activate(const sal_uInt16 nSlotId)
113 : : {
114 : 0 : m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
115 : 0 : SwDrawBase::Activate(nSlotId);
116 : 0 : m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
117 : :
118 [ # # ]: 0 : m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
119 : 0 : }
120 : :
121 : 0 : void ConstFormControl::CreateDefaultObject()
122 : : {
123 [ # # ]: 0 : Point aStartPos(GetDefaultCenterPos());
124 : 0 : Point aEndPos(aStartPos);
125 : 0 : aStartPos.X() -= 2 * MM50;
126 : 0 : aStartPos.Y() -= MM50;
127 : 0 : aEndPos.X() += 2 * MM50;
128 : 0 : aEndPos.Y() += MM50;
129 : :
130 [ # # ][ # # ]: 0 : if(!m_pSh->HasDrawView())
131 [ # # ]: 0 : m_pSh->MakeDrawView();
132 : :
133 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
134 [ # # ]: 0 : pSdrView->SetDesignMode(sal_True);
135 [ # # ]: 0 : m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos);
136 [ # # ]: 0 : m_pSh->MoveCreate(aEndPos);
137 [ # # ]: 0 : m_pSh->EndCreate(SDRCREATE_FORCEEND);
138 : 0 : }
139 : :
140 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|