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 , m_bMarquee(false)
42 , m_bCapVertical(false)
43 , mbVertical(false)
44{
45}
46
48{
49 bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
50
51 if (bReturn)
52 {
53 if (m_pWin->GetSdrDrawMode() == SdrObjKind::Caption)
54 {
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 SdrObjKind::Text:
89 if( m_bMarquee )
90 {
91 m_pSh->ChgAnchor(RndStdIds::FLY_AS_CHAR);
92
93 if( pObj )
94 {
95 // Set the attributes needed for scrolling
97 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 = DynCastSdrTextObj(pObj))
113 {
114 SfxItemSet aSet(pSdrView->GetModel().GetItemPool());
115
116 pText->SetVerticalWriting(true);
117
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 SdrObjKind::Caption:
137 {
138 SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
139 if( m_bCapVertical && pCaptObj )
140 {
141 pCaptObj->ForceOutlinerParaObject();
142 OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
143 if( pOPO && !pOPO->IsEffectivelyVertical() )
144 pOPO->SetVertical( true );
145 }
146 }
147 break;
148 default:; //prevent warning
149 }
150 }
151 return bRet;
152}
153
154void ConstRectangle::Activate(const sal_uInt16 nSlotId)
155{
156 m_bMarquee = m_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:
170 m_pWin->SetSdrDrawMode(SdrObjKind::Line);
171 break;
172
173 case SID_DRAW_MEASURELINE:
174 m_pWin->SetSdrDrawMode(SdrObjKind::Measure);
175 break;
176
177 case SID_DRAW_RECT:
178 m_pWin->SetSdrDrawMode(SdrObjKind::Rectangle);
179 break;
180
181 case SID_DRAW_ELLIPSE:
182 m_pWin->SetSdrDrawMode(SdrObjKind::CircleOrEllipse);
183 break;
184
185 case SID_DRAW_TEXT_MARQUEE:
186 m_bMarquee = true;
187 m_pWin->SetSdrDrawMode(SdrObjKind::Text);
188 break;
189
190 case SID_DRAW_TEXT_VERTICAL:
191 mbVertical = true;
192 m_pWin->SetSdrDrawMode(SdrObjKind::Text);
193 break;
194
195 case SID_DRAW_TEXT:
196 m_pWin->SetSdrDrawMode(SdrObjKind::Text);
197 break;
198
199 case SID_DRAW_CAPTION_VERTICAL:
200 m_bCapVertical = true;
201 [[fallthrough]];
202 case SID_DRAW_CAPTION:
203 m_pWin->SetSdrDrawMode(SdrObjKind::Caption);
204 break;
205
206 default:
207 m_pWin->SetSdrDrawMode(SdrObjKind::NONE);
208 break;
209 }
210
211 SwDrawBase::Activate(nSlotId);
212}
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bMarquee
Definition: conrect.hxx:28
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conrect.cxx:77
ConstRectangle(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conrect.cxx:38
bool m_bCapVertical
Definition: conrect.hxx:29
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conrect.cxx:47
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conrect.cxx:154
bool mbVertical
Definition: conrect.hxx:31
void SetVertical(bool bNew)
bool IsEffectivelyVertical() const
SdrObject * GetCreateObj() const
SdrMark * GetMark(size_t nNum) const
void SetFrameDragSingles(bool bOn=true)
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrModel & getSdrModelFromSdrObject() const
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
virtual OutlinerParaObject * GetOutlinerParaObject() const override
void ForceOutlinerParaObject()
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxBindings & GetBindings()
SfxViewFrame & GetViewFrame() const
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:432
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
SwView * m_pView
Definition: drawbase.hxx:35
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:62
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: drawbase.cxx:239
sal_uInt16 m_nSlotId
Definition: drawbase.hxx:39
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2239
static void SetLineEnds(SfxItemSet &rAttr, SdrObject const &rObj, sal_uInt16 nSlotId)
Definition: feshview.cxx:923
SdrView * GetDrawView()
Definition: vnew.cxx:386
Definition: view.hxx:146
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:507
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:621
void NoRotate()
Definition: viewdraw.cxx:439
bool IsDrawSelMode() const
Definition: view.hxx:542
void FlipDrawSelMode()
Definition: view.hxx:544
void LeaveDrawCreate()
Definition: view.hxx:549
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
const SwView & GetView() const
Definition: wrtsh.hxx:443
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
SDRTEXTVERTADJUST_TOP
SDRTEXTHORZADJUST_RIGHT
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)