1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
35 #include <drawbase.hxx>
36 #include <conrect.hxx>
38 ConstRectangle::ConstRectangle( SwWrtShell
* pWrtShell
, SwEditWin
* pEditWin
,
40 : SwDrawBase( pWrtShell
, pEditWin
, pSwView
)
42 , m_bCapVertical(false)
47 bool ConstRectangle::MouseButtonDown(const MouseEvent
& rMEvt
)
49 bool bReturn
= SwDrawBase::MouseButtonDown(rMEvt
);
53 if (m_pWin
->GetSdrDrawMode() == SdrObjKind::Caption
)
56 if (m_pView
->IsDrawSelMode())
58 m_pView
->FlipDrawSelMode();
59 m_pSh
->GetDrawView()->SetFrameDragSingles(m_pView
->IsDrawSelMode());
64 SdrObject
* pObj
= m_pView
->GetDrawView()->GetCreateObj();
67 SfxItemSet
aAttr(pObj
->getSdrModelFromSdrObject().GetItemPool());
68 SwFEShell::SetLineEnds(aAttr
, *pObj
, m_nSlotId
);
69 pObj
->SetMergedItemSet(aAttr
);
77 bool ConstRectangle::MouseButtonUp(const MouseEvent
& rMEvt
)
79 bool bRet
= SwDrawBase::MouseButtonUp(rMEvt
);
82 SdrView
*pSdrView
= m_pSh
->GetDrawView();
83 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
84 SdrObject
* pObj
= rMarkList
.GetMark(0) ? rMarkList
.GetMark(0)->GetMarkedSdrObj()
86 switch( m_pWin
->GetSdrDrawMode() )
88 case SdrObjKind::Text
:
91 m_pSh
->ChgAnchor(RndStdIds::FLY_AS_CHAR
);
95 // Set the attributes needed for scrolling
96 SfxItemSetFixed
<SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
>
97 aItemSet(pSdrView
->GetModel().GetItemPool());
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())) );
107 pObj
->SetMergedItemSetAndBroadcast(aItemSet
);
112 if (SdrTextObj
* pText
= DynCastSdrTextObj(pObj
))
114 SfxItemSet
aSet(pSdrView
->GetModel().GetItemPool());
116 pText
->SetVerticalWriting(true);
118 aSet
.Put(makeSdrTextAutoGrowWidthItem(true));
119 aSet
.Put(makeSdrTextAutoGrowHeightItem(false));
120 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
));
121 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
123 pText
->SetMergedItemSet(aSet
);
129 SdrPageView
* pPV
= pSdrView
->GetSdrPageView();
130 m_pView
->BeginTextEdit( pObj
, pPV
, m_pWin
, true );
132 m_pView
->LeaveDrawCreate(); // Switch to selection mode
133 m_pSh
->GetView().GetViewFrame().GetBindings().Invalidate(SID_INSERT_DRAW
);
136 case SdrObjKind::Caption
:
138 SdrCaptionObj
* pCaptObj
= dynamic_cast<SdrCaptionObj
*>(pObj
);
139 if( m_bCapVertical
&& pCaptObj
)
141 pCaptObj
->ForceOutlinerParaObject();
142 OutlinerParaObject
* pOPO
= pCaptObj
->GetOutlinerParaObject();
143 if( pOPO
&& !pOPO
->IsEffectivelyVertical() )
144 pOPO
->SetVertical( true );
148 default:; //prevent warning
154 void ConstRectangle::Activate(const sal_uInt16 nSlotId
)
156 m_bMarquee
= m_bCapVertical
= false;
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
:
170 m_pWin
->SetSdrDrawMode(SdrObjKind::Line
);
173 case SID_DRAW_MEASURELINE
:
174 m_pWin
->SetSdrDrawMode(SdrObjKind::Measure
);
178 m_pWin
->SetSdrDrawMode(SdrObjKind::Rectangle
);
181 case SID_DRAW_ELLIPSE
:
182 m_pWin
->SetSdrDrawMode(SdrObjKind::CircleOrEllipse
);
185 case SID_DRAW_TEXT_MARQUEE
:
187 m_pWin
->SetSdrDrawMode(SdrObjKind::Text
);
190 case SID_DRAW_TEXT_VERTICAL
:
192 m_pWin
->SetSdrDrawMode(SdrObjKind::Text
);
196 m_pWin
->SetSdrDrawMode(SdrObjKind::Text
);
199 case SID_DRAW_CAPTION_VERTICAL
:
200 m_bCapVertical
= true;
202 case SID_DRAW_CAPTION
:
203 m_pWin
->SetSdrDrawMode(SdrObjKind::Caption
);
207 m_pWin
->SetSdrDrawMode(SdrObjKind::NONE
);
211 SwDrawBase::Activate(nSlotId
);
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */