1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/fmglob.hxx>
21 #include <svx/svdview.hxx>
22 #include <svx/fmshell.hxx>
27 #include "drawbase.hxx"
28 #include "conform.hxx"
30 extern bool bNoInterrupt
; // in mainwn.cxx
32 ConstFormControl::ConstFormControl(SwWrtShell
* pWrtShell
, SwEditWin
* pEditWin
, SwView
* pSwView
) :
33 SwDrawBase(pWrtShell
, pEditWin
, pSwView
)
38 sal_Bool
ConstFormControl::MouseButtonDown(const MouseEvent
& rMEvt
)
40 sal_Bool bReturn
= sal_False
;
42 SdrView
*pSdrView
= m_pSh
->GetDrawView();
44 pSdrView
->SetOrtho(rMEvt
.IsShift());
45 pSdrView
->SetAngleSnapEnabled(rMEvt
.IsShift());
49 pSdrView
->SetCreate1stPointAsCenter(sal_True
);
50 pSdrView
->SetResizeAtCenter(sal_True
);
54 pSdrView
->SetCreate1stPointAsCenter(sal_False
);
55 pSdrView
->SetResizeAtCenter(sal_False
);
59 SdrHitKind eHit
= pSdrView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
61 // Only new object; if not in base mode (or pure selection mode)
62 if (rMEvt
.IsLeft() && !m_pWin
->IsDrawAction() &&
63 (eHit
== SDRHIT_UNMARKEDOBJECT
|| eHit
== SDRHIT_NONE
|| m_pSh
->IsDrawCreate()))
66 m_pWin
->CaptureMouse();
68 m_pWin
->SetPointer(Pointer(POINTER_DRAW_RECT
));
70 m_aStartPos
= m_pWin
->PixelToLogic(rMEvt
.GetPosPixel());
71 bReturn
= m_pSh
->BeginCreate( static_cast< sal_uInt16
>(m_pWin
->GetSdrDrawMode()), FmFormInventor
, m_aStartPos
);
74 m_pWin
->SetDrawAction(sal_True
);
77 bReturn
= SwDrawBase::MouseButtonDown(rMEvt
);
82 void ConstFormControl::Activate(const sal_uInt16 nSlotId
)
84 m_pWin
->SetSdrDrawMode( static_cast<SdrObjKind
>(nSlotId
) );
85 SwDrawBase::Activate(nSlotId
);
86 m_pSh
->GetDrawView()->SetCurrentObj(nSlotId
);
88 m_pWin
->SetPointer(Pointer(POINTER_DRAW_RECT
));
91 void ConstFormControl::CreateDefaultObject()
93 Point
aStartPos(GetDefaultCenterPos());
94 Point
aEndPos(aStartPos
);
95 aStartPos
.X() -= 2 * MM50
;
96 aStartPos
.Y() -= MM50
;
97 aEndPos
.X() += 2 * MM50
;
100 if(!m_pSh
->HasDrawView())
101 m_pSh
->MakeDrawView();
103 SdrView
*pSdrView
= m_pSh
->GetDrawView();
104 pSdrView
->SetDesignMode(sal_True
);
105 m_pSh
->BeginCreate( static_cast< sal_uInt16
>(m_pWin
->GetSdrDrawMode()), FmFormInventor
, aStartPos
);
106 m_pSh
->MoveCreate(aEndPos
);
107 m_pSh
->EndCreate(SDRCREATE_FORCEEND
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */