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

Generated by: LCOV version 1.10