xref: /AOO41X/main/sd/source/ui/func/futext.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_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "futext.hxx"
33*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
34*cdf0e10cSrcweir #include <editeng/editerr.hxx>
35*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
36*cdf0e10cSrcweir #include <svx/svxerr.hxx>
37*cdf0e10cSrcweir #include <tools/urlobj.hxx>
38*cdf0e10cSrcweir #include <vcl/help.hxx>
39*cdf0e10cSrcweir #include <editeng/editstat.hxx>
40*cdf0e10cSrcweir #include <svl/aeitem.hxx>
41*cdf0e10cSrcweir #include <svl/intitem.hxx>
42*cdf0e10cSrcweir #include <svx/svdotext.hxx>
43*cdf0e10cSrcweir #include <svx/svdogrp.hxx>
44*cdf0e10cSrcweir #include <editeng/flditem.hxx>
45*cdf0e10cSrcweir #include <svl/style.hxx>
46*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
47*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
48*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
49*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
50*cdf0e10cSrcweir #include <sfx2/request.hxx>
51*cdf0e10cSrcweir #include <editeng/editeng.hxx>
52*cdf0e10cSrcweir #include <svx/svdoutl.hxx>
53*cdf0e10cSrcweir #include <svx/svxids.hrc>
54*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
55*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
56*cdf0e10cSrcweir #include <editeng/outlobj.hxx>
57*cdf0e10cSrcweir #include <svtools/langtab.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // #104122#
60*cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir #include <svx/svdetc.hxx>
63*cdf0e10cSrcweir #include <editeng/editview.hxx>
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #include "sdresid.hxx"
66*cdf0e10cSrcweir #include "app.hrc"
67*cdf0e10cSrcweir #include "res_bmp.hrc"
68*cdf0e10cSrcweir #include "ViewShell.hxx"
69*cdf0e10cSrcweir #include "ViewShellBase.hxx"
70*cdf0e10cSrcweir #include "View.hxx"
71*cdf0e10cSrcweir #include "Outliner.hxx"
72*cdf0e10cSrcweir #include "Window.hxx"
73*cdf0e10cSrcweir #include "drawdoc.hxx"
74*cdf0e10cSrcweir #include "sdpage.hxx"
75*cdf0e10cSrcweir #include "sdmod.hxx"
76*cdf0e10cSrcweir #include "FrameView.hxx"
77*cdf0e10cSrcweir #include "ToolBarManager.hxx"
78*cdf0e10cSrcweir #include "DrawDocShell.hxx"
79*cdf0e10cSrcweir #include "glob.hrc"
80*cdf0e10cSrcweir #include "pres.hxx"
81*cdf0e10cSrcweir #include "optsitem.hxx"
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir using ::rtl::OUString;
84*cdf0e10cSrcweir using namespace ::com::sun::star;
85*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
86*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
87*cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir namespace sd {
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir static sal_uInt16 SidArray[] = {
92*cdf0e10cSrcweir 	SID_STYLE_FAMILY2,                //    5542
93*cdf0e10cSrcweir 	SID_STYLE_FAMILY5,                //    5545
94*cdf0e10cSrcweir 	SID_CUT,                          //    5710
95*cdf0e10cSrcweir 	SID_COPY,                         //    5711
96*cdf0e10cSrcweir 	SID_ATTR_TABSTOP,                 //   10002
97*cdf0e10cSrcweir 	SID_ATTR_CHAR_FONT,               //   10007
98*cdf0e10cSrcweir 	SID_ATTR_CHAR_POSTURE,            //   10008
99*cdf0e10cSrcweir 	SID_ATTR_CHAR_WEIGHT,             //   10009
100*cdf0e10cSrcweir 	SID_ATTR_CHAR_UNDERLINE,          //   10014
101*cdf0e10cSrcweir 	SID_ATTR_CHAR_FONTHEIGHT,         //   10015
102*cdf0e10cSrcweir 	SID_ATTR_CHAR_COLOR,              //   10017
103*cdf0e10cSrcweir 	SID_ATTR_PARA_ADJUST_LEFT,        //   10028
104*cdf0e10cSrcweir 	SID_ATTR_PARA_ADJUST_RIGHT,       //   10029
105*cdf0e10cSrcweir 	SID_ATTR_PARA_ADJUST_CENTER,      //   10030
106*cdf0e10cSrcweir 	SID_ATTR_PARA_ADJUST_BLOCK,       //   10031
107*cdf0e10cSrcweir 	SID_ATTR_PARA_LINESPACE_10,       //   10034
108*cdf0e10cSrcweir 	SID_ATTR_PARA_LINESPACE_15,       //   10035
109*cdf0e10cSrcweir 	SID_ATTR_PARA_LINESPACE_20,       //   10036
110*cdf0e10cSrcweir 	SID_ATTR_PARA_LRSPACE,            //   10043
111*cdf0e10cSrcweir 	SID_OUTLINE_UP,                   //   10150
112*cdf0e10cSrcweir 	SID_OUTLINE_DOWN,                 //   10151
113*cdf0e10cSrcweir 	SID_OUTLINE_LEFT,                 //   10152
114*cdf0e10cSrcweir 	SID_OUTLINE_RIGHT,                //   10153
115*cdf0e10cSrcweir 	SID_FORMTEXT_STYLE,               //   10257
116*cdf0e10cSrcweir 	SID_SET_SUPER_SCRIPT,             //   10294
117*cdf0e10cSrcweir 	SID_SET_SUB_SCRIPT,               //   10295
118*cdf0e10cSrcweir 	SID_HYPERLINK_GETLINK,            //   10361
119*cdf0e10cSrcweir 	SID_CHARMAP,					  //   10503
120*cdf0e10cSrcweir 	SID_TEXTDIRECTION_LEFT_TO_RIGHT,  //   10907
121*cdf0e10cSrcweir 	SID_TEXTDIRECTION_TOP_TO_BOTTOM,  //   10908
122*cdf0e10cSrcweir     SID_ATTR_PARA_LEFT_TO_RIGHT,      //   10950
123*cdf0e10cSrcweir     SID_ATTR_PARA_RIGHT_TO_LEFT,      //   10951
124*cdf0e10cSrcweir 	FN_NUM_BULLET_ON,                 //   20138
125*cdf0e10cSrcweir 	SID_PARASPACE_INCREASE,           //   27346
126*cdf0e10cSrcweir 	SID_PARASPACE_DECREASE,           //   27347
127*cdf0e10cSrcweir 							0 };
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir TYPEINIT1( FuText, FuConstruct );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir static sal_Bool bTestText = 0;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir /*************************************************************************
135*cdf0e10cSrcweir |*
136*cdf0e10cSrcweir |* Basisklasse fuer Textfunktionen
137*cdf0e10cSrcweir |*
138*cdf0e10cSrcweir \************************************************************************/
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
141*cdf0e10cSrcweir : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
142*cdf0e10cSrcweir , bFirstObjCreated(sal_False)
143*cdf0e10cSrcweir , rRequest (rReq)
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir FunctionReference FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir 	FunctionReference xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
150*cdf0e10cSrcweir 	return xFunc;
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir /*************************************************************************
154*cdf0e10cSrcweir |*
155*cdf0e10cSrcweir |* Destruktor
156*cdf0e10cSrcweir |*
157*cdf0e10cSrcweir \************************************************************************/
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir void FuText::disposing()
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	if(mpView)
162*cdf0e10cSrcweir 	{
163*cdf0e10cSrcweir 		if(mpView->SdrEndTextEdit(sal_False) == SDRENDTEXTEDIT_DELETED)
164*cdf0e10cSrcweir 			mxTextObj.reset( 0 );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 		// die RequestHandler der benutzten Outliner zuruecksetzen auf den
167*cdf0e10cSrcweir 		// Handler am Dokument
168*cdf0e10cSrcweir 		::Outliner* pOutliner = mpView->GetTextEditOutliner();
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		if (pOutliner)
171*cdf0e10cSrcweir 			pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
172*cdf0e10cSrcweir 	}
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir /*************************************************************************
176*cdf0e10cSrcweir |*
177*cdf0e10cSrcweir |* Execute functionality of this class:
178*cdf0e10cSrcweir |*
179*cdf0e10cSrcweir |* #71422: Start the functionality of this class in this method
180*cdf0e10cSrcweir |* and not in the ctor.
181*cdf0e10cSrcweir |* If you construct an object of this class and you put the
182*cdf0e10cSrcweir |* address of this object to pFuActual you've got a problem,
183*cdf0e10cSrcweir |* because some methods inside DoExecute use the pFuActual-Pointer.
184*cdf0e10cSrcweir |* If the code inside DoExecute is executed inside the ctor,
185*cdf0e10cSrcweir |* the value of pFuActual is not right. And the value will not
186*cdf0e10cSrcweir |* be right until the ctor finished !!!
187*cdf0e10cSrcweir |*
188*cdf0e10cSrcweir \************************************************************************/
189*cdf0e10cSrcweir void FuText::DoExecute( SfxRequest& )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir 	mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
192*cdf0e10cSrcweir         ToolBarManager::TBG_FUNCTION,
193*cdf0e10cSrcweir         RID_DRAW_TEXT_TOOLBOX);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	mpView->SetCurrentObj(OBJ_TEXT);
196*cdf0e10cSrcweir 	mpView->SetEditMode(SDREDITMODE_EDIT);
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 	if (nSlotId == SID_TEXTEDIT)
201*cdf0e10cSrcweir 	{
202*cdf0e10cSrcweir 		// Try to select an object
203*cdf0e10cSrcweir 		SdrPageView* pPV = mpView->GetSdrPageView();
204*cdf0e10cSrcweir 		SdrViewEvent aVEvt;
205*cdf0e10cSrcweir 		mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
206*cdf0e10cSrcweir 		mpView->MarkObj(aVEvt.pRootObj, pPV);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 		mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
209*cdf0e10cSrcweir 	}
210*cdf0e10cSrcweir 	else if (mpView->AreObjectsMarked())
211*cdf0e10cSrcweir 	{
212*cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
215*cdf0e10cSrcweir 		{
216*cdf0e10cSrcweir 			SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
217*cdf0e10cSrcweir 			mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
218*cdf0e10cSrcweir 		}
219*cdf0e10cSrcweir 	}
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	// check for table
222*cdf0e10cSrcweir 	if (mpView->AreObjectsMarked())
223*cdf0e10cSrcweir 	{
224*cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
227*cdf0e10cSrcweir 		{
228*cdf0e10cSrcweir 			SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
229*cdf0e10cSrcweir 			if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
230*cdf0e10cSrcweir 			{
231*cdf0e10cSrcweir 				mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
232*cdf0e10cSrcweir 			}
233*cdf0e10cSrcweir 		}
234*cdf0e10cSrcweir 	}
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 	sal_Bool bQuickDrag = sal_True;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	const SfxItemSet* pArgs = rRequest.GetArgs();
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	if (pArgs
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 		// #98198# test for type before using
243*cdf0e10cSrcweir 		&& SID_TEXTEDIT == nSlotId
244*cdf0e10cSrcweir 		&& SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 		&& (sal_uInt16)((SfxUInt16Item&)pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
247*cdf0e10cSrcweir 	{
248*cdf0e10cSrcweir 		// Selection by doubleclick -> don't allow QuickDrag
249*cdf0e10cSrcweir 		bQuickDrag = sal_False;
250*cdf0e10cSrcweir 	}
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	SetInEditMode(aMEvt, bQuickDrag);
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir /*************************************************************************
256*cdf0e10cSrcweir |*
257*cdf0e10cSrcweir |* MouseButtonDown-event
258*cdf0e10cSrcweir |*
259*cdf0e10cSrcweir \************************************************************************/
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir 	bMBDown = sal_True;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     /* af: (de)Select object before showing the context menu.
268*cdf0e10cSrcweir 	// Fuer PopupMenu (vorher DrawViewShell)
269*cdf0e10cSrcweir 	if ((rMEvt.GetButtons() == MOUSE_RIGHT) && rMEvt.GetClicks() == 1 &&
270*cdf0e10cSrcweir 		mpView->IsTextEdit())
271*cdf0e10cSrcweir 	{
272*cdf0e10cSrcweir 		return (sal_True);
273*cdf0e10cSrcweir 	}
274*cdf0e10cSrcweir         */
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	mpView->SetMarkHdlWhenTextEdit(sal_True);
277*cdf0e10cSrcweir 	SdrViewEvent aVEvt;
278*cdf0e10cSrcweir 	SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	if (eHit == SDRHIT_TEXTEDIT)
281*cdf0e10cSrcweir 	{
282*cdf0e10cSrcweir 		// Text getroffen -> Event von SdrView auswerten lassen
283*cdf0e10cSrcweir 		if (mpView->MouseButtonDown(rMEvt, mpWindow))
284*cdf0e10cSrcweir 			return (sal_True);
285*cdf0e10cSrcweir 	}
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	if (rMEvt.GetClicks() == 1)
288*cdf0e10cSrcweir 	{
289*cdf0e10cSrcweir 		if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
290*cdf0e10cSrcweir 		{
291*cdf0e10cSrcweir 			// Texteingabe beenden
292*cdf0e10cSrcweir 			if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
293*cdf0e10cSrcweir 			{
294*cdf0e10cSrcweir 				// Bugfix von MBA: bei Doppelclick auf der Wiese im Modus Text wird
295*cdf0e10cSrcweir 				// beim zweiten Click eHit = SDRHIT_TEXTEDITOBJ erhalten, weil ja der
296*cdf0e10cSrcweir 				// zweite Click auf das im ersten Click angelegte TextObject geht.
297*cdf0e10cSrcweir 				// Dieses wird aber in SdrEndTextEdit entfernt, weil es leer ist. Es
298*cdf0e10cSrcweir 				// befindet sich aber noch in der Mark-Liste und der Aufruf MarkObj
299*cdf0e10cSrcweir 				// weiter unten greift dann auf das tote Object zu.
300*cdf0e10cSrcweir 				// Als einfacher Fix wird nach SdrEndTextEdit noch einmal eHit ermittelt,
301*cdf0e10cSrcweir 				// was dann SDRHIT_NONE liefert.
302*cdf0e10cSrcweir 				mxTextObj.reset( NULL );
303*cdf0e10cSrcweir 				eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
304*cdf0e10cSrcweir 			}
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 			mpView->SetCurrentObj(OBJ_TEXT);
307*cdf0e10cSrcweir 			mpView->SetEditMode(SDREDITMODE_EDIT);
308*cdf0e10cSrcweir 		}
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 		if (rMEvt.IsLeft() || rMEvt.IsRight())
311*cdf0e10cSrcweir 		{
312*cdf0e10cSrcweir 			mpWindow->CaptureMouse();
313*cdf0e10cSrcweir 			SdrObject* pObj;
314*cdf0e10cSrcweir 			SdrPageView* pPV = mpView->GetSdrPageView();
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 			if (eHit == SDRHIT_TEXTEDIT)
317*cdf0e10cSrcweir 			{
318*cdf0e10cSrcweir 				SetInEditMode(rMEvt, sal_False);
319*cdf0e10cSrcweir 			}
320*cdf0e10cSrcweir 			else
321*cdf0e10cSrcweir 			{
322*cdf0e10cSrcweir 				sal_Bool bMacro = sal_False;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 				if (bMacro && mpView->PickObj(aMDPos,mpView->getHitTolLog(),pObj,pPV,SDRSEARCH_PICKMACRO))
325*cdf0e10cSrcweir 				{
326*cdf0e10cSrcweir 					// Makro
327*cdf0e10cSrcweir 					sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
328*cdf0e10cSrcweir 					mpView->BegMacroObj(aMDPos,nHitLog,pObj,pPV,mpWindow);
329*cdf0e10cSrcweir 				}
330*cdf0e10cSrcweir 				else
331*cdf0e10cSrcweir 				{
332*cdf0e10cSrcweir 					if (eHit != SDRHIT_HANDLE)
333*cdf0e10cSrcweir 					{
334*cdf0e10cSrcweir 						// Selektion aufheben
335*cdf0e10cSrcweir 						if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
336*cdf0e10cSrcweir 						{
337*cdf0e10cSrcweir 							mpView->UnmarkAll();
338*cdf0e10cSrcweir 							mpView->SetDragMode(SDRDRAG_MOVE);
339*cdf0e10cSrcweir 						}
340*cdf0e10cSrcweir 					}
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir 					if ( aVEvt.eEvent == SDREVENT_EXECUTEURL                   ||
343*cdf0e10cSrcweir 						 eHit == SDRHIT_HANDLE                                 ||
344*cdf0e10cSrcweir 						 eHit == SDRHIT_MARKEDOBJECT                           ||
345*cdf0e10cSrcweir 						 eHit == SDRHIT_TEXTEDITOBJ                            ||
346*cdf0e10cSrcweir 						 ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
347*cdf0e10cSrcweir 						   !bPermanent ) )
348*cdf0e10cSrcweir 					{
349*cdf0e10cSrcweir 						/**********************************************************
350*cdf0e10cSrcweir 						* Handle, markiertes oder unmarkiertes Objekt getroffen
351*cdf0e10cSrcweir 						**********************************************************/
352*cdf0e10cSrcweir 						if (eHit == SDRHIT_TEXTEDITOBJ)
353*cdf0e10cSrcweir 						{
354*cdf0e10cSrcweir 							/******************************************************
355*cdf0e10cSrcweir 							* Text eines unmarkierten Objekts getroffen:
356*cdf0e10cSrcweir 							* Objekt wird selektiert und in EditMode versetzt
357*cdf0e10cSrcweir 							******************************************************/
358*cdf0e10cSrcweir 							mpView->MarkObj(aVEvt.pRootObj, pPV);
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 							if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
361*cdf0e10cSrcweir 							{
362*cdf0e10cSrcweir 								mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
363*cdf0e10cSrcweir 							}
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 							SetInEditMode(rMEvt, sal_True);
366*cdf0e10cSrcweir 						}
367*cdf0e10cSrcweir 						else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
368*cdf0e10cSrcweir 						{
369*cdf0e10cSrcweir 							/******************************************************
370*cdf0e10cSrcweir 							* URL ausfuehren
371*cdf0e10cSrcweir 							******************************************************/
372*cdf0e10cSrcweir 							mpWindow->ReleaseMouse();
373*cdf0e10cSrcweir 							SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
374*cdf0e10cSrcweir 							SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
375*cdf0e10cSrcweir 							SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
376*cdf0e10cSrcweir 							SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
377*cdf0e10cSrcweir 							mpWindow->ReleaseMouse();
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 							if (rMEvt.IsMod1())
380*cdf0e10cSrcweir 							{
381*cdf0e10cSrcweir 								// Im neuen Frame oeffnen
382*cdf0e10cSrcweir 								pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
383*cdf0e10cSrcweir 											&aStrItem, &aBrowseItem, &aReferer, 0L);
384*cdf0e10cSrcweir 							}
385*cdf0e10cSrcweir 							else
386*cdf0e10cSrcweir 							{
387*cdf0e10cSrcweir 								// Im aktuellen Frame oeffnen
388*cdf0e10cSrcweir 								SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
389*cdf0e10cSrcweir 								pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
390*cdf0e10cSrcweir 											&aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
391*cdf0e10cSrcweir 							}
392*cdf0e10cSrcweir 						}
393*cdf0e10cSrcweir 						else
394*cdf0e10cSrcweir 						{
395*cdf0e10cSrcweir 							/******************************************************
396*cdf0e10cSrcweir 							* Objekt oder Handle draggen
397*cdf0e10cSrcweir 							******************************************************/
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 							// #i78748#
400*cdf0e10cSrcweir 							// do the EndTextEdit first, it will delete the handles and force a
401*cdf0e10cSrcweir 							// recreation. This will make aVEvt.pHdl to point to a deleted handle,
402*cdf0e10cSrcweir 							// thus it is necessary to reset it and to get it again.
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 							// #i112855#
405*cdf0e10cSrcweir 							// cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObjet
406*cdf0e10cSrcweir 							// this caused SdrEndTextEdit() to be called also when not in text editing and
407*cdf0e10cSrcweir 							// this does not make sense and caused troubles. (see issue 112855)
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir //							::Outliner* pOutl = mpView->GetTextEditOutliner();
410*cdf0e10cSrcweir //
411*cdf0e10cSrcweir //							if (mxTextObj.is() && (mxTextObj->GetOutlinerParaObject() ||
412*cdf0e10cSrcweir //								(pOutl && pOutl->GetText(pOutl->GetParagraph( 0 )).Len() != 0)))
413*cdf0e10cSrcweir 							if( mpView->IsTextEdit() )
414*cdf0e10cSrcweir 							{
415*cdf0e10cSrcweir 								mpView->SdrEndTextEdit();
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 								if(aVEvt.pHdl)
418*cdf0e10cSrcweir 								{
419*cdf0e10cSrcweir 									// force new handle identification, the pointer will be dead here
420*cdf0e10cSrcweir 									// since SdrEndTextEdit has resetted (deleted) the handles.
421*cdf0e10cSrcweir 									aVEvt.pHdl = 0;
422*cdf0e10cSrcweir 									mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
423*cdf0e10cSrcweir 								}
424*cdf0e10cSrcweir 							}
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 							if (!aVEvt.pHdl)
427*cdf0e10cSrcweir 							{
428*cdf0e10cSrcweir 								if( eHit == SDRHIT_UNMARKEDOBJECT )
429*cdf0e10cSrcweir 								{
430*cdf0e10cSrcweir 									if ( !rMEvt.IsShift() )
431*cdf0e10cSrcweir 										mpView->UnmarkAll();
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 									mpView->MarkObj(aVEvt.pRootObj, pPV);
434*cdf0e10cSrcweir 								}
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 								// Objekt draggen
437*cdf0e10cSrcweir 								bFirstMouseMove = sal_True;
438*cdf0e10cSrcweir 								aDragTimer.Start();
439*cdf0e10cSrcweir 							}
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir                             if ( ! rMEvt.IsRight())
443*cdf0e10cSrcweir                             {
444*cdf0e10cSrcweir 							    // we need to pick again since SdrEndTextEdit can rebuild the handles list
445*cdf0e10cSrcweir                                 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
446*cdf0e10cSrcweir 							    if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
447*cdf0e10cSrcweir 							    {
448*cdf0e10cSrcweir 								    sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
449*cdf0e10cSrcweir 								    mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
450*cdf0e10cSrcweir 							    }
451*cdf0e10cSrcweir                             }
452*cdf0e10cSrcweir                             bReturn = true;
453*cdf0e10cSrcweir 						}
454*cdf0e10cSrcweir 					}
455*cdf0e10cSrcweir 					else if ( nSlotId != SID_TEXTEDIT &&
456*cdf0e10cSrcweir 							  (bPermanent || !bFirstObjCreated) )
457*cdf0e10cSrcweir 					{
458*cdf0e10cSrcweir 						/**********************************************************
459*cdf0e10cSrcweir 						* Objekt erzeugen
460*cdf0e10cSrcweir 						**********************************************************/
461*cdf0e10cSrcweir 						mpView->SetCurrentObj(OBJ_TEXT);
462*cdf0e10cSrcweir 						mpView->SetEditMode(SDREDITMODE_CREATE);
463*cdf0e10cSrcweir 						sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
464*cdf0e10cSrcweir 						mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
465*cdf0e10cSrcweir 					}
466*cdf0e10cSrcweir 					else
467*cdf0e10cSrcweir 					{
468*cdf0e10cSrcweir 						/**********************************************************
469*cdf0e10cSrcweir 						* Selektieren
470*cdf0e10cSrcweir 						**********************************************************/
471*cdf0e10cSrcweir 						if( !rMEvt.IsShift() )
472*cdf0e10cSrcweir 							mpView->UnmarkAll();
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 						mpView->BegMarkObj( aMDPos );
475*cdf0e10cSrcweir 					}
476*cdf0e10cSrcweir 				}
477*cdf0e10cSrcweir 			}
478*cdf0e10cSrcweir 		}
479*cdf0e10cSrcweir 	}
480*cdf0e10cSrcweir 	else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
481*cdf0e10cSrcweir 	{
482*cdf0e10cSrcweir 		MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
483*cdf0e10cSrcweir 		SetInEditMode( aMEvt, sal_False );
484*cdf0e10cSrcweir 	}
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	if (!bIsInDragMode)
487*cdf0e10cSrcweir 	{
488*cdf0e10cSrcweir 		ForcePointer(&rMEvt);
489*cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
490*cdf0e10cSrcweir 	}
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 	return (bReturn);
493*cdf0e10cSrcweir }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir /*************************************************************************
496*cdf0e10cSrcweir |*
497*cdf0e10cSrcweir |* MouseMove-event
498*cdf0e10cSrcweir |*
499*cdf0e10cSrcweir \************************************************************************/
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir sal_Bool FuText::MouseMove(const MouseEvent& rMEvt)
502*cdf0e10cSrcweir {
503*cdf0e10cSrcweir 	sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 	if (aDragTimer.IsActive() )
506*cdf0e10cSrcweir 	{
507*cdf0e10cSrcweir 		if( bFirstMouseMove )
508*cdf0e10cSrcweir 			bFirstMouseMove = sal_False;
509*cdf0e10cSrcweir 		else
510*cdf0e10cSrcweir 			aDragTimer.Stop();
511*cdf0e10cSrcweir 	}
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 	if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
514*cdf0e10cSrcweir 	{
515*cdf0e10cSrcweir 		Point aPix(rMEvt.GetPosPixel());
516*cdf0e10cSrcweir 		Point aPnt(mpWindow->PixelToLogic(aPix));
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 		ForceScroll(aPix);
519*cdf0e10cSrcweir 		mpView->MovAction(aPnt);
520*cdf0e10cSrcweir 	}
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 	ForcePointer(&rMEvt);
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 	return (bReturn);
525*cdf0e10cSrcweir }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir /*************************************************************************
528*cdf0e10cSrcweir |*
529*cdf0e10cSrcweir |* MouseButtonUp-event
530*cdf0e10cSrcweir |*
531*cdf0e10cSrcweir \************************************************************************/
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir // #97016#
534*cdf0e10cSrcweir void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
535*cdf0e10cSrcweir {
536*cdf0e10cSrcweir 	if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
537*cdf0e10cSrcweir 	{
538*cdf0e10cSrcweir 		if( nSlotId == SID_ATTR_CHAR )
539*cdf0e10cSrcweir 		{
540*cdf0e10cSrcweir 			// Impress-Textobjekt wird erzeugt (faellt auf Zeilenhoehe zusammen)
541*cdf0e10cSrcweir 			// Damit das Objekt beim anschliessenden Erzeugen gleich die richtige
542*cdf0e10cSrcweir 			// Hoehe bekommt (sonst wird zuviel gepainted)
543*cdf0e10cSrcweir 			SfxItemSet aSet(mpViewShell->GetPool());
544*cdf0e10cSrcweir 			aSet.Put(SdrTextMinFrameHeightItem(0));
545*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
546*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
547*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
548*cdf0e10cSrcweir 			pTxtObj->AdjustTextFrameWidthAndHeight();
549*cdf0e10cSrcweir 			aSet.Put(SdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
550*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
551*cdf0e10cSrcweir 		}
552*cdf0e10cSrcweir 		else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
553*cdf0e10cSrcweir 		{
554*cdf0e10cSrcweir 			SfxItemSet aSet(mpViewShell->GetPool());
555*cdf0e10cSrcweir 			aSet.Put(SdrTextMinFrameWidthItem(0));
556*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
557*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 			// #91853# Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
560*cdf0e10cSrcweir 			aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
561*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
562*cdf0e10cSrcweir 			pTxtObj->AdjustTextFrameWidthAndHeight();
563*cdf0e10cSrcweir 			aSet.Put(SdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
564*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
565*cdf0e10cSrcweir 		}
566*cdf0e10cSrcweir 	}
567*cdf0e10cSrcweir 	else
568*cdf0e10cSrcweir 	{
569*cdf0e10cSrcweir 		if( nSlotId == SID_ATTR_CHAR_VERTICAL )
570*cdf0e10cSrcweir 		{
571*cdf0e10cSrcweir 			// draw text object, needs to be initialized when vertical text is used
572*cdf0e10cSrcweir 			SfxItemSet aSet(mpViewShell->GetPool());
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir 			// #91510#
575*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
576*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 			// #91508#
579*cdf0e10cSrcweir 			//aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
580*cdf0e10cSrcweir 			//aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 			// #107235#
583*cdf0e10cSrcweir 			// Set defaults for vertical klick-n'drag text object, pool defaults are:
584*cdf0e10cSrcweir 			// SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
585*cdf0e10cSrcweir 			// SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
586*cdf0e10cSrcweir 			// Analog to that (thus, #91508# was not completely correct):
587*cdf0e10cSrcweir 			aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
588*cdf0e10cSrcweir 			aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
591*cdf0e10cSrcweir 		}
592*cdf0e10cSrcweir 	}
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir // #97016#
596*cdf0e10cSrcweir void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
597*cdf0e10cSrcweir {
598*cdf0e10cSrcweir 	// FitToSize (An Rahmen anpassen)
599*cdf0e10cSrcweir 	SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
600*cdf0e10cSrcweir 	SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
601*cdf0e10cSrcweir 	aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
602*cdf0e10cSrcweir 	aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
603*cdf0e10cSrcweir 	aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
604*cdf0e10cSrcweir 	pTxtObj->SetMergedItemSet(aSet);
605*cdf0e10cSrcweir 	pTxtObj->AdjustTextFrameWidthAndHeight();
606*cdf0e10cSrcweir }
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir // #97016#
609*cdf0e10cSrcweir void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
610*cdf0e10cSrcweir {
611*cdf0e10cSrcweir 	SfxItemSet aSet(mpViewShell->GetPool(),
612*cdf0e10cSrcweir 		SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
613*cdf0e10cSrcweir 	SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
614*cdf0e10cSrcweir 	aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
615*cdf0e10cSrcweir 	aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
616*cdf0e10cSrcweir 	aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
617*cdf0e10cSrcweir 	pTxtObj->SetMergedItemSet(aSet);
618*cdf0e10cSrcweir 	pTxtObj->AdjustTextFrameWidthAndHeight();
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir // #97016#
622*cdf0e10cSrcweir void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir 	// Normales Textobjekt
625*cdf0e10cSrcweir 	if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
626*cdf0e10cSrcweir 	{
627*cdf0e10cSrcweir 		if( nSlotId == SID_ATTR_CHAR )
628*cdf0e10cSrcweir 		{
629*cdf0e10cSrcweir 			// Impress-Textobjekt (faellt auf Zeilenhoehe zusammen)
630*cdf0e10cSrcweir 			SfxItemSet aSet(mpViewShell->GetPool());
631*cdf0e10cSrcweir 			aSet.Put(SdrTextMinFrameHeightItem(0));
632*cdf0e10cSrcweir 			aSet.Put(SdrTextMaxFrameHeightItem(0));
633*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
634*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
635*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
636*cdf0e10cSrcweir 		}
637*cdf0e10cSrcweir 		else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
638*cdf0e10cSrcweir 		{
639*cdf0e10cSrcweir 			SfxItemSet aSet(mpViewShell->GetPool());
640*cdf0e10cSrcweir 			aSet.Put(SdrTextMinFrameWidthItem(0));
641*cdf0e10cSrcweir 			aSet.Put(SdrTextMaxFrameWidthItem(0));
642*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
643*cdf0e10cSrcweir 			aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
644*cdf0e10cSrcweir 			pTxtObj->SetMergedItemSet(aSet);
645*cdf0e10cSrcweir 		}
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 		pTxtObj->AdjustTextFrameWidthAndHeight();
648*cdf0e10cSrcweir 	}
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
652*cdf0e10cSrcweir {
653*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	if (aDragTimer.IsActive())
656*cdf0e10cSrcweir 	{
657*cdf0e10cSrcweir 		aDragTimer.Stop();
658*cdf0e10cSrcweir 		bIsInDragMode = sal_False;
659*cdf0e10cSrcweir 	}
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 	mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir 	Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 	if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
666*cdf0e10cSrcweir 		return (sal_True); // Event von der SdrView ausgewertet
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 	sal_Bool bEmptyTextObj = sal_False;
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 	if (mxTextObj.is())
671*cdf0e10cSrcweir 	{
672*cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1
675*cdf0e10cSrcweir             && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
676*cdf0e10cSrcweir 		{
677*cdf0e10cSrcweir 			if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
678*cdf0e10cSrcweir 				bEmptyTextObj = sal_True;
679*cdf0e10cSrcweir 			else
680*cdf0e10cSrcweir 				bFirstObjCreated = sal_True;
681*cdf0e10cSrcweir 		}
682*cdf0e10cSrcweir 		else
683*cdf0e10cSrcweir 		{
684*cdf0e10cSrcweir 			mxTextObj.reset( 0 );
685*cdf0e10cSrcweir 		}
686*cdf0e10cSrcweir 	}
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	if( mpView && mpView->IsDragObj())
689*cdf0e10cSrcweir 	{
690*cdf0e10cSrcweir 		/**********************************************************************
691*cdf0e10cSrcweir 		* Objekt wurde verschoben
692*cdf0e10cSrcweir 		**********************************************************************/
693*cdf0e10cSrcweir 		FrameView* pFrameView = mpViewShell->GetFrameView();
694*cdf0e10cSrcweir 		sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 		if (bDragWithCopy)
697*cdf0e10cSrcweir 		{
698*cdf0e10cSrcweir 			bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
699*cdf0e10cSrcweir 		}
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 		mpView->SetDragWithCopy(bDragWithCopy);
702*cdf0e10cSrcweir 		mpView->EndDragObj( mpView->IsDragWithCopy() );
703*cdf0e10cSrcweir 		mpView->ForceMarkedToAnotherPage();
704*cdf0e10cSrcweir 		mpView->SetCurrentObj(OBJ_TEXT);
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 	    sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir         if ( mpView->IsRotateAllowed() && mpViewShell->GetFrameView()->IsClickChangeRotation() && (rMEvt.GetClicks() != 2) &&
709*cdf0e10cSrcweir 			!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
710*cdf0e10cSrcweir             Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
711*cdf0e10cSrcweir             Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
712*cdf0e10cSrcweir         {
713*cdf0e10cSrcweir 			// toggle to rotation mode
714*cdf0e10cSrcweir 			mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_ROTATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
715*cdf0e10cSrcweir 		}
716*cdf0e10cSrcweir 	}
717*cdf0e10cSrcweir 	else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
718*cdf0e10cSrcweir 	{
719*cdf0e10cSrcweir 		/**********************************************************************
720*cdf0e10cSrcweir 		* Objekt wurde erzeugt
721*cdf0e10cSrcweir 		**********************************************************************/
722*cdf0e10cSrcweir 		mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 		if( mxTextObj.is() )
725*cdf0e10cSrcweir 		{
726*cdf0e10cSrcweir 			//AW outliner needs to be set to vertical when there is no
727*cdf0e10cSrcweir 			// outliner object up to now; also it needs to be set back to not
728*cdf0e10cSrcweir 			// vertical when there was a vertical one used last time.
729*cdf0e10cSrcweir 			OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
730*cdf0e10cSrcweir 			SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
731*cdf0e10cSrcweir 			sal_Bool bVertical((pOPO && pOPO->IsVertical())
732*cdf0e10cSrcweir 				|| nSlotId == SID_ATTR_CHAR_VERTICAL
733*cdf0e10cSrcweir 				|| nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
734*cdf0e10cSrcweir 			rOutl.SetVertical(bVertical);
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir 			// #107235#
737*cdf0e10cSrcweir 			// Before ImpSetAttributesForNewTextObject the vertical writing mode
738*cdf0e10cSrcweir 			// needs to be set at the object. This is done here at the OutlinerParaObject
739*cdf0e10cSrcweir 			// directly to not mirror the layout text items involved. These items will be set
740*cdf0e10cSrcweir 			// from ImpSetAttributesForNewTextObject and below.
741*cdf0e10cSrcweir 			OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir 			if(!pPara)
744*cdf0e10cSrcweir 			{
745*cdf0e10cSrcweir 				GetTextObj()->ForceOutlinerParaObject();
746*cdf0e10cSrcweir 				pPara = GetTextObj()->GetOutlinerParaObject();
747*cdf0e10cSrcweir 			}
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir 			if(pPara && (bool)bVertical != pPara->IsVertical())
750*cdf0e10cSrcweir 			{
751*cdf0e10cSrcweir 				// set ParaObject orientation accordingly
752*cdf0e10cSrcweir 				pPara->SetVertical(bVertical);
753*cdf0e10cSrcweir 			}
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 			// #97016#
756*cdf0e10cSrcweir 			ImpSetAttributesForNewTextObject(GetTextObj());
757*cdf0e10cSrcweir 		}
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 		if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
760*cdf0e10cSrcweir 		{
761*cdf0e10cSrcweir 			// Textobjekt konnte nicht erzeugt werden
762*cdf0e10cSrcweir 			mxTextObj.reset(0);
763*cdf0e10cSrcweir 		}
764*cdf0e10cSrcweir 		else if (nSlotId == SID_TEXT_FITTOSIZE)
765*cdf0e10cSrcweir 		{
766*cdf0e10cSrcweir 			// #97016#
767*cdf0e10cSrcweir 			ImpSetAttributesFitToSize(GetTextObj());
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 			SetInEditMode(rMEvt, sal_False);
770*cdf0e10cSrcweir 		}
771*cdf0e10cSrcweir 		else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
772*cdf0e10cSrcweir 		{
773*cdf0e10cSrcweir 			// #97016#
774*cdf0e10cSrcweir 			ImpSetAttributesFitToSizeVertical(GetTextObj());
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 			SetInEditMode(rMEvt, sal_False);
777*cdf0e10cSrcweir 		}
778*cdf0e10cSrcweir 		else
779*cdf0e10cSrcweir 		{
780*cdf0e10cSrcweir 			// #97016#
781*cdf0e10cSrcweir 			ImpSetAttributesFitCommon(GetTextObj());
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 			// Damit die Handles und der graue Rahmen stimmen
784*cdf0e10cSrcweir 			mpView->AdjustMarkHdl();
785*cdf0e10cSrcweir 			mpView->PickHandle(aPnt);
786*cdf0e10cSrcweir 			SetInEditMode(rMEvt, sal_False);
787*cdf0e10cSrcweir 		}
788*cdf0e10cSrcweir 	}
789*cdf0e10cSrcweir 	else if ( mpView && mpView->IsAction())
790*cdf0e10cSrcweir 	{
791*cdf0e10cSrcweir 		mpView->EndAction();
792*cdf0e10cSrcweir 	}
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir 	ForcePointer(&rMEvt);
795*cdf0e10cSrcweir 	mpWindow->ReleaseMouse();
796*cdf0e10cSrcweir 	sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 	if ( mpView && !mpView->AreObjectsMarked() &&
799*cdf0e10cSrcweir 		 Abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
800*cdf0e10cSrcweir 		 Abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
801*cdf0e10cSrcweir 		 !rMEvt.IsShift() && !rMEvt.IsMod2() )
802*cdf0e10cSrcweir 	{
803*cdf0e10cSrcweir 		SdrPageView* pPV = mpView->GetSdrPageView();
804*cdf0e10cSrcweir 		SdrViewEvent aVEvt;
805*cdf0e10cSrcweir 		mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
806*cdf0e10cSrcweir 		mpView->MarkObj(aVEvt.pRootObj, pPV);
807*cdf0e10cSrcweir 	}
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir 	if ( !mxTextObj.is() && mpView )
810*cdf0e10cSrcweir 	{
811*cdf0e10cSrcweir 		if ( ( (!bEmptyTextObj   &&  bPermanent) ||
812*cdf0e10cSrcweir 			 (!bFirstObjCreated && !bPermanent) ) &&
813*cdf0e10cSrcweir 			  !mpDocSh->IsReadOnly()               &&
814*cdf0e10cSrcweir 			  nSlotId != SID_TEXTEDIT )
815*cdf0e10cSrcweir 		{
816*cdf0e10cSrcweir 			/**********************************************************************
817*cdf0e10cSrcweir 			* Mengentext (linksbuendiges AutoGrow)
818*cdf0e10cSrcweir 			**********************************************************************/
819*cdf0e10cSrcweir 			mpView->SetCurrentObj(OBJ_TEXT);
820*cdf0e10cSrcweir 			mpView->SetEditMode(SDREDITMODE_CREATE);
821*cdf0e10cSrcweir 			sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
822*cdf0e10cSrcweir 			mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir 			sal_Bool bSnapEnabled = mpView->IsSnapEnabled();
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir 			if (bSnapEnabled)
827*cdf0e10cSrcweir 				mpView->SetSnapEnabled(sal_False);
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir 			aPnt.X() += nDrgLog + nDrgLog;
830*cdf0e10cSrcweir 			aPnt.Y() += nDrgLog + nDrgLog;
831*cdf0e10cSrcweir 			mpView->MovAction(aPnt);
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir 			mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir 			if(mxTextObj.is())
836*cdf0e10cSrcweir 			{
837*cdf0e10cSrcweir 				GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
838*cdf0e10cSrcweir 			}
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir 			if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
841*cdf0e10cSrcweir 			{
842*cdf0e10cSrcweir 				mxTextObj.reset(0);
843*cdf0e10cSrcweir 			}
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir 			if(bSnapEnabled)
846*cdf0e10cSrcweir 				mpView->SetSnapEnabled(bSnapEnabled);
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir 			if(mxTextObj.is())
849*cdf0e10cSrcweir 			{
850*cdf0e10cSrcweir 				SfxItemSet aSet(mpViewShell->GetPool());
851*cdf0e10cSrcweir 				aSet.Put(SdrTextMinFrameHeightItem(0));
852*cdf0e10cSrcweir 				aSet.Put(SdrTextMinFrameWidthItem(0));
853*cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
854*cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 				// #91508#
857*cdf0e10cSrcweir 				if(nSlotId == SID_ATTR_CHAR_VERTICAL)
858*cdf0e10cSrcweir 				{
859*cdf0e10cSrcweir 					// #107235#
860*cdf0e10cSrcweir 					//
861*cdf0e10cSrcweir 					// Here, all items which need to be different from pool default need to be set
862*cdf0e10cSrcweir 					// again on the newly created text object.
863*cdf0e10cSrcweir 					// Since this is a simple klick text object, it is first created, then SetVertical()
864*cdf0e10cSrcweir 					// is used, then ImpSetAttributesForNewTextObject is called and then the object is
865*cdf0e10cSrcweir 					// deleted again since not the minimum drag distance was travelled. Then, a new
866*cdf0e10cSrcweir 					// klick text object is created and thus all that stuff needs to be set again here.
867*cdf0e10cSrcweir 					//
868*cdf0e10cSrcweir 					// Before using the new object the vertical writing mode
869*cdf0e10cSrcweir 					// needs to be set. This is done here at the OutlinerParaObject
870*cdf0e10cSrcweir 					// directly to not mirror the layout text items involved. These items will be set
871*cdf0e10cSrcweir 					// below.
872*cdf0e10cSrcweir 					OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir 					if(!pPara)
875*cdf0e10cSrcweir 					{
876*cdf0e10cSrcweir 						GetTextObj()->ForceOutlinerParaObject();
877*cdf0e10cSrcweir 						pPara = GetTextObj()->GetOutlinerParaObject();
878*cdf0e10cSrcweir 					}
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 					if(pPara && sal_True != pPara->IsVertical())
881*cdf0e10cSrcweir 					{
882*cdf0e10cSrcweir 						// set ParaObject orientation accordingly
883*cdf0e10cSrcweir 						pPara->SetVertical(sal_True);
884*cdf0e10cSrcweir 					}
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir 					// #91508#
887*cdf0e10cSrcweir 					// aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
888*cdf0e10cSrcweir 					aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 					// #107235#
891*cdf0e10cSrcweir 					// Analog to the else case below, for vertical simple click texts
892*cdf0e10cSrcweir 					// one of the defaulted setted items from ImpSetAttributesForNewTextObject
893*cdf0e10cSrcweir 					// needs to be adapted to non-block mode. This could have been done with the
894*cdf0e10cSrcweir 					// #104122#, but was obviously overseen.
895*cdf0e10cSrcweir 					const SfxItemSet& rSet = mpView->GetDefaultAttr();
896*cdf0e10cSrcweir 					SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir 					if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
899*cdf0e10cSrcweir 					{
900*cdf0e10cSrcweir 	                    aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
901*cdf0e10cSrcweir 					}
902*cdf0e10cSrcweir 					else
903*cdf0e10cSrcweir 					{
904*cdf0e10cSrcweir 	                    aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
905*cdf0e10cSrcweir 					}
906*cdf0e10cSrcweir 				}
907*cdf0e10cSrcweir 				else
908*cdf0e10cSrcweir 				{
909*cdf0e10cSrcweir 					// #104122# This is for Format/Page settings. Since this also leads
910*cdf0e10cSrcweir 					// to the object defaults to be changed, i think this code can be
911*cdf0e10cSrcweir 					// removed. CL. wanted to take a look before adding this.
912*cdf0e10cSrcweir                     //const SdrTextHorzAdjust eHA = ( ( pDoc && pDoc->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ) ?
913*cdf0e10cSrcweir                     //                                SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_LEFT );
914*cdf0e10cSrcweir                     //aSet.Put( SdrTextHorzAdjustItem( eHA ) );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 					// #104122# Look in the object defaults if left-to-right is wanted. If
917*cdf0e10cSrcweir 					// yes, set text anchoring to right to let the box grow to left.
918*cdf0e10cSrcweir 					const SfxItemSet& rSet = mpView->GetDefaultAttr();
919*cdf0e10cSrcweir 					SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir 					if(FRMDIR_HORI_RIGHT_TOP == eDirection)
922*cdf0e10cSrcweir 					{
923*cdf0e10cSrcweir 	                    aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
924*cdf0e10cSrcweir 					}
925*cdf0e10cSrcweir 					else
926*cdf0e10cSrcweir 					{
927*cdf0e10cSrcweir 	                    aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
928*cdf0e10cSrcweir 					}
929*cdf0e10cSrcweir 				}
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir 				GetTextObj()->SetMergedItemSet(aSet);
932*cdf0e10cSrcweir 				GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
933*cdf0e10cSrcweir 				SetInEditMode(rMEvt, sal_False);
934*cdf0e10cSrcweir 			}
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir 			bFirstObjCreated = sal_True;
937*cdf0e10cSrcweir 		}
938*cdf0e10cSrcweir 		else
939*cdf0e10cSrcweir 		{
940*cdf0e10cSrcweir 			// In die Fkt. Selektion wechseln
941*cdf0e10cSrcweir 			if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
942*cdf0e10cSrcweir 			{
943*cdf0e10cSrcweir 				mxTextObj.reset(0);
944*cdf0e10cSrcweir 			}
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 			mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
947*cdf0e10cSrcweir 									  SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
948*cdf0e10cSrcweir 		}
949*cdf0e10cSrcweir 	}
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir 	bMBDown = sal_False;
952*cdf0e10cSrcweir 	FuConstruct::MouseButtonUp(rMEvt);
953*cdf0e10cSrcweir 	return (bReturn);
954*cdf0e10cSrcweir }
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir /*************************************************************************
957*cdf0e10cSrcweir |*
958*cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
959*cdf0e10cSrcweir |*
960*cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
961*cdf0e10cSrcweir |* sal_False.
962*cdf0e10cSrcweir |*
963*cdf0e10cSrcweir \************************************************************************/
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir sal_Bool FuText::KeyInput(const KeyEvent& rKEvt)
966*cdf0e10cSrcweir {
967*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
968*cdf0e10cSrcweir 	mpView->SetMarkHdlWhenTextEdit(sal_True);
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 	KeyCode nCode = rKEvt.GetKeyCode();
971*cdf0e10cSrcweir 	sal_Bool bShift = nCode.IsShift();
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir 	// #97016# IV
974*cdf0e10cSrcweir 	if(mxTextObj.is())
975*cdf0e10cSrcweir 	{
976*cdf0e10cSrcweir 		// maybe object is deleted, test if it's equal to the selected object
977*cdf0e10cSrcweir 		const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
978*cdf0e10cSrcweir 		SdrObject* pSelectedObj = 0L;
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir 		if(1 == rMarkList.GetMarkCount())
981*cdf0e10cSrcweir 		{
982*cdf0e10cSrcweir 			SdrMark* pMark = rMarkList.GetMark(0);
983*cdf0e10cSrcweir 			pSelectedObj = pMark->GetMarkedSdrObj();
984*cdf0e10cSrcweir 		}
985*cdf0e10cSrcweir 
986*cdf0e10cSrcweir 		if(mxTextObj.get() != pSelectedObj)
987*cdf0e10cSrcweir 		{
988*cdf0e10cSrcweir 			mxTextObj.reset(0);
989*cdf0e10cSrcweir 		}
990*cdf0e10cSrcweir 	}
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir 	if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
993*cdf0e10cSrcweir 	{
994*cdf0e10cSrcweir 		// Titeltext-Objekt: immer "weiche" Umbrueche
995*cdf0e10cSrcweir 		bShift = sal_True;
996*cdf0e10cSrcweir 	}
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 	sal_uInt16 nKey = nCode.GetCode();
999*cdf0e10cSrcweir 	KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
1000*cdf0e10cSrcweir 	KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir 	sal_Bool bOK = sal_True;
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 	if (mpDocSh->IsReadOnly())
1005*cdf0e10cSrcweir 	{
1006*cdf0e10cSrcweir 		bOK = !EditEngine::DoesKeyChangeText(aKEvt);
1007*cdf0e10cSrcweir 	}
1008*cdf0e10cSrcweir 	if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
1009*cdf0e10cSrcweir 	{
1010*cdf0e10cSrcweir 		bOK = sal_False;   // default handling in base class
1011*cdf0e10cSrcweir 	}
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir 	if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
1014*cdf0e10cSrcweir 	{
1015*cdf0e10cSrcweir 		bReturn = sal_True;
1016*cdf0e10cSrcweir 
1017*cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir //		if ( pTextObj )
1020*cdf0e10cSrcweir //			pTextObj->SetEmptyPresObj(sal_False);
1021*cdf0e10cSrcweir 	}
1022*cdf0e10cSrcweir 	else if (aKeyCode == KEY_ESCAPE)
1023*cdf0e10cSrcweir 	{
1024*cdf0e10cSrcweir 		bReturn = cancel();
1025*cdf0e10cSrcweir 	}
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir 	if( bPermanent )
1028*cdf0e10cSrcweir 	{
1029*cdf0e10cSrcweir 		mpView->SetCurrentObj(OBJ_TEXT);
1030*cdf0e10cSrcweir 		mpView->SetEditMode(SDREDITMODE_CREATE);
1031*cdf0e10cSrcweir 	}
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir 	if (!bReturn)
1034*cdf0e10cSrcweir 	{
1035*cdf0e10cSrcweir 		bReturn = FuDraw::KeyInput(aKEvt);
1036*cdf0e10cSrcweir 	}
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir 	return (bReturn);
1039*cdf0e10cSrcweir }
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir /*************************************************************************
1044*cdf0e10cSrcweir |*
1045*cdf0e10cSrcweir |* Function aktivieren
1046*cdf0e10cSrcweir |*
1047*cdf0e10cSrcweir \************************************************************************/
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir void FuText::Activate()
1050*cdf0e10cSrcweir {
1051*cdf0e10cSrcweir 	mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir     // #i89661# it's no longer necessary to make it so big here, it's fine tuned
1054*cdf0e10cSrcweir     // for text objects in SdrMarkView::CheckSingleSdrObjectHit
1055*cdf0e10cSrcweir 	mpView->SetHitTolerancePixel( 2 * HITPIX );
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 	if (pOLV)
1060*cdf0e10cSrcweir 		pOLV->ShowCursor();
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 	FuConstruct::Activate();
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir 	if( pOLV )
1065*cdf0e10cSrcweir 		mpView->SetEditMode(SDREDITMODE_EDIT);
1066*cdf0e10cSrcweir }
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir /*************************************************************************
1070*cdf0e10cSrcweir |*
1071*cdf0e10cSrcweir |* Function deaktivieren
1072*cdf0e10cSrcweir |*
1073*cdf0e10cSrcweir \************************************************************************/
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir void FuText::Deactivate()
1076*cdf0e10cSrcweir {
1077*cdf0e10cSrcweir 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir 	if (pOLV)
1080*cdf0e10cSrcweir 		pOLV->HideCursor();
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir 	mpView->SetHitTolerancePixel( HITPIX );
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir 	FuConstruct::Deactivate();
1085*cdf0e10cSrcweir }
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir /*************************************************************************
1089*cdf0e10cSrcweir |*
1090*cdf0e10cSrcweir |* Objekt in Edit-Mode setzen
1091*cdf0e10cSrcweir |*
1092*cdf0e10cSrcweir \************************************************************************/
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir void FuText::SetInEditMode(const MouseEvent& rMEvt, sal_Bool bQuickDrag)
1095*cdf0e10cSrcweir {
1096*cdf0e10cSrcweir 	SdrPageView* pPV = mpView->GetSdrPageView();
1097*cdf0e10cSrcweir 	if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1098*cdf0e10cSrcweir 	{
1099*cdf0e10cSrcweir 		mpView->SetCurrentObj(OBJ_TEXT);
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir 		if( bPermanent )
1102*cdf0e10cSrcweir 			mpView->SetEditMode(SDREDITMODE_CREATE);
1103*cdf0e10cSrcweir 		else
1104*cdf0e10cSrcweir 			mpView->SetEditMode(SDREDITMODE_EDIT);
1105*cdf0e10cSrcweir 
1106*cdf0e10cSrcweir 		sal_Bool bEmptyOutliner = sal_False;
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir 		if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1109*cdf0e10cSrcweir 		{
1110*cdf0e10cSrcweir 			::Outliner* pOutl = mpView->GetTextEditOutliner();
1111*cdf0e10cSrcweir 			sal_uLong nParaAnz = pOutl->GetParagraphCount();
1112*cdf0e10cSrcweir 			Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir 			if (nParaAnz==1 && p1stPara)
1115*cdf0e10cSrcweir 			{
1116*cdf0e10cSrcweir 				// Bei nur einem Pararaph
1117*cdf0e10cSrcweir 				if (pOutl->GetText(p1stPara).Len() == 0)
1118*cdf0e10cSrcweir 				{
1119*cdf0e10cSrcweir 					bEmptyOutliner = sal_True;
1120*cdf0e10cSrcweir 				}
1121*cdf0e10cSrcweir 			}
1122*cdf0e10cSrcweir 		}
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir 		if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1125*cdf0e10cSrcweir 		{
1126*cdf0e10cSrcweir 			sal_uInt32 nInv = mxTextObj->GetObjInventor();
1127*cdf0e10cSrcweir 			sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1128*cdf0e10cSrcweir 
1129*cdf0e10cSrcweir 			if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1130*cdf0e10cSrcweir 				(nSdrObjKind == OBJ_TEXT ||
1131*cdf0e10cSrcweir 			 	nSdrObjKind == OBJ_TITLETEXT ||
1132*cdf0e10cSrcweir 			 	nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1133*cdf0e10cSrcweir 			{
1134*cdf0e10cSrcweir 				// Neuen Outliner machen (gehoert der SdrObjEditView)
1135*cdf0e10cSrcweir 				SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir 				if (bEmptyOutliner)
1138*cdf0e10cSrcweir 					mpView->SdrEndTextEdit(sal_True);
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir 				SdrTextObj* pTextObj = GetTextObj();
1141*cdf0e10cSrcweir 				if( pTextObj )
1142*cdf0e10cSrcweir 				{
1143*cdf0e10cSrcweir 					OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1144*cdf0e10cSrcweir 					if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1145*cdf0e10cSrcweir 						pOutl->SetVertical( sal_True );
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir 					if( pTextObj->getTextCount() > 1 )
1148*cdf0e10cSrcweir 					{
1149*cdf0e10cSrcweir 						Point aPix(rMEvt.GetPosPixel());
1150*cdf0e10cSrcweir 						Point aPnt(mpWindow->PixelToLogic(aPix));
1151*cdf0e10cSrcweir 						pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1152*cdf0e10cSrcweir 					}
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir 					if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, sal_True, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1155*cdf0e10cSrcweir 					{
1156*cdf0e10cSrcweir 						bFirstObjCreated = sal_True;
1157*cdf0e10cSrcweir 						DeleteDefaultText();
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir 						OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir 						nSdrObjKind = mxTextObj->GetObjIdentifier();
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir 						SdrViewEvent aVEvt;
1164*cdf0e10cSrcweir 						SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir 						if (eHit == SDRHIT_TEXTEDIT)
1167*cdf0e10cSrcweir 						{
1168*cdf0e10cSrcweir 							// Text getroffen
1169*cdf0e10cSrcweir 							if (nSdrObjKind == OBJ_TEXT ||
1170*cdf0e10cSrcweir 								nSdrObjKind == OBJ_TITLETEXT ||
1171*cdf0e10cSrcweir 								nSdrObjKind == OBJ_OUTLINETEXT ||
1172*cdf0e10cSrcweir 								nSdrObjKind == OBJ_TABLE ||
1173*cdf0e10cSrcweir 								nSlotId == SID_TEXTEDIT ||
1174*cdf0e10cSrcweir 								!bQuickDrag)
1175*cdf0e10cSrcweir 							{
1176*cdf0e10cSrcweir 								pOLV->MouseButtonDown(rMEvt);
1177*cdf0e10cSrcweir 								pOLV->MouseMove(rMEvt);
1178*cdf0e10cSrcweir 								pOLV->MouseButtonUp(rMEvt);
1179*cdf0e10cSrcweir 							}
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir 							if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1182*cdf0e10cSrcweir 							{
1183*cdf0e10cSrcweir 								pOLV->MouseButtonDown(rMEvt);
1184*cdf0e10cSrcweir 							}
1185*cdf0e10cSrcweir 						}
1186*cdf0e10cSrcweir 						else
1187*cdf0e10cSrcweir 						{
1188*cdf0e10cSrcweir 							// #98198# Move cursor to end of text
1189*cdf0e10cSrcweir 							ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1190*cdf0e10cSrcweir 							pOLV->SetSelection(aNewSelection);
1191*cdf0e10cSrcweir 						}
1192*cdf0e10cSrcweir 					}
1193*cdf0e10cSrcweir 					else
1194*cdf0e10cSrcweir 					{
1195*cdf0e10cSrcweir 						mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1196*cdf0e10cSrcweir 					}
1197*cdf0e10cSrcweir 				}
1198*cdf0e10cSrcweir 			}
1199*cdf0e10cSrcweir 		}
1200*cdf0e10cSrcweir 	}
1201*cdf0e10cSrcweir 	else
1202*cdf0e10cSrcweir 	{
1203*cdf0e10cSrcweir 		mxTextObj.reset(0);
1204*cdf0e10cSrcweir 	}
1205*cdf0e10cSrcweir }
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir /*************************************************************************
1208*cdf0e10cSrcweir |*
1209*cdf0e10cSrcweir |* Texteingabe wird gestartet, ggf. Default-Text loeschen
1210*cdf0e10cSrcweir |*
1211*cdf0e10cSrcweir \************************************************************************/
1212*cdf0e10cSrcweir 
1213*cdf0e10cSrcweir sal_Bool FuText::DeleteDefaultText()
1214*cdf0e10cSrcweir {
1215*cdf0e10cSrcweir 	sal_Bool bDeleted = sal_False;
1216*cdf0e10cSrcweir 
1217*cdf0e10cSrcweir 	if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1218*cdf0e10cSrcweir 	{
1219*cdf0e10cSrcweir 		String aString;
1220*cdf0e10cSrcweir 		SdPage* pPage = (SdPage*) mxTextObj->GetPage();
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir 		if (pPage)
1223*cdf0e10cSrcweir 		{
1224*cdf0e10cSrcweir 			PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir 			if ( (ePresObjKind == PRESOBJ_TITLE   ||
1227*cdf0e10cSrcweir 				  ePresObjKind == PRESOBJ_OUTLINE ||
1228*cdf0e10cSrcweir 				  ePresObjKind == PRESOBJ_NOTES   ||
1229*cdf0e10cSrcweir 				  ePresObjKind == PRESOBJ_TEXT) &&
1230*cdf0e10cSrcweir 				  !pPage->IsMasterPage() )
1231*cdf0e10cSrcweir 			{
1232*cdf0e10cSrcweir 				::Outliner* pOutliner = mpView->GetTextEditOutliner();
1233*cdf0e10cSrcweir 				SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1234*cdf0e10cSrcweir 				sal_Bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1235*cdf0e10cSrcweir 				if( bIsUndoEnabled )
1236*cdf0e10cSrcweir 					pOutliner->EnableUndo(sal_False);
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir 				pOutliner->SetText( String(), pOutliner->GetParagraph( 0 ) );
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir 				if( bIsUndoEnabled )
1241*cdf0e10cSrcweir 					pOutliner->EnableUndo(sal_True);
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir 				if (pSheet &&
1244*cdf0e10cSrcweir 					(ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1245*cdf0e10cSrcweir 					pOutliner->SetStyleSheet(0, pSheet);
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 				mxTextObj->SetEmptyPresObj(sal_True);
1248*cdf0e10cSrcweir 				bDeleted = sal_True;
1249*cdf0e10cSrcweir 			}
1250*cdf0e10cSrcweir 		}
1251*cdf0e10cSrcweir 	}
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir 	return(bDeleted);
1254*cdf0e10cSrcweir }
1255*cdf0e10cSrcweir 
1256*cdf0e10cSrcweir /*************************************************************************
1257*cdf0e10cSrcweir |*
1258*cdf0e10cSrcweir |* Command-event
1259*cdf0e10cSrcweir |*
1260*cdf0e10cSrcweir \************************************************************************/
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir sal_Bool FuText::Command(const CommandEvent& rCEvt)
1263*cdf0e10cSrcweir {
1264*cdf0e10cSrcweir 	return( FuPoor::Command(rCEvt) );
1265*cdf0e10cSrcweir }
1266*cdf0e10cSrcweir 
1267*cdf0e10cSrcweir /*************************************************************************
1268*cdf0e10cSrcweir |*
1269*cdf0e10cSrcweir |* Help-event
1270*cdf0e10cSrcweir |*
1271*cdf0e10cSrcweir \************************************************************************/
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir sal_Bool FuText::RequestHelp(const HelpEvent& rHEvt)
1274*cdf0e10cSrcweir {
1275*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir 	OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir 	if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1280*cdf0e10cSrcweir 		mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1281*cdf0e10cSrcweir 	{
1282*cdf0e10cSrcweir 		String aHelpText;
1283*cdf0e10cSrcweir 		const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1284*cdf0e10cSrcweir 		const SvxFieldData* pField = pFieldItem->GetField();
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 		if (pField && pField->ISA(SvxURLField))
1287*cdf0e10cSrcweir 		{
1288*cdf0e10cSrcweir 			/******************************************************************
1289*cdf0e10cSrcweir 			* URL-Field
1290*cdf0e10cSrcweir 			******************************************************************/
1291*cdf0e10cSrcweir 			aHelpText = INetURLObject::decode( ((const SvxURLField*)pField)->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1292*cdf0e10cSrcweir 		}
1293*cdf0e10cSrcweir 		if (aHelpText.Len())
1294*cdf0e10cSrcweir 		{
1295*cdf0e10cSrcweir 			Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1296*cdf0e10cSrcweir 			Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1297*cdf0e10cSrcweir 								  mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir 			if (Help::IsBalloonHelpEnabled())
1300*cdf0e10cSrcweir 			{
1301*cdf0e10cSrcweir 				bReturn = Help::ShowBalloon( (Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1302*cdf0e10cSrcweir 			}
1303*cdf0e10cSrcweir 			else if (Help::IsQuickHelpEnabled())
1304*cdf0e10cSrcweir 			{
1305*cdf0e10cSrcweir 				bReturn = Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1306*cdf0e10cSrcweir 			}
1307*cdf0e10cSrcweir 		}
1308*cdf0e10cSrcweir 	}
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir 	if (!bReturn)
1311*cdf0e10cSrcweir 	{
1312*cdf0e10cSrcweir 		bReturn = FuConstruct::RequestHelp(rHEvt);
1313*cdf0e10cSrcweir 	}
1314*cdf0e10cSrcweir 
1315*cdf0e10cSrcweir 	return(bReturn);
1316*cdf0e10cSrcweir }
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir /*************************************************************************
1319*cdf0e10cSrcweir |*
1320*cdf0e10cSrcweir |* Request verarbeiten
1321*cdf0e10cSrcweir |*
1322*cdf0e10cSrcweir \************************************************************************/
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir void FuText::ReceiveRequest(SfxRequest& rReq)
1325*cdf0e10cSrcweir {
1326*cdf0e10cSrcweir 	nSlotId = rReq.GetSlot();
1327*cdf0e10cSrcweir 
1328*cdf0e10cSrcweir 	// Dann Basisklasse rufen (dort wird u.a. nSlotId NICHT gesetzt)
1329*cdf0e10cSrcweir 	FuPoor::ReceiveRequest(rReq);
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir 	if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || /*#95971#*/ SID_ATTR_CHAR == nSlotId)
1332*cdf0e10cSrcweir 	{
1333*cdf0e10cSrcweir 		MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir 		mxTextObj.reset(0);
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir 		if (nSlotId == SID_TEXTEDIT)
1338*cdf0e10cSrcweir 		{
1339*cdf0e10cSrcweir 			// Wird gerade editiert?
1340*cdf0e10cSrcweir 			if(!bTestText)
1341*cdf0e10cSrcweir 				mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir 			if (!mxTextObj.is())
1344*cdf0e10cSrcweir 			{
1345*cdf0e10cSrcweir 				// Versuchen, ein Obj zu selektieren
1346*cdf0e10cSrcweir 				SdrPageView* pPV = mpView->GetSdrPageView();
1347*cdf0e10cSrcweir 				SdrViewEvent aVEvt;
1348*cdf0e10cSrcweir 				mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1349*cdf0e10cSrcweir 				mpView->MarkObj(aVEvt.pRootObj, pPV);
1350*cdf0e10cSrcweir 
1351*cdf0e10cSrcweir 				if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1352*cdf0e10cSrcweir 				{
1353*cdf0e10cSrcweir 					mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1354*cdf0e10cSrcweir 				}
1355*cdf0e10cSrcweir 			}
1356*cdf0e10cSrcweir 		}
1357*cdf0e10cSrcweir 		else if (mpView->AreObjectsMarked())
1358*cdf0e10cSrcweir 		{
1359*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir 			if (rMarkList.GetMarkCount() == 1)
1362*cdf0e10cSrcweir 			{
1363*cdf0e10cSrcweir 				SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir 				if (pObj->ISA(SdrTextObj))
1366*cdf0e10cSrcweir 				{
1367*cdf0e10cSrcweir 					mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1368*cdf0e10cSrcweir 				}
1369*cdf0e10cSrcweir 			}
1370*cdf0e10cSrcweir 		}
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir 		sal_Bool bQuickDrag = sal_True;
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir 		const SfxItemSet* pArgs = rReq.GetArgs();
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir 		if (pArgs
1377*cdf0e10cSrcweir 
1378*cdf0e10cSrcweir 			// #98198# test for type before using
1379*cdf0e10cSrcweir 			&& SID_TEXTEDIT == nSlotId
1380*cdf0e10cSrcweir 			&& SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
1381*cdf0e10cSrcweir 
1382*cdf0e10cSrcweir 			&& (sal_uInt16) ((SfxUInt16Item&) pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1383*cdf0e10cSrcweir 		{
1384*cdf0e10cSrcweir 			// Anwahl per Doppelklick -> kein QuickDrag zulassen
1385*cdf0e10cSrcweir 			bQuickDrag = sal_False;
1386*cdf0e10cSrcweir 		}
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir 		SetInEditMode(aMEvt, bQuickDrag);
1389*cdf0e10cSrcweir 	}
1390*cdf0e10cSrcweir }
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir 
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir /*************************************************************************
1395*cdf0e10cSrcweir |*
1396*cdf0e10cSrcweir |* SpellChecker: Error-LinkHdl
1397*cdf0e10cSrcweir |*
1398*cdf0e10cSrcweir \************************************************************************/
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir IMPL_LINK( FuText, SpellError, void *, nLang )
1401*cdf0e10cSrcweir {
1402*cdf0e10cSrcweir 	String aError( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_uLong)nLang ) );
1403*cdf0e10cSrcweir 	ErrorHandler::HandleError(* new StringErrorInfo(
1404*cdf0e10cSrcweir 								ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) );
1405*cdf0e10cSrcweir 	return 0;
1406*cdf0e10cSrcweir }
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir /*************************************************************************
1410*cdf0e10cSrcweir |*
1411*cdf0e10cSrcweir |* Reaktion auf Doppelklick
1412*cdf0e10cSrcweir |*
1413*cdf0e10cSrcweir \************************************************************************/
1414*cdf0e10cSrcweir void FuText::DoubleClick(const MouseEvent& )
1415*cdf0e10cSrcweir {
1416*cdf0e10cSrcweir 	// Nichts zu tun
1417*cdf0e10cSrcweir }
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir /** #97016#
1420*cdf0e10cSrcweir     #105815# Removed the insertion of default text and putting a new text
1421*cdf0e10cSrcweir     object directly into edit mode.
1422*cdf0e10cSrcweir */
1423*cdf0e10cSrcweir SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1424*cdf0e10cSrcweir {
1425*cdf0e10cSrcweir 	// case SID_TEXTEDIT:	// BASIC ???
1426*cdf0e10cSrcweir 	// case SID_ATTR_CHAR:
1427*cdf0e10cSrcweir 	// case SID_ATTR_CHAR_VERTICAL:
1428*cdf0e10cSrcweir 	// case SID_TEXT_FITTOSIZE:
1429*cdf0e10cSrcweir 	// case SID_TEXT_FITTOSIZE_VERTICAL:
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
1432*cdf0e10cSrcweir 		mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1433*cdf0e10cSrcweir 		0L, mpDoc);
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir 	if(pObj)
1436*cdf0e10cSrcweir 	{
1437*cdf0e10cSrcweir 		if(pObj->ISA(SdrTextObj))
1438*cdf0e10cSrcweir 		{
1439*cdf0e10cSrcweir 			SdrTextObj* pText = (SdrTextObj*)pObj;
1440*cdf0e10cSrcweir 			pText->SetLogicRect(rRectangle);
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 			sal_Bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1443*cdf0e10cSrcweir 			pText->SetVerticalWriting(bVertical);
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir 			// #97016#
1446*cdf0e10cSrcweir 			ImpSetAttributesForNewTextObject(pText);
1447*cdf0e10cSrcweir 
1448*cdf0e10cSrcweir 			if (nSlotId == SID_TEXT_FITTOSIZE)
1449*cdf0e10cSrcweir 			{
1450*cdf0e10cSrcweir 				// #97016#
1451*cdf0e10cSrcweir 				ImpSetAttributesFitToSize(pText);
1452*cdf0e10cSrcweir 			}
1453*cdf0e10cSrcweir 			else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1454*cdf0e10cSrcweir 			{
1455*cdf0e10cSrcweir 				// #97016#
1456*cdf0e10cSrcweir 				ImpSetAttributesFitToSizeVertical(pText);
1457*cdf0e10cSrcweir 			}
1458*cdf0e10cSrcweir 			else
1459*cdf0e10cSrcweir 			{
1460*cdf0e10cSrcweir 				// #97016#
1461*cdf0e10cSrcweir 				ImpSetAttributesFitCommon(pText);
1462*cdf0e10cSrcweir 			}
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir             // Put text object into edit mode.
1465*cdf0e10cSrcweir             SdrPageView* pPV = mpView->GetSdrPageView();
1466*cdf0e10cSrcweir             mpView->SdrBeginTextEdit(pText, pPV);
1467*cdf0e10cSrcweir 		}
1468*cdf0e10cSrcweir 		else
1469*cdf0e10cSrcweir 		{
1470*cdf0e10cSrcweir 			DBG_ERROR("Object is NO text object");
1471*cdf0e10cSrcweir 		}
1472*cdf0e10cSrcweir 	}
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir 	return pObj;
1475*cdf0e10cSrcweir }
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir 
1479*cdf0e10cSrcweir 
1480*cdf0e10cSrcweir /** is called when the currenct function should be aborted. <p>
1481*cdf0e10cSrcweir 	This is used when a function gets a KEY_ESCAPE but can also
1482*cdf0e10cSrcweir 	be called directly.
1483*cdf0e10cSrcweir 
1484*cdf0e10cSrcweir 	@returns true if a active function was aborted
1485*cdf0e10cSrcweir */
1486*cdf0e10cSrcweir bool FuText::cancel()
1487*cdf0e10cSrcweir {
1488*cdf0e10cSrcweir 	if ( mpView->IsTextEdit() )
1489*cdf0e10cSrcweir 	{
1490*cdf0e10cSrcweir 		if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1491*cdf0e10cSrcweir 			mxTextObj.reset(0);
1492*cdf0e10cSrcweir 
1493*cdf0e10cSrcweir 		mpView->SetCurrentObj(OBJ_TEXT);
1494*cdf0e10cSrcweir 		mpView->SetEditMode(SDREDITMODE_EDIT);
1495*cdf0e10cSrcweir 		return true;
1496*cdf0e10cSrcweir 	}
1497*cdf0e10cSrcweir 	else
1498*cdf0e10cSrcweir 	{
1499*cdf0e10cSrcweir 		return false;
1500*cdf0e10cSrcweir 	}
1501*cdf0e10cSrcweir }
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1504*cdf0e10cSrcweir {
1505*cdf0e10cSrcweir     if( !pFontList || !pView )
1506*cdf0e10cSrcweir         return;
1507*cdf0e10cSrcweir 
1508*cdf0e10cSrcweir     if( pOLV )
1509*cdf0e10cSrcweir     {
1510*cdf0e10cSrcweir         pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1511*cdf0e10cSrcweir     }
1512*cdf0e10cSrcweir     else
1513*cdf0e10cSrcweir     {
1514*cdf0e10cSrcweir //		SdDrawDocument* pDoc = pView->GetDoc();
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1517*cdf0e10cSrcweir         for( sal_uInt32 nMark = 0; nMark < rMarkList.GetMarkCount(); nMark++ )
1518*cdf0e10cSrcweir         {
1519*cdf0e10cSrcweir             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1520*cdf0e10cSrcweir             if( pTextObj )
1521*cdf0e10cSrcweir             {
1522*cdf0e10cSrcweir                 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1523*cdf0e10cSrcweir                 {
1524*cdf0e10cSrcweir                     pTextObj->setActiveText( nText );
1525*cdf0e10cSrcweir 
1526*cdf0e10cSrcweir                     // Put text object into edit mode.
1527*cdf0e10cSrcweir                     SdrPageView* pPV = pView->GetSdrPageView();
1528*cdf0e10cSrcweir                     pView->SdrBeginTextEdit(pTextObj, pPV);
1529*cdf0e10cSrcweir 
1530*cdf0e10cSrcweir                     pOLV = pView->GetTextEditOutlinerView();
1531*cdf0e10cSrcweir                     if( pOLV )
1532*cdf0e10cSrcweir                     {
1533*cdf0e10cSrcweir                         EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1534*cdf0e10cSrcweir                         if( pEditEngine )
1535*cdf0e10cSrcweir                         {
1536*cdf0e10cSrcweir                             ESelection aSel;
1537*cdf0e10cSrcweir                             aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1538*cdf0e10cSrcweir                             aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1539*cdf0e10cSrcweir                             pOLV->SetSelection(aSel);
1540*cdf0e10cSrcweir                         }
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir                         ChangeFontSize( bGrow, pOLV, pFontList, pView );
1543*cdf0e10cSrcweir                     }
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir                     pView->SdrEndTextEdit();
1546*cdf0e10cSrcweir                 }
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir                 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1549*cdf0e10cSrcweir                 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1550*cdf0e10cSrcweir                 {
1551*cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1552*cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1553*cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1554*cdf0e10cSrcweir                 }
1555*cdf0e10cSrcweir             }
1556*cdf0e10cSrcweir         }
1557*cdf0e10cSrcweir     }
1558*cdf0e10cSrcweir }
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir } // end of namespace sd
1561*cdf0e10cSrcweir 
1562