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/fmglob.hxx>
21 #include <svx/svdview.hxx>
22 #include <svx/fmshell.hxx>
23 #include <vcl/ptrstyle.hxx>
24 
25 #include <swmodule.hxx>
26 #include <view.hxx>
27 #include <edtwin.hxx>
28 #include <wrtsh.hxx>
29 #include <drawbase.hxx>
30 #include <conform.hxx>
31 
33  SwDrawBase(pWrtShell, pEditWin, pSwView)
34 {
35  m_bInsForm = true;
36 }
37 
39 {
40  bool bReturn = false;
41 
42  SdrView *pSdrView = m_pSh->GetDrawView();
43 
44  pSdrView->SetOrtho(rMEvt.IsShift());
45  pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
46 
47  if (rMEvt.IsMod2())
48  {
49  pSdrView->SetCreate1stPointAsCenter(true);
50  pSdrView->SetResizeAtCenter(true);
51  }
52  else
53  {
54  pSdrView->SetCreate1stPointAsCenter(false);
55  pSdrView->SetResizeAtCenter(false);
56  }
57 
58  SdrViewEvent aVEvt;
59  SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
60 
61  // Only new object; if not in base mode (or pure selection mode)
62  if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
63  (eHit == SdrHitKind::UnmarkedObject || eHit == SdrHitKind::NONE || m_pSh->IsDrawCreate()))
64  {
65  g_bNoInterrupt = true;
67 
68  m_pWin->SetPointer(PointerStyle::DrawRect);
69 
71  bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), SdrInventor::FmForm, m_aStartPos);
72 
73  if (bReturn)
74  m_pWin->SetDrawAction(true);
75  }
76  else
77  bReturn = SwDrawBase::MouseButtonDown(rMEvt);
78 
79  return bReturn;
80 }
81 
82 void ConstFormControl::Activate(const sal_uInt16 nSlotId)
83 {
84  m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
85  SwDrawBase::Activate(nSlotId);
86  m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
87 
88  m_pWin->SetPointer(PointerStyle::DrawRect);
89 }
90 
92 {
93  Point aStartPos(GetDefaultCenterPos());
94  Point aEndPos(aStartPos);
95  aStartPos.AdjustX( -(2 * MM50) );
96  aStartPos.AdjustY( -(MM50) );
97  aEndPos.AdjustX(2 * MM50 );
98  aEndPos.AdjustY(MM50 );
99 
100  if(!m_pSh->HasDrawView())
101  m_pSh->MakeDrawView();
102 
103  SdrView *pSdrView = m_pSh->GetDrawView();
104  pSdrView->SetDesignMode();
105  m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), SdrInventor::FmForm, aStartPos);
106  m_pSh->MoveCreate(aEndPos);
107  m_pSh->EndCreate(SdrCreateCmd::ForceEnd);
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CaptureMouse()
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conform.cxx:82
SdrView * GetDrawView()
Definition: vnew.cxx:375
void SetDesignMode(bool bOn=true)
long AdjustX(long nHorzMove)
Point GetDefaultCenterPos() const
Definition: drawbase.cxx:526
bool m_bInsForm
Definition: drawbase.hxx:41
bool IsShift() const
bool HasDrawView() const
Definition: vnew.cxx:360
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
SdrHitKind PickAnything(const MouseEvent &rMEvt, SdrMouseEventKind nMouseDownOrMoveOrUp, SdrViewEvent &rVEvt) const
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void SetResizeAtCenter(bool bOn)
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:212
Point m_aStartPos
Definition: drawbase.hxx:38
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:429
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
SdrHitKind
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conform.cxx:38
long AdjustY(long nVertMove)
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
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:64
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:211
Point PixelToLogic(const Point &rDevicePt) const
void SetAngleSnapEnabled(bool bOn)
void SetPointer(PointerStyle)
void MoveCreate(const Point &rPos)
Definition: feshview.cxx:1730
void MakeDrawView()
Definition: vnew.cxx:365
#define MM50
Definition: swtypes.hxx:59
virtual void CreateDefaultObject() override
Definition: conform.cxx:91
void SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent=SdrInventor::Default)
void SetOrtho(bool bOn)
bool IsLeft() const
const Point & GetPosPixel() const
bool BeginCreate(sal_uInt16 eSdrObjectKind, const Point &rPos)
Process of creating draw objects.
Definition: feshview.cxx:1688
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:206
bool g_bNoInterrupt
Definition: swmodule.cxx:137
ConstFormControl(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conform.cxx:32
bool IsDrawAction() const
Definition: edtwin.hxx:205
void SetCreate1stPointAsCenter(bool bOn)
bool IsDrawCreate() const
Definition: feshview.cxx:2139
Definition: view.hxx:146
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1741