LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - futext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 365 0.3 %
Date: 2014-04-11 Functions: 2 17 11.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svx/svddef.hxx>
      22             : #include <svx/svdoutl.hxx>
      23             : #include <editeng/outlobj.hxx>
      24             : #include <svx/sdtaaitm.hxx>
      25             : #include <svx/sdtacitm.hxx>
      26             : #include <svx/svdotext.hxx>
      27             : #include <editeng/unolingu.hxx>
      28             : #include <svx/svdocapt.hxx>
      29             : #include <sfx2/bindings.hxx>
      30             : #include <sfx2/dispatch.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <svx/svxids.hrc>
      33             : #include <editeng/eeitem.hxx>
      34             : #include <svl/itemset.hxx>
      35             : 
      36             : #include "futext.hxx"
      37             : #include "drwlayer.hxx"
      38             : #include "sc.hrc"
      39             : #include "tabvwsh.hxx"
      40             : #include "drawview.hxx"
      41             : 
      42             : // Create default drawing objects via keyboard
      43             : #include "scresid.hxx"
      44             : 
      45             : //  Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
      46             : //! fusel,fuconstr,futext - zusammenfassen!
      47             : #define SC_MAXDRAGMOVE  3
      48             : 
      49           0 : static void lcl_InvalidateAttribs( SfxBindings& rBindings )
      50             : {
      51           0 :     rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
      52           0 :     rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
      53           0 :     rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
      54           0 :     rBindings.Invalidate( SID_ULINE_VAL_NONE );
      55           0 :     rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
      56           0 :     rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
      57           0 :     rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
      58           0 :     rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
      59           0 :     rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
      60           0 :     rBindings.Invalidate( SID_ATTR_CHAR_FONT );
      61           0 :     rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
      62           0 :     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
      63           0 :     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
      64           0 :     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
      65           0 :     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
      66           0 :     rBindings.Invalidate( SID_ALIGNLEFT );
      67           0 :     rBindings.Invalidate( SID_ALIGNCENTERHOR );
      68           0 :     rBindings.Invalidate( SID_ALIGNRIGHT );
      69           0 :     rBindings.Invalidate( SID_ALIGNBLOCK );
      70           0 :     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
      71           0 :     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
      72           0 :     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
      73           0 :     rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
      74           0 :     rBindings.Invalidate( SID_SET_SUB_SCRIPT );
      75           0 :     rBindings.Invalidate( SID_HYPERLINK_GETLINK );
      76           0 :     rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
      77           0 :     rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
      78           0 :     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
      79           0 :     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
      80           0 :     rBindings.Invalidate( SID_TABLE_VERT_NONE );
      81           0 :     rBindings.Invalidate( SID_TABLE_VERT_CENTER );
      82           0 :     rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
      83             :     // pseudo slots for Format menu
      84           0 :     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
      85           0 :     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
      86           0 :     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
      87           0 :     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
      88           0 :     rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
      89           0 :     rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
      90           0 :     rBindings.Invalidate( SID_SET_SUB_SCRIPT );
      91           0 :     rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
      92           0 :     rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
      93           0 : }
      94             : 
      95           0 : static void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
      96             : {
      97             :     // use hyphenator only if hyphenation attribute is set
      98           0 :     if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
      99           0 :             com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
     100           0 :             rOutliner.SetHyphenator( xHyphenator );
     101             :     }
     102           0 : }
     103             : 
     104             : /*************************************************************************
     105             : |*
     106             : |* Basisklasse fuer Textfunktionen
     107             : |*
     108             : \************************************************************************/
     109             : 
     110           0 : FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
     111             :                    SdrModel* pDoc, SfxRequest& rReq) :
     112             :     FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
     113           0 :     pTextObj(NULL)
     114             : {
     115           0 : }
     116             : 
     117             : /*************************************************************************
     118             : |*
     119             : |* Destruktor
     120             : |*
     121             : \************************************************************************/
     122             : 
     123           0 : FuText::~FuText()
     124             : {
     125             : //  StopEditMode();                 // in Deactivate !
     126           0 : }
     127             : 
     128             : /*************************************************************************
     129             : |*
     130             : |* MouseButtonDown-event
     131             : |*
     132             : \************************************************************************/
     133             : 
     134           0 : bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
     135             : {
     136             :     // remember button state for creation of own MouseEvents
     137           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     138           0 :     bool bStraightEnter = true;
     139             : 
     140           0 :     if ( pView->MouseButtonDown(rMEvt, pWindow) )
     141           0 :         return true;                 // Event von der SdrView ausgewertet
     142             : 
     143           0 :     if ( pView->IsTextEdit() )
     144             :     {
     145           0 :         if ( IsEditingANote() )
     146             :         {
     147           0 :             if( !IsSizingOrMovingNote(rMEvt) )
     148             :             {
     149           0 :                 StopEditMode();            // Danebengeklickt, Ende mit Edit
     150           0 :                 bStraightEnter = false;
     151             :             }
     152             :         }
     153             :         else
     154             :         {
     155           0 :             StopEditMode();            // Clicked outside, ending edit.
     156           0 :             pView->UnmarkAll();
     157           0 :             bStraightEnter = false;
     158             :         }
     159           0 :         pView->SetCreateMode();
     160             :     }
     161             : 
     162           0 :     aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
     163             : 
     164           0 :     if ( rMEvt.IsLeft() )
     165             :     {
     166           0 :         SdrHdl* pHdl = pView->PickHandle(aMDPos);
     167             : 
     168           0 :         sal_uLong nHdlNum = pView->GetHdlNum(pHdl);
     169             : 
     170           0 :         if (pHdl != NULL)
     171             :         {
     172           0 :             if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
     173             :             {
     174           0 :                 sal_Bool bPointMarked=pView->IsPointMarked(*pHdl);
     175             : 
     176           0 :                 if ( rMEvt.IsShift() )
     177             :                 {
     178           0 :                     if (!bPointMarked)
     179             :                     {
     180           0 :                         pView->MarkPoint(*pHdl);
     181             :                     }
     182             :                     else
     183             :                     {
     184           0 :                         pView->UnmarkPoint(*pHdl);
     185             :                     }
     186             :                 }
     187             :                 else
     188             :                 {
     189           0 :                     if (!bPointMarked)
     190             :                     {
     191           0 :                         pView->UnmarkAllPoints();
     192           0 :                         pView->MarkPoint(*pHdl);
     193             :                     }
     194             :                 }
     195           0 :                 pHdl=pView->GetHdl(nHdlNum);
     196             :             }
     197             :         }
     198             : 
     199             :         SdrObject* pObj;
     200             :         SdrPageView* pPV;
     201             : 
     202           0 :         if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
     203             :         {
     204           0 :             if (pHdl == NULL &&
     205             : //              pView->TakeTextEditObject(aMDPos, pObj, pPV) )
     206           0 :                 pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) )
     207             :             {
     208           0 :                 SdrOutliner* pO = MakeOutliner();
     209           0 :                 lcl_UpdateHyphenator( *pO, pObj );
     210             : 
     211             :                 //  vertical flag:
     212             :                 //  deduced from slot ids only if text object has no content
     213             : 
     214           0 :                 sal_uInt16 nSlotID = aSfxRequest.GetSlot();
     215           0 :                 sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
     216           0 :                 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
     217           0 :                 if ( pOPO )
     218           0 :                     bVertical = pOPO->IsVertical();     // content wins
     219           0 :                 pO->SetVertical( bVertical );
     220             : 
     221             :                 //!??   ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
     222           0 :                 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) )
     223             :                 {
     224             :                     //  EditEngine-UndoManager anmelden
     225           0 :                     pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
     226             : 
     227           0 :                     OutlinerView* pOLV = pView->GetTextEditOutlinerView();
     228           0 :                     if ( pOLV->MouseButtonDown(rMEvt) )
     229           0 :                         return true; // Event an den Outliner
     230             :                 }
     231             :             }
     232             :             else
     233             :             {
     234             :                 // disable tail & circular move for caption objects.
     235           0 :                 bool bDrag = false;
     236           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     237           0 :                 if( rMarkList.GetMarkCount() == 1 )
     238             :                 {
     239           0 :                     SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     240           0 :                     if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
     241             :                     {
     242           0 :                         if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
     243           0 :                             bDrag = true;
     244             :                     }
     245             :                     else
     246           0 :                         bDrag = true;   // different object
     247             :                 }
     248             :                 else
     249           0 :                     bDrag = true;       // several objects
     250             : 
     251           0 :                 if ( bDrag )
     252             :                 {
     253           0 :                     aDragTimer.Start();
     254           0 :                     pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
     255             :                 }
     256             :             }
     257             :         }
     258             :         else
     259             :         {
     260           0 :             sal_Bool bMacro = false;
     261             : 
     262             : //          if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV))
     263           0 :             if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
     264             : 
     265             :             {
     266           0 :                 pView->BegMacroObj(aMDPos,pObj,pPV,pWindow);
     267             :             }
     268             :             else
     269             :             {
     270           0 :                 if (pView->IsEditMode())
     271             :                 {
     272           0 :                     sal_Bool bPointMode=pView->HasMarkablePoints();
     273             : 
     274           0 :                     if (!rMEvt.IsShift())
     275             :                     {
     276           0 :                         if (bPointMode)
     277             :                         {
     278           0 :                             pView->UnmarkAllPoints();
     279             :                         }
     280             :                         else
     281             :                         {
     282           0 :                             pView->UnmarkAll();
     283             :                         }
     284             : 
     285           0 :                         pView->SetDragMode(SDRDRAG_MOVE);
     286           0 :                         SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
     287           0 :                         rBindings.Invalidate( SID_OBJECT_ROTATE );
     288           0 :                         rBindings.Invalidate( SID_OBJECT_MIRROR );
     289             :                     }
     290             : 
     291           0 :                     if ( pView->MarkObj(aMDPos, -2, false, rMEvt.IsMod1()) )
     292             :                     {
     293           0 :                         aDragTimer.Start();
     294             : 
     295           0 :                         pHdl=pView->PickHandle(aMDPos);
     296             : 
     297           0 :                         if (pHdl!=NULL)
     298             :                         {
     299           0 :                             pView->MarkPoint(*pHdl);
     300           0 :                             pHdl=pView->GetHdl(nHdlNum);
     301             :                         }
     302             : 
     303           0 :                         pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
     304             :                     }
     305             :                     else
     306             :                     {
     307           0 :                         if (bPointMode)
     308             :                         {
     309           0 :                             pView->BegMarkPoints(aMDPos);
     310             :                         }
     311             :                         else
     312             :                         {
     313           0 :                             pView->BegMarkObj(aMDPos);
     314             :                         }
     315             :                     }
     316             :                 }
     317           0 :                 else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
     318             :                 {
     319             :                     //  Notizen editieren -> keine neuen Textobjekte erzeugen,
     320             :                     //  stattdessen Textmodus verlassen
     321             : 
     322           0 :                     pViewShell->GetViewData()->GetDispatcher().
     323           0 :                         Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     324             :                 }
     325             :                 else
     326             :                 {
     327           0 :                     if (bStraightEnter)//Hack for that silly idea that creating text fields is inside the text routine
     328             :                     {
     329             :                         /**********************************************************
     330             :                         * Objekt erzeugen
     331             :                         **********************************************************/
     332             :                         // Hack  to align object to nearest grid position where object
     333             :                         // would be anchored ( if it were cell anchored )
     334             :                         // Get grid offset for current position ( note: aPnt is
     335             :                         // also adjusted )
     336           0 :                         Point aGridOff = CurrentGridSyncOffsetAndPos( aMDPos );
     337             : 
     338           0 :                         bool bRet = pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
     339           0 :                         if ( bRet )
     340           0 :                         pView->GetCreateObj()->SetGridOffset( aGridOff );
     341             :                     }
     342           0 :                     else if (pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
     343             :                     {
     344           0 :                         pView->UnmarkAllObj();
     345           0 :                         ScViewData& rViewData = *pViewShell->GetViewData();
     346           0 :                         rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     347           0 :                         pView->MarkObj(pObj,pPV,false,false);
     348             : 
     349           0 :                         pHdl=pView->PickHandle(aMDPos);
     350           0 :                         pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
     351           0 :                         return true;
     352             :                     }
     353             :                 }
     354             :             }
     355             :         }
     356             :     }
     357             : 
     358             : 
     359           0 :     if (!bIsInDragMode)
     360             :     {
     361           0 :         pWindow->CaptureMouse();
     362             : //      ForcePointer(&rMEvt);
     363           0 :         lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
     364             :     }
     365             : 
     366             :     pViewShell->SetActivePointer(pView->GetPreferredPointer(
     367           0 :                     pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
     368           0 :     if (!bStraightEnter)
     369             :     {
     370           0 :             pView->UnmarkAll();
     371           0 :             ScViewData& rViewData = *pViewShell->GetViewData();
     372           0 :             rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     373             :     }
     374             : 
     375             : //  return (bReturn);
     376           0 :     return true;
     377             : }
     378             : 
     379             : /*************************************************************************
     380             : |*
     381             : |* MouseMove-event
     382             : |*
     383             : \************************************************************************/
     384             : 
     385           0 : bool FuText::MouseMove(const MouseEvent& rMEvt)
     386             : {
     387           0 :     bool bReturn = false;
     388             : 
     389             : //  pViewShell->SetActivePointer(aNewPointer);
     390             : 
     391             :     pViewShell->SetActivePointer(pView->GetPreferredPointer(
     392           0 :                     pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
     393             : 
     394           0 :     if (aDragTimer.IsActive() )
     395             :     {
     396           0 :         Point aOldPixel = pWindow->LogicToPixel( aMDPos );
     397           0 :         Point aNewPixel = rMEvt.GetPosPixel();
     398           0 :         if ( std::abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
     399           0 :              std::abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
     400           0 :             aDragTimer.Stop();
     401             :     }
     402             : 
     403           0 :     Point aPix(rMEvt.GetPosPixel());
     404           0 :     Point aPnt(pWindow->PixelToLogic(aPix));
     405             :     // if object is being created then more than likely the mouse
     406             :     // position has been 'adjusted' for the current zoom, need to
     407             :     // restore the mouse position here to ensure resize works as expected
     408           0 :     if ( pView->GetCreateObj() )
     409           0 :         aPnt -= pView->GetCreateObj()->GetGridOffset();
     410             : 
     411           0 :     if ( pView->MouseMove(rMEvt, pWindow) )
     412           0 :         return true; // Event von der SdrView ausgewertet
     413             : 
     414           0 :     if ( pView->IsAction() )
     415             :     {
     416           0 :         ForceScroll(aPix);
     417           0 :         pView->MovAction(aPnt);
     418             :     }
     419             : 
     420           0 :     return bReturn;
     421             : }
     422             : 
     423             : /*************************************************************************
     424             : |*
     425             : |* MouseButtonUp-event
     426             : |*
     427             : \************************************************************************/
     428             : 
     429           0 : bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
     430             : {
     431             :     // remember button state for creation of own MouseEvents
     432           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     433             : 
     434           0 :     bool bReturn = false;
     435             : 
     436           0 :     if (aDragTimer.IsActive() )
     437             :     {
     438           0 :         aDragTimer.Stop();
     439             :     }
     440             : 
     441           0 :     lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
     442             : 
     443           0 :     Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     444             : 
     445           0 :     if ( pView->MouseButtonUp(rMEvt, pWindow) )
     446           0 :         return true; // Event von der SdrView ausgewertet
     447             : 
     448           0 :     if ( pView->IsDragObj() )
     449             :     {
     450           0 :         pView->EndDragObj( rMEvt.IsShift() );
     451           0 :         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     452           0 :         if (rMarkList.GetMarkCount() == 1)
     453             :         {
     454           0 :               SdrMark* pMark = rMarkList.GetMark(0);
     455           0 :               SdrObject* pObj = pMark->GetMarkedSdrObj();
     456           0 :               FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
     457           0 :               FuText* pText = static_cast<FuText*>(pPoor);
     458           0 :             pText->StopDragMode(pObj );
     459             :         }
     460           0 :         pView->ForceMarkedToAnotherPage();
     461             :     }
     462           0 :     else if ( pView->IsCreateObj() )
     463             :     {
     464           0 :         if (rMEvt.IsLeft())
     465             :         {
     466           0 :             pView->EndCreateObj(SDRCREATE_FORCEEND);
     467           0 :             if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
     468             :             {
     469             :                 //  Lauftext-Objekt erzeugen?
     470             : 
     471           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     472           0 :                 if (rMarkList.GetMark(0))
     473             :                 {
     474           0 :                     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     475             : 
     476             :                     // die fuer das Scrollen benoetigten Attribute setzen
     477           0 :                     SfxItemSet aItemSet( pDrDoc->GetItemPool(),
     478           0 :                                             SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
     479             : 
     480           0 :                     aItemSet.Put( SdrTextAutoGrowWidthItem( false ) );
     481           0 :                     aItemSet.Put( SdrTextAutoGrowHeightItem( false ) );
     482           0 :                     aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
     483           0 :                     aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
     484           0 :                     aItemSet.Put( SdrTextAniCountItem( 1 ) );
     485             :                     aItemSet.Put( SdrTextAniAmountItem(
     486           0 :                                     (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
     487           0 :                     pObj->SetMergedItemSetAndBroadcast(aItemSet);
     488             :                 }
     489             :             }
     490             : 
     491             :             // init object different when vertical writing
     492           0 :             sal_uInt16 nSlotID(aSfxRequest.GetSlot());
     493           0 :             sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
     494           0 :             if(bVertical)
     495             :             {
     496           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     497           0 :                 if(rMarkList.GetMark(0))
     498             :                 {
     499           0 :                     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     500           0 :                     if(pObj && pObj->ISA(SdrTextObj))
     501             :                     {
     502           0 :                         SdrTextObj* pText = (SdrTextObj*)pObj;
     503           0 :                         SfxItemSet aSet(pDrDoc->GetItemPool());
     504             : 
     505           0 :                         pText->SetVerticalWriting(true);
     506             : 
     507           0 :                         aSet.Put(SdrTextAutoGrowWidthItem(true));
     508           0 :                         aSet.Put(SdrTextAutoGrowHeightItem(false));
     509           0 :                         aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
     510           0 :                         aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
     511             : 
     512           0 :                         pText->SetMergedItemSet(aSet);
     513             :                     }
     514             :                 }
     515             :             }
     516             : 
     517           0 :             SetInEditMode();
     518             : 
     519             :                 //  Modus verlassen bei einzelnem Klick
     520             :                 //  (-> fuconstr)
     521             : 
     522           0 :             if ( !pView->AreObjectsMarked() )
     523             :             {
     524           0 :                 pView->MarkObj(aPnt, -2, false, rMEvt.IsMod1());
     525             : 
     526           0 :                 SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
     527           0 :                 if ( pView->AreObjectsMarked() )
     528           0 :                     rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     529             :                 else
     530           0 :                     rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     531             :             }
     532             :         }
     533             :     }
     534           0 :     else if ( pView->IsAction() )
     535             :     {
     536           0 :         pView->EndAction();
     537             :     }
     538           0 :     else if( !pView->IsAction() )
     539             :     {
     540           0 :         pWindow->ReleaseMouse();
     541             : 
     542           0 :         if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
     543             :         {
     544           0 :             pView->MarkObj(aPnt, -2, false, rMEvt.IsMod1());
     545             : 
     546           0 :             SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
     547           0 :             if ( pView->AreObjectsMarked() )
     548           0 :                 rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     549             :             else
     550           0 :                 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     551             :         }
     552             :     }
     553             : 
     554           0 :     return bReturn;
     555             : }
     556             : 
     557             : /*************************************************************************
     558             : |*
     559             : |* Maus-Pointer umschalten
     560             : |*
     561             : \************************************************************************/
     562             : 
     563           0 : void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
     564             : {
     565           0 :     pViewShell->SetActivePointer( aNewPointer );
     566           0 : }
     567             : 
     568             : /*************************************************************************
     569             : |*
     570             : |* Tastaturereignisse bearbeiten
     571             : |*
     572             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     573             : |* FALSE.
     574             : |*
     575             : \************************************************************************/
     576             : 
     577           0 : bool FuText::KeyInput(const KeyEvent& rKEvt)
     578             : {
     579           0 :     bool bReturn = false;
     580             : 
     581           0 :     if ( pView->KeyInput(rKEvt, pWindow) )
     582             :     {
     583           0 :         bReturn = true;
     584           0 :         lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
     585             :     }
     586             :     else
     587             :     {
     588           0 :         bReturn = FuDraw::KeyInput(rKEvt);
     589             :     }
     590             : 
     591           0 :     return bReturn;
     592             : }
     593             : 
     594             : /*************************************************************************
     595             : |*
     596             : |* Function aktivieren
     597             : |*
     598             : \************************************************************************/
     599             : 
     600           0 : void FuText::Activate()
     601             : {
     602           0 :     pView->SetDragMode(SDRDRAG_MOVE);
     603           0 :     SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
     604           0 :     rBindings.Invalidate( SID_OBJECT_ROTATE );
     605           0 :     rBindings.Invalidate( SID_OBJECT_MIRROR );
     606             : 
     607             : //  Sofort in den Edit Mode setzen
     608             : //  SetInEditMode();
     609             : 
     610             : //  if (!pTextObj)
     611             :     {
     612             :         /**********************************************************************
     613             :         * Kein Textobjekt im EditMode, daher CreateMode setzen
     614             :         **********************************************************************/
     615           0 :         sal_uInt16 nObj = OBJ_TEXT;
     616             : 
     617           0 :         pView->SetCurrentObj(nObj);
     618             : 
     619           0 :         pView->SetCreateMode();
     620             :     }
     621             : 
     622           0 :     aNewPointer = Pointer(POINTER_TEXT);
     623             : 
     624           0 :     aOldPointer = pWindow->GetPointer();
     625           0 :     pViewShell->SetActivePointer( aNewPointer );
     626             : 
     627           0 :     FuConstruct::Activate();
     628           0 : }
     629             : 
     630             : 
     631             : /*************************************************************************
     632             : |*
     633             : |* Function deaktivieren
     634             : |*
     635             : \************************************************************************/
     636             : 
     637           0 : void FuText::Deactivate()
     638             : {
     639           0 :     FuConstruct::Deactivate();
     640           0 :     pViewShell->SetActivePointer( aOldPointer );
     641           0 :     StopEditMode();
     642           0 : }
     643             : 
     644             : 
     645             : /*************************************************************************
     646             : |*
     647             : |* Selektion hat sich geaendert
     648             : |*
     649             : \************************************************************************/
     650             : 
     651           0 : void FuText::SelectionHasChanged()
     652             : {
     653           0 :     pView->SetDragMode(SDRDRAG_MOVE);
     654           0 :     SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
     655           0 :     rBindings.Invalidate( SID_OBJECT_ROTATE );
     656           0 :     rBindings.Invalidate( SID_OBJECT_MIRROR );
     657             : 
     658           0 :     pTextObj = NULL;
     659             : 
     660           0 :     if ( pView->AreObjectsMarked() )
     661             :     {
     662           0 :         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     663             : 
     664           0 :         if (rMarkList.GetMarkCount() == 1)
     665             :         {
     666           0 :             SdrMark* pMark = rMarkList.GetMark(0);
     667           0 :             SdrObject* pObj = pMark->GetMarkedSdrObj();
     668             : 
     669           0 :             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
     670             : 
     671           0 :             if (nSdrObjKind == OBJ_TEXT ||
     672           0 :                 nSdrObjKind == OBJ_TITLETEXT ||
     673             :                 nSdrObjKind == OBJ_OUTLINETEXT /* ||
     674             :                 pObj->ISA(SdrTextObj) */ )
     675             :             {
     676           0 :                 pTextObj = (SdrTextObj*) pObj;
     677             :             }
     678             :         }
     679             :     }
     680             : 
     681           0 :     if (!pTextObj)
     682             :     {
     683             :         /**********************************************************************
     684             :         * Kein Textobjekt im EditMode, daher CreateMode setzen
     685             :         **********************************************************************/
     686           0 :         sal_uInt16 nObj = OBJ_TEXT;
     687             :         sal_uInt16 nIdent;
     688             :         sal_uInt32 nInvent;
     689           0 :         pView->TakeCurrentObj(nIdent, nInvent);
     690             : 
     691           0 :         pView->SetCurrentObj(nObj);
     692             : 
     693           0 :         pView->SetCreateMode();
     694             :     }
     695           0 : }
     696             : 
     697             : /*************************************************************************
     698             : |*
     699             : |* Objekt in Edit-Mode setzen
     700             : |*
     701             : \************************************************************************/
     702             : 
     703           0 : void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
     704             :                             bool bCursorToEnd, const KeyEvent* pInitialKey)
     705             : {
     706             :     /*  It is possible to pass a special (unselected) object in pObj, e.g. the
     707             :         caption object of a cell note. If pObj is 0, then the selected object
     708             :         is used. The layer will be relocked in FuText::StopEditMode(). */
     709           0 :     if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
     710           0 :         pView->UnlockInternalLayer();
     711             : 
     712           0 :     if ( !pObj && pView->AreObjectsMarked() )
     713             :     {
     714           0 :         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     715           0 :         if (rMarkList.GetMarkCount() == 1)
     716             :         {
     717           0 :             SdrMark* pMark = rMarkList.GetMark(0);
     718           0 :             pObj = pMark->GetMarkedSdrObj();
     719             :         }
     720             :     }
     721             : 
     722           0 :     pTextObj = NULL;
     723             : 
     724           0 :     if ( pObj )
     725             :     {
     726           0 :         sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
     727             : 
     728           0 :         if (nSdrObjKind == OBJ_TEXT ||
     729           0 :             nSdrObjKind == OBJ_TITLETEXT ||
     730           0 :             nSdrObjKind == OBJ_OUTLINETEXT ||
     731           0 :             pObj->ISA(SdrTextObj))
     732             :         {
     733           0 :             SdrPageView* pPV = pView->GetSdrPageView();
     734             : 
     735           0 :             if ( pObj->HasTextEdit() )
     736             :             {
     737           0 :                 SdrOutliner* pO = MakeOutliner();
     738           0 :                 lcl_UpdateHyphenator( *pO, pObj );
     739             : 
     740             :                 //  vertical flag:
     741             :                 //  deduced from slot ids only if text object has no content
     742             : 
     743           0 :                 sal_uInt16 nSlotID = aSfxRequest.GetSlot();
     744           0 :                 sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
     745           0 :                 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
     746           0 :                 if ( pOPO )
     747           0 :                     bVertical = pOPO->IsVertical();     // content wins
     748           0 :                 pO->SetVertical( bVertical );
     749             : 
     750             :                 //!??   ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
     751           0 :                 if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) )
     752             :                 {
     753             :                     //  EditEngine-UndoManager anmelden
     754           0 :                     pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
     755             : 
     756           0 :                     pTextObj = (SdrTextObj*) pObj;
     757           0 :                     pView->SetEditMode();
     758             : 
     759             :                     //  set text cursor to click position or to end,
     760             :                     //  pass initial key event to outliner view
     761           0 :                     if ( pMousePixel || bCursorToEnd || pInitialKey )
     762             :                     {
     763           0 :                         OutlinerView* pOLV = pView->GetTextEditOutlinerView();
     764           0 :                         if (pOLV)
     765             :                         {
     766           0 :                             if ( pMousePixel )
     767             :                             {
     768           0 :                                 MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
     769           0 :                                 pOLV->MouseButtonDown(aEditEvt);
     770           0 :                                 pOLV->MouseButtonUp(aEditEvt);
     771             :                             }
     772           0 :                             else if ( bCursorToEnd )
     773             :                             {
     774           0 :                                 ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
     775           0 :                                 pOLV->SetSelection(aNewSelection);
     776             :                             }
     777             : 
     778           0 :                             if ( pInitialKey )
     779           0 :                                 pOLV->PostKeyEvent( *pInitialKey );
     780             :                         }
     781             :                     }
     782             :                 }
     783             :             }
     784             :         }
     785             :     }
     786           0 : }
     787             : 
     788             : // Create default drawing objects via keyboard
     789           0 : SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     790             : {
     791             :     // case SID_DRAW_TEXT:
     792             :     // case SID_DRAW_TEXT_VERTICAL:
     793             :     // case SID_DRAW_TEXT_MARQUEE:
     794             :     // case SID_DRAW_NOTEEDIT:
     795             : 
     796             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     797           0 :         pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
     798           0 :         0L, pDrDoc);
     799             : 
     800           0 :     if(pObj)
     801             :     {
     802           0 :         if(pObj->ISA(SdrTextObj))
     803             :         {
     804           0 :             SdrTextObj* pText = (SdrTextObj*)pObj;
     805           0 :             pText->SetLogicRect(rRectangle);
     806             : 
     807             :             //  don't set default text, start edit mode instead
     808             :             // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
     809             :             // pText->SetText(aText);
     810             : 
     811           0 :             sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
     812           0 :             sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
     813             : 
     814           0 :             pText->SetVerticalWriting(bVertical);
     815             : 
     816           0 :             if(bVertical)
     817             :             {
     818           0 :                 SfxItemSet aSet(pDrDoc->GetItemPool());
     819             : 
     820           0 :                 aSet.Put(SdrTextAutoGrowWidthItem(true));
     821           0 :                 aSet.Put(SdrTextAutoGrowHeightItem(false));
     822           0 :                 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
     823           0 :                 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
     824             : 
     825           0 :                 pText->SetMergedItemSet(aSet);
     826             :             }
     827             : 
     828           0 :             if(bMarquee)
     829             :             {
     830           0 :                 SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
     831             : 
     832           0 :                 aSet.Put( SdrTextAutoGrowWidthItem( false ) );
     833           0 :                 aSet.Put( SdrTextAutoGrowHeightItem( false ) );
     834           0 :                 aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
     835           0 :                 aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
     836           0 :                 aSet.Put( SdrTextAniCountItem( 1 ) );
     837           0 :                 aSet.Put( SdrTextAniAmountItem( (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
     838             : 
     839           0 :                 pObj->SetMergedItemSetAndBroadcast(aSet);
     840             :             }
     841             : 
     842           0 :             SetInEditMode( pObj );      // start edit mode
     843             :         }
     844             :         else
     845             :         {
     846             :             OSL_FAIL("Object is NO text object");
     847             :         }
     848             :     }
     849             : 
     850           0 :     return pObj;
     851         102 : }
     852             : 
     853             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10