Update ooo320-m1
[ooovba.git] / sw / source / ui / ribbar / conrect.cxx
blob2bd57967d261f578f16120763138a595d549b22f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conrect.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <sfx2/bindings.hxx>
36 #include <svx/htmlmode.hxx>
37 #include <svx/sdtacitm.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/sdtagitm.hxx>
40 #include <svx/sdtakitm.hxx>
41 #include <svx/sdtaditm.hxx>
42 #include <svx/sdtaaitm.hxx>
43 #include <svx/svdview.hxx>
44 #include <svx/svdocapt.hxx>
45 #include <svx/outlobj.hxx>
46 #ifndef _CMDID_H
47 #include <cmdid.h>
48 #endif
49 #ifndef _VIEW_HXX
50 #include <view.hxx>
51 #endif
52 #include <edtwin.hxx>
53 #include <wrtsh.hxx>
54 #include <viewopt.hxx>
55 #ifndef _DRAWBASE_HXX
56 #include <drawbase.hxx>
57 #endif
58 #ifndef _CONRECT_HXX
59 #include <conrect.hxx>
60 #endif
62 /*************************************************************************
64 |* Konstruktor
66 \************************************************************************/
68 ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
69 SwView* pSwView )
70 : SwDrawBase( pWrtShell, pEditWin, pSwView ),
71 bMarquee(FALSE),
72 // #93382#
73 mbVertical(sal_False)
77 /*************************************************************************
79 |* MouseButtonDown-event
81 \************************************************************************/
83 BOOL ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
85 BOOL bReturn;
87 if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == TRUE
88 && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
90 m_pView->NoRotate();
91 if (m_pView->IsDrawSelMode())
93 m_pView->FlipDrawSelMode();
94 m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
97 return (bReturn);
100 /*************************************************************************
102 |* MouseButtonUp-event
104 \************************************************************************/
106 BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
108 Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
110 BOOL bRet = SwDrawBase::MouseButtonUp(rMEvt);
111 if( bRet )
113 SdrView *pSdrView = m_pSh->GetDrawView();
114 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
115 SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
116 : 0;
117 switch( m_pWin->GetSdrDrawMode() )
119 case OBJ_TEXT:
120 if( bMarquee )
122 m_pSh->ChgAnchor(FLY_IN_CNTNT);
124 if( pObj )
126 // die fuer das Scrollen benoetigten Attribute setzen
127 SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
128 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
130 aItemSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
131 aItemSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
132 aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
133 aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
134 aItemSet.Put( SdrTextAniCountItem( 0 ) );
135 aItemSet.Put( SdrTextAniAmountItem(
136 (INT16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
138 pObj->SetMergedItemSetAndBroadcast(aItemSet);
141 else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
143 // #93382#
144 SdrTextObj* pText = (SdrTextObj*)pObj;
145 SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
147 pText->SetVerticalWriting(TRUE);
149 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
150 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
151 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
152 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
154 pText->SetMergedItemSet(aSet);
156 if( pObj )
158 SdrPageView* pPV = pSdrView->GetSdrPageView();
159 m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
161 m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
162 m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
163 break;
165 case OBJ_CAPTION:
167 SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
168 if( bCapVertical && pCaptObj )
170 pCaptObj->ForceOutlinerParaObject();
171 OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
172 if( pOPO && !pOPO->IsVertical() )
173 pOPO->SetVertical( TRUE );
176 break;
177 default:; //prevent warning
180 return bRet;
183 /*************************************************************************
185 |* Function aktivieren
187 \************************************************************************/
189 void ConstRectangle::Activate(const USHORT nSlotId)
191 bMarquee = bCapVertical = FALSE;
192 mbVertical = sal_False;
194 switch (nSlotId)
196 case SID_DRAW_LINE:
197 m_pWin->SetSdrDrawMode(OBJ_LINE);
198 break;
200 case SID_DRAW_RECT:
201 m_pWin->SetSdrDrawMode(OBJ_RECT);
202 break;
204 case SID_DRAW_ELLIPSE:
205 m_pWin->SetSdrDrawMode(OBJ_CIRC);
206 break;
208 case SID_DRAW_TEXT_MARQUEE:
209 bMarquee = TRUE;
210 m_pWin->SetSdrDrawMode(OBJ_TEXT);
211 break;
213 case SID_DRAW_TEXT_VERTICAL:
214 // #93382#
215 mbVertical = sal_True;
216 m_pWin->SetSdrDrawMode(OBJ_TEXT);
217 break;
219 case SID_DRAW_TEXT:
220 m_pWin->SetSdrDrawMode(OBJ_TEXT);
221 break;
223 case SID_DRAW_CAPTION_VERTICAL:
224 bCapVertical = TRUE;
225 // no break
226 case SID_DRAW_CAPTION:
227 m_pWin->SetSdrDrawMode(OBJ_CAPTION);
228 break;
230 default:
231 m_pWin->SetSdrDrawMode(OBJ_NONE);
232 break;
235 SwDrawBase::Activate(nSlotId);