fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / futext.cxx
blob43629a63f192c75c455fe63d8b2865233b924250
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svddef.hxx>
21 #include <svx/svdoutl.hxx>
22 #include <editeng/outlobj.hxx>
23 #include <svx/sdtaaitm.hxx>
24 #include <svx/sdtacitm.hxx>
25 #include <svx/svdotext.hxx>
26 #include <editeng/unolingu.hxx>
27 #include <svx/svdocapt.hxx>
28 #include <sfx2/bindings.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <svx/svxids.hrc>
32 #include <editeng/eeitem.hxx>
33 #include <svl/itemset.hxx>
35 #include "futext.hxx"
36 #include "drwlayer.hxx"
37 #include "sc.hrc"
38 #include "tabvwsh.hxx"
39 #include "drawview.hxx"
41 // Create default drawing objects via keyboard
42 #include "scresid.hxx"
44 // Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
45 //! fusel,fuconstr,futext - zusammenfassen!
46 #define SC_MAXDRAGMOVE 3
48 static void lcl_InvalidateAttribs( SfxBindings& rBindings )
50 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
51 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
52 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
53 rBindings.Invalidate( SID_ULINE_VAL_NONE );
54 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
55 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
56 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
57 rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
58 rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
59 rBindings.Invalidate( SID_ATTR_CHAR_BACK_COLOR );
60 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
61 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
62 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
63 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
64 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
65 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
66 rBindings.Invalidate( SID_ALIGNLEFT );
67 rBindings.Invalidate( SID_ALIGNCENTERHOR );
68 rBindings.Invalidate( SID_ALIGNRIGHT );
69 rBindings.Invalidate( SID_ALIGNBLOCK );
70 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
71 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
72 rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
73 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
74 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
75 rBindings.Invalidate( SID_HYPERLINK_GETLINK );
76 rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
77 rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
78 rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
79 rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
80 rBindings.Invalidate( SID_TABLE_VERT_NONE );
81 rBindings.Invalidate( SID_TABLE_VERT_CENTER );
82 rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
83 // pseudo slots for Format menu
84 rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
85 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
86 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
87 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
88 rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
89 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
90 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
91 rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
92 rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
95 static void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
97 // use hyphenator only if hyphenation attribute is set
98 if ( pObj && static_cast<const SfxBoolItem&>(pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
99 com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
100 rOutliner.SetHyphenator( xHyphenator );
104 /*************************************************************************
106 |* Basisklasse fuer Textfunktionen
108 \************************************************************************/
110 FuText::FuText(ScTabViewShell* pViewSh, vcl::Window* pWin, ScDrawView* pViewP,
111 SdrModel* pDoc, SfxRequest& rReq) :
112 FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
113 pTextObj(NULL)
117 /*************************************************************************
119 |* Destruktor
121 \************************************************************************/
123 FuText::~FuText()
125 // StopEditMode(); // in Deactivate !
128 /*************************************************************************
130 |* MouseButtonDown-event
132 \************************************************************************/
134 bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
136 // remember button state for creation of own MouseEvents
137 SetMouseButtonCode(rMEvt.GetButtons());
138 bool bStraightEnter = true;
140 if ( pView->MouseButtonDown(rMEvt, pWindow) )
141 return true; // Event von der SdrView ausgewertet
143 if ( pView->IsTextEdit() )
145 if ( IsEditingANote() )
147 if( !IsSizingOrMovingNote(rMEvt) )
149 StopEditMode(); // Danebengeklickt, Ende mit Edit
150 bStraightEnter = false;
153 else
155 StopEditMode(); // Clicked outside, ending edit.
156 pView->UnmarkAll();
157 bStraightEnter = false;
159 pView->SetCreateMode();
162 aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
164 if ( rMEvt.IsLeft() )
166 SdrHdl* pHdl = pView->PickHandle(aMDPos);
168 const size_t nHdlNum = pView->GetHdlNum(pHdl);
170 if (pHdl != NULL)
172 if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
174 bool bPointMarked=pView->IsPointMarked(*pHdl);
176 if ( rMEvt.IsShift() )
178 if (!bPointMarked)
180 pView->MarkPoint(*pHdl);
182 else
184 pView->UnmarkPoint(*pHdl);
187 else
189 if (!bPointMarked)
191 pView->UnmarkAllPoints();
192 pView->MarkPoint(*pHdl);
195 pHdl=pView->GetHdl(nHdlNum);
199 SdrObject* pObj;
200 SdrPageView* pPV;
202 if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
204 if (pHdl == NULL &&
205 // pView->TakeTextEditObject(aMDPos, pObj, pPV) )
206 pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKTEXTEDIT) )
208 SdrOutliner* pO = MakeOutliner();
209 lcl_UpdateHyphenator( *pO, pObj );
211 // vertical flag:
212 // deduced from slot ids only if text object has no content
214 sal_uInt16 nSlotID = aSfxRequest.GetSlot();
215 bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
216 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
217 if ( pOPO )
218 bVertical = pOPO->IsVertical(); // content wins
219 pO->SetVertical( bVertical );
221 //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
222 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) )
224 // EditEngine-UndoManager anmelden
225 pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
227 OutlinerView* pOLV = pView->GetTextEditOutlinerView();
228 if ( pOLV->MouseButtonDown(rMEvt) )
229 return true; // Event an den Outliner
232 else
234 // disable tail & circular move for caption objects.
235 bool bDrag = false;
236 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
237 if( rMarkList.GetMarkCount() == 1 )
239 SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
240 if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
242 if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
243 bDrag = true;
245 else
246 bDrag = true; // different object
248 else
249 bDrag = true; // several objects
251 if ( bDrag )
253 aDragTimer.Start();
254 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
258 else
260 if (pView->IsEditMode())
262 bool bPointMode=pView->HasMarkablePoints();
264 if (!rMEvt.IsShift())
266 if (bPointMode)
268 pView->UnmarkAllPoints();
270 else
272 pView->UnmarkAll();
275 pView->SetDragMode(SDRDRAG_MOVE);
276 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
277 rBindings.Invalidate( SID_OBJECT_ROTATE );
278 rBindings.Invalidate( SID_OBJECT_MIRROR );
281 if ( pView->MarkObj(aMDPos, -2, false, rMEvt.IsMod1()) )
283 aDragTimer.Start();
285 pHdl=pView->PickHandle(aMDPos);
287 if (pHdl!=NULL)
289 pView->MarkPoint(*pHdl);
290 pHdl=pView->GetHdl(nHdlNum);
293 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
295 else
297 if (bPointMode)
299 pView->BegMarkPoints(aMDPos);
301 else
303 pView->BegMarkObj(aMDPos);
307 else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
309 // Notizen editieren -> keine neuen Textobjekte erzeugen,
310 // stattdessen Textmodus verlassen
312 pViewShell->GetViewData().GetDispatcher().
313 Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
315 else
317 if (bStraightEnter)//Hack for that silly idea that creating text fields is inside the text routine
319 /**********************************************************
320 * Objekt erzeugen
321 **********************************************************/
322 // Hack to align object to nearest grid position where object
323 // would be anchored ( if it were cell anchored )
324 // Get grid offset for current position ( note: aPnt is
325 // also adjusted )
326 Point aGridOff = CurrentGridSyncOffsetAndPos( aMDPos );
328 bool bRet = pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
329 if ( bRet )
330 pView->GetCreateObj()->SetGridOffset( aGridOff );
332 else if (pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK))
334 pView->UnmarkAllObj();
335 ScViewData& rViewData = pViewShell->GetViewData();
336 rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
337 pView->MarkObj(pObj,pPV,false,false);
339 pHdl=pView->PickHandle(aMDPos);
340 pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
341 return true;
347 if (!bIsInDragMode)
349 pWindow->CaptureMouse();
350 // ForcePointer(&rMEvt);
351 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
354 pViewShell->SetActivePointer(pView->GetPreferredPointer(
355 pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
356 if (!bStraightEnter)
358 pView->UnmarkAll();
359 ScViewData& rViewData = pViewShell->GetViewData();
360 rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
363 return true;
366 /*************************************************************************
368 |* MouseMove-event
370 \************************************************************************/
372 bool FuText::MouseMove(const MouseEvent& rMEvt)
374 bool bReturn = false;
376 // pViewShell->SetActivePointer(aNewPointer);
378 pViewShell->SetActivePointer(pView->GetPreferredPointer(
379 pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
381 if (aDragTimer.IsActive() )
383 Point aOldPixel = pWindow->LogicToPixel( aMDPos );
384 Point aNewPixel = rMEvt.GetPosPixel();
385 if ( std::abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
386 std::abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
387 aDragTimer.Stop();
390 Point aPix(rMEvt.GetPosPixel());
391 Point aPnt(pWindow->PixelToLogic(aPix));
392 // if object is being created then more than likely the mouse
393 // position has been 'adjusted' for the current zoom, need to
394 // restore the mouse position here to ensure resize works as expected
395 if ( pView->GetCreateObj() )
396 aPnt -= pView->GetCreateObj()->GetGridOffset();
398 if ( pView->MouseMove(rMEvt, pWindow) )
399 return true; // Event von der SdrView ausgewertet
401 if ( pView->IsAction() )
403 ForceScroll(aPix);
404 pView->MovAction(aPnt);
407 return bReturn;
410 /*************************************************************************
412 |* MouseButtonUp-event
414 \************************************************************************/
416 bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
418 // remember button state for creation of own MouseEvents
419 SetMouseButtonCode(rMEvt.GetButtons());
421 bool bReturn = false;
423 if (aDragTimer.IsActive() )
425 aDragTimer.Stop();
428 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
430 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
432 if ( pView->MouseButtonUp(rMEvt, pWindow) )
433 return true; // Event von der SdrView ausgewertet
435 if ( pView->IsDragObj() )
437 pView->EndDragObj( rMEvt.IsShift() );
438 pView->ForceMarkedToAnotherPage();
440 else if ( pView->IsCreateObj() )
442 if (rMEvt.IsLeft())
444 pView->EndCreateObj(SDRCREATE_FORCEEND);
445 if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
447 // Lauftext-Objekt erzeugen?
449 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
450 if (rMarkList.GetMark(0))
452 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
454 // die fuer das Scrollen benoetigten Attribute setzen
455 SfxItemSet aItemSet( pDrDoc->GetItemPool(),
456 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
458 aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
459 aItemSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
460 aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
461 aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
462 aItemSet.Put( SdrTextAniCountItem( 1 ) );
463 aItemSet.Put( SdrTextAniAmountItem(
464 (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
465 pObj->SetMergedItemSetAndBroadcast(aItemSet);
469 // init object different when vertical writing
470 sal_uInt16 nSlotID(aSfxRequest.GetSlot());
471 bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
472 if(bVertical)
474 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
475 if(rMarkList.GetMark(0))
477 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
478 if(pObj && pObj->ISA(SdrTextObj))
480 SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
481 SfxItemSet aSet(pDrDoc->GetItemPool());
483 pText->SetVerticalWriting(true);
485 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
486 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
487 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
488 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
490 pText->SetMergedItemSet(aSet);
495 SetInEditMode();
497 // Modus verlassen bei einzelnem Klick
498 // (-> fuconstr)
500 if ( !pView->AreObjectsMarked() )
502 pView->MarkObj(aPnt, -2, false, rMEvt.IsMod1());
504 SfxDispatcher& rDisp = pViewShell->GetViewData().GetDispatcher();
505 if ( pView->AreObjectsMarked() )
506 rDisp.Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
507 else
508 rDisp.Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
512 else if ( pView->IsAction() )
514 pView->EndAction();
516 else if( !pView->IsAction() )
518 pWindow->ReleaseMouse();
520 if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
522 pView->MarkObj(aPnt, -2, false, rMEvt.IsMod1());
524 SfxDispatcher& rDisp = pViewShell->GetViewData().GetDispatcher();
525 if ( pView->AreObjectsMarked() )
526 rDisp.Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
527 else
528 rDisp.Execute(aSfxRequest.GetSlot(), SfxCallMode::SLOT | SfxCallMode::RECORD);
532 return bReturn;
535 /*************************************************************************
537 |* Maus-Pointer umschalten
539 \************************************************************************/
541 void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
543 pViewShell->SetActivePointer( aNewPointer );
546 /*************************************************************************
548 |* Tastaturereignisse bearbeiten
550 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
551 |* FALSE.
553 \************************************************************************/
555 bool FuText::KeyInput(const KeyEvent& rKEvt)
557 bool bReturn = false;
559 if ( pView->KeyInput(rKEvt, pWindow) )
561 bReturn = true;
562 lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
564 else
566 bReturn = FuDraw::KeyInput(rKEvt);
569 return bReturn;
572 /*************************************************************************
574 |* Function aktivieren
576 \************************************************************************/
578 void FuText::Activate()
580 pView->SetDragMode(SDRDRAG_MOVE);
581 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
582 rBindings.Invalidate( SID_OBJECT_ROTATE );
583 rBindings.Invalidate( SID_OBJECT_MIRROR );
585 // Sofort in den Edit Mode setzen
586 // SetInEditMode();
588 // if (!pTextObj)
590 /**********************************************************************
591 * Kein Textobjekt im EditMode, daher CreateMode setzen
592 **********************************************************************/
593 sal_uInt16 nObj = OBJ_TEXT;
595 pView->SetCurrentObj(nObj);
597 pView->SetCreateMode();
600 aNewPointer = Pointer(PointerStyle::Text);
602 aOldPointer = pWindow->GetPointer();
603 pViewShell->SetActivePointer( aNewPointer );
605 FuConstruct::Activate();
608 /*************************************************************************
610 |* Function deaktivieren
612 \************************************************************************/
614 void FuText::Deactivate()
616 FuConstruct::Deactivate();
617 pViewShell->SetActivePointer( aOldPointer );
618 StopEditMode();
621 /*************************************************************************
623 |* Selektion hat sich geaendert
625 \************************************************************************/
627 void FuText::SelectionHasChanged()
629 pView->SetDragMode(SDRDRAG_MOVE);
630 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
631 rBindings.Invalidate( SID_OBJECT_ROTATE );
632 rBindings.Invalidate( SID_OBJECT_MIRROR );
634 pTextObj = NULL;
636 if ( pView->AreObjectsMarked() )
638 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
640 if (rMarkList.GetMarkCount() == 1)
642 SdrMark* pMark = rMarkList.GetMark(0);
643 SdrObject* pObj = pMark->GetMarkedSdrObj();
645 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
647 if (nSdrObjKind == OBJ_TEXT ||
648 nSdrObjKind == OBJ_TITLETEXT ||
649 nSdrObjKind == OBJ_OUTLINETEXT /* ||
650 pObj->ISA(SdrTextObj) */ )
652 pTextObj = static_cast<SdrTextObj*>(pObj);
657 if (!pTextObj)
659 /**********************************************************************
660 * Kein Textobjekt im EditMode, daher CreateMode setzen
661 **********************************************************************/
662 sal_uInt16 nObj = OBJ_TEXT;
663 sal_uInt16 nIdent;
664 sal_uInt32 nInvent;
665 pView->TakeCurrentObj(nIdent, nInvent);
667 pView->SetCurrentObj(nObj);
669 pView->SetCreateMode();
673 /*************************************************************************
675 |* Objekt in Edit-Mode setzen
677 \************************************************************************/
679 void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
680 bool bCursorToEnd, const KeyEvent* pInitialKey)
682 /* It is possible to pass a special (unselected) object in pObj, e.g. the
683 caption object of a cell note. If pObj is 0, then the selected object
684 is used. The layer will be relocked in FuText::StopEditMode(). */
685 if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
686 pView->UnlockInternalLayer();
688 if ( !pObj && pView->AreObjectsMarked() )
690 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
691 if (rMarkList.GetMarkCount() == 1)
693 SdrMark* pMark = rMarkList.GetMark(0);
694 pObj = pMark->GetMarkedSdrObj();
698 pTextObj = NULL;
700 if ( pObj )
702 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
704 if (nSdrObjKind == OBJ_TEXT ||
705 nSdrObjKind == OBJ_TITLETEXT ||
706 nSdrObjKind == OBJ_OUTLINETEXT ||
707 pObj->ISA(SdrTextObj))
709 SdrPageView* pPV = pView->GetSdrPageView();
711 if ( pObj->HasTextEdit() )
713 SdrOutliner* pO = MakeOutliner();
714 lcl_UpdateHyphenator( *pO, pObj );
716 // vertical flag:
717 // deduced from slot ids only if text object has no content
719 sal_uInt16 nSlotID = aSfxRequest.GetSlot();
720 bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
721 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
722 if ( pOPO )
723 bVertical = pOPO->IsVertical(); // content wins
724 pO->SetVertical( bVertical );
726 //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
727 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) )
729 // Toggle out of paste mode if we are in it, otherwise
730 // pressing return in this object will instead go to the
731 // sheet and be considered an overwrite-cell instruction
732 pViewShell->GetViewData().SetPasteMode(SC_PASTE_NONE);
733 pViewShell->UpdateCopySourceOverlay();
735 // EditEngine-UndoManager anmelden
736 pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
738 pTextObj = static_cast<SdrTextObj*>(pObj);
739 pView->SetEditMode();
741 // set text cursor to click position or to end,
742 // pass initial key event to outliner view
743 if ( pMousePixel || bCursorToEnd || pInitialKey )
745 OutlinerView* pOLV = pView->GetTextEditOutlinerView();
746 if (pOLV)
748 if ( pMousePixel )
750 MouseEvent aEditEvt( *pMousePixel, 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0 );
751 pOLV->MouseButtonDown(aEditEvt);
752 pOLV->MouseButtonUp(aEditEvt);
754 else if ( bCursorToEnd )
756 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
757 pOLV->SetSelection(aNewSelection);
760 if ( pInitialKey )
761 pOLV->PostKeyEvent( *pInitialKey );
770 // Create default drawing objects via keyboard
771 SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
773 // case SID_DRAW_TEXT:
774 // case SID_DRAW_TEXT_VERTICAL:
775 // case SID_DRAW_TEXT_MARQUEE:
776 // case SID_DRAW_NOTEEDIT:
778 SdrObject* pObj = SdrObjFactory::MakeNewObject(
779 pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
780 0L, pDrDoc);
782 if(pObj)
784 if(pObj->ISA(SdrTextObj))
786 SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
787 pText->SetLogicRect(rRectangle);
789 // don't set default text, start edit mode instead
790 // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
791 // pText->SetText(aText);
793 bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
794 bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
796 pText->SetVerticalWriting(bVertical);
798 if(bVertical)
800 SfxItemSet aSet(pDrDoc->GetItemPool());
802 aSet.Put(makeSdrTextAutoGrowWidthItem(true));
803 aSet.Put(makeSdrTextAutoGrowHeightItem(false));
804 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
805 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
807 pText->SetMergedItemSet(aSet);
810 if(bMarquee)
812 SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
814 aSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
815 aSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
816 aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
817 aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
818 aSet.Put( SdrTextAniCountItem( 1 ) );
819 aSet.Put( SdrTextAniAmountItem( (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
821 pObj->SetMergedItemSetAndBroadcast(aSet);
824 SetInEditMode( pObj ); // start edit mode
826 else
828 OSL_FAIL("Object is NO text object");
832 return pObj;
835 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */