Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/fmglob.hxx>
21 : #include <svx/svdview.hxx>
22 : #include <svx/fmshell.hxx>
23 :
24 : #include "view.hxx"
25 : #include "edtwin.hxx"
26 : #include "wrtsh.hxx"
27 : #include "drawbase.hxx"
28 : #include "conform.hxx"
29 :
30 : extern sal_Bool bNoInterrupt; // in mainwn.cxx
31 :
32 : /*************************************************************************
33 : |*
34 : |* Konstruktor
35 : |*
36 : \************************************************************************/
37 :
38 :
39 0 : ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
40 0 : SwDrawBase(pWrtShell, pEditWin, pSwView)
41 : {
42 0 : m_bInsForm = sal_True;
43 0 : }
44 :
45 : /*************************************************************************
46 : |*
47 : |* MouseButtonDown-event
48 : |*
49 : \************************************************************************/
50 :
51 :
52 0 : sal_Bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
53 : {
54 0 : sal_Bool bReturn = sal_False;
55 :
56 0 : SdrView *pSdrView = m_pSh->GetDrawView();
57 :
58 0 : pSdrView->SetOrtho(rMEvt.IsShift());
59 0 : pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
60 :
61 0 : if (rMEvt.IsMod2())
62 : {
63 0 : pSdrView->SetCreate1stPointAsCenter(sal_True);
64 0 : pSdrView->SetResizeAtCenter(sal_True);
65 : }
66 : else
67 : {
68 0 : pSdrView->SetCreate1stPointAsCenter(sal_False);
69 0 : pSdrView->SetResizeAtCenter(sal_False);
70 : }
71 :
72 0 : SdrViewEvent aVEvt;
73 0 : SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
74 :
75 : // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
76 0 : if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
77 0 : (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
78 : {
79 0 : bNoInterrupt = sal_True;
80 0 : m_pWin->CaptureMouse();
81 :
82 0 : m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
83 :
84 0 : m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
85 0 : bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos);
86 :
87 0 : if (bReturn)
88 0 : m_pWin->SetDrawAction(sal_True);
89 : }
90 : else
91 0 : bReturn = SwDrawBase::MouseButtonDown(rMEvt);
92 :
93 0 : return (bReturn);
94 : }
95 :
96 : /*************************************************************************
97 : |*
98 : |* Function aktivieren
99 : |*
100 : \************************************************************************/
101 :
102 :
103 0 : void ConstFormControl::Activate(const sal_uInt16 nSlotId)
104 : {
105 0 : m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
106 0 : SwDrawBase::Activate(nSlotId);
107 0 : m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
108 :
109 0 : m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
110 0 : }
111 :
112 0 : void ConstFormControl::CreateDefaultObject()
113 : {
114 0 : Point aStartPos(GetDefaultCenterPos());
115 0 : Point aEndPos(aStartPos);
116 0 : aStartPos.X() -= 2 * MM50;
117 0 : aStartPos.Y() -= MM50;
118 0 : aEndPos.X() += 2 * MM50;
119 0 : aEndPos.Y() += MM50;
120 :
121 0 : if(!m_pSh->HasDrawView())
122 0 : m_pSh->MakeDrawView();
123 :
124 0 : SdrView *pSdrView = m_pSh->GetDrawView();
125 0 : pSdrView->SetDesignMode(sal_True);
126 0 : m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos);
127 0 : m_pSh->MoveCreate(aEndPos);
128 0 : m_pSh->EndCreate(SDRCREATE_FORCEEND);
129 0 : }
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|