1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <sfx2/bindings.hxx>
29cdf0e10cSrcweir #include <svx/htmlmode.hxx>
30cdf0e10cSrcweir #include <svx/sdtacitm.hxx>
31cdf0e10cSrcweir #include <svx/svdobj.hxx>
32cdf0e10cSrcweir #include <svx/sdtagitm.hxx>
33cdf0e10cSrcweir #include <svx/sdtakitm.hxx>
34cdf0e10cSrcweir #include <svx/sdtaditm.hxx>
35cdf0e10cSrcweir #include <svx/sdtaaitm.hxx>
36cdf0e10cSrcweir #include <svx/svdview.hxx>
37cdf0e10cSrcweir #include <svx/svdocapt.hxx>
38cdf0e10cSrcweir #include <editeng/outlobj.hxx>
39cdf0e10cSrcweir #include <cmdid.h>
40cdf0e10cSrcweir #include <view.hxx>
41cdf0e10cSrcweir #include <edtwin.hxx>
42cdf0e10cSrcweir #include <wrtsh.hxx>
43cdf0e10cSrcweir #include <viewopt.hxx>
44cdf0e10cSrcweir #include <drawbase.hxx>
45cdf0e10cSrcweir #include <conrect.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir /*************************************************************************
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir |* Konstruktor
51cdf0e10cSrcweir |*
52cdf0e10cSrcweir \************************************************************************/
53cdf0e10cSrcweir
ConstRectangle(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)54cdf0e10cSrcweir ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
55cdf0e10cSrcweir SwView* pSwView )
56cdf0e10cSrcweir : SwDrawBase( pWrtShell, pEditWin, pSwView ),
57cdf0e10cSrcweir bMarquee(sal_False),
58cdf0e10cSrcweir // #93382#
59cdf0e10cSrcweir mbVertical(sal_False)
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir /*************************************************************************
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* MouseButtonDown-event
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir \************************************************************************/
68cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)69cdf0e10cSrcweir sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir sal_Bool bReturn;
72cdf0e10cSrcweir
73cdf0e10cSrcweir if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
74cdf0e10cSrcweir && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir m_pView->NoRotate();
77cdf0e10cSrcweir if (m_pView->IsDrawSelMode())
78cdf0e10cSrcweir {
79cdf0e10cSrcweir m_pView->FlipDrawSelMode();
80cdf0e10cSrcweir m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
81cdf0e10cSrcweir }
82cdf0e10cSrcweir }
83cdf0e10cSrcweir return (bReturn);
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir /*************************************************************************
87cdf0e10cSrcweir |*
88cdf0e10cSrcweir |* MouseButtonUp-event
89cdf0e10cSrcweir |*
90cdf0e10cSrcweir \************************************************************************/
91cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)92cdf0e10cSrcweir sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
95cdf0e10cSrcweir
96cdf0e10cSrcweir sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
97cdf0e10cSrcweir if( bRet )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir SdrView *pSdrView = m_pSh->GetDrawView();
100cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
101cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
102cdf0e10cSrcweir : 0;
103cdf0e10cSrcweir switch( m_pWin->GetSdrDrawMode() )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir case OBJ_TEXT:
106cdf0e10cSrcweir if( bMarquee )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir m_pSh->ChgAnchor(FLY_AS_CHAR);
109cdf0e10cSrcweir
110cdf0e10cSrcweir if( pObj )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir // die fuer das Scrollen benoetigten Attribute setzen
113cdf0e10cSrcweir SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
114cdf0e10cSrcweir SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
115cdf0e10cSrcweir
116cdf0e10cSrcweir aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
117cdf0e10cSrcweir aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
118cdf0e10cSrcweir aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
119cdf0e10cSrcweir aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
120cdf0e10cSrcweir aItemSet.Put( SdrTextAniCountItem( 0 ) );
121cdf0e10cSrcweir aItemSet.Put( SdrTextAniAmountItem(
122cdf0e10cSrcweir (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
123cdf0e10cSrcweir
124cdf0e10cSrcweir pObj->SetMergedItemSetAndBroadcast(aItemSet);
125cdf0e10cSrcweir }
126cdf0e10cSrcweir }
127cdf0e10cSrcweir else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
128cdf0e10cSrcweir {
129cdf0e10cSrcweir // #93382#
130cdf0e10cSrcweir SdrTextObj* pText = (SdrTextObj*)pObj;
131cdf0e10cSrcweir SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
132cdf0e10cSrcweir
133cdf0e10cSrcweir pText->SetVerticalWriting(sal_True);
134cdf0e10cSrcweir
135cdf0e10cSrcweir aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
136cdf0e10cSrcweir aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
137cdf0e10cSrcweir aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
138cdf0e10cSrcweir aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
139cdf0e10cSrcweir
140cdf0e10cSrcweir pText->SetMergedItemSet(aSet);
141cdf0e10cSrcweir }
142cdf0e10cSrcweir if( pObj )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir SdrPageView* pPV = pSdrView->GetSdrPageView();
145cdf0e10cSrcweir m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
148cdf0e10cSrcweir m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
149cdf0e10cSrcweir break;
150cdf0e10cSrcweir
151cdf0e10cSrcweir case OBJ_CAPTION:
152cdf0e10cSrcweir {
153cdf0e10cSrcweir SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
154cdf0e10cSrcweir if( bCapVertical && pCaptObj )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir pCaptObj->ForceOutlinerParaObject();
157cdf0e10cSrcweir OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
158cdf0e10cSrcweir if( pOPO && !pOPO->IsVertical() )
159cdf0e10cSrcweir pOPO->SetVertical( sal_True );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir }
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir default:; //prevent warning
164cdf0e10cSrcweir }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir return bRet;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir /*************************************************************************
170cdf0e10cSrcweir |*
171cdf0e10cSrcweir |* Function aktivieren
172cdf0e10cSrcweir |*
173cdf0e10cSrcweir \************************************************************************/
174cdf0e10cSrcweir
Activate(const sal_uInt16 nSlotId)175cdf0e10cSrcweir void ConstRectangle::Activate(const sal_uInt16 nSlotId)
176cdf0e10cSrcweir {
177cdf0e10cSrcweir bMarquee = bCapVertical = sal_False;
178cdf0e10cSrcweir mbVertical = sal_False;
179cdf0e10cSrcweir
180cdf0e10cSrcweir switch (nSlotId)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir case SID_DRAW_LINE:
183cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_LINE);
184cdf0e10cSrcweir break;
185cdf0e10cSrcweir
186cdf0e10cSrcweir case SID_DRAW_RECT:
187cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_RECT);
188cdf0e10cSrcweir break;
189cdf0e10cSrcweir
190cdf0e10cSrcweir case SID_DRAW_ELLIPSE:
191cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_CIRC);
192cdf0e10cSrcweir break;
193cdf0e10cSrcweir
194cdf0e10cSrcweir case SID_DRAW_TEXT_MARQUEE:
195cdf0e10cSrcweir bMarquee = sal_True;
196cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_TEXT);
197cdf0e10cSrcweir break;
198cdf0e10cSrcweir
199cdf0e10cSrcweir case SID_DRAW_TEXT_VERTICAL:
200cdf0e10cSrcweir // #93382#
201cdf0e10cSrcweir mbVertical = sal_True;
202cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_TEXT);
203cdf0e10cSrcweir break;
204cdf0e10cSrcweir
205cdf0e10cSrcweir case SID_DRAW_TEXT:
206cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_TEXT);
207cdf0e10cSrcweir break;
208cdf0e10cSrcweir
209cdf0e10cSrcweir case SID_DRAW_CAPTION_VERTICAL:
210cdf0e10cSrcweir bCapVertical = sal_True;
211cdf0e10cSrcweir // no break
212cdf0e10cSrcweir case SID_DRAW_CAPTION:
213cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_CAPTION);
214cdf0e10cSrcweir break;
215cdf0e10cSrcweir
216cdf0e10cSrcweir default:
217cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_NONE);
218cdf0e10cSrcweir break;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir SwDrawBase::Activate(nSlotId);
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir
225cdf0e10cSrcweir
226