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

Generated by: LCOV version 1.10