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/viewfrm.hxx>
22 #include <svx/sdtacitm.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/sdtagitm.hxx>
25 #include <svx/sdtakitm.hxx>
26 #include <svx/sdtaditm.hxx>
27 #include <svx/sdtaaitm.hxx>
28 #include <svx/svdview.hxx>
29 #include <svx/svdocapt.hxx>
30 #include <editeng/outlobj.hxx>
31 #include <cmdid.h>
32 #include <view.hxx>
33 #include <edtwin.hxx>
34 #include <wrtsh.hxx>
35 #include <drawbase.hxx>
36 #include <conrect.hxx>
37 
39  SwView* pSwView )
40  : SwDrawBase( pWrtShell, pEditWin, pSwView )
41  , bMarquee(false)
42  , bCapVertical(false)
43  , mbVertical(false)
44 {
45 }
46 
48 {
49  bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
50 
51  if (bReturn)
52  {
54  {
55  m_pView->NoRotate();
56  if (m_pView->IsDrawSelMode())
57  {
60  }
61  }
62  else
63  {
65  if (pObj)
66  {
68  SwFEShell::SetLineEnds(aAttr, *pObj, m_nSlotId);
69  pObj->SetMergedItemSet(aAttr);
70  }
71  }
72  }
73 
74  return bReturn;
75 }
76 
78 {
79  bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
80  if( bRet )
81  {
82  SdrView *pSdrView = m_pSh->GetDrawView();
83  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
84  SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
85  : nullptr;
86  switch( m_pWin->GetSdrDrawMode() )
87  {
88  case OBJ_TEXT:
89  if( bMarquee )
90  {
91  m_pSh->ChgAnchor(RndStdIds::FLY_AS_CHAR);
92 
93  if( pObj )
94  {
95  // Set the attributes needed for scrolling
96  SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
98 
99  aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
100  aItemSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
101  aItemSet.Put( SdrTextAniKindItem( SdrTextAniKind::Scroll ) );
102  aItemSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) );
103  aItemSet.Put( SdrTextAniCountItem( 0 ) );
104  aItemSet.Put( SdrTextAniAmountItem(
105  static_cast<sal_Int16>(m_pWin->PixelToLogic(Size(2,1)).Width())) );
106 
107  pObj->SetMergedItemSetAndBroadcast(aItemSet);
108  }
109  }
110  else if(mbVertical)
111  {
112  if (SdrTextObj* pText = dynamic_cast<SdrTextObj*>(pObj))
113  {
114  SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
115 
116  pText->SetVerticalWriting(true);
117 
118  aSet.Put(makeSdrTextAutoGrowWidthItem(true));
119  aSet.Put(makeSdrTextAutoGrowHeightItem(false));
122 
123  pText->SetMergedItemSet(aSet);
124  }
125  }
126 
127  if( pObj )
128  {
129  SdrPageView* pPV = pSdrView->GetSdrPageView();
130  m_pView->BeginTextEdit( pObj, pPV, m_pWin, true );
131  }
132  m_pView->LeaveDrawCreate(); // Switch to selection mode
133  m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
134  break;
135 
136  case OBJ_CAPTION:
137  {
138  SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
139  if( bCapVertical && pCaptObj )
140  {
141  pCaptObj->ForceOutlinerParaObject();
142  OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
143  if( pOPO && !pOPO->IsVertical() )
144  pOPO->SetVertical( true );
145  }
146  }
147  break;
148  default:; //prevent warning
149  }
150  }
151  return bRet;
152 }
153 
154 void ConstRectangle::Activate(const sal_uInt16 nSlotId)
155 {
156  bMarquee = bCapVertical = false;
157  mbVertical = false;
158 
159  switch (nSlotId)
160  {
161  case SID_LINE_ARROW_END:
162  case SID_LINE_ARROW_CIRCLE:
163  case SID_LINE_ARROW_SQUARE:
164  case SID_LINE_ARROW_START:
165  case SID_LINE_CIRCLE_ARROW:
166  case SID_LINE_SQUARE_ARROW:
167  case SID_LINE_ARROWS:
168  case SID_DRAW_LINE:
169  case SID_DRAW_XLINE:
171  break;
172 
173  case SID_DRAW_MEASURELINE:
175  break;
176 
177  case SID_DRAW_RECT:
179  break;
180 
181  case SID_DRAW_ELLIPSE:
183  break;
184 
185  case SID_DRAW_TEXT_MARQUEE:
186  bMarquee = true;
188  break;
189 
190  case SID_DRAW_TEXT_VERTICAL:
191  mbVertical = true;
193  break;
194 
195  case SID_DRAW_TEXT:
197  break;
198 
199  case SID_DRAW_CAPTION_VERTICAL:
200  bCapVertical = true;
201  [[fallthrough]];
202  case SID_DRAW_CAPTION:
204  break;
205 
206  default:
208  break;
209  }
210 
211  SwDrawBase::Activate(nSlotId);
212 }
213 
214 /* 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:2262
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:497
void ForceOutlinerParaObject()
bool IsVertical() const
OBJ_TEXT
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conrect.cxx:47
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:239
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:214
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
static void SetLineEnds(SfxItemSet &rAttr, SdrObject const &rObj, sal_uInt16 nSlotId)
Definition: feshview.cxx:909
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:427
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
bool IsDrawSelMode() const
Definition: view.hxx:516
SdrObject * GetMarkedSdrObj() const
OBJ_LINE
void NoRotate()
Definition: viewdraw.cxx:430
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
void SetVertical(bool bNew)
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:62
bool bCapVertical
Definition: conrect.hxx:29
void LeaveDrawCreate()
Definition: view.hxx:523
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:213
Point PixelToLogic(const Point &rDevicePt) const
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conrect.cxx:154
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:38
const SfxItemPool & GetItemPool() const
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:612
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conrect.cxx:77
SdrModel * GetModel() const
void FlipDrawSelMode()
Definition: view.hxx:518
Definition: view.hxx:144
OBJ_CIRC