LibreOffice Module sw (master)  1
conrect.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 <sfx2/bindings.hxx>
21 #include <sfx2/htmlmode.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <svx/sdtacitm.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/sdtagitm.hxx>
26 #include <svx/sdtakitm.hxx>
27 #include <svx/sdtaditm.hxx>
28 #include <svx/sdtaaitm.hxx>
29 #include <svx/svdview.hxx>
30 #include <svx/svdocapt.hxx>
31 #include <svx/svxids.hrc>
32 #include <editeng/outlobj.hxx>
33 #include <cmdid.h>
34 #include <view.hxx>
35 #include <edtwin.hxx>
36 #include <wrtsh.hxx>
37 #include <viewopt.hxx>
38 #include <drawbase.hxx>
39 #include <conrect.hxx>
40 
42  SwView* pSwView )
43  : SwDrawBase( pWrtShell, pEditWin, pSwView )
44  , bMarquee(false)
45  , bCapVertical(false)
46  , mbVertical(false)
47 {
48 }
49 
51 {
52  bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
53 
54  if (bReturn)
55  {
57  {
58  m_pView->NoRotate();
59  if (m_pView->IsDrawSelMode())
60  {
63  }
64  }
65  else
66  {
68  if (pObj)
69  {
71  SwFEShell::SetLineEnds(aAttr, *pObj, m_nSlotId);
72  pObj->SetMergedItemSet(aAttr);
73  }
74  }
75  }
76 
77  return bReturn;
78 }
79 
81 {
82  bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
83  if( bRet )
84  {
85  SdrView *pSdrView = m_pSh->GetDrawView();
86  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
87  SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
88  : nullptr;
89  switch( m_pWin->GetSdrDrawMode() )
90  {
91  case OBJ_TEXT:
92  if( bMarquee )
93  {
94  m_pSh->ChgAnchor(RndStdIds::FLY_AS_CHAR);
95 
96  if( pObj )
97  {
98  // Set the attributes needed for scrolling
99  SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
101 
102  aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
103  aItemSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
104  aItemSet.Put( SdrTextAniKindItem( SdrTextAniKind::Scroll ) );
105  aItemSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) );
106  aItemSet.Put( SdrTextAniCountItem( 0 ) );
107  aItemSet.Put( SdrTextAniAmountItem(
108  static_cast<sal_Int16>(m_pWin->PixelToLogic(Size(2,1)).Width())) );
109 
110  pObj->SetMergedItemSetAndBroadcast(aItemSet);
111  }
112  }
113  else if(mbVertical)
114  {
115  if (SdrTextObj* pText = dynamic_cast<SdrTextObj*>(pObj))
116  {
117  SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
118 
119  pText->SetVerticalWriting(true);
120 
121  aSet.Put(makeSdrTextAutoGrowWidthItem(true));
122  aSet.Put(makeSdrTextAutoGrowHeightItem(false));
125 
126  pText->SetMergedItemSet(aSet);
127  }
128  }
129 
130  if( pObj )
131  {
132  SdrPageView* pPV = pSdrView->GetSdrPageView();
133  m_pView->BeginTextEdit( pObj, pPV, m_pWin, true );
134  }
135  m_pView->LeaveDrawCreate(); // Switch to selection mode
136  m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
137  break;
138 
139  case OBJ_CAPTION:
140  {
141  SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
142  if( bCapVertical && pCaptObj )
143  {
144  pCaptObj->ForceOutlinerParaObject();
145  OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
146  if( pOPO && !pOPO->IsVertical() )
147  pOPO->SetVertical( true );
148  }
149  }
150  break;
151  default:; //prevent warning
152  }
153  }
154  return bRet;
155 }
156 
157 void ConstRectangle::Activate(const sal_uInt16 nSlotId)
158 {
159  bMarquee = bCapVertical = false;
160  mbVertical = false;
161 
162  switch (nSlotId)
163  {
164  case SID_LINE_ARROW_END:
165  case SID_LINE_ARROW_CIRCLE:
166  case SID_LINE_ARROW_SQUARE:
167  case SID_LINE_ARROW_START:
168  case SID_LINE_CIRCLE_ARROW:
169  case SID_LINE_SQUARE_ARROW:
170  case SID_LINE_ARROWS:
171  case SID_DRAW_LINE:
172  case SID_DRAW_XLINE:
174  break;
175 
176  case SID_DRAW_MEASURELINE:
178  break;
179 
180  case SID_DRAW_RECT:
182  break;
183 
184  case SID_DRAW_ELLIPSE:
186  break;
187 
188  case SID_DRAW_TEXT_MARQUEE:
189  bMarquee = true;
191  break;
192 
193  case SID_DRAW_TEXT_VERTICAL:
194  mbVertical = true;
196  break;
197 
198  case SID_DRAW_TEXT:
200  break;
201 
202  case SID_DRAW_CAPTION_VERTICAL:
203  bCapVertical = true;
204  [[fallthrough]];
205  case SID_DRAW_CAPTION:
207  break;
208 
209  default:
211  break;
212  }
213 
214  SwDrawBase::Activate(nSlotId);
215 }
216 
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
SDRTEXTVERTADJUST_TOP
bool mbVertical
Definition: conrect.hxx:31
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2270
SdrView * GetDrawView()
Definition: vnew.cxx:375
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:507
void ForceOutlinerParaObject()
bool IsVertical() const
OBJ_TEXT
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conrect.cxx:50
sal_uInt16 m_nSlotId
Definition: drawbase.hxx:39
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
SdrMark * GetMark(size_t nNum) const
void SetFrameDragSingles(bool bOn=true)
void Invalidate(sal_uInt16 nId)
OBJ_MEASURE
OBJ_RECT
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: drawbase.cxx:241
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
const SwView & GetView() const
Definition: wrtsh.hxx:428
OBJ_CAPTION
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:212
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
static void SetLineEnds(SfxItemSet &rAttr, SdrObject const &rObj, sal_uInt16 nSlotId)
Definition: feshview.cxx:910
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:429
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
bool IsDrawSelMode() const
Definition: view.hxx:518
SdrObject * GetMarkedSdrObj() const
OBJ_LINE
void NoRotate()
Definition: viewdraw.cxx:440
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
SdrObject * GetCreateObj() const
OBJ_NONE
SfxBindings & GetBindings()
const SdrMarkList & GetMarkedObjectList() const
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrModel & getSdrModelFromSdrObject() const
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:64
bool bCapVertical
Definition: conrect.hxx:29
void LeaveDrawCreate()
Definition: view.hxx:525
void SetVertical(bool bNew, bool bTopToBottom=true)
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:211
Point PixelToLogic(const Point &rDevicePt) const
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conrect.cxx:157
SDRTEXTHORZADJUST_RIGHT
virtual OutlinerParaObject * GetOutlinerParaObject() const override
SwView * m_pView
Definition: drawbase.hxx:35
SdrPageView * GetSdrPageView() const
ConstRectangle(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conrect.cxx:41
const SfxItemPool & GetItemPool() const
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:622
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conrect.cxx:80
SdrModel * GetModel() const
void FlipDrawSelMode()
Definition: view.hxx:520
Definition: view.hxx:146
OBJ_CIRC