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

Generated by: LCOV version 1.10