merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / futext.cxx
blobcb1e38e3aa7e76ff79093a96f1df587025202aa3
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: futext.cxx,v $
10 * $Revision: 1.66.8.1 $
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_sd.hxx"
35 #include "futext.hxx"
36 #include <svx/eeitem.hxx>
37 #include <svx/dlgutil.hxx>
38 #include <svx/svxerr.hxx>
39 #include <tools/urlobj.hxx>
40 #include <vcl/help.hxx>
41 #include <svx/editstat.hxx>
42 #include <svtools/aeitem.hxx>
43 #include <svtools/intitem.hxx>
44 #include <svx/svdotext.hxx>
45 #ifndef _SVDOGROUP_HXX //autogen
46 #include <svx/svdogrp.hxx>
47 #endif
48 #include <svx/flditem.hxx>
49 #include <svtools/style.hxx>
50 #include <svx/svdpagv.hxx>
51 #include <sfx2/viewfrm.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <sfx2/bindings.hxx>
54 #include <sfx2/request.hxx>
55 #include <svx/editeng.hxx>
56 #include <svx/svdoutl.hxx>
57 #include <svx/svxids.hrc>
58 #include <sfx2/docfile.hxx>
59 #include <comphelper/processfactory.hxx>
60 #include <svx/outlobj.hxx>
63 // #104122#
64 #include <svx/frmdiritem.hxx>
66 #include <svx/svdetc.hxx>
67 #include <svx/editview.hxx>
69 #include "sdresid.hxx"
70 #include "app.hrc"
71 #include "res_bmp.hrc"
72 #include "ViewShell.hxx"
73 #include "ViewShellBase.hxx"
74 #include "View.hxx"
75 #include "Outliner.hxx"
76 #include "Window.hxx"
77 #include "drawdoc.hxx"
78 #include "sdpage.hxx"
79 #include "sdmod.hxx"
80 #include "FrameView.hxx"
81 #include "ToolBarManager.hxx"
82 #include "DrawDocShell.hxx"
83 #include "glob.hrc"
84 #include "pres.hxx"
85 #include "optsitem.hxx"
87 using ::rtl::OUString;
88 using namespace ::com::sun::star;
89 using namespace ::com::sun::star::uno;
90 using namespace ::com::sun::star::lang;
91 using namespace ::com::sun::star::linguistic2;
93 namespace sd {
95 static USHORT SidArray[] = {
96 SID_STYLE_FAMILY2, // 5542
97 SID_STYLE_FAMILY5, // 5545
98 SID_CUT, // 5710
99 SID_COPY, // 5711
100 SID_ATTR_TABSTOP, // 10002
101 SID_ATTR_CHAR_FONT, // 10007
102 SID_ATTR_CHAR_POSTURE, // 10008
103 SID_ATTR_CHAR_WEIGHT, // 10009
104 SID_ATTR_CHAR_UNDERLINE, // 10014
105 SID_ATTR_CHAR_FONTHEIGHT, // 10015
106 SID_ATTR_CHAR_COLOR, // 10017
107 SID_ATTR_PARA_ADJUST_LEFT, // 10028
108 SID_ATTR_PARA_ADJUST_RIGHT, // 10029
109 SID_ATTR_PARA_ADJUST_CENTER, // 10030
110 SID_ATTR_PARA_ADJUST_BLOCK, // 10031
111 SID_ATTR_PARA_LINESPACE_10, // 10034
112 SID_ATTR_PARA_LINESPACE_15, // 10035
113 SID_ATTR_PARA_LINESPACE_20, // 10036
114 SID_ATTR_PARA_LRSPACE, // 10043
115 SID_OUTLINE_UP, // 10150
116 SID_OUTLINE_DOWN, // 10151
117 SID_OUTLINE_LEFT, // 10152
118 SID_OUTLINE_RIGHT, // 10153
119 SID_FORMTEXT_STYLE, // 10257
120 SID_SET_SUPER_SCRIPT, // 10294
121 SID_SET_SUB_SCRIPT, // 10295
122 SID_HYPERLINK_GETLINK, // 10361
123 SID_CHARMAP, // 10503
124 SID_TEXTDIRECTION_LEFT_TO_RIGHT, // 10907
125 SID_TEXTDIRECTION_TOP_TO_BOTTOM, // 10908
126 SID_ATTR_PARA_LEFT_TO_RIGHT, // 10950
127 SID_ATTR_PARA_RIGHT_TO_LEFT, // 10951
128 FN_NUM_BULLET_ON, // 20138
129 SID_PARASPACE_INCREASE, // 27346
130 SID_PARASPACE_DECREASE, // 27347
131 0 };
133 TYPEINIT1( FuText, FuConstruct );
136 static BOOL bTestText = 0;
138 /*************************************************************************
140 |* Basisklasse fuer Textfunktionen
142 \************************************************************************/
144 FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
145 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
146 , bFirstObjCreated(FALSE)
147 , rRequest (rReq)
151 FunctionReference FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
153 FunctionReference xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
154 return xFunc;
157 /*************************************************************************
159 |* Destruktor
161 \************************************************************************/
163 void FuText::disposing()
165 if(mpView)
167 if(mpView->SdrEndTextEdit(FALSE) == SDRENDTEXTEDIT_DELETED)
168 mxTextObj.reset( 0 );
170 // die RequestHandler der benutzten Outliner zuruecksetzen auf den
171 // Handler am Dokument
172 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
174 if (pOutliner)
175 pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
179 /*************************************************************************
181 |* Execute functionality of this class:
183 |* #71422: Start the functionality of this class in this method
184 |* and not in the ctor.
185 |* If you construct an object of this class and you put the
186 |* address of this object to pFuActual you've got a problem,
187 |* because some methods inside DoExecute use the pFuActual-Pointer.
188 |* If the code inside DoExecute is executed inside the ctor,
189 |* the value of pFuActual is not right. And the value will not
190 |* be right until the ctor finished !!!
192 \************************************************************************/
193 void FuText::DoExecute( SfxRequest& )
195 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
196 ToolBarManager::TBG_FUNCTION,
197 RID_DRAW_TEXT_TOOLBOX);
199 mpView->SetCurrentObj(OBJ_TEXT);
200 mpView->SetEditMode(SDREDITMODE_EDIT);
202 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
204 if (nSlotId == SID_TEXTEDIT)
206 // Try to select an object
207 SdrPageView* pPV = mpView->GetSdrPageView();
208 SdrViewEvent aVEvt;
209 mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
210 mpView->MarkObj(aVEvt.pRootObj, pPV);
212 mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
214 else if (mpView->AreObjectsMarked())
216 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
218 if (rMarkList.GetMarkCount() == 1)
220 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
221 mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
225 // check for table
226 if (mpView->AreObjectsMarked())
228 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
230 if (rMarkList.GetMarkCount() == 1)
232 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
233 if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
235 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
240 BOOL bQuickDrag = TRUE;
242 const SfxItemSet* pArgs = rRequest.GetArgs();
244 if (pArgs
246 // #98198# test for type before using
247 && SID_TEXTEDIT == nSlotId
248 && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
250 && (UINT16)((SfxUInt16Item&)pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
252 // Selection by doubleclick -> don't allow QuickDrag
253 bQuickDrag = FALSE;
256 SetInEditMode(aMEvt, bQuickDrag);
259 /*************************************************************************
261 |* MouseButtonDown-event
263 \************************************************************************/
265 BOOL FuText::MouseButtonDown(const MouseEvent& rMEvt)
267 bMBDown = TRUE;
269 BOOL bReturn = FuDraw::MouseButtonDown(rMEvt);
271 /* af: (de)Select object before showing the context menu.
272 // Fuer PopupMenu (vorher DrawViewShell)
273 if ((rMEvt.GetButtons() == MOUSE_RIGHT) && rMEvt.GetClicks() == 1 &&
274 mpView->IsTextEdit())
276 return (TRUE);
280 mpView->SetMarkHdlWhenTextEdit(TRUE);
281 SdrViewEvent aVEvt;
282 SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
284 if (eHit == SDRHIT_TEXTEDIT)
286 // Text getroffen -> Event von SdrView auswerten lassen
287 if (mpView->MouseButtonDown(rMEvt, mpWindow))
288 return (TRUE);
291 if (rMEvt.GetClicks() == 1)
293 if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
295 // Texteingabe beenden
296 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
298 // Bugfix von MBA: bei Doppelclick auf der Wiese im Modus Text wird
299 // beim zweiten Click eHit = SDRHIT_TEXTEDITOBJ erhalten, weil ja der
300 // zweite Click auf das im ersten Click angelegte TextObject geht.
301 // Dieses wird aber in SdrEndTextEdit entfernt, weil es leer ist. Es
302 // befindet sich aber noch in der Mark-Liste und der Aufruf MarkObj
303 // weiter unten greift dann auf das tote Object zu.
304 // Als einfacher Fix wird nach SdrEndTextEdit noch einmal eHit ermittelt,
305 // was dann SDRHIT_NONE liefert.
306 mxTextObj.reset( NULL );
307 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
310 mpView->SetCurrentObj(OBJ_TEXT);
311 mpView->SetEditMode(SDREDITMODE_EDIT);
314 if (rMEvt.IsLeft() || rMEvt.IsRight())
316 mpWindow->CaptureMouse();
317 SdrObject* pObj;
318 SdrPageView* pPV = mpView->GetSdrPageView();
320 if (eHit == SDRHIT_TEXTEDIT)
322 SetInEditMode(rMEvt, FALSE);
324 else
326 BOOL bMacro = FALSE;
328 if (bMacro && mpView->PickObj(aMDPos,mpView->getHitTolLog(),pObj,pPV,SDRSEARCH_PICKMACRO))
330 // Makro
331 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
332 mpView->BegMacroObj(aMDPos,nHitLog,pObj,pPV,mpWindow);
334 else
336 if (eHit != SDRHIT_HANDLE)
338 // Selektion aufheben
339 if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
341 mpView->UnmarkAll();
342 mpView->SetDragMode(SDRDRAG_MOVE);
346 if ( aVEvt.eEvent == SDREVENT_EXECUTEURL ||
347 eHit == SDRHIT_HANDLE ||
348 eHit == SDRHIT_MARKEDOBJECT ||
349 eHit == SDRHIT_TEXTEDITOBJ ||
350 ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
351 !bPermanent ) )
353 /**********************************************************
354 * Handle, markiertes oder unmarkiertes Objekt getroffen
355 **********************************************************/
356 if (eHit == SDRHIT_TEXTEDITOBJ)
358 /******************************************************
359 * Text eines unmarkierten Objekts getroffen:
360 * Objekt wird selektiert und in EditMode versetzt
361 ******************************************************/
362 mpView->MarkObj(aVEvt.pRootObj, pPV);
364 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
366 mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
369 SetInEditMode(rMEvt, TRUE);
371 else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
373 /******************************************************
374 * URL ausfuehren
375 ******************************************************/
376 mpWindow->ReleaseMouse();
377 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
378 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
379 SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
380 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
381 mpWindow->ReleaseMouse();
383 if (rMEvt.IsMod1())
385 // Im neuen Frame oeffnen
386 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
387 &aStrItem, &aBrowseItem, &aReferer, 0L);
389 else
391 // Im aktuellen Frame oeffnen
392 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
393 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
394 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
397 else
399 /******************************************************
400 * Objekt oder Handle draggen
401 ******************************************************/
403 // #i78748#
404 // do the EndTextEdit first, it will delete the handles and force a
405 // recreation. This will make aVEvt.pHdl to point to a deleted handle,
406 // thus it is necessary to reset it and to get it again.
407 ::Outliner* pOutl = mpView->GetTextEditOutliner();
409 if (mxTextObj.is() && (mxTextObj->GetOutlinerParaObject() ||
410 (pOutl && pOutl->GetText(pOutl->GetParagraph( 0 )).Len() != 0)))
412 mpView->SdrEndTextEdit();
414 if(aVEvt.pHdl)
416 // force new handle identification, the pointer will be dead here
417 // since SdrEndTextEdit has resetted (deleted) the handles.
418 aVEvt.pHdl = 0;
419 mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
423 if (!aVEvt.pHdl)
425 if( eHit == SDRHIT_UNMARKEDOBJECT )
427 if ( !rMEvt.IsShift() )
428 mpView->UnmarkAll();
430 mpView->MarkObj(aVEvt.pRootObj, pPV);
433 // Objekt draggen
434 bFirstMouseMove = TRUE;
435 aDragTimer.Start();
439 if ( ! rMEvt.IsRight())
441 // we need to pick again since SdrEndTextEdit can rebuild the handles list
442 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
443 if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
445 USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
446 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
449 bReturn = true;
452 else if ( nSlotId != SID_TEXTEDIT &&
453 (bPermanent || !bFirstObjCreated) )
455 /**********************************************************
456 * Objekt erzeugen
457 **********************************************************/
458 mpView->SetCurrentObj(OBJ_TEXT);
459 mpView->SetEditMode(SDREDITMODE_CREATE);
460 USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
461 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
463 else
465 /**********************************************************
466 * Selektieren
467 **********************************************************/
468 if( !rMEvt.IsShift() )
469 mpView->UnmarkAll();
471 mpView->BegMarkObj( aMDPos );
477 else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
479 MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
480 SetInEditMode( aMEvt, FALSE );
483 if (!bIsInDragMode)
485 ForcePointer(&rMEvt);
486 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
489 return (bReturn);
492 /*************************************************************************
494 |* MouseMove-event
496 \************************************************************************/
498 BOOL FuText::MouseMove(const MouseEvent& rMEvt)
500 BOOL bReturn = FuDraw::MouseMove(rMEvt);
502 if (aDragTimer.IsActive() )
504 if( bFirstMouseMove )
505 bFirstMouseMove = FALSE;
506 else
507 aDragTimer.Stop();
510 if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
512 Point aPix(rMEvt.GetPosPixel());
513 Point aPnt(mpWindow->PixelToLogic(aPix));
515 ForceScroll(aPix);
516 mpView->MovAction(aPnt);
519 ForcePointer(&rMEvt);
521 return (bReturn);
524 /*************************************************************************
526 |* MouseButtonUp-event
528 \************************************************************************/
530 // #97016#
531 void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
533 if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
535 if( nSlotId == SID_ATTR_CHAR )
537 // Impress-Textobjekt wird erzeugt (faellt auf Zeilenhoehe zusammen)
538 // Damit das Objekt beim anschliessenden Erzeugen gleich die richtige
539 // Hoehe bekommt (sonst wird zuviel gepainted)
540 SfxItemSet aSet(mpViewShell->GetPool());
541 aSet.Put(SdrTextMinFrameHeightItem(0));
542 aSet.Put(SdrTextAutoGrowWidthItem(FALSE));
543 aSet.Put(SdrTextAutoGrowHeightItem(TRUE));
544 pTxtObj->SetMergedItemSet(aSet);
545 pTxtObj->AdjustTextFrameWidthAndHeight();
546 aSet.Put(SdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
547 pTxtObj->SetMergedItemSet(aSet);
549 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
551 SfxItemSet aSet(mpViewShell->GetPool());
552 aSet.Put(SdrTextMinFrameWidthItem(0));
553 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
554 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
556 // #91853# Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
557 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
558 pTxtObj->SetMergedItemSet(aSet);
559 pTxtObj->AdjustTextFrameWidthAndHeight();
560 aSet.Put(SdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
561 pTxtObj->SetMergedItemSet(aSet);
564 else
566 if( nSlotId == SID_ATTR_CHAR_VERTICAL )
568 // draw text object, needs to be initialized when vertical text is used
569 SfxItemSet aSet(mpViewShell->GetPool());
571 // #91510#
572 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
573 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
575 // #91508#
576 //aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
577 //aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
579 // #107235#
580 // Set defaults for vertical klick-n'drag text object, pool defaults are:
581 // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
582 // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
583 // Analog to that (thus, #91508# was not completely correct):
584 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
585 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
587 pTxtObj->SetMergedItemSet(aSet);
592 // #97016#
593 void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
595 // FitToSize (An Rahmen anpassen)
596 SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
597 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
598 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
599 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
600 aSet.Put(SdrTextAutoGrowWidthItem(FALSE));
601 pTxtObj->SetMergedItemSet(aSet);
602 pTxtObj->AdjustTextFrameWidthAndHeight();
605 // #97016#
606 void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
608 SfxItemSet aSet(mpViewShell->GetPool(),
609 SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
610 SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
611 aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
612 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
613 aSet.Put(SdrTextAutoGrowWidthItem(FALSE));
614 pTxtObj->SetMergedItemSet(aSet);
615 pTxtObj->AdjustTextFrameWidthAndHeight();
618 // #97016#
619 void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
621 // Normales Textobjekt
622 if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
624 if( nSlotId == SID_ATTR_CHAR )
626 // Impress-Textobjekt (faellt auf Zeilenhoehe zusammen)
627 SfxItemSet aSet(mpViewShell->GetPool());
628 aSet.Put(SdrTextMinFrameHeightItem(0));
629 aSet.Put(SdrTextMaxFrameHeightItem(0));
630 aSet.Put(SdrTextAutoGrowHeightItem(TRUE));
631 aSet.Put(SdrTextAutoGrowWidthItem(FALSE));
632 pTxtObj->SetMergedItemSet(aSet);
634 else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
636 SfxItemSet aSet(mpViewShell->GetPool());
637 aSet.Put(SdrTextMinFrameWidthItem(0));
638 aSet.Put(SdrTextMaxFrameWidthItem(0));
639 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
640 aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
641 pTxtObj->SetMergedItemSet(aSet);
644 pTxtObj->AdjustTextFrameWidthAndHeight();
648 BOOL FuText::MouseButtonUp(const MouseEvent& rMEvt)
650 BOOL bReturn = FALSE;
652 if (aDragTimer.IsActive())
654 aDragTimer.Stop();
655 bIsInDragMode = FALSE;
658 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
660 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
662 if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
663 return (TRUE); // Event von der SdrView ausgewertet
665 BOOL bEmptyTextObj = FALSE;
667 if (mxTextObj.is())
669 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
671 if (rMarkList.GetMarkCount() == 1
672 && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
674 if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
675 bEmptyTextObj = TRUE;
676 else
677 bFirstObjCreated = TRUE;
679 else
681 mxTextObj.reset( 0 );
685 if( mpView && mpView->IsDragObj())
687 /**********************************************************************
688 * Objekt wurde verschoben
689 **********************************************************************/
690 FrameView* pFrameView = mpViewShell->GetFrameView();
691 BOOL bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
693 if (bDragWithCopy)
695 bDragWithCopy = !mpView->IsPresObjSelected(FALSE, TRUE);
698 mpView->SetDragWithCopy(bDragWithCopy);
699 mpView->EndDragObj( mpView->IsDragWithCopy() );
700 mpView->ForceMarkedToAnotherPage();
701 mpView->SetCurrentObj(OBJ_TEXT);
703 else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
705 /**********************************************************************
706 * Objekt wurde erzeugt
707 **********************************************************************/
708 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
710 if( mxTextObj.is() )
712 //AW outliner needs to be set to vertical when there is no
713 // outliner object up to now; also it needs to be set back to not
714 // vertical when there was a vertical one used last time.
715 OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
716 SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
717 BOOL bVertical((pOPO && pOPO->IsVertical())
718 || nSlotId == SID_ATTR_CHAR_VERTICAL
719 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
720 rOutl.SetVertical(bVertical);
722 // #107235#
723 // Before ImpSetAttributesForNewTextObject the vertical writing mode
724 // needs to be set at the object. This is done here at the OutlinerParaObject
725 // directly to not mirror the layout text items involved. These items will be set
726 // from ImpSetAttributesForNewTextObject and below.
727 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
729 if(!pPara)
731 GetTextObj()->ForceOutlinerParaObject();
732 pPara = GetTextObj()->GetOutlinerParaObject();
735 if(pPara && (bool)bVertical != pPara->IsVertical())
737 // set ParaObject orientation accordingly
738 pPara->SetVertical(bVertical);
741 // #97016#
742 ImpSetAttributesForNewTextObject(GetTextObj());
745 if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
747 // Textobjekt konnte nicht erzeugt werden
748 mxTextObj.reset(0);
750 else if (nSlotId == SID_TEXT_FITTOSIZE)
752 // #97016#
753 ImpSetAttributesFitToSize(GetTextObj());
755 SetInEditMode(rMEvt, FALSE);
757 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
759 // #97016#
760 ImpSetAttributesFitToSizeVertical(GetTextObj());
762 SetInEditMode(rMEvt, FALSE);
764 else
766 // #97016#
767 ImpSetAttributesFitCommon(GetTextObj());
769 // Damit die Handles und der graue Rahmen stimmen
770 mpView->AdjustMarkHdl();
771 mpView->PickHandle(aPnt);
772 SetInEditMode(rMEvt, FALSE);
775 else if ( mpView && mpView->IsAction())
777 mpView->EndAction();
780 ForcePointer(&rMEvt);
781 mpWindow->ReleaseMouse();
782 USHORT nDrgLog1 = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
784 if ( mpView && !mpView->AreObjectsMarked() &&
785 Abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
786 Abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
787 !rMEvt.IsShift() && !rMEvt.IsMod2() )
789 SdrPageView* pPV = mpView->GetSdrPageView();
790 SdrViewEvent aVEvt;
791 mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
792 mpView->MarkObj(aVEvt.pRootObj, pPV);
795 if ( !mxTextObj.is() && mpView )
797 if ( ( (!bEmptyTextObj && bPermanent) ||
798 (!bFirstObjCreated && !bPermanent) ) &&
799 !mpDocSh->IsReadOnly() &&
800 nSlotId != SID_TEXTEDIT )
802 /**********************************************************************
803 * Mengentext (linksbuendiges AutoGrow)
804 **********************************************************************/
805 mpView->SetCurrentObj(OBJ_TEXT);
806 mpView->SetEditMode(SDREDITMODE_CREATE);
807 USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
808 mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
810 BOOL bSnapEnabled = mpView->IsSnapEnabled();
812 if (bSnapEnabled)
813 mpView->SetSnapEnabled(FALSE);
815 aPnt.X() += nDrgLog + nDrgLog;
816 aPnt.Y() += nDrgLog + nDrgLog;
817 mpView->MovAction(aPnt);
819 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
821 if(mxTextObj.is())
823 GetTextObj()->SetDisableAutoWidthOnDragging(TRUE);
826 if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
828 mxTextObj.reset(0);
831 if(bSnapEnabled)
832 mpView->SetSnapEnabled(bSnapEnabled);
834 if(mxTextObj.is())
836 SfxItemSet aSet(mpViewShell->GetPool());
837 aSet.Put(SdrTextMinFrameHeightItem(0));
838 aSet.Put(SdrTextMinFrameWidthItem(0));
839 aSet.Put(SdrTextAutoGrowHeightItem(TRUE));
840 aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
842 // #91508#
843 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
845 // #107235#
847 // Here, all items which need to be different from pool default need to be set
848 // again on the newly created text object.
849 // Since this is a simple klick text object, it is first created, then SetVertical()
850 // is used, then ImpSetAttributesForNewTextObject is called and then the object is
851 // deleted again since not the minimum drag distance was travelled. Then, a new
852 // klick text object is created and thus all that stuff needs to be set again here.
854 // Before using the new object the vertical writing mode
855 // needs to be set. This is done here at the OutlinerParaObject
856 // directly to not mirror the layout text items involved. These items will be set
857 // below.
858 OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
860 if(!pPara)
862 GetTextObj()->ForceOutlinerParaObject();
863 pPara = GetTextObj()->GetOutlinerParaObject();
866 if(pPara && sal_True != pPara->IsVertical())
868 // set ParaObject orientation accordingly
869 pPara->SetVertical(sal_True);
872 // #91508#
873 // aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
874 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
876 // #107235#
877 // Analog to the else case below, for vertical simple click texts
878 // one of the defaulted setted items from ImpSetAttributesForNewTextObject
879 // needs to be adapted to non-block mode. This could have been done with the
880 // #104122#, but was obviously overseen.
881 const SfxItemSet& rSet = mpView->GetDefaultAttr();
882 SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
884 if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
886 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
888 else
890 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
893 else
895 // #104122# This is for Format/Page settings. Since this also leads
896 // to the object defaults to be changed, i think this code can be
897 // removed. CL. wanted to take a look before adding this.
898 //const SdrTextHorzAdjust eHA = ( ( pDoc && pDoc->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ) ?
899 // SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_LEFT );
900 //aSet.Put( SdrTextHorzAdjustItem( eHA ) );
902 // #104122# Look in the object defaults if left-to-right is wanted. If
903 // yes, set text anchoring to right to let the box grow to left.
904 const SfxItemSet& rSet = mpView->GetDefaultAttr();
905 SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
907 if(FRMDIR_HORI_RIGHT_TOP == eDirection)
909 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
911 else
913 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
917 GetTextObj()->SetMergedItemSet(aSet);
918 GetTextObj()->SetDisableAutoWidthOnDragging(TRUE);
919 SetInEditMode(rMEvt, FALSE);
922 bFirstObjCreated = TRUE;
924 else
926 // In die Fkt. Selektion wechseln
927 if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
929 mxTextObj.reset(0);
932 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
933 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
937 bMBDown = FALSE;
938 FuConstruct::MouseButtonUp(rMEvt);
939 return (bReturn);
942 /*************************************************************************
944 |* Tastaturereignisse bearbeiten
946 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
947 |* FALSE.
949 \************************************************************************/
951 BOOL FuText::KeyInput(const KeyEvent& rKEvt)
953 BOOL bReturn = FALSE;
954 mpView->SetMarkHdlWhenTextEdit(TRUE);
956 KeyCode nCode = rKEvt.GetKeyCode();
957 BOOL bShift = nCode.IsShift();
959 // #97016# IV
960 if(mxTextObj.is())
962 // maybe object is deleted, test if it's equal to the selected object
963 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
964 SdrObject* pSelectedObj = 0L;
966 if(1 == rMarkList.GetMarkCount())
968 SdrMark* pMark = rMarkList.GetMark(0);
969 pSelectedObj = pMark->GetMarkedSdrObj();
972 if(mxTextObj.get() != pSelectedObj)
974 mxTextObj.reset(0);
978 if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
980 // Titeltext-Objekt: immer "weiche" Umbrueche
981 bShift = TRUE;
984 USHORT nKey = nCode.GetCode();
985 KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
986 KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
988 BOOL bOK = TRUE;
990 if (mpDocSh->IsReadOnly())
992 bOK = !EditEngine::DoesKeyChangeText(aKEvt);
994 if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
996 bOK = FALSE; // default handling in base class
999 if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
1001 bReturn = TRUE;
1003 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
1005 // if ( pTextObj )
1006 // pTextObj->SetEmptyPresObj(FALSE);
1008 else if (aKeyCode == KEY_ESCAPE)
1010 bReturn = cancel();
1013 if( bPermanent )
1015 mpView->SetCurrentObj(OBJ_TEXT);
1016 mpView->SetEditMode(SDREDITMODE_CREATE);
1019 if (!bReturn)
1021 bReturn = FuDraw::KeyInput(aKEvt);
1024 return (bReturn);
1029 /*************************************************************************
1031 |* Function aktivieren
1033 \************************************************************************/
1035 void FuText::Activate()
1037 mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
1039 // #i89661# it's no longer necessary to make it so big here, it's fine tuned
1040 // for text objects in SdrMarkView::CheckSingleSdrObjectHit
1041 mpView->SetHitTolerancePixel( 2 * HITPIX );
1043 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1045 if (pOLV)
1046 pOLV->ShowCursor();
1048 FuConstruct::Activate();
1050 if( pOLV )
1051 mpView->SetEditMode(SDREDITMODE_EDIT);
1055 /*************************************************************************
1057 |* Function deaktivieren
1059 \************************************************************************/
1061 void FuText::Deactivate()
1063 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1065 if (pOLV)
1066 pOLV->HideCursor();
1068 mpView->SetHitTolerancePixel( HITPIX );
1070 FuConstruct::Deactivate();
1074 /*************************************************************************
1076 |* Objekt in Edit-Mode setzen
1078 \************************************************************************/
1080 void FuText::SetInEditMode(const MouseEvent& rMEvt, BOOL bQuickDrag)
1082 SdrPageView* pPV = mpView->GetSdrPageView();
1083 if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1085 mpView->SetCurrentObj(OBJ_TEXT);
1087 if( bPermanent )
1088 mpView->SetEditMode(SDREDITMODE_CREATE);
1089 else
1090 mpView->SetEditMode(SDREDITMODE_EDIT);
1092 BOOL bEmptyOutliner = FALSE;
1094 if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1096 ::Outliner* pOutl = mpView->GetTextEditOutliner();
1097 ULONG nParaAnz = pOutl->GetParagraphCount();
1098 Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1100 if (nParaAnz==1 && p1stPara)
1102 // Bei nur einem Pararaph
1103 if (pOutl->GetText(p1stPara).Len() == 0)
1105 bEmptyOutliner = TRUE;
1110 if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1112 UINT32 nInv = mxTextObj->GetObjInventor();
1113 UINT16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1115 if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1116 (nSdrObjKind == OBJ_TEXT ||
1117 nSdrObjKind == OBJ_TITLETEXT ||
1118 nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1120 // Neuen Outliner machen (gehoert der SdrObjEditView)
1121 SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
1123 if (bEmptyOutliner)
1124 mpView->SdrEndTextEdit(sal_True);
1126 SdrTextObj* pTextObj = GetTextObj();
1127 if( pTextObj )
1129 OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1130 if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1131 pOutl->SetVertical( TRUE );
1133 if( pTextObj->getTextCount() > 1 )
1135 Point aPix(rMEvt.GetPosPixel());
1136 Point aPnt(mpWindow->PixelToLogic(aPix));
1137 pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1140 if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, sal_True, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1142 bFirstObjCreated = TRUE;
1143 DeleteDefaultText();
1145 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1147 nSdrObjKind = mxTextObj->GetObjIdentifier();
1149 SdrViewEvent aVEvt;
1150 SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1152 if (eHit == SDRHIT_TEXTEDIT)
1154 // Text getroffen
1155 if (nSdrObjKind == OBJ_TEXT ||
1156 nSdrObjKind == OBJ_TITLETEXT ||
1157 nSdrObjKind == OBJ_OUTLINETEXT ||
1158 nSdrObjKind == OBJ_TABLE ||
1159 nSlotId == SID_TEXTEDIT ||
1160 !bQuickDrag)
1162 pOLV->MouseButtonDown(rMEvt);
1163 pOLV->MouseMove(rMEvt);
1164 pOLV->MouseButtonUp(rMEvt);
1167 if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1169 pOLV->MouseButtonDown(rMEvt);
1172 else
1174 // #98198# Move cursor to end of text
1175 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1176 pOLV->SetSelection(aNewSelection);
1179 else
1181 mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1187 else
1189 mxTextObj.reset(0);
1193 /*************************************************************************
1195 |* Texteingabe wird gestartet, ggf. Default-Text loeschen
1197 \************************************************************************/
1199 BOOL FuText::DeleteDefaultText()
1201 BOOL bDeleted = FALSE;
1203 if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1205 String aString;
1206 SdPage* pPage = (SdPage*) mxTextObj->GetPage();
1208 if (pPage)
1210 PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1212 if ( (ePresObjKind == PRESOBJ_TITLE ||
1213 ePresObjKind == PRESOBJ_OUTLINE ||
1214 ePresObjKind == PRESOBJ_NOTES ||
1215 ePresObjKind == PRESOBJ_TEXT) &&
1216 !pPage->IsMasterPage() )
1218 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1219 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1220 BOOL bIsUndoEnabled = pOutliner->IsUndoEnabled();
1221 if( bIsUndoEnabled )
1222 pOutliner->EnableUndo(FALSE);
1224 pOutliner->SetText( String(), pOutliner->GetParagraph( 0 ) );
1226 if( bIsUndoEnabled )
1227 pOutliner->EnableUndo(TRUE);
1229 if (pSheet &&
1230 (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1231 pOutliner->SetStyleSheet(0, pSheet);
1233 mxTextObj->SetEmptyPresObj(TRUE);
1234 bDeleted = TRUE;
1239 return(bDeleted);
1242 /*************************************************************************
1244 |* Command-event
1246 \************************************************************************/
1248 BOOL FuText::Command(const CommandEvent& rCEvt)
1250 return( FuPoor::Command(rCEvt) );
1253 /*************************************************************************
1255 |* Help-event
1257 \************************************************************************/
1259 BOOL FuText::RequestHelp(const HelpEvent& rHEvt)
1261 BOOL bReturn = FALSE;
1263 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1265 if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1266 mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1268 String aHelpText;
1269 const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1270 const SvxFieldData* pField = pFieldItem->GetField();
1272 if (pField && pField->ISA(SvxURLField))
1274 /******************************************************************
1275 * URL-Field
1276 ******************************************************************/
1277 aHelpText = INetURLObject::decode( ((const SvxURLField*)pField)->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1279 if (aHelpText.Len())
1281 Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1282 Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1283 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1285 if (Help::IsBalloonHelpEnabled())
1287 bReturn = Help::ShowBalloon( (Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1289 else if (Help::IsQuickHelpEnabled())
1291 bReturn = Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1296 if (!bReturn)
1298 bReturn = FuConstruct::RequestHelp(rHEvt);
1301 return(bReturn);
1304 /*************************************************************************
1306 |* Request verarbeiten
1308 \************************************************************************/
1310 void FuText::ReceiveRequest(SfxRequest& rReq)
1312 nSlotId = rReq.GetSlot();
1314 // Dann Basisklasse rufen (dort wird u.a. nSlotId NICHT gesetzt)
1315 FuPoor::ReceiveRequest(rReq);
1317 if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || /*#95971#*/ SID_ATTR_CHAR == nSlotId)
1319 MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1321 mxTextObj.reset(0);
1323 if (nSlotId == SID_TEXTEDIT)
1325 // Wird gerade editiert?
1326 if(!bTestText)
1327 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1329 if (!mxTextObj.is())
1331 // Versuchen, ein Obj zu selektieren
1332 SdrPageView* pPV = mpView->GetSdrPageView();
1333 SdrViewEvent aVEvt;
1334 mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1335 mpView->MarkObj(aVEvt.pRootObj, pPV);
1337 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1339 mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1343 else if (mpView->AreObjectsMarked())
1345 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1347 if (rMarkList.GetMarkCount() == 1)
1349 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1351 if (pObj->ISA(SdrTextObj))
1353 mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1358 BOOL bQuickDrag = TRUE;
1360 const SfxItemSet* pArgs = rReq.GetArgs();
1362 if (pArgs
1364 // #98198# test for type before using
1365 && SID_TEXTEDIT == nSlotId
1366 && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
1368 && (UINT16) ((SfxUInt16Item&) pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1370 // Anwahl per Doppelklick -> kein QuickDrag zulassen
1371 bQuickDrag = FALSE;
1374 SetInEditMode(aMEvt, bQuickDrag);
1380 /*************************************************************************
1382 |* SpellChecker: Error-LinkHdl
1384 \************************************************************************/
1386 IMPL_LINK( FuText, SpellError, void *, nLang )
1388 String aError( ::GetLanguageString( (LanguageType)(ULONG)nLang ) );
1389 ErrorHandler::HandleError(* new StringErrorInfo(
1390 ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) );
1391 return 0;
1395 /*************************************************************************
1397 |* Reaktion auf Doppelklick
1399 \************************************************************************/
1400 void FuText::DoubleClick(const MouseEvent& )
1402 // Nichts zu tun
1405 /** #97016#
1406 #105815# Removed the insertion of default text and putting a new text
1407 object directly into edit mode.
1409 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1411 // case SID_TEXTEDIT: // BASIC ???
1412 // case SID_ATTR_CHAR:
1413 // case SID_ATTR_CHAR_VERTICAL:
1414 // case SID_TEXT_FITTOSIZE:
1415 // case SID_TEXT_FITTOSIZE_VERTICAL:
1417 SdrObject* pObj = SdrObjFactory::MakeNewObject(
1418 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1419 0L, mpDoc);
1421 if(pObj)
1423 if(pObj->ISA(SdrTextObj))
1425 SdrTextObj* pText = (SdrTextObj*)pObj;
1426 pText->SetLogicRect(rRectangle);
1428 sal_Bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1429 pText->SetVerticalWriting(bVertical);
1431 // #97016#
1432 ImpSetAttributesForNewTextObject(pText);
1434 if (nSlotId == SID_TEXT_FITTOSIZE)
1436 // #97016#
1437 ImpSetAttributesFitToSize(pText);
1439 else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1441 // #97016#
1442 ImpSetAttributesFitToSizeVertical(pText);
1444 else
1446 // #97016#
1447 ImpSetAttributesFitCommon(pText);
1450 // Put text object into edit mode.
1451 SdrPageView* pPV = mpView->GetSdrPageView();
1452 mpView->SdrBeginTextEdit(pText, pPV);
1454 else
1456 DBG_ERROR("Object is NO text object");
1460 return pObj;
1466 /** is called when the currenct function should be aborted. <p>
1467 This is used when a function gets a KEY_ESCAPE but can also
1468 be called directly.
1470 @returns true if a active function was aborted
1472 bool FuText::cancel()
1474 if ( mpView->IsTextEdit() )
1476 if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1477 mxTextObj.reset(0);
1479 mpView->SetCurrentObj(OBJ_TEXT);
1480 mpView->SetEditMode(SDREDITMODE_EDIT);
1481 return true;
1483 else
1485 return false;
1489 void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1491 if( !pFontList || !pView )
1492 return;
1494 if( pOLV )
1496 pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1498 else
1500 // SdDrawDocument* pDoc = pView->GetDoc();
1502 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1503 for( sal_uInt32 nMark = 0; nMark < rMarkList.GetMarkCount(); nMark++ )
1505 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1506 if( pTextObj )
1508 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1510 pTextObj->setActiveText( nText );
1512 // Put text object into edit mode.
1513 SdrPageView* pPV = pView->GetSdrPageView();
1514 pView->SdrBeginTextEdit(pTextObj, pPV);
1516 pOLV = pView->GetTextEditOutlinerView();
1517 if( pOLV )
1519 EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1520 if( pEditEngine )
1522 ESelection aSel;
1523 aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1524 aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1525 pOLV->SetSelection(aSel);
1528 ChangeFontSize( bGrow, pOLV, pFontList, pView );
1531 pView->SdrEndTextEdit();
1534 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1535 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1537 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1538 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1539 pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1546 } // end of namespace sd