xref: /AOO41X/main/sw/source/ui/ribbar/conrect.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
33*cdf0e10cSrcweir #include <svx/htmlmode.hxx>
34*cdf0e10cSrcweir #include <svx/sdtacitm.hxx>
35*cdf0e10cSrcweir #include <svx/svdobj.hxx>
36*cdf0e10cSrcweir #include <svx/sdtagitm.hxx>
37*cdf0e10cSrcweir #include <svx/sdtakitm.hxx>
38*cdf0e10cSrcweir #include <svx/sdtaditm.hxx>
39*cdf0e10cSrcweir #include <svx/sdtaaitm.hxx>
40*cdf0e10cSrcweir #include <svx/svdview.hxx>
41*cdf0e10cSrcweir #include <svx/svdocapt.hxx>
42*cdf0e10cSrcweir #include <editeng/outlobj.hxx>
43*cdf0e10cSrcweir #include <cmdid.h>
44*cdf0e10cSrcweir #include <view.hxx>
45*cdf0e10cSrcweir #include <edtwin.hxx>
46*cdf0e10cSrcweir #include <wrtsh.hxx>
47*cdf0e10cSrcweir #include <viewopt.hxx>
48*cdf0e10cSrcweir #include <drawbase.hxx>
49*cdf0e10cSrcweir #include <conrect.hxx>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir /*************************************************************************
53*cdf0e10cSrcweir |*
54*cdf0e10cSrcweir |* Konstruktor
55*cdf0e10cSrcweir |*
56*cdf0e10cSrcweir \************************************************************************/
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
59*cdf0e10cSrcweir 								SwView* pSwView )
60*cdf0e10cSrcweir 	: SwDrawBase( pWrtShell, pEditWin, pSwView ),
61*cdf0e10cSrcweir 	bMarquee(sal_False),
62*cdf0e10cSrcweir 	// #93382#
63*cdf0e10cSrcweir 	mbVertical(sal_False)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir /*************************************************************************
68*cdf0e10cSrcweir |*
69*cdf0e10cSrcweir |* MouseButtonDown-event
70*cdf0e10cSrcweir |*
71*cdf0e10cSrcweir \************************************************************************/
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir 	sal_Bool bReturn;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
78*cdf0e10cSrcweir                                     && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
79*cdf0e10cSrcweir 	{
80*cdf0e10cSrcweir         m_pView->NoRotate();
81*cdf0e10cSrcweir         if (m_pView->IsDrawSelMode())
82*cdf0e10cSrcweir 		{
83*cdf0e10cSrcweir             m_pView->FlipDrawSelMode();
84*cdf0e10cSrcweir             m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
85*cdf0e10cSrcweir 		}
86*cdf0e10cSrcweir 	}
87*cdf0e10cSrcweir 	return (bReturn);
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir /*************************************************************************
91*cdf0e10cSrcweir |*
92*cdf0e10cSrcweir |* MouseButtonUp-event
93*cdf0e10cSrcweir |*
94*cdf0e10cSrcweir \************************************************************************/
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
101*cdf0e10cSrcweir 	if( bRet )
102*cdf0e10cSrcweir 	{
103*cdf0e10cSrcweir         SdrView *pSdrView = m_pSh->GetDrawView();
104*cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
105*cdf0e10cSrcweir 		SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
106*cdf0e10cSrcweir 											   : 0;
107*cdf0e10cSrcweir         switch( m_pWin->GetSdrDrawMode() )
108*cdf0e10cSrcweir 		{
109*cdf0e10cSrcweir 		case OBJ_TEXT:
110*cdf0e10cSrcweir 			if( bMarquee )
111*cdf0e10cSrcweir 			{
112*cdf0e10cSrcweir                 m_pSh->ChgAnchor(FLY_AS_CHAR);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 				if( pObj )
115*cdf0e10cSrcweir 				{
116*cdf0e10cSrcweir 					// die fuer das Scrollen benoetigten Attribute setzen
117*cdf0e10cSrcweir 					SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
118*cdf0e10cSrcweir 										SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
121*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
122*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
123*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
124*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniCountItem( 0 ) );
125*cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniAmountItem(
126*cdf0e10cSrcweir                             (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 					pObj->SetMergedItemSetAndBroadcast(aItemSet);
129*cdf0e10cSrcweir 				}
130*cdf0e10cSrcweir 			}
131*cdf0e10cSrcweir 			else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
132*cdf0e10cSrcweir 			{
133*cdf0e10cSrcweir 				// #93382#
134*cdf0e10cSrcweir 				SdrTextObj* pText = (SdrTextObj*)pObj;
135*cdf0e10cSrcweir 				SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 				pText->SetVerticalWriting(sal_True);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
140*cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
141*cdf0e10cSrcweir 				aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
142*cdf0e10cSrcweir 				aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 				pText->SetMergedItemSet(aSet);
145*cdf0e10cSrcweir 			}
146*cdf0e10cSrcweir 			if( pObj )
147*cdf0e10cSrcweir 			{
148*cdf0e10cSrcweir 				SdrPageView* pPV = pSdrView->GetSdrPageView();
149*cdf0e10cSrcweir                 m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
150*cdf0e10cSrcweir 			}
151*cdf0e10cSrcweir             m_pView->LeaveDrawCreate();  // In Selektionsmode wechseln
152*cdf0e10cSrcweir             m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
153*cdf0e10cSrcweir 			break;
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		case OBJ_CAPTION:
156*cdf0e10cSrcweir         {
157*cdf0e10cSrcweir             SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
158*cdf0e10cSrcweir             if( bCapVertical && pCaptObj )
159*cdf0e10cSrcweir 			{
160*cdf0e10cSrcweir 				pCaptObj->ForceOutlinerParaObject();
161*cdf0e10cSrcweir 				OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
162*cdf0e10cSrcweir 				if( pOPO && !pOPO->IsVertical() )
163*cdf0e10cSrcweir 					pOPO->SetVertical( sal_True );
164*cdf0e10cSrcweir 			}
165*cdf0e10cSrcweir         }
166*cdf0e10cSrcweir         break;
167*cdf0e10cSrcweir         default:; //prevent warning
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 	}
170*cdf0e10cSrcweir 	return bRet;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir /*************************************************************************
174*cdf0e10cSrcweir |*
175*cdf0e10cSrcweir |* Function aktivieren
176*cdf0e10cSrcweir |*
177*cdf0e10cSrcweir \************************************************************************/
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir void ConstRectangle::Activate(const sal_uInt16 nSlotId)
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	bMarquee = bCapVertical = sal_False;
182*cdf0e10cSrcweir 	mbVertical = sal_False;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	switch (nSlotId)
185*cdf0e10cSrcweir 	{
186*cdf0e10cSrcweir 	case SID_DRAW_LINE:
187*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_LINE);
188*cdf0e10cSrcweir 		break;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 	case SID_DRAW_RECT:
191*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_RECT);
192*cdf0e10cSrcweir 		break;
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	case SID_DRAW_ELLIPSE:
195*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_CIRC);
196*cdf0e10cSrcweir 		break;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	case SID_DRAW_TEXT_MARQUEE:
199*cdf0e10cSrcweir 		bMarquee = sal_True;
200*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_TEXT);
201*cdf0e10cSrcweir 		break;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	case SID_DRAW_TEXT_VERTICAL:
204*cdf0e10cSrcweir 		// #93382#
205*cdf0e10cSrcweir 		mbVertical = sal_True;
206*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_TEXT);
207*cdf0e10cSrcweir 		break;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	case SID_DRAW_TEXT:
210*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_TEXT);
211*cdf0e10cSrcweir 		break;
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	case SID_DRAW_CAPTION_VERTICAL:
214*cdf0e10cSrcweir 		bCapVertical = sal_True;
215*cdf0e10cSrcweir 		// no break
216*cdf0e10cSrcweir 	case SID_DRAW_CAPTION:
217*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_CAPTION);
218*cdf0e10cSrcweir 		break;
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	default:
221*cdf0e10cSrcweir         m_pWin->SetSdrDrawMode(OBJ_NONE);
222*cdf0e10cSrcweir 		break;
223*cdf0e10cSrcweir 	}
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	SwDrawBase::Activate(nSlotId);
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 
230