LibreOffice Module sw (master)  1
conform.cxx
Go to the documentation of this file.
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/svdview.hxx>
21 #include <vcl/ptrstyle.hxx>
22 
23 #include <swmodule.hxx>
24 #include <view.hxx>
25 #include <edtwin.hxx>
26 #include <wrtsh.hxx>
27 #include <drawbase.hxx>
28 #include <conform.hxx>
29 
30 ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SdrObjKind eObjKind)
31  : SwDrawBase(pWrtShell, pEditWin, pSwView)
32  , m_eObjKind(eObjKind)
33 {
34  m_bInsForm = true;
35 }
36 
38 {
39  bool bReturn = false;
40 
41  SdrView *pSdrView = m_pSh->GetDrawView();
42 
43  pSdrView->SetOrtho(rMEvt.IsShift());
44  pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
45 
46  if (rMEvt.IsMod2())
47  {
48  pSdrView->SetCreate1stPointAsCenter(true);
49  pSdrView->SetResizeAtCenter(true);
50  }
51  else
52  {
53  pSdrView->SetCreate1stPointAsCenter(false);
54  pSdrView->SetResizeAtCenter(false);
55  }
56 
57  SdrViewEvent aVEvt;
58  SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
59 
60  // Only new object; if not in base mode (or pure selection mode)
61  if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
62  (eHit == SdrHitKind::UnmarkedObject || eHit == SdrHitKind::NONE || m_pSh->IsDrawCreate()))
63  {
64  g_bNoInterrupt = true;
66 
67  m_pWin->SetPointer(PointerStyle::DrawRect);
68 
70  bReturn = m_pSh->BeginCreate(m_pWin->GetSdrDrawMode(), SdrInventor::FmForm, m_aStartPos);
71 
72  if (bReturn)
73  m_pWin->SetDrawAction(true);
74  }
75  else
76  bReturn = SwDrawBase::MouseButtonDown(rMEvt);
77 
78  return bReturn;
79 }
80 
81 void ConstFormControl::Activate(const sal_uInt16 nSlotId)
82 {
84  SwDrawBase::Activate(nSlotId);
86 
87  m_pWin->SetPointer(PointerStyle::DrawRect);
88 }
89 
91 {
92  Point aStartPos(GetDefaultCenterPos());
93  Point aEndPos(aStartPos);
94  aStartPos.AdjustX( -(2 * MM50) );
95  aStartPos.AdjustY( -(MM50) );
96  aEndPos.AdjustX(2 * MM50 );
97  aEndPos.AdjustY(MM50 );
98 
99  if(!m_pSh->HasDrawView())
100  m_pSh->MakeDrawView();
101 
102  SdrView *pSdrView = m_pSh->GetDrawView();
103  pSdrView->SetDesignMode();
104  m_pSh->BeginCreate(m_pWin->GetSdrDrawMode(), SdrInventor::FmForm, aStartPos);
105  m_pSh->MoveCreate(aEndPos);
106  m_pSh->EndCreate(SdrCreateCmd::ForceEnd);
107 }
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CaptureMouse()
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conform.cxx:81
SdrView * GetDrawView()
Definition: vnew.cxx:375
void SetDesignMode(bool bOn=true)
ConstFormControl(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView, SdrObjKind eObjKind)
Definition: conform.cxx:30
Point GetDefaultCenterPos() const
Definition: drawbase.cxx:524
bool m_bInsForm
Definition: drawbase.hxx:41
bool IsShift() const
bool HasDrawView() const
Definition: vnew.cxx:360
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
SdrObjKind m_eObjKind
Definition: conform.hxx:26
SdrHitKind PickAnything(const MouseEvent &rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent &rVEvt) const
SdrObjKind
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void SetResizeAtCenter(bool bOn)
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:215
Point m_aStartPos
Definition: drawbase.hxx:38
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:427
bool BeginCreate(SdrObjKind eSdrObjectKind, const Point &rPos)
Process of creating draw objects.
Definition: feshview.cxx:1679
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
SdrHitKind
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conform.cxx:37
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
bool IsMod2() const
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:62
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:214
Point PixelToLogic(const Point &rDevicePt) const
void SetAngleSnapEnabled(bool bOn)
void SetPointer(PointerStyle)
void MoveCreate(const Point &rPos)
Definition: feshview.cxx:1721
void MakeDrawView()
Definition: vnew.cxx:365
#define MM50
Definition: swtypes.hxx:59
virtual void CreateDefaultObject() override
Definition: conform.cxx:90
void SetOrtho(bool bOn)
bool IsLeft() const
const Point & GetPosPixel() const
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:209
bool g_bNoInterrupt
Definition: swmodule.cxx:114
bool IsDrawAction() const
Definition: edtwin.hxx:208
void SetCreate1stPointAsCenter(bool bOn)
bool IsDrawCreate() const
Definition: feshview.cxx:2131
Definition: view.hxx:144
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1732